diff --git a/sudoq-app/.classpath b/sudoq-app/.classpath
index 7f11e920..5f456a8a 100644
--- a/sudoq-app/.classpath
+++ b/sudoq-app/.classpath
@@ -5,5 +5,6 @@
+
diff --git a/sudoq-app/.settings/org.eclipse.jdt.core.prefs b/sudoq-app/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..8000cd6c
--- /dev/null
+++ b/sudoq-app/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sudoq-app/AndroidManifest.xml b/sudoq-app/AndroidManifest.xml
index 1a19e059..64ab18c0 100644
--- a/sudoq-app/AndroidManifest.xml
+++ b/sudoq-app/AndroidManifest.xml
@@ -5,8 +5,8 @@
@@ -14,23 +14,29 @@
-
+ android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/sudoq-app/project.properties b/sudoq-app/project.properties
index 85aac540..d0628c45 100644
--- a/sudoq-app/project.properties
+++ b/sudoq-app/project.properties
@@ -11,4 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-8
+target=android-19
+android.library.reference.1=../../JakeWharton-ActionBarSherlock-5a15d92/actionbarsherlock
diff --git a/sudoq-app/res/drawable-hdpi/launcher.png b/sudoq-app/res/drawable-hdpi/launcher.png
new file mode 100644
index 00000000..f6bf53f8
Binary files /dev/null and b/sudoq-app/res/drawable-hdpi/launcher.png differ
diff --git a/sudoq-app/res/drawable-hdpi/tutorial_bookmark.png b/sudoq-app/res/drawable-hdpi/tutorial_bookmark.png
new file mode 100644
index 00000000..804d9a9b
Binary files /dev/null and b/sudoq-app/res/drawable-hdpi/tutorial_bookmark.png differ
diff --git a/sudoq-app/res/drawable-hdpi/tutorial_branching.png b/sudoq-app/res/drawable-hdpi/tutorial_branching.png
new file mode 100644
index 00000000..49a9c438
Binary files /dev/null and b/sudoq-app/res/drawable-hdpi/tutorial_branching.png differ
diff --git a/sudoq-app/res/drawable-hdpi/tutorial_current_state.png b/sudoq-app/res/drawable-hdpi/tutorial_current_state.png
new file mode 100644
index 00000000..1b30859c
Binary files /dev/null and b/sudoq-app/res/drawable-hdpi/tutorial_current_state.png differ
diff --git a/sudoq-app/res/drawable-hdpi/tutorial_state.png b/sudoq-app/res/drawable-hdpi/tutorial_state.png
new file mode 100644
index 00000000..c689c51f
Binary files /dev/null and b/sudoq-app/res/drawable-hdpi/tutorial_state.png differ
diff --git a/sudoq-app/res/drawable-ldpi/ic_launcher.png b/sudoq-app/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index 1095584e..00000000
Binary files a/sudoq-app/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/sudoq-app/res/drawable-ldpi/tutorial_bookmark.png b/sudoq-app/res/drawable-ldpi/tutorial_bookmark.png
new file mode 100644
index 00000000..e068eaf0
Binary files /dev/null and b/sudoq-app/res/drawable-ldpi/tutorial_bookmark.png differ
diff --git a/sudoq-app/res/drawable-ldpi/tutorial_branching.png b/sudoq-app/res/drawable-ldpi/tutorial_branching.png
new file mode 100644
index 00000000..4bccbcff
Binary files /dev/null and b/sudoq-app/res/drawable-ldpi/tutorial_branching.png differ
diff --git a/sudoq-app/res/drawable-ldpi/tutorial_current_state.png b/sudoq-app/res/drawable-ldpi/tutorial_current_state.png
new file mode 100644
index 00000000..1d88ef2f
Binary files /dev/null and b/sudoq-app/res/drawable-ldpi/tutorial_current_state.png differ
diff --git a/sudoq-app/res/drawable-ldpi/tutorial_state.png b/sudoq-app/res/drawable-ldpi/tutorial_state.png
new file mode 100644
index 00000000..9309ec5c
Binary files /dev/null and b/sudoq-app/res/drawable-ldpi/tutorial_state.png differ
diff --git a/sudoq-app/res/drawable-mdpi/launcher.png b/sudoq-app/res/drawable-mdpi/launcher.png
new file mode 100644
index 00000000..1fb91751
Binary files /dev/null and b/sudoq-app/res/drawable-mdpi/launcher.png differ
diff --git a/sudoq-app/res/drawable-mdpi/tutorial_bookmark.png b/sudoq-app/res/drawable-mdpi/tutorial_bookmark.png
new file mode 100644
index 00000000..c4ad4e22
Binary files /dev/null and b/sudoq-app/res/drawable-mdpi/tutorial_bookmark.png differ
diff --git a/sudoq-app/res/drawable-mdpi/tutorial_branching.png b/sudoq-app/res/drawable-mdpi/tutorial_branching.png
new file mode 100644
index 00000000..14faec7b
Binary files /dev/null and b/sudoq-app/res/drawable-mdpi/tutorial_branching.png differ
diff --git a/sudoq-app/res/drawable-mdpi/tutorial_current_state.png b/sudoq-app/res/drawable-mdpi/tutorial_current_state.png
new file mode 100644
index 00000000..cdd2a5ed
Binary files /dev/null and b/sudoq-app/res/drawable-mdpi/tutorial_current_state.png differ
diff --git a/sudoq-app/res/drawable-mdpi/tutorial_state.png b/sudoq-app/res/drawable-mdpi/tutorial_state.png
new file mode 100644
index 00000000..dd3e84f3
Binary files /dev/null and b/sudoq-app/res/drawable-mdpi/tutorial_state.png differ
diff --git a/sudoq-app/res/drawable-xhdpi/launcher.png b/sudoq-app/res/drawable-xhdpi/launcher.png
new file mode 100644
index 00000000..009df9ff
Binary files /dev/null and b/sudoq-app/res/drawable-xhdpi/launcher.png differ
diff --git a/sudoq-app/res/drawable-xhdpi/tutorial_bookmark.png b/sudoq-app/res/drawable-xhdpi/tutorial_bookmark.png
new file mode 100644
index 00000000..d193acd1
Binary files /dev/null and b/sudoq-app/res/drawable-xhdpi/tutorial_bookmark.png differ
diff --git a/sudoq-app/res/drawable-xhdpi/tutorial_branching.png b/sudoq-app/res/drawable-xhdpi/tutorial_branching.png
new file mode 100644
index 00000000..c3c93a5b
Binary files /dev/null and b/sudoq-app/res/drawable-xhdpi/tutorial_branching.png differ
diff --git a/sudoq-app/res/drawable-xhdpi/tutorial_current_state.png b/sudoq-app/res/drawable-xhdpi/tutorial_current_state.png
new file mode 100644
index 00000000..cd861615
Binary files /dev/null and b/sudoq-app/res/drawable-xhdpi/tutorial_current_state.png differ
diff --git a/sudoq-app/res/drawable-xhdpi/tutorial_state.png b/sudoq-app/res/drawable-xhdpi/tutorial_state.png
new file mode 100644
index 00000000..e400760e
Binary files /dev/null and b/sudoq-app/res/drawable-xhdpi/tutorial_state.png differ
diff --git a/sudoq-app/res/drawable/launcher.png b/sudoq-app/res/drawable/launcher.png
index aed29a4b..af140b78 100644
Binary files a/sudoq-app/res/drawable/launcher.png and b/sudoq-app/res/drawable/launcher.png differ
diff --git a/sudoq-app/res/drawable/tutorial_bookmark.png b/sudoq-app/res/drawable/tutorial_bookmark.png
new file mode 100644
index 00000000..d193acd1
Binary files /dev/null and b/sudoq-app/res/drawable/tutorial_bookmark.png differ
diff --git a/sudoq-app/res/drawable/tutorial_branching.png b/sudoq-app/res/drawable/tutorial_branching.png
new file mode 100644
index 00000000..c3c93a5b
Binary files /dev/null and b/sudoq-app/res/drawable/tutorial_branching.png differ
diff --git a/sudoq-app/res/drawable/tutorial_current_state.png b/sudoq-app/res/drawable/tutorial_current_state.png
new file mode 100644
index 00000000..cd861615
Binary files /dev/null and b/sudoq-app/res/drawable/tutorial_current_state.png differ
diff --git a/sudoq-app/res/drawable/tutorial_state.png b/sudoq-app/res/drawable/tutorial_state.png
new file mode 100644
index 00000000..e400760e
Binary files /dev/null and b/sudoq-app/res/drawable/tutorial_state.png differ
diff --git a/sudoq-app/res/layout-land/mainmenu.xml b/sudoq-app/res/layout-land/mainmenu.xml
index 4d79326c..42b2d3f7 100644
--- a/sudoq-app/res/layout-land/mainmenu.xml
+++ b/sudoq-app/res/layout-land/mainmenu.xml
@@ -23,41 +23,42 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
-
-
+
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/layout-land/playerpreferences.xml b/sudoq-app/res/layout-land/playerpreferences.xml
index 28886032..016a69ee 100644
--- a/sudoq-app/res/layout-land/playerpreferences.xml
+++ b/sudoq-app/res/layout-land/playerpreferences.xml
@@ -14,54 +14,28 @@
android:layout_height="wrap_content"
android:orientation="vertical" >
-
-
-
-
-
+
-
-
+
-
-
+
-
-
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/layout/playerpreferences.xml b/sudoq-app/res/layout/playerpreferences.xml
index 6f6652b0..2169864d 100644
--- a/sudoq-app/res/layout/playerpreferences.xml
+++ b/sudoq-app/res/layout/playerpreferences.xml
@@ -13,18 +13,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
-
-
-
+
-
+
-
+
@@ -200,6 +201,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
+ android:background="@android:drawable/btn_default"
android:onClick="onClick"
android:text="@string/sf_sudoku_button_close" />
diff --git a/sudoq-app/res/layout/sudokupreferences.xml b/sudoq-app/res/layout/sudokupreferences.xml
index d9458327..1f613252 100644
--- a/sudoq-app/res/layout/sudokupreferences.xml
+++ b/sudoq-app/res/layout/sudokupreferences.xml
@@ -14,14 +14,14 @@
android:layout_height="wrap_content"
android:orientation="vertical" >
-
+ android:textColor="@android:color/black" /-->
+ android:src="@drawable/action_tree"/>
@@ -59,15 +59,16 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
-
+ android:layout_margin="5dp"
+ android:src="@drawable/tutorial_state" />
@@ -79,12 +80,12 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
-
+ android:layout_margin="5dp"
+ android:src="@drawable/tutorial_bookmark" />
-
+ android:layout_margin="5dp"
+ android:src="@drawable/tutorial_current_state" />
-
+ android:layout_margin="5dp"
+ android:src="@drawable/tutorial_branching" />
+
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/menu/action_bar_player_preferences.xml b/sudoq-app/res/menu/action_bar_player_preferences.xml
new file mode 100644
index 00000000..d81f3798
--- /dev/null
+++ b/sudoq-app/res/menu/action_bar_player_preferences.xml
@@ -0,0 +1,29 @@
+
+
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/menu/action_bar_standard.xml b/sudoq-app/res/menu/action_bar_standard.xml
new file mode 100644
index 00000000..2ffedefb
--- /dev/null
+++ b/sudoq-app/res/menu/action_bar_standard.xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/menu/action_bar_sudoku.xml b/sudoq-app/res/menu/action_bar_sudoku.xml
new file mode 100644
index 00000000..7389404a
--- /dev/null
+++ b/sudoq-app/res/menu/action_bar_sudoku.xml
@@ -0,0 +1,20 @@
+
+
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/menu/action_bar_sudoku_loading.xml b/sudoq-app/res/menu/action_bar_sudoku_loading.xml
new file mode 100644
index 00000000..bced288b
--- /dev/null
+++ b/sudoq-app/res/menu/action_bar_sudoku_loading.xml
@@ -0,0 +1,23 @@
+
+
+
+
\ No newline at end of file
diff --git a/sudoq-app/res/values-de/strings.xml b/sudoq-app/res/values-de/strings.xml
index 84ef2dfd..959e8632 100644
--- a/sudoq-app/res/values-de/strings.xml
+++ b/sudoq-app/res/values-de/strings.xml
@@ -25,13 +25,17 @@
SudoQ wird für die erste Benutzung vorbereitet
-
- Tutorial
- Gesten für Ziffern
- Gesten für Buchstaben
- Alle Gesten löschen
- Spezifische Geste löschen
+
+ Tutorial
+
+ Neues Profil erstellen
+ Dieses Profil löschen
+ Profil wechseln
+ Alle Gesten löschen
+ Spezifische Geste löschen
+
+
Ja
Nein
@@ -67,10 +71,7 @@
Zufälliges Feld lösen
Tipps
Notizen automatisch anpassen
- Profil wechseln
Profil
- Neues Profil erstellen
- Profil löschen
Statistik
Gesten definieren
Speichern
@@ -89,6 +90,7 @@
Profil
+ Gesten definieren
Zeichne die gewünschte Geste
diff --git a/sudoq-app/res/values-fr/strings.xml b/sudoq-app/res/values-fr/strings.xml
index fdc61256..18212920 100644
--- a/sudoq-app/res/values-fr/strings.xml
+++ b/sudoq-app/res/values-fr/strings.xml
@@ -9,7 +9,7 @@
Erreur! Le dossier Profile n’a pas pu être trouvé!
Erreur! Paramètres incomplets!
Gestes non disponibles!
-Vignette n’a pas pu être créé!
+ Vignette n’a pas pu être créé!
Reçu miniature n’a pas pu être sauvé!
Les vignettes peuvent ne pas être chargé!
Certains symboles ne sont pas liées à un geste!
@@ -25,13 +25,17 @@
SudoQ se prépare pour la première utilisation
-
- Tutorial
-Gestes pour les chiffres
- Gestes pour les lettres
- Supprimer tous les gestes
- Supprimer geste spécifique
-
+
+
+ Tutorial
+
+ Créer un nouveau profil
+ Effacer ce profil
+ Changer de profil
+ Supprimer tous les gestes
+ Supprimer geste spécifique
+
+
Oui
Non
@@ -67,12 +71,9 @@
Résoudre une case au hasard
Conseils
Adapter les remarques automatiquement
- Changer de profil
Profil
- Créer un nouveau profil
- Effacer ce profil
Statistiques
-définir des gestes
+ définir des gestes
Sauvegarder
nouveau profil
@@ -88,6 +89,11 @@
Charger un sudoku
Profil
+
+
+ définir des gestes
+ Dessinez le geste désiré
+
Sudoku
Sudoku officiel
diff --git a/sudoq-app/res/values/strings.xml b/sudoq-app/res/values/strings.xml
index 8704f916..caa3cc7e 100644
--- a/sudoq-app/res/values/strings.xml
+++ b/sudoq-app/res/values/strings.xml
@@ -11,12 +11,16 @@
1.0.4
Berta
-
- Tutorial
- Gestures for digits
- Gestures for letters
- Delete all gestures
- Delete specific gestures
+
+
+ Tutorial
+
+ Create New Profile
+ Delete This Profile
+ Switch Profile
+ Delete all gestures
+ Delete specific gesture
+
Error! Profile folder could not be located!
@@ -73,10 +77,7 @@
Solve Random Field
Hint For Easy Field
Auto Adjust Notices
- Switch Profile
Profile
- Create New Profile
- Delete Profile
Statistics
Gesture Builder
Save
@@ -95,6 +96,7 @@
Profile
+ Gesture Builder
Define a Gesture
diff --git a/sudoq-app/src/de/sudoq/controller/SudoqActivity.java b/sudoq-app/src/de/sudoq/controller/SudoqActivity.java
index 099c8e84..785a35b6 100644
--- a/sudoq-app/src/de/sudoq/controller/SudoqActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/SudoqActivity.java
@@ -7,13 +7,13 @@
*/
package de.sudoq.controller;
+import de.sudoq.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
-import de.sudoq.R;
import de.sudoq.controller.tutorial.TutorialActivity;
import de.sudoq.model.files.FileManager;
@@ -70,7 +70,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
* Das Menü
*/
protected void prepareOptionsMenu(Menu menu) {
- menu.add(0, MENU_TUTORIAL, 0, getString(R.string.optionsmenu_tutorial));
+ menu.add(0, MENU_TUTORIAL, 0, getString(R.string.action_show_tutorial));
}
/**
diff --git a/sudoq-app/src/de/sudoq/controller/SudoqActivitySherlock.java b/sudoq-app/src/de/sudoq/controller/SudoqActivitySherlock.java
new file mode 100644
index 00000000..87eb94ea
--- /dev/null
+++ b/sudoq-app/src/de/sudoq/controller/SudoqActivitySherlock.java
@@ -0,0 +1,90 @@
+/*
+ * SudoQ is a Sudoku-App for Adroid Devices with Version 2.2 at least.
+ * Copyright (C) 2012 Haiko Klare, Julian Geppert, Jan-Bernhard Kordaß, Jonathan Kieling, Tim Zeitz, Timo Abele
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License along with this program; if not, see .
+ */
+package de.sudoq.controller;
+
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import de.sudoq.R;
+import de.sudoq.controller.tutorial.TutorialActivity;
+import de.sudoq.model.files.FileManager;
+
+/**
+ * Eine Activity, welche die für einwandfreie Funktionalität der SudoQ-App
+ * notwendigen Initialisierungsarbeiten ausführt.
+ */
+public class SudoqActivitySherlock extends SherlockActivity {
+
+ /**
+ * Initialisiert eine neue Activity, setzt dabei die für die App notwendigen
+ * System-Properties und initialisiert den FileManager.
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
+ FileManager.initialize(getDir(getString(R.string.path_rel_profiles), Context.MODE_PRIVATE),
+ getDir(getString(R.string.path_rel_sudokus), Context.MODE_PRIVATE));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.gc();
+ }
+
+ /**
+ * Erstellt das Optionsmenü mit einem Tutorial-Eintrag.
+ *
+ * @param menu
+ * Das Menü
+ * @return true
+ */
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.action_bar_standard, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ /**
+ * Fügt dem übergebenen Menü die globalen Einträge (Tutorial) hinzu.
+ *
+ * @param menu
+ * Das Menü
+ *
+ protected void prepareOptionsMenu(Menu menu) {
+ menu.add(0, MENU_TUTORIAL, 0, getString(R.string.action_show_tutorial));
+ }*/
+
+ /**
+ * Verarbeitet das Auswählen des Tutorial-Menüeintrags.
+ *
+ * @param item
+ * Das ausgewählte Menü-Item
+ * @return true
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_show_tutorial:
+ startActivity(new Intent(this, TutorialActivity.class));
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/SudoqListActivity.java b/sudoq-app/src/de/sudoq/controller/SudoqListActivity.java
index 814cf34e..6825802f 100644
--- a/sudoq-app/src/de/sudoq/controller/SudoqListActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/SudoqListActivity.java
@@ -7,12 +7,15 @@
*/
package de.sudoq.controller;
+import com.actionbarsherlock.app.SherlockListActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
import de.sudoq.R;
import de.sudoq.controller.tutorial.TutorialActivity;
import de.sudoq.model.files.FileManager;
@@ -21,12 +24,8 @@
* Eine ListActivity, welche die für einwandfreie Funktionalität der SudoQ-App
* notwendigen Initialisierungsarbeiten ausführt.
*/
-public class SudoqListActivity extends ListActivity {
+public class SudoqListActivity extends SherlockListActivity {
- /**
- * Konstante für den Tutorial Menü-Eintrag
- */
- private static final int MENU_TUTORIAL = -1;
/**
* Initialisiert eine neue Activity, setzt dabei die für die App notwendigen
@@ -58,8 +57,9 @@ public void onDestroy() {
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, MENU_TUTORIAL, 0, getString(R.string.optionsmenu_tutorial));
- return true;
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.action_bar_standard, menu);
+ return super.onCreateOptionsMenu(menu);
}
/**
@@ -71,10 +71,13 @@ public boolean onCreateOptionsMenu(Menu menu) {
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == MENU_TUTORIAL) {
+ switch (item.getItemId()) {
+ case R.id.action_show_tutorial:
startActivity(new Intent(this, TutorialActivity.class));
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
- return true;
}
}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/menus/AssistancesPreferencesActivity.java b/sudoq-app/src/de/sudoq/controller/menus/AssistancesPreferencesActivity.java
index 328b3c17..476df8bb 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/AssistancesPreferencesActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/AssistancesPreferencesActivity.java
@@ -15,6 +15,7 @@
import android.widget.LinearLayout;
import de.sudoq.R;
import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.model.ModelChangeListener;
import de.sudoq.model.game.Assistances;
import de.sudoq.model.profile.Profile;
@@ -22,7 +23,7 @@
/**
* Activity um Profile zu bearbeiten und zu verwalten
*/
-public class AssistancesPreferencesActivity extends SudoqActivity implements ModelChangeListener {
+public class AssistancesPreferencesActivity extends SudoqActivitySherlock implements ModelChangeListener {
/** Attributes */
private static final String LOG_TAG = AssistancesPreferencesActivity.class.getSimpleName();
diff --git a/sudoq-app/src/de/sudoq/controller/menus/GestureBuilder.java b/sudoq-app/src/de/sudoq/controller/menus/GestureBuilder.java
index 5090f818..30e3b02f 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/GestureBuilder.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/GestureBuilder.java
@@ -15,6 +15,10 @@
import java.util.Iterator;
import java.util.Set;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
import android.gesture.Gesture;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
@@ -23,15 +27,13 @@
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import de.sudoq.R;
-import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.controller.sudoku.FieldViewPainter;
import de.sudoq.controller.sudoku.FieldViewStates;
import de.sudoq.controller.sudoku.InputListener;
@@ -45,7 +47,7 @@
* @author Anrion
*
*/
-public class GestureBuilder extends SudoqActivity implements OnGesturePerformedListener, InputListener {
+public class GestureBuilder extends SudoqActivitySherlock implements OnGesturePerformedListener, InputListener {
/**
* Fängt Gesteneingaben des Benutzers ab
@@ -57,15 +59,6 @@ public class GestureBuilder extends SudoqActivity implements OnGesturePerformedL
*/
private GestureStore gestureStore = new GestureStore();
- /**
- * ID des OptionsMenu-Eintrags zum Löschen aller Gesten.
- */
- private static final int MENU_FLUSH_GESTURE_LIBRARY = 2;
-
- /**
- * ID des OptionsMenu-Eintrags zum Löschen einer bestimmten Geste.
- */
- private static final int MENU_DELETE_GESTURE = 3;
private static final String LOG_TAG = GestureBuilder.class.getSimpleName();
@@ -125,7 +118,7 @@ private void inflateGestures() {
this.gestureOverlay = new GestureOverlayView(this);
this.gestureOverlay.addOnGesturePerformedListener(this);
- LayoutParams gestureLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
+ LayoutParams gestureLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
this.gestureOverlay.setLayoutParams(gestureLayoutParams);
this.gestureOverlay.setBackgroundColor(Color.BLACK);
this.gestureOverlay.getBackground().setAlpha(127);
@@ -135,18 +128,18 @@ private void inflateGestures() {
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.gesture_builder_layout);
frameLayout.addView(this.gestureOverlay);
}
-
@Override
- protected void prepareOptionsMenu(Menu menu) {
- super.prepareOptionsMenu(menu);
- menu.add(0, MENU_FLUSH_GESTURE_LIBRARY, 0, getString(R.string.optionsmenu_gesture_builder_flush));
- menu.add(0, MENU_DELETE_GESTURE, 0, getString(R.string.optionsmenu_gesture_builder_delete_single));
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.action_bar_gesture_builder, menu);
+ return true;
}
-
+
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case MENU_FLUSH_GESTURE_LIBRARY:
+ case R.id.action_delete_all_gestures:
Set gestures = this.gestureStore.getGestureEntries();
for (Iterator gestureIterator = gestures.iterator(); gestureIterator.hasNext();) {
String gestureName = (String) gestureIterator.next();
@@ -155,7 +148,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
saveGestures();
refreshKeyboard();
break;
- case MENU_DELETE_GESTURE:
+ case R.id.action_delete_single_gesture:
this.deleteSpecific = true;
break;
}
@@ -217,7 +210,6 @@ public void onBackPressed() {
this.gestureOverlay.setVisibility(View.INVISIBLE);
} else {
saveGestures();
- Set gestures = this.gestureStore.getGestureEntries();
super.onBackPressed();
}
}
diff --git a/sudoq-app/src/de/sudoq/controller/menus/MainActivity.java b/sudoq-app/src/de/sudoq/controller/menus/MainActivity.java
index 740a595c..ab9eeb49 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/MainActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/MainActivity.java
@@ -15,7 +15,7 @@
import android.view.View;
import android.widget.Button;
import de.sudoq.R;
-import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.controller.sudoku.SudokuActivity;
import de.sudoq.model.files.FileManager;
import de.sudoq.model.profile.Profile;
@@ -23,7 +23,7 @@
/**
* Verwaltet das Hauptmenü der App.
*/
-public class MainActivity extends SudoqActivity {
+public class MainActivity extends SudoqActivitySherlock {
/**
* Der Log-Tag für den LogCat
diff --git a/sudoq-app/src/de/sudoq/controller/menus/PlayerPreferencesActivity.java b/sudoq-app/src/de/sudoq/controller/menus/PlayerPreferencesActivity.java
index 08e05678..22596dd3 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/PlayerPreferencesActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/PlayerPreferencesActivity.java
@@ -9,25 +9,34 @@
import java.util.List;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
+
+/*import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;*/
+
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import de.sudoq.R;
import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.model.ModelChangeListener;
import de.sudoq.model.game.Assistances;
import de.sudoq.model.profile.Profile;
/**
* Activity um Profile zu bearbeiten und zu verwalten
+ * aufgerufen im Hauptmenü 4. Button
*/
-public class PlayerPreferencesActivity extends SudoqActivity implements ModelChangeListener {
+public class PlayerPreferencesActivity extends SudoqActivitySherlock implements ModelChangeListener {
/** Attributes */
private static final String LOG_TAG = PlayerPreferencesActivity.class.getSimpleName();
@@ -59,6 +68,9 @@ public class PlayerPreferencesActivity extends SudoqActivity implements ModelCha
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ //setTitle(R.string.profile_preference_title);
+
this.setContentView(R.layout.playerpreferences);
firstStartup = false;
@@ -78,6 +90,7 @@ public void onCreate(Bundle savedInstanceState) {
createProfile = true;
/* Aufruf aus SudokuPreferenceActivity */
+ /* not happening: assistences preference activity would be called*/
if (getIntent().hasExtra(INTENT_ONLYASSISTANCES) && getIntent().getExtras().getBoolean(INTENT_ONLYASSISTANCES)) {
Log.d(LOG_TAG, "Short assistances");
@@ -229,14 +242,6 @@ public void deleteProfile(View view) {
Profile.getInstance().deleteProfile();
}
- /*
- * {@inheritDoc}
- */
- // @Override
- // public void onConfigurationChanged(Configuration newConfig) {
- // super.onConfigurationChanged(newConfig);
- // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- // }
public void onModelChanged(Profile obj) {
this.refreshValues();
@@ -244,18 +249,10 @@ public void onModelChanged(Profile obj) {
// ///////////////////////////////////////optionsMenue
- private static final int MENU_SWITCH_PROFILE = 0;
- private static final int MENU_CREATE_PROFILE = 1;
- private static final int MENU_DELETE_PROFILE = 2;
-
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- if (createProfile)
- menu.clear();
-
- // onPrepareOptionsMenu(menu);
-
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.action_bar_player_preferences, menu);
return true;
}
@@ -268,30 +265,30 @@ public boolean onCreateOptionsMenu(Menu menu) {
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- super.onOptionsItemSelected(item);
- if (item.getItemId() == MENU_SWITCH_PROFILE) {
- switchToProfileList(null);
- } else if (item.getItemId() == MENU_CREATE_PROFILE) {
+ switch (item.getItemId()) {
+ case R.id.action_new_profile:
createProfile(null);
- } else if (item.getItemId() == MENU_DELETE_PROFILE) {
+ return true;
+ case R.id.action_delete_profile:
deleteProfile(null);
+ return true;
+ case R.id.action_switch_profile:
+ switchToProfileList(null);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
- return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
- if (createProfile) {
- menu.clear();
-
- menu.add(0, MENU_CREATE_PROFILE, 0, getString(R.string.profile_preference_title_createprofile));
- if (Profile.getInstance().getNumberOfAvailableProfiles() > 1) {
- menu.add(0, MENU_DELETE_PROFILE, 0, getString(R.string.profile_preference_title_deleteprofile));
- menu.add(0, MENU_SWITCH_PROFILE, 0, getString(R.string.profile_preference_title_switchprofile));
- }
- }
- super.prepareOptionsMenu(menu);
+
+ boolean multipleProfiles=Profile.getInstance().getNumberOfAvailableProfiles() > 1;
+
+ menu.findItem(R.id.action_delete_profile).setVisible(multipleProfiles);
+ menu.findItem(R.id.action_switch_profile).setVisible(multipleProfiles);
+
return true;
}
}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/menus/ProfileListActivity.java b/sudoq-app/src/de/sudoq/controller/menus/ProfileListActivity.java
index 3b91e002..968e2bab 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/ProfileListActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/ProfileListActivity.java
@@ -8,7 +8,6 @@
package de.sudoq.controller.menus;
import java.util.ArrayList;
-
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@@ -51,7 +50,7 @@ public class ProfileListActivity extends SudoqListActivity implements OnItemClic
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- this.setTitle(this.getString(R.string.profile_preference_title_switchprofile));
+ this.setTitle(this.getString(R.string.action_switch_profile));
profileIds = Profile.getInstance().getProfilesIdList();
profileNames = Profile.getInstance().getProfilesNameList();
diff --git a/sudoq-app/src/de/sudoq/controller/menus/SplashActivity.java b/sudoq-app/src/de/sudoq/controller/menus/SplashActivity.java
index 999e37cc..161ee1fa 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/SplashActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/SplashActivity.java
@@ -15,6 +15,9 @@
import java.util.HashSet;
import java.util.Set;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.Window;
+
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
@@ -23,9 +26,8 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
-import android.view.Menu;
import de.sudoq.R;
-import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.model.files.FileManager;
import de.sudoq.model.profile.Profile;
import de.sudoq.model.sudoku.complexity.Complexity;
@@ -36,7 +38,7 @@
* sowie den FileManager initialisiert und die Daten für den ersten Start
* vorbereitet.
*/
-public class SplashActivity extends SudoqActivity {
+public class SplashActivity extends SudoqActivitySherlock {
/**
* Das Log-Tag für das LogCat.
*/
@@ -82,17 +84,23 @@ public class SplashActivity extends SudoqActivity {
private static String currentVersionValue = "";
private Set collectTypesToBeReplaced(String oldVersion) {
+ /*determines which defectious templates need to be replaced*/
Set replacies = new HashSet();
+ /*existing installations older than version 1.0.4
+ * need to replace standard16x16 and standard9x9 */
String replaceVersion = "1.0.4";
if (replaceVersion.compareTo(oldVersion) >= 0) {
replacies.add(SudokuTypes.standard16x16);
replacies.add(SudokuTypes.standard9x9);
}
- /*
- * other versions that replace templates !example! replaceVersion =
- * 1.0.6 if(repl.cpT(oldVersion) >=0 ){
+ /*
+ * In case 1.0.6 would replace some templates we would write:
+ * !example!
+ * String replaceVersion = 1.0.6;
+ * if(repl.cpT(oldVersion) >=0 ){
+ * r.add...
*
* }
*/
@@ -105,7 +113,10 @@ private Set collectTypesToBeReplaced(String oldVersion) {
*/
@Override
public void onCreate(Bundle savedInstanceState) {
+ //this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
+ //requestWindowFeature(Window.FEATURE_ACTION_BAR);
+ //getSupportActionBar().hide();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.splash);
@@ -143,7 +154,7 @@ public void onCreate(Bundle savedInstanceState) {
new Initialization(typesToBeReplaced).execute(null, null, null);
startedCopying = true;
}
-
+ /* splash thread*/
this.splashThread = new Thread() {
@Override
public void run() {
@@ -263,8 +274,8 @@ private void copyAssets() {
typeDir.mkdir();
for (Complexity c : Complexity.playableValues()) {
- String assetsPath = HEAD_DIRECTORY + File.separator + t.toString() + File.separator + c.toString();
- String relPath = typeDir.getAbsolutePath() + File.separator + c.toString();
+ String assetsPath = HEAD_DIRECTORY + File.separator + t.toString() + File.separator + c.toString(); //template that comes with the app
+ String relPath = typeDir.getAbsolutePath() + File.separator + c.toString(); //destination folder
File f = new File(relPath);
f.mkdir();
diff --git a/sudoq-app/src/de/sudoq/controller/menus/StatisticsActivity.java b/sudoq-app/src/de/sudoq/controller/menus/StatisticsActivity.java
index 3e0df1d2..9b4d1eb2 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/StatisticsActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/StatisticsActivity.java
@@ -7,12 +7,11 @@
*/
package de.sudoq.controller.menus;
-import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.TextView;
import de.sudoq.R;
-import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
+import de.sudoq.controller.sudoku.SudokuActivity;
import de.sudoq.model.profile.Profile;
import de.sudoq.model.profile.Statistics;
@@ -20,9 +19,14 @@
* Diese Klasse stellt eine Activity zur Anzeige der Statisik des aktuellen
* Spielerprofils dar.
*/
-public class StatisticsActivity extends SudoqActivity {
+public class StatisticsActivity extends SudoqActivitySherlock {
/** Methods */
+ private void setScore(int textViewID, int label, Statistics statLabel){
+ TextView current = (TextView) findViewById(textViewID);
+ current.setText(getString(label) + ": " + Profile.getInstance().getStatistic(statLabel));
+ }
+
/**
* Wird beim ersten Start der Activity aufgerufen.
*/
@@ -30,27 +34,22 @@ public class StatisticsActivity extends SudoqActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.statistics);
- TextView current = (TextView) findViewById(R.id.text_played_sudokus);
- current.setText(getString(R.string.statistics_played_sudokus) + ": " + Profile.getInstance().getStatistic(Statistics.playedSudokus));
- current = (TextView) findViewById(R.id.text_played_easy_sudokus);
- current.setText(getString(R.string.statistics_played_easy_sudokus) + ": " + Profile.getInstance().getStatistic(Statistics.playedEasySudokus));
- current = (TextView) findViewById(R.id.text_played_medium_sudokus);
- current.setText(getString(R.string.statistics_played_medium_sudokus) + ": " + Profile.getInstance().getStatistic(Statistics.playedMediumSudokus));
- current = (TextView) findViewById(R.id.text_played_difficult_sudokus);
- current.setText(getString(R.string.statistics_played_difficult_sudokus) + ": " + Profile.getInstance().getStatistic(Statistics.playedDifficultSudokus));
- current = (TextView) findViewById(R.id.text_played_infernal_sudokus);
- current.setText(getString(R.string.statistics_played_infernal_sudokus) + ": " + Profile.getInstance().getStatistic(Statistics.playedInfernalSudokus));
- current = (TextView) findViewById(R.id.text_score);
- current.setText(getString(R.string.statistics_score) + ": " + Profile.getInstance().getStatistic(Statistics.maximumPoints));
- current = (TextView) findViewById(R.id.text_fastest_solving_time);
- int fullTime = Profile.getInstance().getStatistic(Statistics.fastestSolvingTime);
+
+ setScore(R.id.text_played_sudokus, R.string.statistics_played_sudokus, Statistics.playedSudokus);
+ setScore(R.id.text_played_easy_sudokus, R.string.statistics_played_easy_sudokus, Statistics.playedEasySudokus);
+ setScore(R.id.text_played_medium_sudokus, R.string.statistics_played_medium_sudokus, Statistics.playedMediumSudokus);
+ setScore(R.id.text_played_difficult_sudokus,R.string.statistics_played_difficult_sudokus, Statistics.playedDifficultSudokus);
+ setScore(R.id.text_played_infernal_sudokus, R.string.statistics_played_infernal_sudokus, Statistics.playedInfernalSudokus);
+ setScore(R.id.text_score, R.string.statistics_score, Statistics.maximumPoints);
+
+ TextView current = (TextView) findViewById(R.id.text_fastest_solving_time);
+
+ int timeRecordInSecs = Profile.getInstance().getStatistic(Statistics.fastestSolvingTime);
+
String timeString = "---";
- if (fullTime != 5999) {
- timeString = fullTime / 60 + ":";
- if (fullTime % 60 < 10) {
- timeString += "0";
- }
- timeString += fullTime % 60;
+
+ if (timeRecordInSecs != Profile.INITIAL_TIME_RECORD) {
+ timeString = SudokuActivity.getTimeString(timeRecordInSecs);
}
current.setText(getString(R.string.statistics_fastest_solving_time) + ": " + timeString);
}
@@ -58,9 +57,9 @@ public void onCreate(Bundle savedInstanceState) {
/**
* {@inheritDoc}
*/
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
+ //@Override
+ /*public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
+ }*/
}
diff --git a/sudoq-app/src/de/sudoq/controller/menus/SudokuLoadingActivity.java b/sudoq-app/src/de/sudoq/controller/menus/SudokuLoadingActivity.java
index ef1c2fa3..8b3cde7c 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/SudokuLoadingActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/SudokuLoadingActivity.java
@@ -9,13 +9,15 @@
import java.util.List;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -52,8 +54,8 @@ public class SudokuLoadingActivity extends SudoqListActivity implements OnItemCl
private static final int MENU_DELETE_SPECIFIC = 1;
private boolean deleteMode = false;
-
- /** Constructors */
+
+ /** Constructors */
/** Methods */
@@ -68,7 +70,9 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.sudokuloading);
initialiseGames();
}
-
+
+
+
/**
* Wird beim ersten Anzeigen des Options-Menü von SudokuLoading aufgerufen
* und initialisiert das Optionsmenü indem das Layout inflated wird.
@@ -77,10 +81,8 @@ public void onCreate(Bundle savedInstanceState) {
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- menuDeleteSpecific = menu.add(0, MENU_DELETE_SPECIFIC, 0, R.string.sudokuloading_delete_specific);
- menuDeleteFinished = menu.add(0, MENU_DELETE_FINISHED, 0, R.string.sudokuloading_delete_finished);
- super.onCreateOptionsMenu(menu);
-
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.action_bar_sudoku_loading, menu);
return true;
}
@@ -94,17 +96,29 @@ public boolean onCreateOptionsMenu(Menu menu) {
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- super.onOptionsItemSelected(item);
-
- if (item.getItemId() == MENU_DELETE_FINISHED) {
- GameManager.getInstance().deleteFinishedGames();
- } else if (item.getItemId() == MENU_DELETE_SPECIFIC) {
+ switch (item.getItemId()) {
+ case R.id.action_sudokuloading_delete_specific:
this.deleteMode = true;
+ case R.id.action_sudokuloading_delete_finished:
+ GameManager.getInstance().deleteFinishedGames();
+ default:
+ super.onOptionsItemSelected(item);
}
-
onContentChanged();
return false;
}
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+ List gamesList = GameManager.getInstance().getGameList();
+ boolean noGames = gamesList.isEmpty();
+
+ menu.findItem(R.id.action_sudokuloading_delete_specific).setVisible(!noGames);
+ menu.findItem(R.id.action_sudokuloading_delete_finished).setVisible(!noGames);
+
+ return true;
+ }
/**
* {@inheritDoc}
@@ -124,6 +138,7 @@ public void onContentChanged() {
initialiseGames();
}
+
/**
* Wird aufgerufen, falls ein Element (eine View) in der AdapterView
* angeklickt wird.
@@ -141,10 +156,12 @@ public void onItemClick(AdapterView> parent, View view, int position, long id)
Log.d(LOG_TAG, position + "");
if (!this.deleteMode) {
+ /* selected in order to play */
Profile.getInstance().setCurrentGame(adapter.getItem(position).getId());
startActivity(new Intent(this, SudokuActivity.class));
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
} else {
+ /* user wants it deleted */
this.deleteMode = false;
GameManager.getInstance().deleteGame(adapter.getItem(position).getId());
onContentChanged();
@@ -193,7 +210,6 @@ public void goBack(View view) {
*/
public int getSize() {
return games.size();
- }
+ }
-}
-
+}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/menus/SudokuPreferencesActivity.java b/sudoq-app/src/de/sudoq/controller/menus/SudokuPreferencesActivity.java
index b087fd4c..3f00d8c2 100644
--- a/sudoq-app/src/de/sudoq/controller/menus/SudokuPreferencesActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/menus/SudokuPreferencesActivity.java
@@ -17,7 +17,7 @@
import android.widget.Spinner;
import android.widget.Toast;
import de.sudoq.R;
-import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.controller.sudoku.SudokuActivity;
import de.sudoq.model.game.AssistanceSet;
import de.sudoq.model.game.Game;
@@ -30,8 +30,10 @@
/**
* SudokuPreferences ermöglicht das Verwalten von Einstellungen eines zu
* startenden Sudokus.
+ *
+ * Hauptmenü -> "neues Sudoku" führt hierher
*/
-public class SudokuPreferencesActivity extends SudoqActivity {
+public class SudokuPreferencesActivity extends SudoqActivitySherlock {
/** Attributes */
private Intent startGameIntent;
@@ -165,12 +167,7 @@ public void onResume() {
this.startGameIntent = new Intent(this, SudokuActivity.class);
this.gameType = GameType.LOCAL;
break;
- // TODO: Enable MP in SudokuPreferences
- // case MULTIPLAYER_GAME:
- // this.startGameIntent = new Intent(this,
- // SudokuMultiplayerActivity.class);
- // this.gameType = GameType.MULTIPLAYER;
- // break;
+ // we assumed there would be multiplayer...
}
}
diff --git a/sudoq-app/src/de/sudoq/controller/sudoku/SudokuActivity.java b/sudoq-app/src/de/sudoq/controller/sudoku/SudokuActivity.java
index 63296402..90dcbc75 100644
--- a/sudoq-app/src/de/sudoq/controller/sudoku/SudokuActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/sudoku/SudokuActivity.java
@@ -13,11 +13,12 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
import java.util.Set;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.gesture.GestureOverlayView;
@@ -42,7 +43,7 @@
import android.widget.TextView;
import android.widget.Toast;
import de.sudoq.R;
-import de.sudoq.controller.SudoqActivity;
+import de.sudoq.controller.SudoqActivitySherlock;
import de.sudoq.model.actionTree.ActionTreeElement;
import de.sudoq.model.files.FileManager;
import de.sudoq.model.game.Assistances;
@@ -61,7 +62,7 @@
* Spielfeld zu reagieren. Die Klasse wird außerdem benutzt um zu verwalten,
* welche Navigationselemente dem Nutzer angezeigt werden.
*/
-public class SudokuActivity extends SudoqActivity implements OnClickListener, ActionListener, ActionTreeNavListener {
+public class SudokuActivity extends SudoqActivitySherlock implements OnClickListener, ActionListener, ActionTreeNavListener {
/** Attributes */
@@ -152,11 +153,6 @@ public class SudokuActivity extends SudoqActivity implements OnClickListener, Ac
*/
private boolean actionTreeShown;
- /**
- * Die Anzeige der Zeit
- */
- private TextView timeView;
-
/**
* Der Handler für die Zeit
*/
@@ -173,7 +169,9 @@ public class SudokuActivity extends SudoqActivity implements OnClickListener, Ac
private UserInteractionMediator mediator;
private String[] currentSymbolSet;
-
+
+ /** for time. YES IT IS USED!*/
+ private Menu mMenu;
/** Methods */
/**
@@ -200,6 +198,7 @@ public void onCreate(Bundle savedInstanceState) {
}
if (game != null) {
+ /* Determine how many numbers are needed. 1-9 or 1-16 ? */
switch (this.game.getSudoku().getSudokuType().getNumberOfSymbols()) {
case 4:
Symbol.createSymbol(Symbol.MAPPING_NUMBERS_FOUR);
@@ -331,57 +330,63 @@ public void onGlobalLayout() {
* Setzt den Text für Typ und Schwierigkeit des aktuellen Sudokus.
*/
private void setTypeText() {
- TextView type = (TextView) findViewById(R.id.sudoku_type);
-
+
+ int t,st;
switch (this.game.getSudoku().getSudokuType().getEnumType()) {
case HyperSudoku:
- type.append(getString(R.string.sudoku_type_hyper));
+ t = R.string.sudoku_type_hyper;
break;
case samurai:
- type.append(getString(R.string.sudoku_type_samurai));
+ t = R.string.sudoku_type_samurai;
break;
case squigglya:
- type.append(getString(R.string.sudoku_type_squiggly_a_9x9));
+ t = R.string.sudoku_type_squiggly_a_9x9;
break;
case squigglyb:
- type.append(getString(R.string.sudoku_type_squiggly_b_9x9));
+ t = R.string.sudoku_type_squiggly_b_9x9;
break;
case stairstep:
- type.append(getString(R.string.sudoku_type_stairstep_9x9));
+ t = R.string.sudoku_type_stairstep_9x9;
break;
case standard16x16:
- type.append(getString(R.string.sudoku_type_standard_16x16));
+ t = R.string.sudoku_type_standard_16x16;
break;
case standard4x4:
- type.append(getString(R.string.sudoku_type_standard_4x4));
+ t = R.string.sudoku_type_standard_4x4;
break;
case standard6x6:
- type.append(getString(R.string.sudoku_type_standard_6x6));
+ t = R.string.sudoku_type_standard_6x6;
break;
case standard9x9:
- type.append(getString(R.string.sudoku_type_standard_9x9));
+ t = R.string.sudoku_type_standard_9x9;
break;
case Xsudoku:
- type.append(getString(R.string.sudoku_type_xsudoku));
+ t = R.string.sudoku_type_xsudoku;
break;
+ default:
+ t = R.string.sudoku_type_xsudoku;//so that compiler shuts up about t not neccessarily being initialized
}
- type.append(", ");
-
+
switch (this.game.getSudoku().getComplexity()) {
- case difficult:
- type.append(getString(R.string.complexity_difficult));
- break;
case easy:
- type.append(getString(R.string.complexity_easy));
- break;
- case infernal:
- type.append(getString(R.string.complexity_infernal));
+ st = R.string.complexity_easy;
break;
case medium:
- type.append(getString(R.string.complexity_medium));
+ st = R.string.complexity_medium;
+ break;
+ case difficult:
+ st = R.string.complexity_difficult;
+ break;
+ case infernal:
+ st = R.string.complexity_infernal;
break;
+ default:
+ st= R.string.complexity_infernal;//s.o.
}
+ ActionBar ab = getSupportActionBar();
+ ab.setTitle(getString(t));
+ ab.setSubtitle(getString(st));
}
/**
@@ -418,7 +423,7 @@ private void inflateGestures(boolean firstStart) {
}
this.gestureOverlay = new GestureOverlayView(this);
- LayoutParams gestureLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
+ LayoutParams gestureLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
this.gestureOverlay.setLayoutParams(gestureLayoutParams);
this.gestureOverlay.setBackgroundColor(Color.BLACK);
this.gestureOverlay.getBackground().setAlpha(127);
@@ -432,9 +437,7 @@ private void inflateGestures(boolean firstStart) {
* Erstellt die Views und Buttons für diese Activity
*/
private void inflateViewAndButtons() {
- this.timeView = (TextView) findViewById(R.id.sudoku_time);
- timeView.setText(getGameTimeString() + " (+ " + getAssistancesTimeString() + ")");
-
+
this.sudokuScrollView = (FullScrollLayout) findViewById(R.id.sudoku_field);
this.sudokuView = new SudokuLayout(this);
Log.d(LOG_TAG, "Inflated sudoku layout");
@@ -449,8 +452,8 @@ private void inflateViewAndButtons() {
Buttons.bookmarkButton = (Button) findViewById(R.id.sudoku_action_tree_button_bookmark);
Buttons.closeButton = (Button) findViewById(R.id.sudoku_action_tree_button_close);
- LinearLayout currentControlsView = (LinearLayout) findViewById(R.id.sudoku_time_border);
- FieldViewPainter.getInstance().setMarking(currentControlsView, FieldViewStates.CONTROLS);
+ LinearLayout currentControlsView;/* = (LinearLayout) findViewById(R.id.sudoku_time_border);
+ FieldViewPainter.getInstance().setMarking(currentControlsView, FieldViewStates.CONTROLS);*/
currentControlsView = (LinearLayout) findViewById(R.id.sudoku_border);
FieldViewPainter.getInstance().setMarking(currentControlsView, FieldViewStates.SUDOKU);
currentControlsView = (LinearLayout) findViewById(R.id.controls);
@@ -753,21 +756,31 @@ protected String getGameTimeString() {
* @param time the time to format in seconds
* @return a string representing the specified time in format "D..D HH:mm:ss"
*/
- private String getTimeString(int time) {
- Date res = new Date();
- res.setMinutes(time / 60);
- res.setSeconds(time % 60);
- res.setHours(time / 3600);
+ public static String getTimeString(int time) {
+
+ int seconds = time % 60;
+ time /= 60;
- StringBuilder pattern = new StringBuilder("mm:ss");
+ int minutes = time % 60;
+ time /= 60;
- if(res.getHours() > 0){
- pattern.insert(0, "H:");
- if(res.getHours() >= 10)
- pattern.insert(0,"H");
+ int hours = time % 24;
+
+ int days = time /= 60;
+
+ StringBuilder pattern = new StringBuilder("");
+
+ if(days > 0)
+ pattern.append(days + " ");
+ if(hours > 0){
+ //padding only if days entry
+ if(days > 0 && hours > 9)
+ pattern.append('0');
+ pattern.append(hours+":");
}
+ pattern.append(String.format("%02d:%02d", minutes, seconds));
- return new SimpleDateFormat(pattern.toString(), Locale.US).format(res);
+ return pattern.toString();
}
/**
@@ -809,14 +822,51 @@ private String getStatisticsString() {
sb.append(getString(R.string.dialog_won_score) + ": " + game.getScore());
return sb.toString();
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.action_bar_sudoku, menu);
+ return true;
+ }
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ mMenu = menu;
+ return super.onPrepareOptionsMenu(menu);
+ }
+
/**
* Das Update-Runnable für die Zeit
*/
private Runnable timeUpdate = new Runnable() {
+ private String offset = "";
public void run() {
game.addTime(1);
- timeView.setText(getGameTimeString() + " (+ " + getAssistancesTimeString() + ")");
+
+ //getSupportActionBar().
+ final TextView timeView = (TextView) findViewById (R.id.time);
+
+ if(timeView != null ) {
+
+ /* for easy formatting, we display both: time and penalty on one element separated by \n
+ * this is not perfect since we padd with whitespace and the font is not 'mono-style'(=not all letters same width)
+ * solution would be: create custom xml for action bar, but as of now I see no way how to make this easy.
+ * to save computing time we cache the offset*/
+ String t = getGameTimeString();
+ String p = " (+ " + getAssistancesTimeString() + ")";
+ int d = t.length() - p.length();
+ while(offset.length() > Math.abs(d)){offset = offset.substring(1);}
+ while(offset.length() < Math.abs(d)){offset = " " + offset;}
+ if(d > 0){
+ p = offset + p;
+ }
+ if(d < 0){
+ t = offset + t;
+ }
+ timeView.setText(t + "\n" + p);
+ }
+
timeHandler.postDelayed(this, 1000);
}
};
diff --git a/sudoq-app/src/de/sudoq/controller/sudoku/UserInteractionMediator.java b/sudoq-app/src/de/sudoq/controller/sudoku/UserInteractionMediator.java
index 5c88c964..53f46f81 100644
--- a/sudoq-app/src/de/sudoq/controller/sudoku/UserInteractionMediator.java
+++ b/sudoq-app/src/de/sudoq/controller/sudoku/UserInteractionMediator.java
@@ -27,6 +27,8 @@
import de.sudoq.model.profile.Profile;
import de.sudoq.model.sudoku.Constraint;
import de.sudoq.model.sudoku.Field;
+import de.sudoq.model.sudoku.sudokuTypes.SudokuTypes;
+import de.sudoq.model.sudoku.sudokuTypes.TypeBasic;
import de.sudoq.view.SudokuFieldView;
import de.sudoq.view.SudokuLayout;
import de.sudoq.view.VirtualKeyboardLayout;
@@ -109,6 +111,7 @@ public void onInput(int symbol) {
if (this.noteMode) {
if (currentField.getField().isNoteSet(symbol)) {
listener.onNoteDelete(currentField.getField(), symbol);
+ restrictCandidates();//because github issue #116 see below
} else {
listener.onNoteAdd(currentField.getField(), symbol);
}
@@ -126,6 +129,7 @@ public void onInput(int symbol) {
public void onFieldSelected(SudokuFieldView view) {
SudokuFieldView currentField = this.sudokuView.getCurrentFieldView();
+ /* select for the first time -> set a solution */
if (currentField != view) {
this.noteMode = Profile.getInstance().isGestureActive() && !game.isFinished();
@@ -143,7 +147,9 @@ public void onFieldSelected(SudokuFieldView view) {
} else {
this.virtualKeyboard.setActivated(false);
}
+ /* second click */
} else if (!game.isFinished()) {
+ /* gestures are enabled -> set solution via touchy swypy*/
if (Profile.getInstance().isGestureActive() && this.sudokuView.getCurrentFieldView().getField().isEditable()) {
this.gestureOverlay.setVisibility(View.VISIBLE);
restrictCandidates();
@@ -152,8 +158,10 @@ public void onFieldSelected(SudokuFieldView view) {
textView.setText(" " + gestureOverlay.getContext().getString(R.string.sf_sudoku_title_gesture_input) + " ");
textView.setTextSize(18);
this.gestureOverlay.addView(textView, new GestureOverlayView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
+ /* no gestures -> toogle noteMode*/
} else {
this.noteMode = !this.noteMode;
+ restrictCandidates();
}
currentField.setNoteState(this.noteMode);
}
@@ -261,19 +269,39 @@ public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
*/
private void restrictCandidates() {
this.virtualKeyboard.enableAllButtons();
+
+ Field currentField = this.sudokuView.getCurrentFieldView().getField();
+ TypeBasic type = this.game.getSudoku().getSudokuType();
+ /* only if assistance 'input assistance' if enabled */
if (this.game.isAssistanceAvailable(Assistances.restrictCandidates)) {
- int save = this.sudokuView.getCurrentFieldView().getField().getCurrentValue();
- for (int i = 0; i < this.game.getSudoku().getSudokuType().getNumberOfSymbols(); i++) {
- this.sudokuView.getCurrentFieldView().getField().setCurrentValue(i, false);
- for (Constraint c : this.game.getSudoku().getSudokuType()) {
- if (!c.isSaturated(this.game.getSudoku())) {
+
+ /* save val of current view */
+ int save = currentField.getCurrentValue();
+
+ /* iterate over all symbols e.g. 0-8 */
+ for (int i = 0; i < type.getNumberOfSymbols(); i++) {
+ /* set fieldval to current symbol */
+ currentField.setCurrentValue(i, false);
+ /* for every constraint */
+ for (Constraint c : type) {
+ /* if constraint not satisfied -> disable*/
+ boolean constraintViolated =! c.isSaturated(this.game.getSudoku());
+
+ /* Github Issue #116
+ * it would be stupid if we were in the mode where notes are set
+ * and would disable a note that has been set.
+ * Because then, it can't be unset by the user*/
+ boolean noteNotSet = ! (noteMode && currentField.isNoteSet(i));
+
+ if (constraintViolated && noteNotSet) {
this.virtualKeyboard.disableButton(i);
break;
}
}
- this.sudokuView.getCurrentFieldView().getField().setCurrentValue(Field.EMPTYVAL, false);
+ currentField.setCurrentValue(Field.EMPTYVAL, false);
}
- this.sudokuView.getCurrentFieldView().getField().setCurrentValue(save, false);
+ currentField.setCurrentValue(save, false);
+
}
}
diff --git a/sudoq-app/src/de/sudoq/controller/tutorial/FragmentActionTree.java b/sudoq-app/src/de/sudoq/controller/tutorial/FragmentActionTree.java
new file mode 100644
index 00000000..bac627bd
--- /dev/null
+++ b/sudoq-app/src/de/sudoq/controller/tutorial/FragmentActionTree.java
@@ -0,0 +1,19 @@
+package de.sudoq.controller.tutorial;
+
+import de.sudoq.R;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+public class FragmentActionTree extends Fragment {
+ Button button;
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
+ {
+ return inflater.inflate(R.layout.tutorial_actiontree, group, false);
+ }
+
+}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/tutorial/FragmentAssistances.java b/sudoq-app/src/de/sudoq/controller/tutorial/FragmentAssistances.java
new file mode 100644
index 00000000..02cb6662
--- /dev/null
+++ b/sudoq-app/src/de/sudoq/controller/tutorial/FragmentAssistances.java
@@ -0,0 +1,18 @@
+package de.sudoq.controller.tutorial;
+
+import de.sudoq.R;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+public class FragmentAssistances extends Fragment {
+ Button button;
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
+ {
+ return inflater.inflate(R.layout.tutorial_assistances, group, false);
+ }
+}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/tutorial/FragmentSudoku.java b/sudoq-app/src/de/sudoq/controller/tutorial/FragmentSudoku.java
new file mode 100644
index 00000000..81be8e2b
--- /dev/null
+++ b/sudoq-app/src/de/sudoq/controller/tutorial/FragmentSudoku.java
@@ -0,0 +1,18 @@
+package de.sudoq.controller.tutorial;
+
+import de.sudoq.R;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+public class FragmentSudoku extends Fragment {
+ Button button;
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
+ {
+ return inflater.inflate(R.layout.tutorial_sudoku, group, false);
+ }
+}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActionTreeActivity.java b/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActionTreeActivity.java
index 21278262..b88f106e 100644
--- a/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActionTreeActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActionTreeActivity.java
@@ -30,21 +30,22 @@ public void onCreate(Bundle savedInstanceState) {
viewLayoutParams.leftMargin = 0;
ActionTreeElementView normal = new ActionElement(this, null, new ActionTreeElement(0, new SolveActionFactory().createAction(0, new Field(1, 9)), null));
-
- ActionTreeElementView view = new BookmarkedElement(this, normal, new ActionTreeElement(0, new SolveActionFactory().createAction(0, new Field(1, 9)), null));
+ ActionTreeElement dummyATE = new ActionTreeElement(0, new SolveActionFactory().createAction(0, new Field(1, 9)), null);
+
+ ActionTreeElementView view = new BookmarkedElement(this, normal, dummyATE);
view.setLayoutParams(viewLayoutParams);
- ((RelativeLayout) findViewById(R.id.tutorial_bookmark)).addView(view);
+ //((RelativeLayout) findViewById(R.id.tutorial_bookmark)).addView(view);
view = normal;
view.setLayoutParams(viewLayoutParams);
- ((RelativeLayout) findViewById(R.id.tutorial_state)).addView(view);
+ //((RelativeLayout) findViewById(R.id.tutorial_state)).addView(view);
- view = new ActiveElement(this, normal, new ActionTreeElement(0, new SolveActionFactory().createAction(0, new Field(1, 9)), null));
+ view = new ActiveElement(this, normal, dummyATE);
view.setLayoutParams(viewLayoutParams);
- ((RelativeLayout) findViewById(R.id.tutorial_current_state)).addView(view);
+ //((RelativeLayout) findViewById(R.id.tutorial_current_state)).addView(view);
- view = new BranchingElement(this, normal, new ActionTreeElement(0, new SolveActionFactory().createAction(0, new Field(1, 9)), null));
+ view = new BranchingElement(this, normal, dummyATE);
view.setLayoutParams(viewLayoutParams);
- ((RelativeLayout) findViewById(R.id.tutorial_branching)).addView(view);
+ //((RelativeLayout) findViewById(R.id.tutorial_branching)).addView(view);
}
}
diff --git a/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActivity.java b/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActivity.java
index 0dd35eaf..5bf5c509 100644
--- a/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActivity.java
+++ b/sudoq-app/src/de/sudoq/controller/tutorial/TutorialActivity.java
@@ -7,49 +7,84 @@
*/
package de.sudoq.controller.tutorial;
-import android.app.TabActivity;
-import android.content.Intent;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.ActionBar.Tab;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+
+import android.content.res.Configuration;
+import android.graphics.drawable.GradientDrawable.Orientation;
import android.os.Bundle;
-import android.widget.TabHost;
-import android.widget.TabHost.TabSpec;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.Window;
import de.sudoq.R;
-public class TutorialActivity extends TabActivity {
+public class TutorialActivity extends SherlockFragmentActivity {
+ private ActionBar.Tab createTab(int text, int icon){
+ ActionBar.Tab tab = getSupportActionBar().newTab();
+ if( getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE )
+ tab.setText(text);
+ else
+ tab.setIcon(icon);
+
+ tab.setTabListener(new MyTabListener());
+ return tab;
+ }
+
/**
* {@inheritDoc}
*/
public void onCreate(Bundle savedInstanceState) {
+ //this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
+
setContentView(R.layout.tutorial);
- TabHost tabHost = getTabHost();
-
- // Tab for sudokus
- TabSpec sudokuspec = tabHost.newTabSpec(getString(R.string.sf_tutorial_sudoku_title));
- // setting Title and Icon for the Tab
- sudokuspec.setIndicator(getString(R.string.sf_tutorial_sudoku_title), getResources().getDrawable(R.drawable.sudoku_tutorial));
- Intent sudokuIntent = new Intent(this, TutorialSudokuActivity.class);
- sudokuspec.setContent(sudokuIntent);
-
- // Tab for assistances
- TabSpec assistancesspec = tabHost.newTabSpec(getString(R.string.sf_tutorial_assistances_title));
- // setting Title and Icon for the Tab
- assistancesspec.setIndicator(getString(R.string.sf_tutorial_assistances_title), getResources().getDrawable(R.drawable.help_tutorial));
- Intent assistancesIntent = new Intent(this, TutorialAssistancesActivity.class);
- assistancesspec.setContent(assistancesIntent);
-
- // Tab for actiontree
- TabSpec actiontreespec = tabHost.newTabSpec(getString(R.string.sf_tutorial_action_title));
- // setting Title and Icon for the Tab
- actiontreespec.setIndicator(getString(R.string.sf_tutorial_action_title), getResources().getDrawable(R.drawable.action_tree_tutorial));
- Intent actiontreeIntent = new Intent(this, TutorialActionTreeActivity.class);
- actiontreespec.setContent(actiontreeIntent);
-
- // Adding all TabSpec to TabHost
- tabHost.addTab(sudokuspec); // Adding sudoku tab
- tabHost.addTab(assistancesspec); // Adding assistances tab
- tabHost.addTab(actiontreespec); // Adding actiontree tab
+ ActionBar bar = getSupportActionBar();
+ bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+
+ /* sudoku tab */
+ bar.addTab(createTab(R.string.sf_tutorial_sudoku_title, R.drawable.sudoku_tutorial));
+
+ /* assistances tab */
+ bar.addTab(createTab(R.string.sf_tutorial_assistances_title, R.drawable.help_tutorial));
+
+ /* action tree tab */
+ bar.addTab(createTab(R.string.sf_tutorial_action_title, R.drawable.action_tree_tutorial));
+
+ getSupportActionBar().setDisplayShowHomeEnabled(false);
+ getSupportActionBar().setDisplayShowTitleEnabled(false);
+
}
-}
+ private class MyTabListener implements ActionBar.TabListener
+ {
+ @Override
+ public void onTabSelected(Tab tab, FragmentTransaction ft) {
+ Fragment frag;
+ switch (tab.getPosition()){
+ case 0:
+ frag = new FragmentSudoku();
+ break;
+
+ case 1:
+ frag = new FragmentAssistances();
+ break;
+
+ default:
+ frag = new FragmentActionTree();
+ }
+ ft.replace(android.R.id.content, frag);
+
+ }
+ @Override
+ public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+ // TODO Auto-generated method stub
+ }
+ @Override
+ public void onTabReselected(Tab tab, FragmentTransaction ft) {
+ // TODO Auto-generated method stub
+ }
+ }
+}
\ No newline at end of file
diff --git a/sudoq-app/src/de/sudoq/view/FullScrollLayout.java b/sudoq-app/src/de/sudoq/view/FullScrollLayout.java
index e033c6e2..582cc2c8 100644
--- a/sudoq-app/src/de/sudoq/view/FullScrollLayout.java
+++ b/sudoq-app/src/de/sudoq/view/FullScrollLayout.java
@@ -100,8 +100,8 @@ private void initialize() {
this.verticalScrollView = new VerticalScroll(getContext());
this.horizontalScrollView = new HorizontalScroll(getContext());
- this.verticalScrollView.addView(this.horizontalScrollView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
- this.addView(this.verticalScrollView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
+ this.verticalScrollView.addView(this.horizontalScrollView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+ this.addView(this.verticalScrollView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
/**
@@ -113,7 +113,7 @@ public void addView(View v) {
if (v instanceof ZoomableView) {
this.horizontalScrollView.removeAllViews();
this.childView = (ZoomableView) v;
- this.horizontalScrollView.addView(v, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
+ this.horizontalScrollView.addView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
}
diff --git a/sudoq-app/src/de/sudoq/view/SudokuFieldView.java b/sudoq-app/src/de/sudoq/view/SudokuFieldView.java
index 1f43c86b..1c61da18 100644
--- a/sudoq-app/src/de/sudoq/view/SudokuFieldView.java
+++ b/sudoq-app/src/de/sudoq/view/SudokuFieldView.java
@@ -210,15 +210,8 @@ public boolean onTouchEvent(MotionEvent touchEvent) {
return false;
}
- /**
- * Benachrichtigt alle Registrierten Listener über Interaktion mit diesem
- * SudokuFieldView.
- */
- public void notifyListener() {
- for (FieldInteractionListener listener : fieldSelectListener) {
- listener.onFieldSelected(this);
- }
- }
+
+
/**
* Gibt das Feld, welches von dieser View angezeigt wird zurück
@@ -398,4 +391,14 @@ public void removeListener(FieldInteractionListener listener) {
}
+ /**
+ * Benachrichtigt alle Registrierten Listener über Interaktion mit diesem
+ * SudokuFieldView.
+ */
+ public void notifyListener() {
+ for (FieldInteractionListener listener : fieldSelectListener) {
+ listener.onFieldSelected(this);
+ }
+ }
+
}
diff --git a/sudoq-app/svgs/tutorial_bookmark.svg b/sudoq-app/svgs/tutorial_bookmark.svg
new file mode 100644
index 00000000..39aa6d75
--- /dev/null
+++ b/sudoq-app/svgs/tutorial_bookmark.svg
@@ -0,0 +1,11 @@
+
diff --git a/sudoq-app/svgs/tutorial_branching.svg b/sudoq-app/svgs/tutorial_branching.svg
new file mode 100644
index 00000000..39ab2c2c
--- /dev/null
+++ b/sudoq-app/svgs/tutorial_branching.svg
@@ -0,0 +1,11 @@
+
diff --git a/sudoq-app/svgs/tutorial_current_state.svg b/sudoq-app/svgs/tutorial_current_state.svg
new file mode 100644
index 00000000..8c39cb51
--- /dev/null
+++ b/sudoq-app/svgs/tutorial_current_state.svg
@@ -0,0 +1,11 @@
+
diff --git a/sudoq-app/svgs/tutorial_state.svg b/sudoq-app/svgs/tutorial_state.svg
new file mode 100644
index 00000000..2aae4358
--- /dev/null
+++ b/sudoq-app/svgs/tutorial_state.svg
@@ -0,0 +1,11 @@
+
diff --git a/sudoq-model/src/de/sudoq/model/actionTree/ActionTree.java b/sudoq-model/src/de/sudoq/model/actionTree/ActionTree.java
index 7de4d74a..4aaf2517 100644
--- a/sudoq-model/src/de/sudoq/model/actionTree/ActionTree.java
+++ b/sudoq-model/src/de/sudoq/model/actionTree/ActionTree.java
@@ -7,11 +7,13 @@
*/
package de.sudoq.model.actionTree;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
+import de.sudoq.model.ModelChangeListener;
import de.sudoq.model.ObservableModelImpl;
/**
@@ -60,20 +62,42 @@ public ActionTree() {
*/
public ActionTreeElement add(Action action, ActionTreeElement mountingElement) {
- ActionTreeElement ate = new ActionTreeElement(idCounter, action, mountingElement);
-
- if (rootElement != null) {
- if (mountingElement == null) {
- throw new IllegalArgumentException();
- }
- } else {
- rootElement = ate;
+ if (rootElement != null && mountingElement == null) {
+ throw new IllegalArgumentException(); //There'a a root but no mounting el? -> throw exception
}
-
- idCounter++;
+
+ /* check if action already in Tree, i.e. we went back in actionTree but are doing same steps again */
+ boolean redundandAction = false;
+ ActionTreeElement ate = null;
+ if (mountingElement != null) {
+ ArrayList children = mountingElement.getChildrenList();
+ for(ActionTreeElement ateI : children)
+ if(ateI.actionEquals(action)){
+ ate = ateI;
+ redundandAction = true;
+ break;
+ }
+ }
+
+ /* */
+ if(!redundandAction)
+ {
+ ate = new ActionTreeElement(idCounter, action, mountingElement);
+ idCounter++;
+ }
+
+
+ if (rootElement==null) {
+ rootElement = ate; //if there's no root, ate is root
+ }
+
notifyListeners(ate);
+
return ate;
+
}
+
+
/**
* Diese Methode durchsucht den Baum nach dem Element mit der gegebenen id.
diff --git a/sudoq-model/src/de/sudoq/model/actionTree/ActionTreeElement.java b/sudoq-model/src/de/sudoq/model/actionTree/ActionTreeElement.java
index 8608668e..12acf9b3 100644
--- a/sudoq-model/src/de/sudoq/model/actionTree/ActionTreeElement.java
+++ b/sudoq-model/src/de/sudoq/model/actionTree/ActionTreeElement.java
@@ -289,6 +289,20 @@ public boolean equals(Object o) {
return false;
}
+ /**
+ * Returns whether the action held by this ActionTreeElement is equal to the action passed as parameter
+ * @param o external action to compare
+ * @return true if this.action.equals(o) else false
+ *
+ */
+ public boolean actionEquals(Object o){
+ if (o instanceof Action){//actually unneccessary as action checks again
+ Action a = (Action) o;
+ return this.action.equals(a);
+ }
+ return false;
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/sudoq-model/src/de/sudoq/model/profile/Profile.java b/sudoq-model/src/de/sudoq/model/profile/Profile.java
index d919993e..98cfad6e 100644
--- a/sudoq-model/src/de/sudoq/model/profile/Profile.java
+++ b/sudoq-model/src/de/sudoq/model/profile/Profile.java
@@ -29,6 +29,8 @@
public class Profile extends ObservableModelImpl implements Xmlable {
/** Attributes */
+ public static final int INITIAL_TIME_RECORD = 5999;
+
private static final String ID = "id";
private static final String NAME = "name";
private static final String CURRENT = "current";
@@ -233,7 +235,7 @@ private void setDefaultValues() {
this.assistances = new AssistanceSet();
this.assistances.setAssistance(Assistances.markRowColumn);
this.statistics = new int[Statistics.values().length];
- this.statistics[Statistics.fastestSolvingTime.ordinal()] = 5999;
+ this.statistics[Statistics.fastestSolvingTime.ordinal()] = INITIAL_TIME_RECORD;
notifyListeners(this);
}
diff --git a/test-app/.classpath b/test-app/.classpath
index 33df53d0..87877f31 100644
--- a/test-app/.classpath
+++ b/test-app/.classpath
@@ -11,5 +11,7 @@
+
+
diff --git a/test-app/libs/robotium-solo-4.1-javadoc.jar b/test-app/libs/robotium-solo-4.1-javadoc.jar
new file mode 100644
index 00000000..24b84e6f
Binary files /dev/null and b/test-app/libs/robotium-solo-4.1-javadoc.jar differ
diff --git a/test-app/libs/robotium-solo-4.1.jar b/test-app/libs/robotium-solo-4.1.jar
new file mode 100644
index 00000000..bc6270ea
Binary files /dev/null and b/test-app/libs/robotium-solo-4.1.jar differ
diff --git a/test-app/src/de/sudoq/test/MenuTest.java b/test-app/src/de/sudoq/test/MenuTest.java
index eff8090b..33526080 100644
--- a/test-app/src/de/sudoq/test/MenuTest.java
+++ b/test-app/src/de/sudoq/test/MenuTest.java
@@ -1,6 +1,7 @@
package de.sudoq.test;
import android.app.Activity;
+import android.util.Log;
import com.jayway.android.robotium.solo.Solo;
@@ -15,19 +16,21 @@
public class MenuTest extends SudoqTestCase {
public void testMenus() {
+ Log.d("debug", "mark0");
Activity a = getActivity();
String continueSudoku = a.getString(R.string.sf_mainmenu_continue);
- String newSudoku = a.getString(R.string.sf_mainmenu_new_sudoku);
- String loadSudoku = a.getString(R.string.sf_mainmenu_load_sudoku);
- String profile = a.getString(R.string.sf_mainmenu_profile);
- String statistics = a.getString(R.string.profile_preference_button_statistics);
+ String newSudoku = a.getString(R.string.sf_mainmenu_new_sudoku);
+ String loadSudoku = a.getString(R.string.sf_mainmenu_load_sudoku);
+ String profile = a.getString(R.string.sf_mainmenu_profile);
+ String statistics = a.getString(R.string.profile_preference_button_statistics);
+ solo.sleep(2000);
assertTrue(solo.searchText(continueSudoku));
assertTrue(solo.searchText(newSudoku));
assertTrue(solo.searchText(loadSudoku));
assertTrue(solo.searchText(profile));
-
+
solo.clickOnText(newSudoku);
solo.assertCurrentActivity("should be sudokupreferences", SudokuPreferencesActivity.class);
assertTrue(solo.searchText(a.getString(R.string.complexity_easy)));
@@ -40,21 +43,25 @@ public void testMenus() {
solo.assertCurrentActivity("should be sudokuloading", SudokuLoadingActivity.class);
solo.goBack();
+ Log.d("debug", "mark1");
solo.clickOnText(profile);
solo.assertCurrentActivity("should be preferences", PlayerPreferencesActivity.class);
solo.clickOnText(statistics);
solo.assertCurrentActivity("should be statistics", StatisticsActivity.class);
solo.goBack();
-
+ Log.d("debug", "mark2");
+
/* AT 140 */
solo.sendKey(Solo.MENU);
- solo.clickOnText(a.getString(R.string.profile_preference_title_switchprofile));
- assertTrue(solo.searchText(a.getString(R.string.profile_preference_title_switchprofile)));
+ solo.clickOnText(a.getString(R.string.action_switch_profile));
+ Log.d("debug", "mark3");
+ assertTrue(solo.searchText(a.getString(R.string.action_switch_profile)));
solo.goBack();
}
public void testAssistanceBeforeSudoku() {
+ solo.sleep(2000);
solo.clickOnText(solo.getCurrentActivity().getString(R.string.sf_mainmenu_new_sudoku));
solo.assertCurrentActivity("should be sudokupreferences", SudokuPreferencesActivity.class);
@@ -76,17 +83,22 @@ public void testAssistanceBeforeSudoku() {
/* AT 150 and AT 160 */
public void testCreateProfile() {
Activity a = getActivity();
+ solo.sleep(2000);
+ /* go to Profile */
solo.clickOnText(a.getString(R.string.sf_mainmenu_profile));
solo.assertCurrentActivity("should be preferences", PlayerPreferencesActivity.class);
+
// create new profile
solo.sendKey(Solo.MENU);
- solo.clickOnText(solo.getCurrentActivity().getString(R.string.profile_preference_title_createprofile));
+ solo.clickOnText(solo.getCurrentActivity().getString(R.string.action_new_profile));
+
solo.clickOnText(a.getString(R.string.profile_preference_title_gesture));
solo.goBack();
solo.clickOnText(a.getString(R.string.sf_mainmenu_profile));
assertTrue(solo.isCheckBoxChecked(a.getString(R.string.profile_preference_title_gesture)));
solo.sendKey(Solo.MENU);
- solo.clickOnText(a.getString(R.string.profile_preference_title_deleteprofile));
+ solo.clickOnText(a.getString(R.string.action_delete_profile));
+ solo.goBack();
}
public void testSudokuLoading() {
@@ -116,7 +128,7 @@ public void testSudokuLoading() {
public void testTutorial() {
Activity a = solo.getCurrentActivity();
solo.sendKey(Solo.MENU);
- solo.clickOnText(a.getString(R.string.optionsmenu_tutorial));
+ solo.clickOnText(a.getString(R.string.action_show_tutorial));
solo.clickOnText(a.getString(R.string.sf_tutorial_sudoku_title));
solo.clickOnText(a.getString(R.string.sf_tutorial_assistances_title));
solo.clickOnText(a.getString(R.string.sf_tutorial_action_title));
diff --git a/test-app/src/de/sudoq/test/SudoqTestCase.java b/test-app/src/de/sudoq/test/SudoqTestCase.java
index 4c620aed..c06f3076 100644
--- a/test-app/src/de/sudoq/test/SudoqTestCase.java
+++ b/test-app/src/de/sudoq/test/SudoqTestCase.java
@@ -33,7 +33,7 @@ public void setUp() {
solo.assertCurrentActivity("Should be MainAcitivty", MainActivity.class);
solo.clickOnButton(solo.getCurrentActivity().getString(R.string.sf_mainmenu_profile));
solo.sendKey(Solo.MENU);
- solo.clickOnText(solo.getCurrentActivity().getString(R.string.profile_preference_title_createprofile));
+ solo.clickOnText(solo.getCurrentActivity().getString(R.string.action_new_profile));
solo.goBack();
}
@@ -43,7 +43,7 @@ public void tearDown() {
solo.waitForActivity("MainActivity",15000);
solo.clickOnButton(solo.getString(R.string.sf_mainmenu_profile));//faster?
solo.sendKey(Solo.MENU);
- solo.clickOnText(solo.getCurrentActivity().getString(R.string.profile_preference_title_deleteprofile));
+ solo.clickOnText(solo.getCurrentActivity().getString(R.string.action_delete_profile));
solo.finishOpenedActivities();
}
}
\ No newline at end of file
diff --git a/test-model/unit/de/sudoq/model/actionTree/ActionTreeIteratorTests.java b/test-model/unit/de/sudoq/model/actionTree/ActionTreeIteratorTests.java
index 1c211cd9..e388af29 100644
--- a/test-model/unit/de/sudoq/model/actionTree/ActionTreeIteratorTests.java
+++ b/test-model/unit/de/sudoq/model/actionTree/ActionTreeIteratorTests.java
@@ -24,10 +24,11 @@ public void testCompleteness() {
ActionFactory factory = new SolveActionFactory();
Field field = new Field(-1, 1);
- ActionTreeElement ate1 = at.add(factory.createAction(1, field), null);
- ActionTreeElement ate2 = at.add(factory.createAction(1, field), ate1);
- at.add(factory.createAction(1, field), ate2);
+ ActionTreeElement ate1 = at.add(factory.createAction(1, field), null); //root element
+ ActionTreeElement ate2 = at.add(factory.createAction(1, field), ate1); //one child
at.add(factory.createAction(1, field), ate2);
+ at.add(factory.createAction(1, field), ate2);//this should not be ignored by the actionTree, cause we've been there already
+ at.add(factory.createAction(2, field), ate2);
int i = 0;
ArrayList ids = new ArrayList();
diff --git a/test-model/unit/de/sudoq/model/actionTree/ActionTreeTests.java b/test-model/unit/de/sudoq/model/actionTree/ActionTreeTests.java
index 27468c31..70eac1dc 100644
--- a/test-model/unit/de/sudoq/model/actionTree/ActionTreeTests.java
+++ b/test-model/unit/de/sudoq/model/actionTree/ActionTreeTests.java
@@ -69,7 +69,7 @@ public void testGettingElementsById() {
ActionTreeElement ate1 = at.add(factory.createAction(1, field), null);
ActionTreeElement ate2 = at.add(factory.createAction(1, field), ate1);
ActionTreeElement ate3 = at.add(factory.createAction(1, field), ate2);
- ActionTreeElement ate4 = at.add(factory.createAction(1, field), ate2);
+ ActionTreeElement ate4 = at.add(factory.createAction(2, field), ate2);
assertEquals(ate1, at.getElement(1));
assertEquals(ate2, at.getElement(2));
@@ -119,11 +119,11 @@ public void testFindPath() {
Field field = new Field(-1, 1);
ActionTreeElement ate1 = at.add(factory.createAction(1, field), null);
- ActionTreeElement ate2 = at.add(factory.createAction(1, field), ate1);
- ActionTreeElement ate3 = at.add(factory.createAction(1, field), ate2);
- ActionTreeElement ate4 = at.add(factory.createAction(1, field), ate3);
- ActionTreeElement ate5 = at.add(factory.createAction(1, field), ate2);
- ActionTreeElement ate6 = at.add(factory.createAction(1, field), ate5);
+ ActionTreeElement ate2 = at.add(factory.createAction(1, field), ate1);
+ ActionTreeElement ate3 = at.add(factory.createAction(1, field), ate2);
+ ActionTreeElement ate4 = at.add(factory.createAction(1, field), ate3);
+ ActionTreeElement ate5 = at.add(factory.createAction(2, field), ate2);
+ ActionTreeElement ate6 = at.add(factory.createAction(1, field), ate5);
assertArrayEquals(new ActionTreeElement[] { ate4, ate3, ate2, ate5, ate6 }, ActionTree.findPath(ate4, ate6)
.toArray());
diff --git a/test-model/unit/de/sudoq/model/files/FileManagerTests.java b/test-model/unit/de/sudoq/model/files/FileManagerTests.java
index a79201b5..74e286fa 100644
--- a/test-model/unit/de/sudoq/model/files/FileManagerTests.java
+++ b/test-model/unit/de/sudoq/model/files/FileManagerTests.java
@@ -56,6 +56,7 @@ public void testInit() {
assertTrue(profiles.exists());
assertTrue(FileManager.getProfilesDir().getAbsolutePath().equals(profiles.getAbsolutePath()));
assertTrue(FileManager.getSudokuDir().getAbsolutePath().equals(sudokus.getAbsolutePath()));
+ File t = sudokus;
assertTrue(sudokus.list().length > 0);
}