diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java index a59edf0..6791322 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java @@ -173,8 +173,8 @@ public class GameController implements IModelChangedListener { } int[] solved = solve(); - // - // reveal the selected value. + // TODO test every placed value so far + // and reveal the selected value. selectValue(solved[selectedRow * getSize() + selectedCol]); usedHints++; diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/SaveLoadStatistics.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/SaveLoadStatistics.java index 1dc8a11..95c818e 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/SaveLoadStatistics.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/SaveLoadStatistics.java @@ -13,11 +13,13 @@ import java.util.List; import org.secuso.privacyfriendlysudoku.controller.helper.HighscoreInfoContainer; import org.secuso.privacyfriendlysudoku.game.GameDifficulty; import org.secuso.privacyfriendlysudoku.game.GameType; +import org.secuso.privacyfriendlysudoku.game.listener.IHintListener; +import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener; /** * Created by TMZ_LToP on 19.11.2015. */ -public class SaveLoadStatistics implements ITimerListener { +public class SaveLoadStatistics implements ITimerListener, IHintListener { private static String FILE_EXTENSION = ".txt"; @@ -114,15 +116,14 @@ public class SaveLoadStatistics implements ITimerListener { } - public void saveTime(GameDifficulty gd, GameType gameType) { - //TODO: Increse time every second + public void incTime(GameDifficulty gd, GameType gameType) { HighscoreInfoContainer infos = loadStats(gameType, gd); infos.incTime(); saveContainer(infos,gd,gameType); } - public void saveHints(GameDifficulty gd, GameType gameType){ + public void incHints(GameDifficulty gd, GameType gameType){ HighscoreInfoContainer infos = loadStats(gameType,gd); infos.incHints(); saveContainer(infos,gd,gameType); @@ -202,7 +203,12 @@ public class SaveLoadStatistics implements ITimerListener { @Override public void onTick(int time) { - saveTime(gc.getDifficulty(),gc.getGameType()); + incTime(gc.getDifficulty(), gc.getGameType()); //gc.getUsedHints(); } + + @Override + public void onHintUsed() { + incHints(gc.getDifficulty(),gc.getGameType()); + } } diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java index 70f867a..86e6ff3 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -18,7 +18,9 @@ import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; +import android.view.Gravity; import android.view.MenuItem; +import android.view.WindowManager; import android.widget.RatingBar; import android.widget.TextView; import android.widget.Toast; @@ -252,15 +254,18 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On gameController.pauseTimer(); gameController.deleteGame(this); - Toast t = Toast.makeText(this, R.string.win_text, Toast.LENGTH_SHORT); - t.show(); + //Show time hints new plus old best time statistics.saveGameStats(); - FragmentManager fr = getSupportFragmentManager(); - DialogWinScreen win = new DialogWinScreen(); - win.setProps(gameController, this); - win.show(fr, "win_screen_layout"); + Dialog dialog = new Dialog(this); + //dialog.setContentView(getLayoutInflater().inflate(R.layout.win_screen_layout,null)); + dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); + //dialog.setContentView(R.layout.win_screen_layout); + dialog.getWindow().setGravity(Gravity.CENTER_HORIZONTAL); + dialog.getWindow().setContentView(R.layout.win_screen_layout); + dialog.getWindow().setBackgroundDrawableResource(R.color.transparent); + dialog.show(); keyboard.setButtonsEnabled(false); specialButtonLayout.setButtonsEnabled(false); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java index eb3c38a..10017be 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java @@ -144,14 +144,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On DialogWinScreen winScreen = new DialogWinScreen(); winScreen.show(fm,"win_screen_layout");*/ - Dialog dialog = new Dialog(this); - //dialog.setContentView(getLayoutInflater().inflate(R.layout.win_screen_layout,null)); - dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); - //dialog.setContentView(R.layout.win_screen_layout); - dialog.getWindow().setGravity(Gravity.CENTER_HORIZONTAL); - dialog.getWindow().setContentView(R.layout.win_screen_layout); - dialog.getWindow().setBackgroundDrawableResource(R.color.transparent); - dialog.show(); + } public void onClick(View view) { diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java index 34c27c0..79ec106 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java @@ -181,7 +181,7 @@ public class StatsActivity extends AppCompatActivity { List stats = s.loadStats(GameType.getValidGameTypes().get(getArguments().getInt(ARG_SECTION_NUMBER))); int j =0; for (HighscoreInfoContainer i : stats){ - updateGeneralIfo(i.getTime(), i.getNumberOfGames(), i.getNumberOfHintsUsed()); + updateGeneralInfo(i.getTime(), i.getNumberOfGames(), i.getNumberOfHintsUsed()); setStats(i,j++); } setGeneralInfo(); @@ -209,7 +209,7 @@ public class StatsActivity extends AppCompatActivity { return (h + ":" + m + ":" + s); } - private void updateGeneralIfo(int time, int games, int hints){ + private void updateGeneralInfo(int time, int games, int hints){ totalHints +=hints; totalGames +=games; totalTime +=time; @@ -264,6 +264,7 @@ public class StatsActivity extends AppCompatActivity { View rootView = inflater.inflate(R.layout.fragment_stats, container, false); this.rootView = rootView; + resetGeneral(); TextView textView = (TextView) rootView.findViewById(R.id.section_label); SaveLoadStatistics s = new SaveLoadStatistics(this.getContext()); @@ -272,7 +273,7 @@ public class StatsActivity extends AppCompatActivity { int j =0; for (HighscoreInfoContainer i : stats){ - updateGeneralIfo(i.getTime(), i.getNumberOfGames(), i.getNumberOfHintsUsed()); + updateGeneralInfo(i.getTime(), i.getNumberOfGames(), i.getNumberOfHintsUsed()); setStats(i,j++); } setGeneralInfo(); diff --git a/app/src/main/res/layout/win_screen_layout.xml b/app/src/main/res/layout/win_screen_layout.xml index 360f5bc..6dc33e6 100644 --- a/app/src/main/res/layout/win_screen_layout.xml +++ b/app/src/main/res/layout/win_screen_layout.xml @@ -115,6 +115,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/colorPrimaryDark" + android:textColor="@color/white" android:text="@string/win_button_text"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b428ac0..46a3a06 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -98,11 +98,11 @@ Statistics - Number of hints used: - Number of games played: + # used hints: + # completed games: Total time played: - Average time: - Minimum time: + average time: + best time: Reset All