deleteList = new LinkedList<>();
for(int i = 0; i < states.size(); i++) {
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java
index 0bc85e3..27d5af1 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java
@@ -245,4 +245,31 @@ public class GameBoard implements Cloneable {
modelChangedListeners.remove(listener);
}
}
+
+ @Override
+ public boolean equals(Object o) {
+ if(o instanceof GameBoard) {
+ GameBoard other = (GameBoard) o;
+
+ if(!other.gameType.equals(gameType)
+ || other.sectionHeight != sectionHeight
+ || other.sectionWidth != sectionWidth
+ || other.size != size) {
+ return false;
+ }
+ try {
+ for(int i = 0; i < size; i++) {
+ for(int j = 0; j < size; j++) {
+ if(!other.field[i][j].equals(field[i][j])) {
+ return false;
+ }
+ }
+ }
+ } catch(IndexOutOfBoundsException e) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
}
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AppCompatPreferenceActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AppCompatPreferenceActivity.java
index 0a7891c..ac22c1a 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AppCompatPreferenceActivity.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AppCompatPreferenceActivity.java
@@ -4,7 +4,6 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
-import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatDelegate;
@@ -42,7 +41,6 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
getDelegate().setSupportActionBar(toolbar);
}
- @NonNull
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java
index 86e6ff3..d5c2561 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java
@@ -10,6 +10,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.os.Bundle;
+import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.v4.app.FragmentManager;
@@ -218,6 +219,8 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
case R.id.menu_settings:
//open settings
intent = new Intent(this,SettingsActivity.class);
+ intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GamePreferenceFragment.class.getName() );
+ intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true );
startActivity(intent);
break;
@@ -267,6 +270,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
dialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
dialog.show();
+ layout.setEnabled(false);
keyboard.setButtonsEnabled(false);
specialButtonLayout.setButtonsEnabled(false);
}
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java
new file mode 100644
index 0000000..9106d72
--- /dev/null
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java
@@ -0,0 +1,193 @@
+package org.secuso.privacyfriendlysudoku.ui;
+
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.media.Ringtone;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.support.v7.app.ActionBar;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.RingtonePreference;
+import android.text.TextUtils;
+import android.view.MenuItem;
+
+import org.secuso.privacyfriendlysudoku.ui.view.R;
+
+import java.util.List;
+
+/**
+ * A {@link PreferenceActivity} that presents a set of application settings. On
+ * handset devices, settings are presented as a single list. On tablets,
+ * settings are split by category, with category headers shown to the left of
+ * the list of settings.
+ *
+ * See
+ * Android Design: Settings for design guidelines and the Settings
+ * API Guide for more information on developing a Settings UI.
+ */
+public class HelpActivity extends AppCompatPreferenceActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setupActionBar();
+ }
+
+ /**
+ * Set up the {@link android.app.ActionBar}, if the API is available.
+ */
+ private void setupActionBar() {
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ // Show the Up button in the action bar.
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean onIsMultiPane() {
+ return isXLargeTablet(this);
+ }
+
+ /**
+ * Helper method to determine if the device has an extra-large screen. For
+ * example, 10" tablets are extra-large.
+ */
+ private static boolean isXLargeTablet(Context context) {
+ return (context.getResources().getConfiguration().screenLayout
+ & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public void onBuildHeaders(List target) {
+ loadHeadersFromResource(R.xml.pref_help_headers, target);
+ }
+
+ /**
+ * A preference value change listener that updates the preference's summary
+ * to reflect its new value.
+ */
+ private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object value) {
+ String stringValue = value.toString();
+
+ if (preference instanceof ListPreference) {
+ // For list preferences, look up the correct display value in
+ // the preference's 'entries' list.
+ ListPreference listPreference = (ListPreference) preference;
+ int index = listPreference.findIndexOfValue(stringValue);
+
+ // Set the summary to reflect the new value.
+ preference.setSummary(
+ index >= 0
+ ? listPreference.getEntries()[index]
+ : null);
+
+ } else if (preference instanceof RingtonePreference) {
+ // For ringtone preferences, look up the correct display value
+ // using RingtoneManager.
+ if (TextUtils.isEmpty(stringValue)) {
+ // Empty values correspond to 'silent' (no ringtone).
+ preference.setSummary(R.string.pref_ringtone_silent);
+
+ } else {
+ Ringtone ringtone = RingtoneManager.getRingtone(
+ preference.getContext(), Uri.parse(stringValue));
+
+ if (ringtone == null) {
+ // Clear the summary if there was a lookup error.
+ preference.setSummary(null);
+ } else {
+ // Set the summary to reflect the new ringtone display
+ // name.
+ String name = ringtone.getTitle(preference.getContext());
+ preference.setSummary(name);
+ }
+ }
+
+ } else {
+ // For all other preferences, set the summary to the value's
+ // simple string representation.
+ preference.setSummary(stringValue);
+ }
+ return true;
+ }
+ };
+
+ /**
+ * Binds a preference's summary to its value. More specifically, when the
+ * preference's value is changed, its summary (line of text below the
+ * preference title) is updated to reflect the value. The summary is also
+ * immediately updated upon calling this method. The exact display format is
+ * dependent on the type of preference.
+ *
+ * @see #sBindPreferenceSummaryToValueListener
+ */
+ private static void bindPreferenceSummaryToValue(Preference preference) {
+ // Set the listener to watch for value changes.
+ preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
+
+ // Trigger the listener immediately with the preference's
+ // current value.
+ sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
+ PreferenceManager
+ .getDefaultSharedPreferences(preference.getContext())
+ .getString(preference.getKey(), ""));
+ }
+
+ /**
+ * This method stops fragment injection in malicious applications.
+ * Make sure to deny any unknown fragments here.
+ */
+ protected boolean isValidFragment(String fragmentName) {
+ return PreferenceFragment.class.getName().equals(fragmentName)
+ || HelpFragment.class.getName().equals(fragmentName);
+ }
+
+ /**
+ * This fragment shows general preferences only. It is used when the
+ * activity is showing a two-pane settings UI.
+ */
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public static class HelpFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.pref_help_general);
+ setHasOptionsMenu(true);
+
+ // Bind the summaries of EditText/List/Dialog/Ringtone preferences
+ // to their values. When their values change, their summaries are
+ // updated to reflect the new value, per the Android Design
+ // guidelines.
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ if (id == android.R.id.home) {
+ startActivity(new Intent(getActivity(), SettingsActivity.class));
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java
index 10017be..b9f5661 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java
@@ -4,6 +4,7 @@ import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
+import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
@@ -58,8 +59,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
settings = PreferenceManager.getDefaultSharedPreferences(this);
- NewLevelManager.init(getApplicationContext(), settings);
- NewLevelManager newLevelManager = NewLevelManager.getInstance();
+ NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings);
// Is this the very first time we start this app?
boolean firstStart = settings.getBoolean("firstStart", true);
@@ -151,38 +151,41 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Intent i = null;
- if(view instanceof Button) {
- Button b = (Button)view;
- switch(b.getId()) {
- case R.id.continueButton:
- i = new Intent(this, LoadGameActivity.class);
- break;
- case R.id.playButton:
- GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
- int index = difficultyBar.getProgress()-1;
- GameDifficulty gameDifficulty = GameDifficulty.getValidDifficultyList().get(index < 0 ? 0 : index);
+ switch(view.getId()) {
+ case R.id.arrow_left:
+ mViewPager.arrowScroll(View.FOCUS_LEFT);
+ break;
+ case R.id.arrow_right:
+ mViewPager.arrowScroll(View.FOCUS_RIGHT);
+ break;
+ case R.id.continueButton:
+ i = new Intent(this, LoadGameActivity.class);
+ break;
+ case R.id.playButton:
+ GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
+ int index = difficultyBar.getProgress()-1;
+ GameDifficulty gameDifficulty = GameDifficulty.getValidDifficultyList().get(index < 0 ? 0 : index);
- NewLevelManager newLevelManager = NewLevelManager.getInstance();
- if(newLevelManager.isLevelLoadable(gameType, gameDifficulty)) {
- // save current setting for later
- SharedPreferences.Editor editor = settings.edit();
- editor.putString("lastChosenGameType", gameType.name());
- editor.putString("lastChosenDifficulty", gameDifficulty.name());
- editor.apply();
+ NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings);
+ if(newLevelManager.isLevelLoadable(gameType, gameDifficulty)) {
+ // save current setting for later
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString("lastChosenGameType", gameType.name());
+ editor.putString("lastChosenDifficulty", gameDifficulty.name());
+ editor.apply();
- // send everything to game activity
- i = new Intent(this, GameActivity.class);
- i.putExtra("gameType", gameType);
- i.putExtra("gameDifficulty", gameDifficulty);
- } else {
- newLevelManager.checkAndRestock();
- Toast t = Toast.makeText(getApplicationContext(), R.string.generating, Toast.LENGTH_SHORT);
- t.show();
- return;
- }
- break;
- default:
- }
+ // send everything to game activity
+ i = new Intent(this, GameActivity.class);
+ i.putExtra("gameType", gameType);
+ i.putExtra("gameDifficulty", gameDifficulty);
+ } else {
+ newLevelManager.checkAndRestock();
+ Toast t = Toast.makeText(getApplicationContext(), R.string.generating, Toast.LENGTH_SHORT);
+ t.show();
+ return;
+ }
+ break;
+ default:
}
if(i != null) {
startActivity(i);
@@ -221,6 +224,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case R.id.menu_settings_main:
//open settings
intent = new Intent(this,SettingsActivity.class);
+ intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GamePreferenceFragment.class.getName() );
+ intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true );
startActivity(intent);
break;
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java
index 05bd179..0cf60ea 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java
@@ -84,7 +84,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List target) {
- loadHeadersFromResource(R.xml.pref_headers, target);
+ loadHeadersFromResource(R.xml.pref_settings_headers, target);
}
/**
@@ -144,8 +144,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
*/
protected boolean isValidFragment(String fragmentName) {
return PreferenceFragment.class.getName().equals(fragmentName)
- || GamePreferenceFragment.class.getName().equals(fragmentName)
- || HighlightingPreferenceFragment.class.getName().equals(fragmentName);
+ || GamePreferenceFragment.class.getName().equals(fragmentName);
}
/**
@@ -157,7 +156,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.pref_general);
+ addPreferencesFromResource(R.xml.pref_settings_general);
setHasOptionsMenu(true);
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
@@ -181,38 +180,4 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
return super.onOptionsItemSelected(item);
}
}
-
- /**
- * This fragment shows notification preferences only. It is used when the
- * activity is showing a two-pane settings UI.
- */
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static class HighlightingPreferenceFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.pref_highlighting);
- setHasOptionsMenu(true);
-
- // Bind the summaries of EditText/List/Dialog/Ringtone preferences
- // to their values. When their values change, their summaries are
- // updated to reflect the new value, per the Android Design
- // guidelines.
-
- //bindPreferenceSummaryToValue(findPreference("highlighting_connected_rows"));
- //bindPreferenceSummaryToValue(findPreference("highlighting_connected_columns"));
- //bindPreferenceSummaryToValue(findPreference("highlighting_connected_sections"));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == android.R.id.home) {
- getActivity().finish();
- //startActivity(new Intent(getActivity(), SettingsActivity.class));
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
}
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java
index 938770a..e12bf9a 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java
@@ -30,6 +30,22 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang
private int gameCellHeight;
private SharedPreferences settings;
+ private OnTouchListener listener = new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if(v instanceof SudokuCellView) {
+
+ SudokuCellView scv = ((SudokuCellView) v);
+
+ int row = scv.getRow();
+ int col = scv.getCol();
+
+ gameController.selectCell(row, col);
+ }
+ return false;
+ }
+ };
+
private Paint p = new Paint();
public SudokuCellView [][] gamecells;
@@ -52,22 +68,6 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang
gamecells = new SudokuCellView[gc.getSize()][gc.getSize()];
- OnTouchListener listener = new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if(v instanceof SudokuCellView) {
-
- SudokuCellView scv = ((SudokuCellView) v);
-
- int row = scv.getRow();
- int col = scv.getCol();
-
- gameController.selectCell(row, col);
- }
- return false;
- }
- };
-
sectionHeight = gameController.getSectionHeight();
sectionWidth = gameController.getSectionWidth();
@@ -80,6 +80,17 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang
}
}
+ @Override
+ public void setEnabled(boolean enabled) {
+ for (int i = 0; i < gameController.getSize(); i++) {
+ for (int j = 0; j < gameController.getSize(); j++) {
+ gamecells[i][j].setEnabled(false);
+ gamecells[i][j].setOnTouchListener(null);
+ }
+ }
+ return;
+ }
+
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -143,12 +154,12 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang
// Set connected Fields
if(gameController.isValidCellSelected()) {
//String syncConnPref = sharedPref.getString(SettingsActivity., "");
- final boolean highlightConnectedRow = settings.getBoolean("pref_highlight_rows", true);
- final boolean highlightConnectedColumn = settings.getBoolean("pref_highlight_cols", true);
- final boolean highlightConnectedSection = settings.getBoolean("pref_highlight_secs", true);
+ final boolean highlightConnected = settings.getBoolean("pref_highlight_connected", true);
- for (GameCell c : gameController.getConnectedCells(row, col, highlightConnectedRow, highlightConnectedColumn, highlightConnectedSection)) {
- gamecells[c.getRow()][c.getCol()].setHighlightType(CellHighlightTypes.Connected);
+ if(highlightConnected) {
+ for (GameCell c : gameController.getConnectedCells(row, col)) {
+ gamecells[c.getRow()][c.getCol()].setHighlightType(CellHighlightTypes.Connected);
+ }
}
}
@@ -180,5 +191,13 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang
gamecells[gc.getRow()][gc.getCol()].setHighlightType(CellHighlightTypes.Selected);
}
}
+
+ // invalidate everything, so it gets redrawn
+ for(int i = 0; i < gameController.getSize(); i++) {
+ for(int j = 0; j < gameController.getSize(); j++) {
+ gamecells[i][j].invalidate();
+ }
+ }
+
}
}
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java
index 452bdae..75f0330 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java
@@ -4,12 +4,8 @@ import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.TypedValue;
-import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.GridLayout;
-import android.widget.GridView;
import android.widget.LinearLayout;
import org.secuso.privacyfriendlysudoku.controller.GameController;
@@ -58,10 +54,11 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan
public void setKeyBoard(int size,int width, int height) {
LayoutParams p;
- buttons = new SudokuButton[size];
int number = 0;
- int torun = (size % 2 == 0) ? size/2 :(size+1)/2 ;
- int realSize = torun;
+ int numberOfButtonsPerRow = (size % 2 == 0) ? size/2 :(size+1)/2;
+ int numberOfButtons = numberOfButtonsPerRow * 2;
+
+ buttons = new SudokuButton[numberOfButtons];
//set layout parameters and init Layouts
@@ -71,7 +68,7 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan
p.setMargins(0,5,0,5);
layouts[i] = new LinearLayout(getContext(),null);
layouts[i].setLayoutParams(p);
- layouts[i].setWeightSum(torun);
+ layouts[i].setWeightSum(numberOfButtonsPerRow);
layouts[i].setOrientation(LinearLayout.HORIZONTAL);
addView(layouts[i]);
}
@@ -80,15 +77,13 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan
- for (int k = 0; k<2;k++){
- for (int i = 0; i< torun; i++){
- if (number == size) {
- break;
- }
- buttons[number] = new SudokuButton(getContext(),null);
+ for (int layoutNumber = 0; layoutNumber <= 1 ; layoutNumber++){
+ for (int i = 0; i < numberOfButtonsPerRow; i++){
+ int buttonIndex = i + layoutNumber * numberOfButtonsPerRow;
+ buttons[buttonIndex] = new SudokuButton(getContext(),null);
p = new LayoutParams(0, LayoutParams.MATCH_PARENT,1);
p.setMargins(5,5,5,5);
- buttons[number].setLayoutParams(p);
+ buttons[buttonIndex].setLayoutParams(p);
/* removed GridLayout because of bad scaling will use now a Linearlayout
Spec rowSpec = spec(k,1);
Spec colSpec = spec(i,1);
@@ -106,14 +101,18 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan
// buttons[number].setLayoutParams(p);
//buttons[number].setGravity(Gravity.CENTER);
- buttons[number].setType(SudokuButtonType.Value);
- buttons[number].setTextColor(getResources().getColor(R.color.white));
- buttons[number].setBackgroundResource(R.drawable.mnenomic_numpad_button);
- buttons[number].setText(Symbol.getSymbol(symbolsToUse, number));
- buttons[number].setValue(number + 1);
- buttons[number].setOnClickListener(listener);
- layouts[k].addView(buttons[number]);
- number++;
+ buttons[buttonIndex].setType(SudokuButtonType.Value);
+ buttons[buttonIndex].setTextColor(getResources().getColor(R.color.white));
+ buttons[buttonIndex].setBackgroundResource(R.drawable.mnenomic_numpad_button);
+ buttons[buttonIndex].setText(Symbol.getSymbol(symbolsToUse, buttonIndex));
+ buttons[buttonIndex].setValue(buttonIndex + 1);
+ buttons[buttonIndex].setOnClickListener(listener);
+
+ if (buttonIndex == size) {
+ buttons[buttonIndex].setVisibility(INVISIBLE);
+ }
+
+ layouts[layoutNumber].addView(buttons[buttonIndex]);
}
}
}
@@ -175,6 +174,7 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan
}
}
}
+
public void fixHeight (){
int i = getHeight();
i = buttons[0].getHeight();
diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java
index 0645c8b..2791586 100644
--- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java
+++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java
@@ -22,16 +22,19 @@ import android.widget.Toast;
import java.util.LinkedList;
import org.secuso.privacyfriendlysudoku.controller.GameController;
+import org.secuso.privacyfriendlysudoku.game.listener.IHighlightChangedListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;
+import static org.secuso.privacyfriendlysudoku.ui.view.SudokuButtonType.*;
+
/**
* Created by TMZ_LToP on 17.11.2015.
*/
-public class SudokuSpecialButtonLayout extends LinearLayout {
+public class SudokuSpecialButtonLayout extends LinearLayout implements IHighlightChangedListener {
SudokuSpecialButton[] fixedButtons;
- public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size();
+ public int fixedButtonsCount = getSpecialButtons().size();
GameController gameController;
SudokuKeyboardLayout keyboard;
Bitmap bitMap,bitResult;
@@ -114,18 +117,21 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
fragmentManager = fm;
keyboard=key;
gameController = gc;
+ if(gc != null) {
+ gc.registerHighlightChangedListener(this);
+ }
fixedButtons = new SudokuSpecialButton[fixedButtonsCount];
LayoutParams p;
int i = 0;
//ArrayList type = (ArrayList) SudokuButtonType.getSpecialButtons();
- for (SudokuButtonType t : SudokuButtonType.getSpecialButtons()){
+ for (SudokuButtonType t : getSpecialButtons()){
fixedButtons[i] = new SudokuSpecialButton(getContext(),null);
p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,1);
p.setMargins(5, 5, 5, 5);
//int width2 =width/(fixedButtonsCount);
//p.width= width2-15;
- if(t == SudokuButtonType.Spacer) {
+ if(t == Spacer) {
fixedButtons[i].setVisibility(View.INVISIBLE);
}
/*if(t == SudokuButtonType.Do && !gameController.isRedoAvailable()) {
@@ -148,6 +154,24 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
}
+ @Override
+ public void onHighlightChanged() {
+ for(int i = 0; i < fixedButtons.length; i++) {
+ switch(fixedButtons[i].getType()) {
+ case Undo:
+ fixedButtons[i].setBackgroundResource(gameController.isUndoAvailable() ?
+ R.drawable.numpad_highlighted_four : R.drawable.inactive_button);
+ break;
+ case Do:
+ fixedButtons[i].setBackgroundResource(gameController.isRedoAvailable() ?
+ R.drawable.numpad_highlighted_four : R.drawable.inactive_button);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
@SuppressLint("ValidFragment")
public class HintConfirmationDialog extends DialogFragment {
diff --git a/app/src/main/res/drawable-hdpi/ic_info_black_24dp.png b/app/src/main/res/drawable/ic_info_black_24dp.png
similarity index 100%
rename from app/src/main/res/drawable-hdpi/ic_info_black_24dp.png
rename to app/src/main/res/drawable/ic_info_black_24dp.png
diff --git a/app/src/main/res/drawable-hdpi/secuso_logo_blau_blau.png b/app/src/main/res/drawable/secuso_logo_blau_blau.png
similarity index 100%
rename from app/src/main/res/drawable-hdpi/secuso_logo_blau_blau.png
rename to app/src/main/res/drawable/secuso_logo_blau_blau.png
diff --git a/app/src/main/res/layout-land/activity_about.xml b/app/src/main/res/layout-land/activity_about.xml
new file mode 100644
index 0000000..02a88bd
--- /dev/null
+++ b/app/src/main/res/layout-land/activity_about.xml
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout-land/activity_main_menu.xml b/app/src/main/res/layout-land/activity_main_menu.xml
new file mode 100644
index 0000000..d35eb51
--- /dev/null
+++ b/app/src/main/res/layout-land/activity_main_menu.xml
@@ -0,0 +1,165 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout-land/content_game_view.xml b/app/src/main/res/layout-land/content_game_view.xml
new file mode 100644
index 0000000..0107be5
--- /dev/null
+++ b/app/src/main/res/layout-land/content_game_view.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout-land/fragment_stats.xml b/app/src/main/res/layout-land/fragment_stats.xml
new file mode 100644
index 0000000..34a4496
--- /dev/null
+++ b/app/src/main/res/layout-land/fragment_stats.xml
@@ -0,0 +1,316 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout-xlarge-land/activity_about.xml b/app/src/main/res/layout-xlarge-land/activity_about.xml
new file mode 100644
index 0000000..f6ca1d1
--- /dev/null
+++ b/app/src/main/res/layout-xlarge-land/activity_about.xml
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout-xlarge/activity_about.xml b/app/src/main/res/layout-xlarge/activity_about.xml
new file mode 100644
index 0000000..bbdd5cf
--- /dev/null
+++ b/app/src/main/res/layout-xlarge/activity_about.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
index 0a3f71a..bbdd5cf 100644
--- a/app/src/main/res/layout/activity_about.xml
+++ b/app/src/main/res/layout/activity_about.xml
@@ -56,7 +56,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginTop="40dp"
+ android:layout_marginTop="30dp"
android:text="@string/about_affiliation"
android:textStyle="bold" />
@@ -70,7 +70,7 @@
diff --git a/app/src/main/res/layout/activity_game_view.xml b/app/src/main/res/layout/activity_game_view.xml
index 0fb29f0..291e291 100644
--- a/app/src/main/res/layout/activity_game_view.xml
+++ b/app/src/main/res/layout/activity_game_view.xml
@@ -62,9 +62,7 @@
android:text="00:00"
android:layout_weight="2"
android:id="@+id/timerView"
- android:gravity="right"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"/>
+ android:gravity="end"/>
diff --git a/app/src/main/res/layout/activity_main_menu.xml b/app/src/main/res/layout/activity_main_menu.xml
index be7c7e9..51f1f84 100644
--- a/app/src/main/res/layout/activity_main_menu.xml
+++ b/app/src/main/res/layout/activity_main_menu.xml
@@ -44,6 +44,7 @@
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
+
+ android:layout_alignParentStart="true"
+ android:padding="@dimen/activity_horizontal_margin"
+ android:layout_marginStart="@dimen/activity_horizontal_margin"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_centerVertical="true"
+ android:onClick="onClick"/>
+ android:layout_alignParentEnd="true"
+ android:padding="@dimen/activity_horizontal_margin"
+ android:layout_marginEnd="@dimen/activity_horizontal_margin"
+ android:layout_marginRight="@dimen/activity_horizontal_margin"
+ android:layout_centerVertical="true"
+ android:onClick="onClick"/>
+ android:textSize="@dimen/main_text_difficulty"/>
+ android:stepSize="1"/>
+