Add private verification method to CreateSudokuActivity
This commit is contained in:
parent
bc88df46f1
commit
bc047addea
1 changed files with 37 additions and 0 deletions
|
@ -8,10 +8,14 @@ import android.preference.PreferenceManager;
|
|||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.secuso.privacyfriendlysudoku.controller.GameController;
|
||||
import org.secuso.privacyfriendlysudoku.controller.Symbol;
|
||||
import org.secuso.privacyfriendlysudoku.controller.helper.GameInfoContainer;
|
||||
import org.secuso.privacyfriendlysudoku.controller.qqwing.QQWing;
|
||||
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
|
||||
import org.secuso.privacyfriendlysudoku.game.GameType;
|
||||
import org.secuso.privacyfriendlysudoku.ui.view.R;
|
||||
|
@ -30,6 +34,17 @@ public class CreateSudokuActivity extends BaseActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if (sharedPref.getBoolean("pref_dark_mode_setting", false )) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
}
|
||||
|
||||
if(sharedPref.getBoolean("pref_keep_screen_on", true)) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
gameController = new GameController(sharedPref, getApplicationContext());
|
||||
|
||||
if(sharedPref.getBoolean("pref_keep_screen_on", true)) {
|
||||
|
@ -92,4 +107,26 @@ public class CreateSudokuActivity extends BaseActivity {
|
|||
finish();
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private void verify() {
|
||||
Toast.makeText(CreateSudokuActivity.this, "Verifying...", Toast.LENGTH_SHORT).show();
|
||||
GameType gameType = gameController.getGameType();
|
||||
int boardSize = gameType.getSize() * gameType.getSize();
|
||||
QQWing verifier = new QQWing(gameType, GameDifficulty.Unspecified);
|
||||
|
||||
GameInfoContainer container = new GameInfoContainer(0, GameDifficulty.Unspecified,
|
||||
gameType, new int [boardSize], new int [boardSize], new boolean [boardSize][gameType.getSize()]);
|
||||
container.parseFixedValues(gameController.getCodeOfField());
|
||||
|
||||
verifier.setRecordHistory(true);
|
||||
verifier.setPuzzle(container.getFixedValues());
|
||||
boolean solvable = verifier.solve();
|
||||
|
||||
if(solvable) {
|
||||
Toast.makeText(CreateSudokuActivity.this, "Done verifying!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(CreateSudokuActivity.this, "Your sudoku cannot be solved!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue