DroidFish: Added option to control title bar scrolling.

This commit is contained in:
Peter Osterlund 2012-09-29 12:00:40 +00:00
parent 913accffb6
commit 7a2bce1e89
4 changed files with 41 additions and 8 deletions

View File

@ -262,6 +262,8 @@ you are not actively using the program.\
<string name="prefs_user_interface_behavior">Behavior</string>
<string name="prefs_animateMoves_title">Animate Moves</string>
<string name="prefs_animateMoves_summary">Animate piece movements</string>
<string name="prefs_autoScrollTitle_title">Titlebar Scrolling</string>
<string name="prefs_autoScrollTitle_summary">Auto scroll titlebar if player names are too long</string>
<string name="prefs_quickMoveInput_title">Quick Move Input</string>
<string name="prefs_quickMoveInput_summary">From and To squares can be touched in any order. Move is played as soon as uniquely defined.</string>
<string name="prefs_soundEnabled_title">Enable Sounds</string>

View File

@ -173,6 +173,12 @@
android:summary="@string/prefs_animateMoves_summary"
android:defaultValue="true">
</CheckBoxPreference>
<CheckBoxPreference
android:key="autoScrollTitle"
android:title="@string/prefs_autoScrollTitle_title"
android:summary="@string/prefs_autoScrollTitle_summary"
android:defaultValue="true">
</CheckBoxPreference>
<PreferenceScreen
android:key="colors"
android:title="@string/prefs_colors_title"

View File

@ -96,6 +96,7 @@ import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
@ -190,6 +191,7 @@ public class DroidFish extends Activity implements GUIInterface {
private MediaPlayer moveSound;
private boolean vibrateEnabled;
private boolean animateMoves;
private boolean autoScrollTitle;
private boolean showMaterialDiff;
private final static String bookDir = "DroidFish";
@ -415,7 +417,7 @@ public class DroidFish extends Activity implements GUIInterface {
}
/** Create directory structure on SD card. */
private void createDirectories() {
private final void createDirectories() {
File extDir = Environment.getExternalStorageDirectory();
String sep = File.separator;
new File(extDir + sep + bookDir).mkdirs();
@ -842,6 +844,8 @@ public class DroidFish extends Activity implements GUIInterface {
soundEnabled = settings.getBoolean("soundEnabled", false);
vibrateEnabled = settings.getBoolean("vibrateEnabled", false);
animateMoves = settings.getBoolean("animateMoves", true);
autoScrollTitle = settings.getBoolean("autoScrollTitle", true);
setTitleScrolling();
custom1ButtonActions.readPrefs(settings, actionFactory);
custom2ButtonActions.readPrefs(settings, actionFactory);
@ -905,7 +909,7 @@ public class DroidFish extends Activity implements GUIInterface {
/**
* Change the Pieces into figurine or regular (i.e. letters) display
*/
private void setFigurineNotation(boolean displayAsFigures, int fontSize) {
private final void setFigurineNotation(boolean displayAsFigures, int fontSize) {
if (displayAsFigures) {
// increase the font cause it has different kerning and looks small
float increaseFontSize = fontSize * 1.1f;
@ -919,7 +923,17 @@ public class DroidFish extends Activity implements GUIInterface {
}
}
private void updateButtons() {
/** Enable/disable title bar scrolling. */
private final void setTitleScrolling() {
TextUtils.TruncateAt where = autoScrollTitle ? TextUtils.TruncateAt.MARQUEE
: TextUtils.TruncateAt.END;
whiteTitleText.setEllipsize(where);
blackTitleText.setEllipsize(where);
whiteFigText.setEllipsize(where);
blackFigText.setEllipsize(where);
}
private final 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()));
@ -950,8 +964,8 @@ public class DroidFish extends Activity implements GUIInterface {
setButtonData(redoButton, bWidth, bHeight, R.raw.right, svg);
}
private void setButtonData(ImageButton button, int bWidth, int bHeight,
int svgResId, SVG touched) {
private final void setButtonData(ImageButton button, int bWidth, int bHeight,
int svgResId, SVG touched) {
SVG svg = SVGParser.getSVGFromResource(getResources(), svgResId);
button.setBackgroundDrawable(new SVGPictureDrawable(svg));

View File

@ -44,6 +44,7 @@ import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.ClipboardManager;
import android.text.TextUtils;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.Menu;
@ -66,7 +67,8 @@ public class EditBoard extends Activity {
private Button cancelButton;
private TextView whiteTitleText, blackTitleText, engineTitleText;
boolean egtbHints;
private boolean egtbHints;
private boolean autoScrollTitle;
private TextView whiteFigText;
private TextView blackFigText;
private TextView summaryTitleText;
@ -79,11 +81,13 @@ public class EditBoard extends Activity {
figNotation = Typeface.createFromAsset(getAssets(), "fonts/DroidFishChessNotationDark.otf");
initUI();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
egtbHints = settings.getBoolean("tbHintsEdit", false);
boolean fullScreenMode = settings.getBoolean("fullScreenMode", false);
autoScrollTitle = settings.getBoolean("autoScrollTitle", true);
initUI();
Util.setFullScreenMode(this, fullScreenMode);
Intent i = getIntent();
@ -138,6 +142,13 @@ public class EditBoard extends Activity {
summaryTitleText = (TextView) findViewById(R.id.title_text_summary);
summaryTitleText.setVisibility(View.GONE);
TextUtils.TruncateAt where = autoScrollTitle ? TextUtils.TruncateAt.MARQUEE
: TextUtils.TruncateAt.END;
whiteTitleText.setEllipsize(where);
blackTitleText.setEllipsize(where);
whiteFigText.setEllipsize(where);
blackFigText.setEllipsize(where);
okButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
sendBackResult();