From 92c035f860e2cd2bf046a6a32b6dd95eff912364 Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Tue, 19 Jan 2016 15:15:47 +0100 Subject: [PATCH] Fixed a lot of stuff.. and added ... stuff....... yay. --- .../sudoku/controller/GameController.java | 6 + .../sudoku/controller/NewLevelManager.java | 63 ++++++++++- .../tu_darmstadt/sudoku/game/GameBoard.java | 3 + .../tu_darmstadt/sudoku/ui/GameActivity.java | 76 +++++++++++-- .../sudoku/ui/LoadGameActivity.java | 2 +- .../tu_darmstadt/sudoku/ui/MainActivity.java | 15 ++- .../tu_darmstadt/sudoku/ui/StatsActivity.java | 22 +++- .../listener/IHintDialogFragmentListener.java | 9 ++ .../IResetDialogFragmentListener.java | 9 ++ .../sudoku/ui/view/SudokuKeyboardLayout.java | 10 ++ .../ui/view/SudokuSpecialButtonLayout.java | 66 ++++++++++- .../main/res/layout/activity_game_view.xml | 103 +++++++++++++++--- .../main/res/layout/activity_main_menu.xml | 37 ++++--- app/src/main/res/layout/app_bar_game_view.xml | 75 ------------- app/src/main/res/layout/fragment_stats.xml | 13 +-- app/src/main/res/menu/menu_drawer.xml | 18 +-- app/src/main/res/menu/menu_drawer_main.xml | 20 ++-- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values/dimens.xml | 2 +- app/src/main/res/values/strings.xml | 31 ++++-- app/src/main/res/xml/pref_general.xml | 2 +- 21 files changed, 408 insertions(+), 176 deletions(-) create mode 100644 app/src/main/java/tu_darmstadt/sudoku/ui/listener/IHintDialogFragmentListener.java create mode 100644 app/src/main/java/tu_darmstadt/sudoku/ui/listener/IResetDialogFragmentListener.java delete mode 100644 app/src/main/res/layout/app_bar_game_view.xml diff --git a/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java b/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java index b529954..78bb19f 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java +++ b/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java @@ -166,6 +166,9 @@ public class GameController implements IModelChangedListener { }*/ public void hint(){ + if(!isValidCellSelected()) { + return; + } int[] solved = solve(); // TODO test every placed value so far @@ -302,6 +305,7 @@ public class GameController implements IModelChangedListener { public void resetLevel() { gameBoard.reset(); //notifyListeners(); + notifyHighlightChangedListeners(); } public boolean deleteValue(int row, int col) { @@ -620,6 +624,8 @@ public class GameController implements IModelChangedListener { } } } + + notifyHighlightChangedListeners(); return; } diff --git a/app/src/main/java/tu_darmstadt/sudoku/controller/NewLevelManager.java b/app/src/main/java/tu_darmstadt/sudoku/controller/NewLevelManager.java index 0ad9e20..514f761 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/controller/NewLevelManager.java +++ b/app/src/main/java/tu_darmstadt/sudoku/controller/NewLevelManager.java @@ -139,7 +139,6 @@ public class NewLevelManager { return resultPuzzle; } - // TODO: make the UI wait. Or just generate a level now. return null; } @@ -147,6 +146,67 @@ public class NewLevelManager { new AsyncGenerationTask().execute(); } + public void loadFirstStartLevels() { + // Default_9x9 + // Default_12x12 + // Default_6x6 + + // Easy + // Moderate + // Hard + + // 0 + // 1 + + saveToFile(GameType.Default_9x9, GameDifficulty.Easy, 0, "000208090027000000000400000090100706408090201000030080200001000100300469000000007"); + saveToFile(GameType.Default_9x9, GameDifficulty.Easy, 1, "000000052000003007500206830002040700070000046640508003000400000000005000050301008"); + saveToFile(GameType.Default_9x9, GameDifficulty.Moderate, 0, "000800400008004093009003060000700000000400000060002900091000670200000100403006802"); + saveToFile(GameType.Default_9x9, GameDifficulty.Moderate, 1, "000006040000050000600040080043000200500810000100300605209080460004500000001030000"); + saveToFile(GameType.Default_9x9, GameDifficulty.Hard, 0, "086000000000000070090000304968027030000100060200900000072006100000000296000000740"); + saveToFile(GameType.Default_9x9, GameDifficulty.Hard, 1, "450900001001400000600010004006700000500000000100024060002000030000062400040005700"); + + saveToFile(GameType.Default_12x12, GameDifficulty.Easy, 0, "B30050A100701600070030800002894000007008000000B550100004020300B0000090000060000A010000000032050C0407008006A000000000400001000C290000000008005000"); + saveToFile(GameType.Default_12x12, GameDifficulty.Easy, 1, "00B4008A09C002A030C00008007850003000030C000408AB000B00052000000000000070069500030C00B00010467000008000000A100000000800000C0020700001700000095400"); + saveToFile(GameType.Default_12x12, GameDifficulty.Moderate, 0, "00600500000004000000002050004C00800A28049000050000A900C000000000B00000A00B0560000C900C708A00000B0002000000769000008000B002B0C6000017C00107400908"); + saveToFile(GameType.Default_12x12, GameDifficulty.Moderate, 1, "020000B000A608070530000B9050200A03800030980010B001000B6C30900000032000CAB0000000000000067000B000000500000A000C09000081302B0100070950836000100000"); + saveToFile(GameType.Default_12x12, GameDifficulty.Hard, 0, "2000000000000B070C00000000AC100000000020050CA00BB60002097800079001000C60400000B0070A0000A7000298005048000010004000070009A10600C00B000C00B0000020"); + saveToFile(GameType.Default_12x12, GameDifficulty.Hard, 1, "01000002000C00640A800070000A0000082020000008100B0C081090000050A0060C079009BC000A04010500097000000000000000000000904000866070B100020000000C00B009"); + + saveToFile(GameType.Default_6x6, GameDifficulty.Easy, 0, "000000050004013000004003006050040010"); + saveToFile(GameType.Default_6x6, GameDifficulty.Easy, 1, "000450000600104306630000060005010000"); + saveToFile(GameType.Default_6x6, GameDifficulty.Moderate, 0, "630010002000001000040020400006003040"); + saveToFile(GameType.Default_6x6, GameDifficulty.Moderate, 1, "000000060130006000050603030005000041"); + saveToFile(GameType.Default_6x6, GameDifficulty.Hard, 0, "004200200000003002600050300400046000"); + saveToFile(GameType.Default_6x6, GameDifficulty.Hard, 1, "003050200003502000000000640002000045"); + } + + /** Don't use this if you don't know what you are doing! **/ + private void saveToFile(GameType gameType, GameDifficulty gameDifficulty, int saveNumber, String puzzle) { + StringBuilder sb = new StringBuilder(); + sb.append(LEVEL_PREFIX); + sb.append(gameType.name()); + sb.append("_"); + sb.append(gameDifficulty.name()); + sb.append("_"); + sb.append(saveNumber); + sb.append(FILE_EXTENSION); + // create the file + File file = new File(DIR, sb.toString()); + + // save the file + try { + FileOutputStream stream = new FileOutputStream(file); + + try { + stream.write(puzzle.getBytes()); + } finally { + stream.close(); + } + } catch (IOException e) { + Log.e("File Manager", "Could not save game. IOException occured."); + } + } + private class AsyncGenerationTask extends AsyncTask { @Override protected void onPreExecute() { @@ -235,6 +295,7 @@ public class NewLevelManager { String filename = sb.toString(); + // create the file File file = new File(DIR, filename); diff --git a/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java b/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java index ba807bc..f7120d5 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java +++ b/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java @@ -55,6 +55,9 @@ public class GameBoard implements Cloneable { public void initCells(int[] level) { int count = 0; + if(level == null) { + throw new IllegalArgumentException("Level array is null."); + } if(level.length != size*size) { throw new IllegalArgumentException("Levelarray must have length of "+size*size+"."); } diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java index ed1d820..dda5249 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java @@ -1,5 +1,11 @@ package tu_darmstadt.sudoku.ui; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Point; @@ -17,6 +23,7 @@ import android.widget.RatingBar; import android.widget.TextView; import android.widget.Toast; +import java.util.LinkedList; import java.util.List; import tu_darmstadt.sudoku.controller.GameStateManager; @@ -28,13 +35,15 @@ import tu_darmstadt.sudoku.game.GameDifficulty; import tu_darmstadt.sudoku.game.GameType; import tu_darmstadt.sudoku.game.listener.IGameSolvedListener; import tu_darmstadt.sudoku.game.listener.ITimerListener; +import tu_darmstadt.sudoku.ui.listener.IHintDialogFragmentListener; +import tu_darmstadt.sudoku.ui.listener.IResetDialogFragmentListener; import tu_darmstadt.sudoku.ui.view.DialogWinScreen; import tu_darmstadt.sudoku.ui.view.R; import tu_darmstadt.sudoku.ui.view.SudokuFieldLayout; import tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout; import tu_darmstadt.sudoku.ui.view.SudokuSpecialButtonLayout; -public class GameActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, IGameSolvedListener ,ITimerListener { +public class GameActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, IGameSolvedListener ,ITimerListener, IHintDialogFragmentListener, IResetDialogFragmentListener { GameController gameController; SudokuFieldLayout layout; @@ -61,7 +70,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On gameType = (GameType)extras.get("gameType"); } gameDifficulty = (GameDifficulty)(extras.get("gameDifficulty")); - loadLevel = extras.getBoolean("loadLevel"); + loadLevel = extras.getBoolean("loadLevel", false); if(loadLevel) { loadLevelID = extras.getInt("loadLevelID"); } @@ -107,7 +116,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On //set Special keys specialButtonLayout = (SudokuSpecialButtonLayout) findViewById(R.id.sudokuSpecialLayout); - specialButtonLayout.setButtons(p.x, gameController, keyboard); + specialButtonLayout.setButtons(p.x, gameController, keyboard, getFragmentManager()); //set TimerView timerView = (TextView)findViewById(R.id.timerView); @@ -190,6 +199,11 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On Intent intent; switch(id) { + case R.id.menu_reset: + ResetConfirmationDialog hintDialog = new ResetConfirmationDialog(); + hintDialog.show(getFragmentManager(), "ResetDialogFragment"); + break; + case R.id.nav_newgame: //create new game intent = new Intent(this, MainActivity.class); @@ -197,13 +211,6 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On startActivity(intent); break; - case R.id.nav_continue: - //create new game - intent = new Intent(this, LoadGameActivity.class); - finish(); - startActivity(intent); - break; - case R.id.menu_settings: //open settings intent = new Intent(this,SettingsActivity.class); @@ -275,4 +282,53 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On // save time gameController.saveGame(this); } + + @Override + public void onHintDialogPositiveClick() { + gameController.hint(); + } + + @Override + public void onResetDialogPositiveClick() { + gameController.resetLevel(); + } + + @Override + public void onDialogNegativeClick() { + // do nothing + } + @SuppressLint("ValidFragment") + public class ResetConfirmationDialog extends DialogFragment { + + LinkedList listeners = new LinkedList<>(); + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + // Verify that the host activity implements the callback interface + if(activity instanceof IHintDialogFragmentListener) { + listeners.add((IResetDialogFragmentListener) activity); + } + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Use the Builder class for convenient dialog construction + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setMessage(R.string.reset_confirmation) + .setPositiveButton(R.string.reset_confirmation_confirm, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + for(IResetDialogFragmentListener l : listeners) { + l.onResetDialogPositiveClick(); + } + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // User cancelled the dialog + } + }); + return builder.create(); + } + } } diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/LoadGameActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/LoadGameActivity.java index f1f4cdb..d48dee4 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/LoadGameActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/LoadGameActivity.java @@ -149,7 +149,7 @@ public class LoadGameActivity extends AppCompatActivity implements IDeleteDialog } } }) - .setNegativeButton(R.string.loadgame_delete_cancel, new DialogInterface.OnClickListener() { + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java index 71dc5da..3552f01 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.design.widget.NavigationView; +import android.support.v4.content.SharedPreferencesCompat; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; @@ -54,9 +55,21 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On settings = PreferenceManager.getDefaultSharedPreferences(this); - // check if we need to pre generate levels. NewLevelManager.init(getApplicationContext(), settings); NewLevelManager newLevelManager = NewLevelManager.getInstance(); + + // Is this the very first time we start this app? + boolean firstStart = settings.getBoolean("firstStart", true); + if(firstStart) { + // preload some levels so we don't have to generate as many and we can start playing right away. + newLevelManager.loadFirstStartLevels(); + + SharedPreferences.Editor editor = settings.edit(); + editor.putBoolean("firstStart", false); + editor.commit(); + } + + // check if we need to pre generate levels. newLevelManager.checkAndRestock(); setContentView(R.layout.activity_main_menu); diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java index 24e3e33..db841be 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java @@ -1,6 +1,8 @@ package tu_darmstadt.sudoku.ui; import android.content.Context; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.support.design.widget.TabLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; @@ -51,6 +53,12 @@ public class StatsActivity extends AppCompatActivity { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); + + android.support.v7.app.ActionBar actionBar = getSupportActionBar(); + actionBar.setTitle(R.string.menu_highscore); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#024265"))); + // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); @@ -79,19 +87,23 @@ public class StatsActivity extends AppCompatActivity { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); //noinspection SimplifiableIfStatement - if (id == R.id.action_reset) { - SaveLoadStatistics.resetStats(this); - mSectionsPagerAdapter.refresh(this); - return true; + switch(item.getItemId()) { + case R.id.action_reset: + SaveLoadStatistics.resetStats(this); + mSectionsPagerAdapter.refresh(this); + return true; + case R.id.home: + finish(); + return true; } return super.onOptionsItemSelected(item); } + /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/listener/IHintDialogFragmentListener.java b/app/src/main/java/tu_darmstadt/sudoku/ui/listener/IHintDialogFragmentListener.java new file mode 100644 index 0000000..8d5b49c --- /dev/null +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/listener/IHintDialogFragmentListener.java @@ -0,0 +1,9 @@ +package tu_darmstadt.sudoku.ui.listener; + +/** + * Created by Chris on 17.01.2016. + */ +public interface IHintDialogFragmentListener { + public void onHintDialogPositiveClick(); + public void onDialogNegativeClick(); +} diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/listener/IResetDialogFragmentListener.java b/app/src/main/java/tu_darmstadt/sudoku/ui/listener/IResetDialogFragmentListener.java new file mode 100644 index 0000000..97039aa --- /dev/null +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/listener/IResetDialogFragmentListener.java @@ -0,0 +1,9 @@ +package tu_darmstadt.sudoku.ui.listener; + +/** + * Created by Chris on 19.01.2016. + */ +public interface IResetDialogFragmentListener { + public void onResetDialogPositiveClick(); + public void onDialogNegativeClick(); +} diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java index 990b2d3..31eab07 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java @@ -1,15 +1,25 @@ package tu_darmstadt.sudoku.ui.view; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; import android.content.Context; +import android.content.DialogInterface; import android.graphics.Canvas; +import android.os.Bundle; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; import android.widget.GridLayout; +import java.util.LinkedList; + import tu_darmstadt.sudoku.controller.GameController; import tu_darmstadt.sudoku.controller.Symbol; import tu_darmstadt.sudoku.game.listener.IHighlightChangedListener; +import tu_darmstadt.sudoku.ui.listener.IDeleteDialogFragmentListener; /** * Created by TMZ_LToP on 12.11.2015. diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java index d448775..b41427a 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java @@ -1,29 +1,42 @@ package tu_darmstadt.sudoku.ui.view; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.app.FragmentManager; import android.content.Context; +import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; +import android.os.Bundle; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.Toast; + +import java.util.LinkedList; import tu_darmstadt.sudoku.controller.GameController; +import tu_darmstadt.sudoku.ui.listener.IHintDialogFragmentListener; /** * Created by TMZ_LToP on 17.11.2015. */ public class SudokuSpecialButtonLayout extends LinearLayout { + SudokuSpecialButton[] fixedButtons; public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size(); GameController gameController; SudokuKeyboardLayout keyboard; Bitmap bitMap,bitResult; Canvas canvas; - + FragmentManager fragmentManager; OnClickListener listener = new OnClickListener() { @Override @@ -64,9 +77,18 @@ public class SudokuSpecialButtonLayout extends LinearLayout { break; case Hint: if(gameController.isValidCellSelected()) { - gameController.hint(); + if(gameController.getUsedHints() == 0) { + // are you sure you want to use a hint? + HintConfirmationDialog hintDialog = new HintConfirmationDialog(); + hintDialog.show(fragmentManager, "HintDialogFragment"); + + } else { + gameController.hint(); + } } else { - // TODO: Display a Toast that explains how to use the Hint function. + // Display a Toast that explains how to use the Hint function. + Toast t = Toast.makeText(getContext(), R.string.hint_usage, Toast.LENGTH_SHORT); + t.show(); } break; default: @@ -88,7 +110,8 @@ public class SudokuSpecialButtonLayout extends LinearLayout { } } - public void setButtons(int width, GameController gc, SudokuKeyboardLayout key) { + public void setButtons(int width, GameController gc, SudokuKeyboardLayout key, FragmentManager fm) { + fragmentManager = fm; keyboard=key; gameController = gc; fixedButtons = new SudokuSpecialButton[fixedButtonsCount]; @@ -124,4 +147,39 @@ public class SudokuSpecialButtonLayout extends LinearLayout { } } + + @SuppressLint("ValidFragment") + public class HintConfirmationDialog extends DialogFragment { + + LinkedList listeners = new LinkedList<>(); + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + // Verify that the host activity implements the callback interface + if(activity instanceof IHintDialogFragmentListener) { + listeners.add((IHintDialogFragmentListener) activity); + } + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Use the Builder class for convenient dialog construction + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setMessage(R.string.hint_confirmation) + .setPositiveButton(R.string.hint_confirmation_confirm, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + for(IHintDialogFragmentListener l : listeners) { + l.onHintDialogPositiveClick(); + } + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // User cancelled the dialog + } + }); + return builder.create(); + } + } } diff --git a/app/src/main/res/layout/activity_game_view.xml b/app/src/main/res/layout/activity_game_view.xml index b68c58c..0fb29f0 100644 --- a/app/src/main/res/layout/activity_game_view.xml +++ b/app/src/main/res/layout/activity_game_view.xml @@ -1,18 +1,95 @@ - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:id="@+id/game_coordinate_layout" + tools:context="tu_darmstadt.sudoku.activity.GameActivity"> - + - - + + + + + + + - + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main_menu.xml b/app/src/main/res/layout/activity_main_menu.xml index 5ba5152..3254703 100644 --- a/app/src/main/res/layout/activity_main_menu.xml +++ b/app/src/main/res/layout/activity_main_menu.xml @@ -1,21 +1,13 @@ - - - + Neues Spiel Einstellungen - Bestenliste + Statistik Hauptmenü Gruppe Hilfe diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index edfd125..52dafc0 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -7,6 +7,6 @@ 13dp 160dp 8dp - 180dp + 24dp 16dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4e01c61..a7a5533 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,14 +2,18 @@ Sudoku Sudoku + Cancel + - New Game + New Game + Main Menu Settings Highscore Group Help About - continue game + Reset Board + Continue Game a privacy friendly logic puzzle @@ -71,30 +75,33 @@ Hard - + Sudoku Standart Sudoku 9x9 Standart Sudoku 6x6 Unspec Standart Sudoku 12x12 X Sudoku 9x9 Hyper Sudoku 9x9 - StatsGameActivity - Hello World from section: %1$d + Statistics + Select a valid field and then press the hint button to reveal the solution. + Are you sure you want to use this hint? When using hints, you will not be able to achieve a personal best time. + Use + Are you sure you want to reset the game board? + Reset Are you sure you want to delete this save? Delete - Cancel StatsActivity Statistics - Number of Hints Used: - #Games: - Total time Played: - Av time: - Min time: - reset stats + Number of hints used: + Number of games played: + Total time played: + Average time: + Minimum time: + Reset All diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 626632c..3f17484 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -11,7 +11,7 @@