Notify user if a sudoku they tried to import is impossible to solve and close app afterwards.

This commit is contained in:
uykek 2020-05-15 19:07:50 +02:00
parent a1b13a49e5
commit 26d5cab369
3 changed files with 19 additions and 4 deletions

View file

@ -129,10 +129,22 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
difficultyCheck.setPuzzle(container.getFixedValues());
boolean possibleToSolve = difficultyCheck.solve();
if (possibleToSolve) {
String difficulty = difficultyCheck.getDifficulty().toString();
container.parseDifficulty(difficulty);
gameController.loadLevel(container);
String difficulty = difficultyCheck.getDifficulty().toString();
container.parseDifficulty(difficulty);
gameController.loadLevel(container);
if (!possibleToSolve) {
AlertDialog.Builder builder = new AlertDialog.Builder(GameActivity.this);
builder.setMessage(R.string.impossible_import_notice)
.setCancelable(false)
.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}
} else {

View file

@ -32,6 +32,7 @@
<string name="hint_confirmation_confirm">Benutzen</string>
<string name="loadgame_delete_confirm">Löschen</string>
<string name="hint_usage">Wähle ein gültiges Feld aus und drücke dann auf den Hinweis Knopf um dann das makierte Feld aufzulösen.</string>
<string name="impossible_import_notice">Das Sudoku, das du importieren möchtest, hat keine Lösung.</string>
<string name="loadgame_delete_confirmation">Bist du sicher, dass du den Spielstand löschen möchtest?</string>
<string name="menu_continue_game">Spiel Fortsetzen</string>
<string name="menu_reset">Zurücksetzen</string>

View file

@ -20,6 +20,8 @@
<string name="generating">Generating new level in the background&#8230;</string>
<string name="impossible_import_notice">The sudoku you wish to import has no solution.</string>
<!-- ###SETTINGS### -->
<string name="title_activity_settings">Settings</string>
<!-- #Highlight -->