DroidFish: Disable board gestures by default, to improve responsiveness when touching the board to make moves.

This commit is contained in:
Peter Osterlund 2012-09-30 07:35:01 +00:00
parent c43d652207
commit 3047c32ec5
5 changed files with 51 additions and 14 deletions

View File

@ -27,19 +27,6 @@
<h3>Hints</h3>
<ul>
<li>
In game mode, long press chess board to activate copy/paste menu.
</li>
<li>
In edit board mode, long press chess board to activate edit menu.
</li>
<li>
Scroll left/right on the chess board to undo/redo moves.
</li>
<li>
If the game contains multiple variations, scroll up/down on the chess board
to go to the previous/next variation.
</li>
<li>
Long press mode/left/right buttons for additional commands.
</li>

View File

@ -283,6 +283,8 @@ you are not actively using the program.\
<string name="prefs_discardVariations_summary">Discard non-mainline moves from move list</string>
<string name="prefs_leftHanded_title">Left-handed mode</string>
<string name="prefs_leftHanded_summary">Controls on left side in landscape mode</string>
<string name="prefs_boardGestures_title">Board Gestures</string>
<string name="prefs_boardGestures_summary">Long press board for tools menu. Swipe horizontally to undo/redo moves. Swipe vertically to go to previous/next variation.</string>
<string name="prefs_squareSelectType_title">Square selection</string>
<string name="prefs_squareSelectType_summary">Control how selecting squares on the chess board behaves</string>
<string name="prefs_fontSize_title">Text Size</string>

View File

@ -482,8 +482,15 @@
android:entries="@array/squareSelectType_texts"
android:defaultValue="@string/squareSelectType_default">
</ListPreference>
<CheckBoxPreference
android:key="boardGestures"
android:title="@string/prefs_boardGestures_title"
android:summary="@string/prefs_boardGestures_summary"
android:defaultValue="false">
</CheckBoxPreference>
<ListPreference
android:key="scrollSensitivity"
android:dependency="boardGestures"
android:title="@string/prefs_scrollSensitivity_title"
android:summary="@string/prefs_scrollSensitivity_summary"
android:entryValues="@array/scroll_sensitivity_values"
@ -492,6 +499,7 @@
</ListPreference>
<CheckBoxPreference
android:key="invertScrollDirection"
android:dependency="boardGestures"
android:title="@string/prefs_invertScrollDirection_title"
android:summary="@string/prefs_invertScrollDirection_summary"
android:defaultValue="false">

View File

@ -185,8 +185,10 @@ public class DroidFish extends Activity implements GUIInterface {
SharedPreferences settings;
private boolean boardGestures;
private float scrollSensitivity;
private boolean invertScrollDirection;
private boolean leftHanded;
private boolean soundEnabled;
private MediaPlayer moveSound;
@ -574,12 +576,20 @@ public class DroidFish extends Activity implements GUIInterface {
final GestureDetector gd = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
private float scrollX = 0;
private float scrollY = 0;
@Override
public boolean onDown(MotionEvent e) {
if (!boardGestures) {
handleClick(e);
return true;
}
scrollX = 0;
scrollY = 0;
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (!boardGestures)
return false;
cb.cancelLongPress();
if (invertScrollDirection) {
distanceX = -distanceX;
@ -629,12 +639,18 @@ public class DroidFish extends Activity implements GUIInterface {
}
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (!boardGestures)
return false;
cb.cancelLongPress();
handleClick(e);
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
if (!boardGestures)
return false;
if (e.getAction() == MotionEvent.ACTION_UP)
handleClick(e);
return true;
@ -823,6 +839,7 @@ public class DroidFish extends Activity implements GUIInterface {
ctrl.setTimeLimit(timeControl, movesPerSession, timeIncrement);
setSummaryTitle();
boardGestures = settings.getBoolean("boardGestures", false);
scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2"));
invertScrollDirection = settings.getBoolean("invertScrollDirection", false);
discardVariations = settings.getBoolean("discardVariations", false);
@ -1101,6 +1118,13 @@ public class DroidFish extends Activity implements GUIInterface {
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem item = menu.findItem(R.id.item_file_menu);
item.setTitle(boardGestures ? R.string.option_file : R.string.tools_menu);
return true;
}
static private final int RESULT_EDITBOARD = 0;
static private final int RESULT_SETTINGS = 1;
static private final int RESULT_LOAD_PGN = 2;
@ -1582,7 +1606,7 @@ public class DroidFish extends Activity implements GUIInterface {
case NEW_GAME_DIALOG: return newGameDialog();
case PROMOTE_DIALOG: return promoteDialog();
case BOARD_MENU_DIALOG: return boardMenuDialog();
case FILE_MENU_DIALOG: return fileMenuDialog();
case FILE_MENU_DIALOG: return boardGestures ? fileMenuDialog() : boardMenuDialog();
case ABOUT_DIALOG: return aboutDialog();
case SELECT_MOVE_DIALOG: return selectMoveDialog();
case SELECT_BOOK_DIALOG: return selectBookDialog();

View File

@ -68,6 +68,7 @@ public class EditBoard extends Activity {
private boolean egtbHints;
private boolean autoScrollTitle;
private boolean boardGestures;
private TextView whiteFigText;
private TextView blackFigText;
private Typeface figNotation;
@ -83,6 +84,7 @@ public class EditBoard extends Activity {
egtbHints = settings.getBoolean("tbHintsEdit", false);
boolean fullScreenMode = settings.getBoolean("fullScreenMode", false);
autoScrollTitle = settings.getBoolean("autoScrollTitle", true);
boardGestures = settings.getBoolean("boardGestures", false);
initUI();
@ -163,19 +165,33 @@ public class EditBoard extends Activity {
cb.requestFocus();
cb.setClickable(true);
final GestureDetector gd = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
if (!boardGestures) {
handleClick(e);
return true;
}
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (!boardGestures)
return false;
cb.cancelLongPress();
return true;
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (!boardGestures)
return false;
cb.cancelLongPress();
handleClick(e);
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
if (!boardGestures)
return false;
if (e.getAction() == MotionEvent.ACTION_UP)
handleClick(e);
return true;