diff --git a/DroidFish/res/drawable/custom.png b/DroidFish/res/drawable/custom.png deleted file mode 100644 index 2d225a7..0000000 Binary files a/DroidFish/res/drawable/custom.png and /dev/null differ diff --git a/DroidFish/res/drawable/custom_large.png b/DroidFish/res/drawable/custom_large.png deleted file mode 100644 index 39833aa..0000000 Binary files a/DroidFish/res/drawable/custom_large.png and /dev/null differ diff --git a/DroidFish/res/drawable/flip.png b/DroidFish/res/drawable/flip.png deleted file mode 100644 index 503e8f1..0000000 Binary files a/DroidFish/res/drawable/flip.png and /dev/null differ diff --git a/DroidFish/res/drawable/flip_large.png b/DroidFish/res/drawable/flip_large.png deleted file mode 100644 index 5eeb2bc..0000000 Binary files a/DroidFish/res/drawable/flip_large.png and /dev/null differ diff --git a/DroidFish/res/drawable/left.png b/DroidFish/res/drawable/left.png deleted file mode 100644 index bd4684e..0000000 Binary files a/DroidFish/res/drawable/left.png and /dev/null differ diff --git a/DroidFish/res/drawable/left_large.png b/DroidFish/res/drawable/left_large.png deleted file mode 100644 index aaa4a0c..0000000 Binary files a/DroidFish/res/drawable/left_large.png and /dev/null differ diff --git a/DroidFish/res/drawable/mode.png b/DroidFish/res/drawable/mode.png deleted file mode 100644 index 14f7cc8..0000000 Binary files a/DroidFish/res/drawable/mode.png and /dev/null differ diff --git a/DroidFish/res/drawable/mode_large.png b/DroidFish/res/drawable/mode_large.png deleted file mode 100644 index 473a382..0000000 Binary files a/DroidFish/res/drawable/mode_large.png and /dev/null differ diff --git a/DroidFish/res/drawable/right.png b/DroidFish/res/drawable/right.png deleted file mode 100644 index c969620..0000000 Binary files a/DroidFish/res/drawable/right.png and /dev/null differ diff --git a/DroidFish/res/drawable/right_large.png b/DroidFish/res/drawable/right_large.png deleted file mode 100644 index 0140644..0000000 Binary files a/DroidFish/res/drawable/right_large.png and /dev/null differ diff --git a/DroidFish/res/layout-land/main.xml b/DroidFish/res/layout-land/main.xml index 1f7ff7a..e5bde2b 100644 --- a/DroidFish/res/layout-land/main.xml +++ b/DroidFish/res/layout-land/main.xml @@ -23,36 +23,31 @@ android:id="@+id/custom2Button" android:contentDescription="@string/buttonDesc_custom2" android:layout_width="36dp" - android:layout_height="32dp" - android:src="@drawable/custom"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> + android:layout_height="32dp"> User interface improvements by Aaro Korhonen. - -
  • Gaviota Tablebases Probing Code API, Copyright © 2010 Miguel A. Ballicora. +
      +
    • + LZMA compression by Igor Pavlov. +
    • +
    • + ZLIB compression, Copyright © 1995-2005 Jean-loup Gailly and Mark Adler. +
    • +
    • + LZF compression, Copyright © 2000-2007 Marc Alexander Lehmann. +
    • +
  • - LZMA compression by Igor Pavlov. -
  • -
  • - ZLIB compression, Copyright © 1995-2005 Jean-loup Gailly and Mark Adler. -
  • -
  • - LZF compression, Copyright © 2000-2007 Marc Alexander Lehmann. + SVG reader from svg-android project.
diff --git a/DroidFish/res/raw/custom.svg b/DroidFish/res/raw/custom.svg new file mode 100644 index 0000000..c4ebc9b --- /dev/null +++ b/DroidFish/res/raw/custom.svg @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/DroidFish/res/raw/flip.svg b/DroidFish/res/raw/flip.svg new file mode 100644 index 0000000..3d3a3d7 --- /dev/null +++ b/DroidFish/res/raw/flip.svg @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/DroidFish/res/raw/left.svg b/DroidFish/res/raw/left.svg new file mode 100644 index 0000000..184f57a --- /dev/null +++ b/DroidFish/res/raw/left.svg @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/DroidFish/res/raw/mode.svg b/DroidFish/res/raw/mode.svg new file mode 100644 index 0000000..d3b2a90 --- /dev/null +++ b/DroidFish/res/raw/mode.svg @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/DroidFish/res/raw/right.svg b/DroidFish/res/raw/right.svg new file mode 100644 index 0000000..13a1936 --- /dev/null +++ b/DroidFish/res/raw/right.svg @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index 864d9e2..5a5b881 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -106,6 +106,7 @@ you are not actively using the program.\ Toggle Comments Toggle Headers Toggle Engine Analysis + Toggle Large Buttons Cancel Yes No @@ -508,6 +509,7 @@ you are not actively using the program.\ @string/toggle_pgn_variations @string/toggle_pgn_comments @string/toggle_pgn_headers + @string/toggle_large_buttons @@ -518,5 +520,6 @@ you are not actively using the program.\ viewVariations viewComments viewHeaders + largeButtons diff --git a/DroidFish/src/org/petero/droidfish/ButtonActions.java b/DroidFish/src/org/petero/droidfish/ButtonActions.java index c3b8cc5..372ec9e 100644 --- a/DroidFish/src/org/petero/droidfish/ButtonActions.java +++ b/DroidFish/src/org/petero/droidfish/ButtonActions.java @@ -121,12 +121,12 @@ public class ButtonActions { } /** Get icon resource for button. */ - public int getIcon(boolean large) { + public int getIcon() { int ret = -1; if (mainAction != null) - ret = mainAction.getIcon(large); + ret = mainAction.getIcon(); if (ret == -1) - ret = large ? R.drawable.custom_large : R.drawable.custom; + ret = R.raw.custom; return ret; } } diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index 8f84b50..445a4d8 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -51,6 +51,9 @@ import org.petero.droidfish.gamelogic.PgnToken; import org.petero.droidfish.gamelogic.GameTree.Node; import org.petero.droidfish.gtb.Probe; +import com.larvalabs.svgandroid.SVG; +import com.larvalabs.svgandroid.SVGParser; + import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -211,7 +214,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "flipboard"; } public int getName() { return R.string.flip_board; } - public int getIcon(boolean large) { return large ? R.drawable.flip_large : R.drawable.flip; } + public int getIcon() { return R.raw.flip; } public boolean enabled() { return true; } public void run() { boardFlipped = !cb.flipped; @@ -222,7 +225,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "showThinking"; } public int getName() { return R.string.toggle_show_thinking; } - public int getIcon(boolean large) { return -1; } + public int getIcon() { return -1; } public boolean enabled() { return true; } public void run() { mShowThinking = toggleBooleanPref("showThinking"); @@ -232,7 +235,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "bookHints"; } public int getName() { return R.string.toggle_book_hints; } - public int getIcon(boolean large) { return -1; } + public int getIcon() { return -1; } public boolean enabled() { return true; } public void run() { mShowBookHints = toggleBooleanPref("bookHints"); @@ -242,7 +245,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "viewVariations"; } public int getName() { return R.string.toggle_pgn_variations; } - public int getIcon(boolean large) { return -1; } + public int getIcon() { return -1; } public boolean enabled() { return true; } public void run() { pgnOptions.view.variations = toggleBooleanPref("viewVariations"); @@ -253,7 +256,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "viewComments"; } public int getName() { return R.string.toggle_pgn_comments; } - public int getIcon(boolean large) { return -1; } + public int getIcon() { return -1; } public boolean enabled() { return true; } public void run() { pgnOptions.view.comments = toggleBooleanPref("viewComments"); @@ -264,7 +267,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "viewHeaders"; } public int getName() { return R.string.toggle_pgn_headers; } - public int getIcon(boolean large) { return -1; } + public int getIcon() { return -1; } public boolean enabled() { return true; } public void run() { pgnOptions.view.headers = toggleBooleanPref("viewHeaders"); @@ -275,7 +278,7 @@ public class DroidFish extends Activity implements GUIInterface { addAction(new UIAction() { public String getId() { return "toggleAnalysis"; } public int getName() { return R.string.toggle_analysis; } - public int getIcon(boolean large) { return -1; } + public int getIcon() { return -1; } public boolean enabled() { return true; } public void run() { int gameModeType = ctrl.analysisMode() ? GameMode.EDIT_GAME : GameMode.ANALYSIS; @@ -288,6 +291,16 @@ public class DroidFish extends Activity implements GUIInterface { setBoardFlip(true); } }); + addAction(new UIAction() { + public String getId() { return "largeButtons"; } + public int getName() { return R.string.toggle_large_buttons; } + public int getIcon() { return -1; } + public boolean enabled() { return true; } + public void run() { + pgnOptions.view.headers = toggleBooleanPref("largeButtons"); + updateButtons(); + } + }); } @Override @@ -734,30 +747,7 @@ public class DroidFish extends Activity implements GUIInterface { custom1ButtonActions.readPrefs(settings, actionFactory); custom2ButtonActions.readPrefs(settings, actionFactory); - boolean largeButtons = settings.getBoolean("largeButtons", false); - Resources r = getResources(); - int bWidth = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics())); - int bHeight = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics())); - if (largeButtons) { - bWidth = bWidth * 3 / 2; - bHeight = bHeight * 3 / 2; - custom1Button.setImageResource(custom1ButtonActions.getIcon(true)); - custom2Button.setImageResource(custom2ButtonActions.getIcon(true)); - modeButton.setImageResource(R.drawable.mode_large); - undoButton.setImageResource(R.drawable.left_large); - redoButton.setImageResource(R.drawable.right_large); - } else { - custom1Button.setImageResource(custom1ButtonActions.getIcon(false)); - custom2Button.setImageResource(custom2ButtonActions.getIcon(false)); - modeButton.setImageResource(R.drawable.mode); - undoButton.setImageResource(R.drawable.left); - redoButton.setImageResource(R.drawable.right); - } - custom1Button.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); - custom2Button.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); - modeButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); - undoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); - redoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); + updateButtons(); bookOptions.filename = settings.getString("bookFile", ""); bookOptions.maxLength = getIntSetting("bookMaxLength", 1000000); @@ -803,6 +793,39 @@ public class DroidFish extends Activity implements GUIInterface { ctrl.prefsChanged(); } + private void updateButtons() { + boolean largeButtons = settings.getBoolean("largeButtons", false); + Resources r = getResources(); + int bWidth = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics())); + int bHeight = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics())); + if (largeButtons) { + bWidth = bWidth * 3 / 2; + bHeight = bHeight * 3 / 2; + } + SVG svg = SVGParser.getSVGFromResource(getResources(), + custom1ButtonActions.getIcon()); + custom1Button.setBackgroundDrawable(new SVGPictureDrawable(svg)); + + svg = SVGParser.getSVGFromResource(getResources(), + custom2ButtonActions.getIcon()); + custom2Button.setBackgroundDrawable(new SVGPictureDrawable(svg)); + + svg = SVGParser.getSVGFromResource(getResources(), R.raw.right); + redoButton.setBackgroundDrawable(new SVGPictureDrawable(svg)); + + svg = SVGParser.getSVGFromResource(getResources(), R.raw.left); + undoButton.setBackgroundDrawable(new SVGPictureDrawable(svg)); + + svg = SVGParser.getSVGFromResource(getResources(), R.raw.mode); + modeButton.setBackgroundDrawable(new SVGPictureDrawable(svg)); + + custom1Button.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); + custom2Button.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); + modeButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); + undoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); + redoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight)); + } + private synchronized final void setWakeLock(boolean enableLock) { WakeLock wl = wakeLock; if (wl != null) { diff --git a/DroidFish/src/org/petero/droidfish/SVGPictureDrawable.java b/DroidFish/src/org/petero/droidfish/SVGPictureDrawable.java new file mode 100644 index 0000000..5130fb6 --- /dev/null +++ b/DroidFish/src/org/petero/droidfish/SVGPictureDrawable.java @@ -0,0 +1,47 @@ +package org.petero.droidfish; + +import com.larvalabs.svgandroid.SVG; + +import android.graphics.Canvas; +import android.graphics.RectF; +import android.graphics.drawable.PictureDrawable; + +/** + * Like PictureDrawable but scales the picture according to current drawing bounds. + */ +public class SVGPictureDrawable extends PictureDrawable { + + private final int iWidth; + private final int iHeight; + + public SVGPictureDrawable(SVG svg) { + super(svg.getPicture()); + RectF bounds = svg.getBounds(); + RectF limits = svg.getLimits(); + if (bounds != null) { + iWidth = (int)bounds.width(); + iHeight = (int)bounds.height(); + } else if (limits != null) { + iWidth = (int)limits.width(); + iHeight = (int)limits.height(); + } else { + iWidth = -1; + iHeight = -1; + } + } + + @Override + public int getIntrinsicWidth() { + return iWidth; + } + + @Override + public int getIntrinsicHeight() { + return iHeight; + } + + @Override + public void draw(Canvas canvas) { + canvas.drawPicture(getPicture(), getBounds()); + } +} diff --git a/DroidFish/src/org/petero/droidfish/UIAction.java b/DroidFish/src/org/petero/droidfish/UIAction.java index 5ab9d6d..43515a1 100644 --- a/DroidFish/src/org/petero/droidfish/UIAction.java +++ b/DroidFish/src/org/petero/droidfish/UIAction.java @@ -26,8 +26,8 @@ public interface UIAction extends Runnable { /** Get name resource for the action. */ public int getName(); - /** Get icon resource or -1 for no icon. */ - public int getIcon(boolean large); + /** Get icon SVG resource or -1 for no icon. */ + public int getIcon(); /** Return true if the action is currently enabled. */ public boolean enabled();