From a8629fc75c28f11c08e9ad5950a9161f3c216b31 Mon Sep 17 00:00:00 2001 From: uykek Date: Sat, 13 Jun 2020 15:56:37 +0200 Subject: [PATCH 1/2] Adjust GameInfoContainer and GameActivity so that importing a sudoku containing an invalid fixed value (e.g. a 9x9 sudoku containing an 'A' as a fixed value) no longer causes an exception. --- .../controller/helper/GameInfoContainer.java | 5 +++++ .../org/secuso/privacyfriendlysudoku/ui/GameActivity.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/helper/GameInfoContainer.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/helper/GameInfoContainer.java index 43ed14e..9365a39 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/helper/GameInfoContainer.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/helper/GameInfoContainer.java @@ -104,6 +104,11 @@ public class GameInfoContainer { fixedValues = new int[s.length()]; for(int i = 0; i < s.length(); i++) { fixedValues[i] = Symbol.getValue(Symbol.SaveFormat, String.valueOf(s.charAt(i)))+1; + if (gameType != GameType.Unspecified && gameType != null) { + if (fixedValues[i] < 0 || fixedValues[i] > gameType.getSize()) { + throw new IllegalArgumentException("Fixed values must each be smaller than " + gameType.getSize() + "."); + } + } } } 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 bf6e48b..3ea9f1b 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -125,8 +125,8 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig GameType.Unspecified, new int [boardSize], new int [boardSize], new boolean [boardSize][sectionSize]); try { - container.parseFixedValues(input); container.parseGameType("Default_" + sectionSize + "x" + sectionSize); + container.parseFixedValues(input); difficultyCheck = new QQWing(container.getGameType(), GameDifficulty.Unspecified); difficultyCheck.setRecordHistory(true); From 87a80de4b569902ba9632a1bcb20572ab3b42aff Mon Sep 17 00:00:00 2001 From: uykek Date: Mon, 15 Jun 2020 09:05:56 +0200 Subject: [PATCH 2/2] Change launchmode of GameActivityto 'singleTask' and add onNewIntent method to GameActivity --- app/src/main/AndroidManifest.xml | 1 + .../org/secuso/privacyfriendlysudoku/ui/GameActivity.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a1cc005..6e128ce 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -42,6 +42,7 @@ 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 3ea9f1b..4e5982c 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -298,6 +298,14 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig } gameController.deleteTimer(); } + + @Override + public void onNewIntent(Intent intent) { + super.onNewIntent(intent); + startActivity(intent); + finish(); + } + @Override public void onResume(){ super.onResume();