From 00c029fbbce0fbd1cc554ce45e0e8f414fefea52 Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Sun, 31 Jan 2016 14:53:54 +0100 Subject: [PATCH] Renamed some stuff and fixed minor bugs. --- README.md | 22 ++++++++- app/app.iml | 6 +++ .../controller/GameController.java | 3 +- .../controller/QQWingController.java | 6 +-- .../controller/helper/GameInfoContainer.java | 2 +- .../controller/qqwing/QQWing.java | 2 - .../ui/GameActivity.java | 18 ++++--- .../ui/view/DialogActivity.java | 48 ------------------- .../ui/view/WinDialog.java | 48 +++++++++++++++++++ 9 files changed, 87 insertions(+), 68 deletions(-) delete mode 100644 app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DialogActivity.java create mode 100644 app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java diff --git a/README.md b/README.md index 337f4fc..e28bbea 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# privacy-friendly-sudoku -This is a Sudoku App, that needs no permissions to run at all. +## Privacy Friendly Sudoku + +Privacy Friendly Sudoku is a game... // TODO + +It does not use any permission, as the app can provide its full functionality without the usage of permissions. +It also does neither include advertisement nor tracking mechanisms. + +## Motivation + +As it is part of the Privacy Friendly Apps developed by the SECUSO research group of the Technische +Universtität Darmstadt in Germany it is optimized due to user's privacy. + +## Installation + +Further development requires Android Studio. + +## License + +Privacy Friendly Sudoku is lisenced under the GPLv3. + diff --git a/app/app.iml b/app/app.iml index 74d7e06..0bf93b8 100644 --- a/app/app.iml +++ b/app/app.iml @@ -67,9 +67,11 @@ + + @@ -80,15 +82,19 @@ + + + + diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java index 8e60fb7..1165776 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java @@ -516,8 +516,7 @@ public class GameController implements IModelChangedListener, Parcelable { } } else { // notifyErrorListener(); - // TODO: errorList now holds all the errors - // TODO: display errors .. notify some view? + // TODO: errorList now holds all the errors => display errors .. notify some view? } } else { notifiedOnSolvedListeners = false; diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/QQWingController.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/QQWingController.java index 0bafec8..2a2f1d4 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/QQWingController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/QQWingController.java @@ -72,9 +72,9 @@ public class QQWingController { opts.threads = 1; opts.gameType = gameBoard.getGameType(); doAction(); - if(solveImpossible) { - // TODO: do something else. - } + //if(solveImpossible) { + // Can not occur with normal use of the app. + //} return solution; } 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 195c57d..58838d2 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 @@ -162,7 +162,7 @@ public class GameInfoContainer { public static String getGameInfo(GameController controller) { StringBuilder sb = new StringBuilder(); Date today = new Date(); - // TODO add some game information + sb.append(controller.getGameType().name()); sb.append("/"); sb.append(controller.getTime()); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/qqwing/QQWing.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/qqwing/QQWing.java index 2cfb7c5..2e152f9 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/qqwing/QQWing.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/qqwing/QQWing.java @@ -452,7 +452,6 @@ public class QQWing { // Some hack to make easy levels on 12x12 .. because the generator wasn't able to create some if(gameType == GameType.Default_12x12 && difficulty == GameDifficulty.Easy ) { i += 4; // skip every 2nd round to find "easy" levels more frequent. Still takes about 20 Seconds. - // TODO . save games be4 hand to load them when needed } } } @@ -741,7 +740,6 @@ public class QQWing { return false; } - // TODO: checked private boolean colBoxReduction(int round) { for (int valIndex = 0; valIndex < ROW_COL_SEC_SIZE; valIndex++) { for (int col = 0; col < ROW_COL_SEC_SIZE; col++) { 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 8b04ac4..b5ea244 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -11,7 +11,6 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Point; import android.os.Bundle; -import android.os.Parcelable; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.support.design.widget.NavigationView; @@ -42,7 +41,7 @@ import org.secuso.privacyfriendlysudoku.game.listener.IGameSolvedListener; import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener; import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener; import org.secuso.privacyfriendlysudoku.ui.listener.IResetDialogFragmentListener; -import org.secuso.privacyfriendlysudoku.ui.view.DialogActivity; +import org.secuso.privacyfriendlysudoku.ui.view.WinDialog; import org.secuso.privacyfriendlysudoku.ui.view.R; import org.secuso.privacyfriendlysudoku.ui.view.SudokuFieldLayout; import org.secuso.privacyfriendlysudoku.ui.view.SudokuKeyboardLayout; @@ -59,7 +58,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On RatingBar ratingBar; private boolean gameSolved = false; SaveLoadStatistics statistics = new SaveLoadStatistics(this); - DialogActivity dialog = null; + WinDialog dialog = null; @Override protected void onCreate(Bundle savedInstanceState) { @@ -291,13 +290,10 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On statistics.saveGameStats(); + boolean isNewBestTime = gameController.getUsedHints() == 0 + && statistics.loadStats(gameController.getGameType(),gameController.getDifficulty()).getMinTime() >= gameController.getTime(); - if (gameController.getUsedHints() == 0){ - if (statistics.loadStats(gameController.getGameType(),gameController.getDifficulty()).getMinTime() >= gameController.getTime()) { - // ((TextView) dialog.findViewById(R.id.win_new_besttime)).setVisibility(View.VISIBLE); - dialog = new DialogActivity(this,R.style.WinDialog,timeToString(gameController.getTime()),String.valueOf(gameController.getUsedHints()),true); - } - }else dialog = new DialogActivity(this,R.style.WinDialog,timeToString(gameController.getTime()),String.valueOf(gameController.getUsedHints()),true); + dialog = new WinDialog(this, R.style.WinDialog , timeToString(gameController.getTime()), String.valueOf(gameController.getUsedHints()), isNewBestTime); dialog.getWindow().setContentView(R.layout.win_screen_layout); //dialog.setContentView(getLayoutInflater().inflate(R.layout.win_screen_layout,null)); @@ -315,8 +311,10 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On @Override public void onClick(View v) { dialog.dismiss(); + Intent intent = new Intent(activity, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); activity.finish(); - startActivity(new Intent(activity,MainActivity.class)); } }); ((Button)dialog.findViewById(R.id.win_button2)).setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DialogActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DialogActivity.java deleted file mode 100644 index a85bc35..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DialogActivity.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.secuso.privacyfriendlysudoku.ui.view; - -import android.app.Dialog; -import android.content.Context; -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; - -/** - * Created by TMZ_LToP on 30.01.2016. - */ -public class DialogActivity extends Dialog { - - private String time=""; - private String hints=""; - private boolean newBest=false; - - public DialogActivity(Context context, int themeResId) { - super(context, themeResId); - } - - public DialogActivity(Context context,int themeResId,String t,String h, boolean newB) { - super(context,themeResId); - setParam(t,h,newB); - } - - - public void setParam(String t,String h, boolean newB){ - time = t; - hints=h; - newBest=newB; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - - super.onCreate(savedInstanceState); - - ((TextView)findViewById(R.id.win_hints)).setText(hints); - ((TextView)findViewById(R.id.win_time)).setText(time); - if(newBest){ - ((TextView)findViewById(R.id.win_new_besttime)).setVisibility(View.VISIBLE); - } - - } - - -} diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java new file mode 100644 index 0000000..923589f --- /dev/null +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java @@ -0,0 +1,48 @@ +package org.secuso.privacyfriendlysudoku.ui.view; + +import android.app.Dialog; +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +/** + * Created by TMZ_LToP on 30.01.2016. + */ +public class WinDialog extends Dialog { + + private String timeString = ""; + private String hintString = ""; + private boolean isNewBestTime = false; + + public WinDialog(Context context, int themeResId) { + super(context, themeResId); + } + + public WinDialog(Context context, int themeResId, String timeString, String hintString, boolean isNewBestTime) { + super(context,themeResId); + setParam(timeString, hintString, isNewBestTime); + } + + + public void setParam(String timeString, String hintString, boolean isNewBestTime){ + this.timeString = timeString; + this.hintString = hintString; + this.isNewBestTime = isNewBestTime; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + + ((TextView)findViewById(R.id.win_hints)).setText(hintString); + ((TextView)findViewById(R.id.win_time)).setText(timeString); + if(isNewBestTime){ + ((TextView)findViewById(R.id.win_new_besttime)).setVisibility(View.VISIBLE); + } + + } + + +}