From f205532ed442909eb270d62126b3e046d8b3532c Mon Sep 17 00:00:00 2001 From: Gongxter Date: Fri, 11 Dec 2015 14:48:27 +0100 Subject: [PATCH] added DialogeFragment for WinScreen --- .idea/misc.xml | 2 +- .../tu_darmstadt/sudoku/ui/GameActivity.java | 11 ++- .../tu_darmstadt/sudoku/ui/MainActivity.java | 12 ++- .../sudoku/ui/view/DialogWinScreen.java | 50 +++++++++++++ .../sudoku/ui/view/SudokuCellView.java | 1 - .../sudoku/ui/view/SudokuKeyboardLayout.java | 1 - .../drawable/ic_trophy_award_black_48dp.png | Bin 0 -> 2133 bytes .../res/drawable/ic_trophy_black_48dp.png | Bin 0 -> 1901 bytes .../main/res/layout/activity_main_menu.xml | 5 ++ app/src/main/res/layout/app_bar_game_view.xml | 1 + app/src/main/res/layout/win_screen_layout.xml | 69 ++++++++++++++++++ app/src/main/res/values/strings.xml | 3 +- 12 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/tu_darmstadt/sudoku/ui/view/DialogWinScreen.java create mode 100644 app/src/main/res/drawable/ic_trophy_award_black_48dp.png create mode 100644 app/src/main/res/drawable/ic_trophy_black_48dp.png create mode 100644 app/src/main/res/layout/win_screen_layout.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb6828..5d19981 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java index 36dfaaa..e27363d 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java @@ -6,6 +6,7 @@ import android.graphics.Point; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.design.widget.NavigationView; +import android.support.v4.app.FragmentManager; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; @@ -23,10 +24,10 @@ import tu_darmstadt.sudoku.controller.GameController; import tu_darmstadt.sudoku.controller.SaveLoadStatistics; import tu_darmstadt.sudoku.controller.helper.GameInfoContainer; import tu_darmstadt.sudoku.game.GameDifficulty; -import tu_darmstadt.sudoku.game.GameStatus; import tu_darmstadt.sudoku.game.GameType; import tu_darmstadt.sudoku.game.listener.IGameSolvedListener; import tu_darmstadt.sudoku.game.listener.ITimerListener; +import tu_darmstadt.sudoku.ui.view.DialogWinScreen; import tu_darmstadt.sudoku.ui.view.R; import tu_darmstadt.sudoku.ui.view.SudokuFieldLayout; import tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout; @@ -122,7 +123,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On ratingBar = (RatingBar) findViewById(R.id.gameModeStar); ratingBar.setMax(numberOfStarts); ratingBar.setNumStars(numberOfStarts); - ratingBar.setRating(difficutyList.indexOf(gameController.getDifficulty())+1); + ratingBar.setRating(difficutyList.indexOf(gameController.getDifficulty()) + 1); ((TextView)findViewById(R.id.difficultyText)).setText(getString(gameController.getDifficulty().getStringResID())); @@ -231,7 +232,13 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On t.show(); SaveLoadStatistics s = new SaveLoadStatistics(this); s.saveGameStats(gameController); + DialogWinScreen win = new DialogWinScreen(); + win.setProps(gameController); + FragmentManager fr = getSupportFragmentManager(); + win.show(fr, "win_screen_layout"); + // TODO: WE WON.. do something awesome :) + gameController.pauseTimer(); } @Override diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java index f9a3722..71dc5da 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java @@ -34,6 +34,7 @@ import tu_darmstadt.sudoku.controller.NewLevelManager; import tu_darmstadt.sudoku.controller.helper.GameInfoContainer; import tu_darmstadt.sudoku.game.GameDifficulty; import tu_darmstadt.sudoku.game.GameType; +import tu_darmstadt.sudoku.ui.view.DialogWinScreen; import tu_darmstadt.sudoku.ui.view.R; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{ @@ -122,6 +123,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On navigationView.setNavigationItemSelectedListener(this); } + public void callFragment(View view){ + FragmentManager fm = getSupportFragmentManager(); + DialogWinScreen winScreen = new DialogWinScreen(); + winScreen.show(fm,"win_screen_layout"); + } public void onClick(View view) { @@ -133,9 +139,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On /**case R.id.aboutButton: i = new Intent(this, AboutActivity.class); break; - case R.id.continueButton: - i = new Intent(this, LoadGameActivity.class); - break; case R.id.highscoreButton: i = new Intent(this,StatsActivity.class); break; @@ -145,6 +148,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On case R.id.helpButton: // TODO: create help page.. what is supposed to be in there?! break;*/ + case R.id.continueButton: + i = new Intent(this, LoadGameActivity.class); + break; case R.id.playButton: GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem()); int index = difficultyBar.getProgress()-1; diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/DialogWinScreen.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/DialogWinScreen.java new file mode 100644 index 0000000..91f595d --- /dev/null +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/DialogWinScreen.java @@ -0,0 +1,50 @@ +package tu_darmstadt.sudoku.ui.view; + +import android.app.DialogFragment; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.AnimationUtils; +import android.view.animation.LinearInterpolator; +import android.view.animation.RotateAnimation; +import android.widget.ImageView; + +import tu_darmstadt.sudoku.controller.GameController; + +/** + * Created by TMZ_LToP on 11.12.2015. + */ +public class DialogWinScreen extends android.support.v4.app.DialogFragment { + + + ImageView upperView, lowerView; + + public DialogWinScreen(){ + + } + public void setProps(GameController gc){ + + //no second Conjstrutor with argument allowed + //save everything that should be sown in winscreeen and set in the text etc + + } + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.win_screen_layout,container); + getDialog().getWindow().setBackgroundDrawableResource(R.drawable.ic_trophy_black_48dp); + //getDialog().getWindow().setLayout(200,250); + //Maybe creat real animation + //Animation ani = AnimationUtils.loadAnimation(this,R.anim...); + /*RotateAnimation anim = new RotateAnimation(0.0f,350.0f,60f,60f); + anim.setInterpolator(new LinearInterpolator()); + anim.setRepeatCount(Animation.INFINITE); + anim.setDuration(700); + */ + return view; + } +} diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuCellView.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuCellView.java index 60859d6..d47b777 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuCellView.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuCellView.java @@ -155,7 +155,6 @@ public class SudokuCellView extends View { p.setAntiAlias(true); p.setTextSize(Math.min(mHeight * 3 / 4, mHeight * 3 / 4)); p.setTextAlign(Paint.Align.CENTER); - // TODO settings: get SymbolEnum from settings canvas.drawText(Symbol.getSymbol(symbolsToUse, mGameCell.getValue()-1), mHeight / 2, mHeight / 2 + mHeight / 4, p); } diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java index 6962ad1..93b79d5 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java @@ -81,7 +81,6 @@ public class SudokuKeyboardLayout extends GridLayout { buttons[number].setLayoutParams(p); //buttons[number].setGravity(Gravity.CENTER); buttons[number].setType(SudokuButtonType.Value); - // TODO settings: get SymbolEnum from settings buttons[number].setBackgroundResource(R.drawable.mnenomic_numpad_button); buttons[number].setText(Symbol.getSymbol(symbolsToUse, number)); buttons[number].setValue(number + 1); diff --git a/app/src/main/res/drawable/ic_trophy_award_black_48dp.png b/app/src/main/res/drawable/ic_trophy_award_black_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e85ed535b4836a112c49b45b78a513c4a87cad52 GIT binary patch literal 2133 zcmb`IeLNFt8^<@3mza>Sw&;Y^!=xfSb&R|&WoOOd0K9+Nrf zJPu)=uxw^KEm7XiyhLWK;SrX}OWw9Q+HOgmiZeN*MVf^s78D1!?~p{ZsXAH!;nnKQ%vFIFPOXu*_ALACm5$ zL5PU8Ft_oE4L(QBpoX;l{Q2yWT>%8MOsFeM)8ig`SA7)WJDhAUz0FR+{w~YrX6;yU zangyHo)+oJlhRet9tU&t>3=y%3r=#9dXv=5kw5)q54HUI7iZ#9S9sLcbmsAk_O{Uk+}zucc< zi2*7r$-6qD?Pb0vw5v6+Jn0Px#r}u>*LBw%9~HVJ+G{c?*B!5+9f`j-*^$34E_?45^#aP(DYsMRnHG-PT^a z+URZuhKE;aRk5}~tv$P89CB<@TPeuJWkwzR<7OBX55(V*#|qvI9p-SH)*M4BZSLoS zXdf^L>e|TUDk?qC?2WE^n6(xoIvZButi#n`&|Qf6$1Asnv4d=oOw$n}6zNJ-(U$Wg zBeP99AVfAg$ZZKEf{1Bnu=PZJ$796f;6XLf9`0>1&Aa+)4M4rz=#NVhb!STjvax6| zK=kWpkCUf{0A88oyEPwI{K8Pn*CAHCJDj=ORgz!tX}8O(3%DS@R=GK4LNTzFit#*_ z83@S@pTmj%&Ce+%P$r%df#bPCC}ko!wrCa(CM82J@U`1#<{a^;<-Ij4klg;kq@Za3 z0f2EXtETX`vHWV_aajDtJs@fs?R?=DK`DEw-z@ z5|~(+TzIH6h*cjq$mv;mg#jTRIP+&|ogEAfntIcVL58ZKEc{9I6@K*|vd(?OxfdM(<&bxkQNDIYatg#@knaqhgKTvEH`Tb1Gq zR9Y}MCjQPkKuJl&mtUPXfg5p;_Z$oE&FB+d6a!UPJ~KdO2|3PR05y z!8(2T-BvwkXo_$8bU5?t(WXImmu-fh%@ z;}+^^X=xf zup;rz9`=#L47g5k|CcB6?haMSCfDT|wpfAK-~MCN`Xxfa`$)DQ8Oy}gTix$~xj>Q+O4>~ARRzB(3XZ&e znljvv8n<3sCFSbRE`=sNpM(MSbp!qR{~tUlgBn*};977qxa(P_*j^`vOm%@QauWqD zXYmuR?m2Tdwzp>Af43SKL5+c{-@Jv@16gt|_06$`rj^5q(zx>ckGopV$+S(yBDlRgb}18E5W26`i*2>OiXd}Z1c`w_{hq-t|sk_f`{1X#ys)(M#X9xV?6Cy&`{fRHhj_?e-v-W%=d1E z=*(BNwE2;`;yoSox`Cj_i;@}-(1;Uq1m%}e@b+2xm&pFRNT L;p<*|HZ1*5@uv`& literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/ic_trophy_black_48dp.png b/app/src/main/res/drawable/ic_trophy_black_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7d1620fd5f7c86a55ba404e71af582e627724ebc GIT binary patch literal 1901 zcmd6odsxz08pnS>P*4#aBL_v1vYN4UM%TnlAhlGyY-YN7N#$W|$`nCMLl#R=OEW`l zWK1Dl!)xWGc7)0+v$)fYQ;jqwW@3!3iJ2gYqIp|p{+mDdzkQ$cJ)h@&pL3pb{y69T zmPAI7kro&W005AoA%RgwN`IFb%s5Alr^AhaC5Mv(jWou}p&pJA=9wY!Sw@EZq2Qlr z2YxRyGXqkLl>VV#q}dC`t;?Z-0e@qS%_+lMkDc54NY_bXU4E^TM10&pJOF40XiPQO_O^91_8T30j z&!Hkd?1;!v+TtJGW<15A0z0TJuK>C-T?dnEVI9qh`jbr4dHfp^R)d$FP^vLcL8o%c zAV7?m+#k~OTkUEC+5@@}MTDE#OOdBKuOH7SWL%lM zwB@#EmKZW`H6NVl&VTH{ubHKX{yQiM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