Added some strings and HintListener

This commit is contained in:
Christopher Beckmann 2016-01-21 16:08:48 +01:00
parent 06deb5b439
commit 8db2f6ec91
9 changed files with 77 additions and 38 deletions

View file

@ -19,6 +19,7 @@ import org.secuso.privacyfriendlysudoku.game.GameType;
import org.secuso.privacyfriendlysudoku.game.ICellAction;
import org.secuso.privacyfriendlysudoku.game.listener.IGameSolvedListener;
import org.secuso.privacyfriendlysudoku.game.listener.IHighlightChangedListener;
import org.secuso.privacyfriendlysudoku.game.listener.IHintListener;
import org.secuso.privacyfriendlysudoku.game.listener.IModelChangedListener;
import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener;
@ -39,6 +40,7 @@ public class GameController implements IModelChangedListener {
private LinkedList<IHighlightChangedListener> highlightListeners = new LinkedList<>();
private LinkedList<IGameSolvedListener> solvedListeners = new LinkedList<>();
private LinkedList<IHintListener> hintListener = new LinkedList<>();
private boolean notifiedOnSolvedListeners = false;
// Game
@ -175,6 +177,8 @@ public class GameController implements IModelChangedListener {
// reveal the selected value.
selectValue(solved[selectedRow * getSize() + selectedCol]);
usedHints++;
notifyHintListener();
}
private void setGameType(GameType type) {
@ -553,6 +557,19 @@ public class GameController implements IModelChangedListener {
timerListeners.add(listener);
}
}
public void notifyHintListener() {
for (IHintListener listener : hintListener){
listener.onHintUsed();
}
}
public void registerHintListener(IHintListener listener){
if (!hintListener.contains(listener)){
hintListener.add(listener);
}
}
public int getUsedHints(){
return usedHints;
}

View file

@ -0,0 +1,8 @@
package org.secuso.privacyfriendlysudoku.game.listener;
/**
* Created by Chris on 21.01.2016.
*/
public interface IHintListener {
public void onHintUsed();
}

View file

@ -3,6 +3,7 @@ package org.secuso.privacyfriendlysudoku.ui;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
@ -209,8 +210,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
List<GameInfoContainer> gic = fm.loadGameStateInfo();
if(gic.size() > 0) {
continueButton.setEnabled(true);
continueButton.setBackgroundResource(R.drawable.standalone_button);
} else {
continueButton.setEnabled(false);
continueButton.setBackgroundResource(R.drawable.inactive_button);
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- default -->
<item>
<shape >
<solid
android:color="@color/middlegrey" />
<corners android:radius="6dp" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- default -->
<item>
<shape >
<solid
android:color="@color/colorPrimary" />
<corners android:radius="6dp" />
</shape>
</item>
</selector>

View file

@ -114,7 +114,7 @@
android:capitalize="none"
android:clickable="false"
android:elevation="10dp"
android:background="@drawable/mnenomic_numpad_button"/>
android:background="@drawable/standalone_button"/>
<Button
android:textColor="@color/white"
@ -131,7 +131,7 @@
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"
android:background="@drawable/mnenomic_numpad_button"/>
android:background="@drawable/standalone_button"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark" android:orientation="vertical"
android:gravity="bottom">
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@android:drawable/sym_def_app_icon" android:id="@+id/imageView" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing" android:text="Sudoku"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/description" android:id="@+id/textView" />
</LinearLayout>

View file

@ -33,5 +33,17 @@
<string name="difficulty_easy">Leicht</string>
<string name="difficulty_moderate">Normal</string>
<string name="difficulty_hard">Schwer</string>
<string name="about_qqwing">Diese App benutzt QQWing.</string>
<string name="average_time">&#2205; Zeit:</string>
<string name="cancel">Abbrechen</string>
<string name="description">eine privacy friendly App</string>
<string name="gametype_unspecified">Unspezifiziert</string>
<string name="generating">Generiere neue Level im Hintergrund&#8230;</string>
<string name="hint_confirmation">Bist du sicher, dass du einen Hinweis verwenden möchtest? Wenn Hinweise benutzt wurden, kann in dem Spiel keine Bestzeit mehr erreicht werden.</string>
<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="loadgame_delete_confirmation">Bist du sicher, dass du den Spielstand löschen möchtest?</string>
<string name="menu_continue_game">Spiel Fortsetzen</string>
</resources>

View file

@ -1,5 +1,5 @@
<resources>
<string name="app_name">Sudoku</string>
<string name="app_name" translatable="false">Sudoku</string>
<string name="title_activity_game_view">Sudoku</string>
<string name="cancel">Cancel</string>
@ -15,13 +15,13 @@
<string name="menu_reset">Reset Board</string>
<string name="menu_continue_game">Continue Game</string>
<string name="description">a privacy friendly logic puzzle</string>
<string name="description">a privacy friendly app</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="title_activity_load_game">Load Game</string>
<string name="generating">Generating new level in the background...</string>
<string name="generating">Generating new level in the background&#8230;</string>
<!-- ###SETTINGS### -->
<string name="title_activity_settings">Settings</string>
@ -59,10 +59,10 @@
<string name="pref_automatic_note_deletion_summary">Automatically remove notes when setting values on connected cells</string>
<!-- ###ABOUT### -->
<string name="app_name_long">Privacy friendly Sudoku</string>
<string name="app_name_long" translatable="false">Privacy friendly Sudoku</string>
<string name="version_number">v0.9</string>
<string name="about_author">Author:</string>
<string name="about_author_names">Christopher Beckmann, Timm Lippert</string>
<string name="about_author_names" translatable="false">Christopher Beckmann, Timm Lippert</string>
<string name="about_affiliation">In affiliation with:</string>
<string name="privacy_friendly">This application belongs to the Privacy Friendly Apps.</string>
<string name="qqwing">This application uses a modified version of QQWing v1.3.4</string>
@ -77,13 +77,13 @@
<string name="difficulty_hard">Hard</string>
<!--###GameActivity -->
<string name="Sudoku">Sudoku</string>
<string name="gametype_default_9x9">Standart Sudoku 9x9</string>
<string name="gametype_default_6x6">Standart Sudoku 6x6</string>
<string name="gametype_unspecified">Unspec</string>
<string name="gametype_default_12x12">Standart Sudoku 12x12</string>
<string name="gametype_x_9x9">X Sudoku 9x9</string>
<string name="gametype_hyper_9x9">Hyper Sudoku 9x9</string>
<string name="Sudoku" translatable="false">Sudoku</string>
<string name="gametype_default_9x9" translatable="false">Standard Sudoku 9x9</string>
<string name="gametype_default_6x6" translatable="false">Standard Sudoku 6x6</string>
<string name="gametype_unspecified">Unspecified</string>
<string name="gametype_default_12x12" translatable="false">Standard Sudoku 12x12</string>
<string name="gametype_x_9x9" translatable="false">X Sudoku 9x9</string>
<string name="gametype_hyper_9x9" translatable="false">Hyper Sudoku 9x9</string>
<string name="title_activity_stats_game">Statistics</string>
<string name="hint_usage">Select a valid field and then press the hint button to reveal the solution.</string>
<string name="hint_confirmation">Are you sure you want to use this hint? When using hints, you will not be able to achieve a personal best time.</string>
@ -108,6 +108,6 @@
<!--### Win Strings -->
<string name="win_text">Congratulations, you have solved the puzzle!</string>
<string name="win_button_text">OK!</string>
<string name="win_button_text">continue</string>
</resources>