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 df80fc6..9512ce5 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -454,6 +454,10 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig //Save solved sudoku, if it happens to be a daily sudoku, to daily sudoku database if(gameController.getGameID() == GameController.DAILY_SUDOKU_ID) { gameController.saveDailySudoku(GameActivity.this); + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + SharedPreferences.Editor editor = sharedPref.edit(); + editor.putBoolean("finishedForToday", true); + editor.apply(); } //Show time hints new plus old best time diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java index 02eed27..e5197fe 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java @@ -17,6 +17,7 @@ import android.widget.ListView; import android.widget.TextView; import android.view.View; import android.widget.RatingBar; +import android.widget.Toast; import org.secuso.privacyfriendlysudoku.controller.GameController; import org.secuso.privacyfriendlysudoku.controller.database.DatabaseHelper; @@ -85,19 +86,23 @@ public class DailySudokuActivity extends AppCompatActivity { + (currentDate.get(Calendar.MONTH) + 1) * 10000 + currentDate.get(Calendar.YEAR); final Intent intent = new Intent(this,GameActivity.class); - if (settings.getInt("lastPlayed", 0) == id) { - intent.putExtra("loadLevel", true); - intent.putExtra("loadLevelID", GameController.DAILY_SUDOKU_ID); - } else { + if (settings.getInt("lastPlayed", 0) != id) { SharedPreferences.Editor editor = settings.edit(); editor.putInt("lastPlayed", id); + editor.putBoolean("finishedForToday", false); editor.apply(); intent.putExtra("gameDifficulty", gameDifficulty.name()); intent.putExtra("isDailySudoku", true); - } + startActivity(intent); - startActivity(intent); + } else if (!settings.getBoolean("finishedForToday", true)) { + intent.putExtra("loadLevel", true); + intent.putExtra("loadLevelID", GameController.DAILY_SUDOKU_ID); + startActivity(intent); + } else { + Toast.makeText(this, R.string.finished_daily_sudoku, Toast.LENGTH_LONG).show(); + } } public boolean onCreateOptionsMenu(Menu menu) { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4f0215d..dcf4e73 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -102,4 +102,7 @@ Skip Tutorial + + Du hast das Sudoku des Tages bereits gelöst. + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b8595ba..07f27d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -152,4 +152,8 @@ Next Skip Tutorial + + + You have already solved the sudoku of the day +