DroidFish: Implemented auto move forward/backward to view games without having to press the arrow buttons repeatedly.

This commit is contained in:
Peter Osterlund 2015-02-01 20:37:53 +00:00
parent 22e71744a1
commit 243303c96b
3 changed files with 139 additions and 7 deletions

View File

@ -12,6 +12,7 @@
<string name="scroll_sensitivity_default">2</string> <string name="scroll_sensitivity_default">2</string>
<string name="book_line_length_default">1000000</string> <string name="book_line_length_default">1000000</string>
<string name="viewPieceType_default">1</string> <string name="viewPieceType_default">1</string>
<string name="autoDelay_default">5000</string>
<string name="cpu_warning">\ <string name="cpu_warning">\
<b>CPU Usage</b>\n\ <b>CPU Usage</b>\n\
If you leave DroidFish running in the background and <i>GameMode</i> is set to \ If you leave DroidFish running in the background and <i>GameMode</i> is set to \
@ -114,6 +115,8 @@ you are not actively using the program.\
<string name="goto_end_variation">Goto End of Variation</string> <string name="goto_end_variation">Goto End of Variation</string>
<string name="goto_next_variation">Goto Next Variation</string> <string name="goto_next_variation">Goto Next Variation</string>
<string name="load_next_game">Load Next Game</string> <string name="load_next_game">Load Next Game</string>
<string name="auto_forward">Auto Forward</string>
<string name="auto_backward">Auto Backward</string>
<string name="no_prev_game">No previous game</string> <string name="no_prev_game">No previous game</string>
<string name="no_next_game">No next game</string> <string name="no_next_game">No next game</string>
<string name="no_prev_fen">No previous position</string> <string name="no_prev_fen">No previous position</string>
@ -270,6 +273,8 @@ you are not actively using the program.\
<string name="prefs_timeControl_summary">Maximum thinking time between time controls</string> <string name="prefs_timeControl_summary">Maximum thinking time between time controls</string>
<string name="prefs_timeIncrement_title">Increment</string> <string name="prefs_timeIncrement_title">Increment</string>
<string name="prefs_timeIncrement_summary">Extra thinking time for each completed move</string> <string name="prefs_timeIncrement_summary">Extra thinking time for each completed move</string>
<string name="prefs_autoDelay_title">Auto Move Delay</string>
<string name="prefs_autoDelay_summary">Delay between moves in automatic forward/backward mode</string>
<string name="prefs_hints">Hints</string> <string name="prefs_hints">Hints</string>
<string name="prefs_showThinking_title">Show Computer Thinking</string> <string name="prefs_showThinking_title">Show Computer Thinking</string>
<string name="prefs_showThinking_summary">Display computer algorithm information during search</string> <string name="prefs_showThinking_summary">Display computer algorithm information during search</string>
@ -549,6 +554,28 @@ you are not actively using the program.\
<item>30000</item> <item>30000</item>
<item>60000</item> <item>60000</item>
</string-array> </string-array>
<string-array name="autoDelay_texts">
<item>0.5s</item>
<item>1s</item>
<item>2s</item>
<item>3s</item>
<item>5s</item>
<item>10s</item>
<item>15s</item>
<item>30s</item>
<item>60s</item>
</string-array>
<string-array name="autoDelay_values">
<item>500</item>
<item>1000</item>
<item>2000</item>
<item>3000</item>
<item>5000</item>
<item>10000</item>
<item>15000</item>
<item>30000</item>
<item>60000</item>
</string-array>
<string-array name="squareSelectType_texts"> <string-array name="squareSelectType_texts">
<item>Sticky</item> <item>Sticky</item>
<item>Toggle</item> <item>Toggle</item>

View File

@ -509,6 +509,14 @@
android:summary="@string/prefs_invertScrollDirection_summary" android:summary="@string/prefs_invertScrollDirection_summary"
android:defaultValue="false"> android:defaultValue="false">
</CheckBoxPreference> </CheckBoxPreference>
<ListPreference
android:key="autoDelay"
android:title="@string/prefs_autoDelay_title"
android:summary="@string/prefs_autoDelay_summary"
android:entryValues="@array/autoDelay_values"
android:entries="@array/autoDelay_texts"
android:defaultValue="@string/autoDelay_default">
</ListPreference>
<CheckBoxPreference <CheckBoxPreference
android:key="discardVariations" android:key="discardVariations"
android:title="@string/prefs_discardVariations_title" android:title="@string/prefs_discardVariations_title"

View File

@ -210,6 +210,12 @@ public class DroidFish extends Activity implements GUIInterface {
private boolean showMaterialDiff; private boolean showMaterialDiff;
private boolean showVariationLine; private boolean showVariationLine;
private int autoMoveDelay; // Delay in auto forward/backward mode
private static enum AutoMode {
OFF, FORWARD, BACKWARD;
}
private AutoMode autoMode = AutoMode.OFF;
private final static String bookDir = "DroidFish/book"; private final static String bookDir = "DroidFish/book";
private final static String pgnDir = "DroidFish/pgn"; private final static String pgnDir = "DroidFish/pgn";
private final static String fenDir = "DroidFish/epd"; private final static String fenDir = "DroidFish/epd";
@ -410,7 +416,7 @@ public class DroidFish extends Activity implements GUIInterface {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
initUI(); initUI();
gameTextListener = new PgnScreenText(pgnOptions); gameTextListener = new PgnScreenText(this, pgnOptions);
if (ctrl != null) if (ctrl != null)
ctrl.shutdownEngine(); ctrl.shutdownEngine();
ctrl = new DroidChessController(this, gameTextListener, pgnOptions); ctrl = new DroidChessController(this, gameTextListener, pgnOptions);
@ -419,6 +425,7 @@ public class DroidFish extends Activity implements GUIInterface {
TimeControlData tcData = new TimeControlData(); TimeControlData tcData = new TimeControlData();
tcData.setTimeControl(timeControl, movesPerSession, timeIncrement); tcData.setTimeControl(timeControl, movesPerSession, timeIncrement);
ctrl.newGame(gameMode, tcData); ctrl.newGame(gameMode, tcData);
setAutoMode(AutoMode.OFF);
{ {
byte[] data = null; byte[] data = null;
int version = 1; int version = 1;
@ -619,6 +626,7 @@ public class DroidFish extends Activity implements GUIInterface {
reInitUI(); reInitUI();
else else
readPrefs(); readPrefs();
maybeAutoModeOff(gameMode);
ctrl.setGameMode(gameMode); ctrl.setGameMode(gameMode);
} }
@ -736,8 +744,10 @@ public class DroidFish extends Activity implements GUIInterface {
if (sq == sq0) { if (sq == sq0) {
if (ctrl.humansTurn()) { if (ctrl.humansTurn()) {
Move m = cb.mousePressed(sq); Move m = cb.mousePressed(sq);
if (m != null) if (m != null) {
setAutoMode(AutoMode.OFF);
ctrl.makeHumanMove(m); ctrl.makeHumanMove(m);
}
setEgtbHints(cb.getSelectedSquare()); setEgtbHints(cb.getSelectedSquare());
} }
} }
@ -771,8 +781,10 @@ public class DroidFish extends Activity implements GUIInterface {
nUndo++; nUndo++;
scrollX += scrollUnit; scrollX += scrollUnit;
} }
if (nUndo + nRedo > 0) if (nUndo + nRedo > 0) {
scrollY = 0; scrollY = 0;
setAutoMode(AutoMode.OFF);
}
if (nRedo + nUndo > 1) { if (nRedo + nUndo > 1) {
boolean analysis = gameMode.analysisMode(); boolean analysis = gameMode.analysisMode();
boolean human = gameMode.playerWhite() || gameMode.playerBlack(); boolean human = gameMode.playerWhite() || gameMode.playerBlack();
@ -796,6 +808,7 @@ public class DroidFish extends Activity implements GUIInterface {
} }
if (varDelta != 0) { if (varDelta != 0) {
scrollX = 0; scrollX = 0;
setAutoMode(AutoMode.OFF);
ctrl.changeVariation(varDelta); ctrl.changeVariation(varDelta);
} }
return varDelta != 0; return varDelta != 0;
@ -808,8 +821,10 @@ public class DroidFish extends Activity implements GUIInterface {
public void onTrackballEvent(MotionEvent event) { public void onTrackballEvent(MotionEvent event) {
if (ctrl.humansTurn()) { if (ctrl.humansTurn()) {
Move m = cb.handleTrackballEvent(event); Move m = cb.handleTrackballEvent(event);
if (m != null) if (m != null) {
setAutoMode(AutoMode.OFF);
ctrl.makeHumanMove(m); ctrl.makeHumanMove(m);
}
setEgtbHints(cb.getSelectedSquare()); setEgtbHints(cb.getSelectedSquare());
} }
} }
@ -859,6 +874,7 @@ public class DroidFish extends Activity implements GUIInterface {
undoButton.setOnClickListener(new OnClickListener() { undoButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setAutoMode(AutoMode.OFF);
ctrl.undoMove(); ctrl.undoMove();
} }
}); });
@ -874,6 +890,7 @@ public class DroidFish extends Activity implements GUIInterface {
redoButton.setOnClickListener(new OnClickListener() { redoButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setAutoMode(AutoMode.OFF);
ctrl.redoMove(); ctrl.redoMove();
} }
}); });
@ -911,6 +928,7 @@ public class DroidFish extends Activity implements GUIInterface {
@Override @Override
protected void onPause() { protected void onPause() {
if (ctrl != null) { if (ctrl != null) {
setAutoMode(AutoMode.OFF);
ctrl.setGuiPaused(true); ctrl.setGuiPaused(true);
byte[] data = ctrl.toByteArray(); byte[] data = ctrl.toByteArray();
Editor editor = settings.edit(); Editor editor = settings.edit();
@ -927,6 +945,7 @@ public class DroidFish extends Activity implements GUIInterface {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
setAutoMode(AutoMode.OFF);
if (ctrl != null) if (ctrl != null)
ctrl.shutdownEngine(); ctrl.shutdownEngine();
setNotification(false); setNotification(false);
@ -975,6 +994,8 @@ public class DroidFish extends Activity implements GUIInterface {
movesPerSession = getIntSetting("movesPerSession", 60); movesPerSession = getIntSetting("movesPerSession", 60);
timeIncrement = getIntSetting("timeIncrement", 0); timeIncrement = getIntSetting("timeIncrement", 0);
autoMoveDelay = getIntSetting("autoDelay", 5000);
scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2")); scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2"));
invertScrollDirection = settings.getBoolean("invertScrollDirection", false); invertScrollDirection = settings.getBoolean("invertScrollDirection", false);
discardVariations = settings.getBoolean("discardVariations", false); discardVariations = settings.getBoolean("discardVariations", false);
@ -1299,6 +1320,7 @@ public class DroidFish extends Activity implements GUIInterface {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
setAutoMode(AutoMode.OFF);
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.item_new_game: case R.id.item_new_game:
showDialog(NEW_GAME_DIALOG); showDialog(NEW_GAME_DIALOG);
@ -1469,6 +1491,7 @@ public class DroidFish extends Activity implements GUIInterface {
editor.putString("gameMode", gameModeStr); editor.putString("gameMode", gameModeStr);
editor.commit(); editor.commit();
gameMode = new GameMode(gameModeType); gameMode = new GameMode(gameModeType);
maybeAutoModeOff(gameMode);
ctrl.setGameMode(gameMode); ctrl.setGameMode(gameMode);
} }
@ -1888,6 +1911,7 @@ public class DroidFish extends Activity implements GUIInterface {
final int COPY_POSITION = 1; final int COPY_POSITION = 1;
final int PASTE = 2; final int PASTE = 2;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>(); List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>(); List<Integer> actions = new ArrayList<Integer>();
lst.add(getString(R.string.copy_game)); actions.add(COPY_GAME); lst.add(getString(R.string.copy_game)); actions.add(COPY_GAME);
@ -1937,6 +1961,7 @@ public class DroidFish extends Activity implements GUIInterface {
final int SHARE = 2; final int SHARE = 2;
final int GET_FEN = 3; final int GET_FEN = 3;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>(); List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>(); List<Integer> actions = new ArrayList<Integer>();
lst.add(getString(R.string.clipboard)); actions.add(CLIPBOARD); lst.add(getString(R.string.clipboard)); actions.add(CLIPBOARD);
@ -1993,6 +2018,7 @@ public class DroidFish extends Activity implements GUIInterface {
final int LOAD_SCID_GAME = 3; final int LOAD_SCID_GAME = 3;
final int SAVE_GAME = 4; final int SAVE_GAME = 4;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>(); List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>(); List<Integer> actions = new ArrayList<Integer>();
if (currFileType() != FT_NONE) { if (currFileType() != FT_NONE) {
@ -2040,6 +2066,7 @@ public class DroidFish extends Activity implements GUIInterface {
String path = currPathName(); String path = currPathName();
if (path.length() == 0) if (path.length() == 0)
return; return;
setAutoMode(AutoMode.OFF);
switch (currFileType()) { switch (currFileType()) {
case FT_PGN: case FT_PGN:
loadPGNFromFile(path); loadPGNFromFile(path);
@ -2077,6 +2104,7 @@ public class DroidFish extends Activity implements GUIInterface {
} }
private final Dialog selectMoveDialog() { private final Dialog selectMoveDialog() {
setAutoMode(AutoMode.OFF);
View content = View.inflate(this, R.layout.select_move_number, null); View content = View.inflate(this, R.layout.select_move_number, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(content); builder.setView(content);
@ -2271,6 +2299,7 @@ public class DroidFish extends Activity implements GUIInterface {
private final Dialog selectFileDialog(final String defaultDir, int selectFileMsg, int noFilesMsg, private final Dialog selectFileDialog(final String defaultDir, int selectFileMsg, int noFilesMsg,
String settingsName, final Loader loader) { String settingsName, final Loader loader) {
setAutoMode(AutoMode.OFF);
final String[] fileNames = findFilesInDirectory(defaultDir, null); final String[] fileNames = findFilesInDirectory(defaultDir, null);
final int numFiles = fileNames.length; final int numFiles = fileNames.length;
if (numFiles == 0) { if (numFiles == 0) {
@ -2304,6 +2333,7 @@ public class DroidFish extends Activity implements GUIInterface {
} }
private final Dialog selectPgnFileSaveDialog() { private final Dialog selectPgnFileSaveDialog() {
setAutoMode(AutoMode.OFF);
final String[] fileNames = findFilesInDirectory(pgnDir, null); final String[] fileNames = findFilesInDirectory(pgnDir, null);
final int numFiles = fileNames.length; final int numFiles = fileNames.length;
int defaultItem = 0; int defaultItem = 0;
@ -2342,6 +2372,7 @@ public class DroidFish extends Activity implements GUIInterface {
} }
private final Dialog selectPgnSaveNewFileDialog() { private final Dialog selectPgnSaveNewFileDialog() {
setAutoMode(AutoMode.OFF);
View content = View.inflate(this, R.layout.create_pgn_file, null); View content = View.inflate(this, R.layout.create_pgn_file, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(content); builder.setView(content);
@ -2430,6 +2461,7 @@ public class DroidFish extends Activity implements GUIInterface {
editor.putString("gameMode", gameModeStr); editor.putString("gameMode", gameModeStr);
editor.commit(); editor.commit();
gameMode = new GameMode(gameModeType); gameMode = new GameMode(gameModeType);
maybeAutoModeOff(gameMode);
ctrl.setGameMode(gameMode); ctrl.setGameMode(gameMode);
setBoardFlip(flipSite); setBoardFlip(flipSite);
} }
@ -2447,6 +2479,7 @@ public class DroidFish extends Activity implements GUIInterface {
final int MOVE_VAR_DOWN = 4; final int MOVE_VAR_DOWN = 4;
final int ADD_NULL_MOVE = 5; final int ADD_NULL_MOVE = 5;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>(); List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>(); List<Integer> actions = new ArrayList<Integer>();
lst.add(getString(R.string.edit_headers)); actions.add(EDIT_HEADERS); lst.add(getString(R.string.edit_headers)); actions.add(EDIT_HEADERS);
@ -2657,7 +2690,9 @@ public class DroidFish extends Activity implements GUIInterface {
final int GOTO_START_VAR = 1; final int GOTO_START_VAR = 1;
final int GOTO_PREV_VAR = 2; final int GOTO_PREV_VAR = 2;
final int LOAD_PREV_GAME = 3; final int LOAD_PREV_GAME = 3;
final int AUTO_BACKWARD = 4;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>(); List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>(); List<Integer> actions = new ArrayList<Integer>();
lst.add(getString(R.string.goto_start_game)); actions.add(GOTO_START_GAME); lst.add(getString(R.string.goto_start_game)); actions.add(GOTO_START_GAME);
@ -2670,6 +2705,9 @@ public class DroidFish extends Activity implements GUIInterface {
if ((currFT != FT_NONE) && !gameMode.clocksActive()) { if ((currFT != FT_NONE) && !gameMode.clocksActive()) {
lst.add(getString(R.string.load_prev_game)); actions.add(LOAD_PREV_GAME); lst.add(getString(R.string.load_prev_game)); actions.add(LOAD_PREV_GAME);
} }
if (!gameMode.clocksActive()) {
lst.add(getString(R.string.auto_backward)); actions.add(AUTO_BACKWARD);
}
final List<Integer> finalActions = actions; final List<Integer> finalActions = actions;
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.go_back); builder.setTitle(R.string.go_back);
@ -2698,6 +2736,9 @@ public class DroidFish extends Activity implements GUIInterface {
startActivityForResult(i, RESULT_LOAD_FEN); startActivityForResult(i, RESULT_LOAD_FEN);
} }
break; break;
case AUTO_BACKWARD:
setAutoMode(AutoMode.BACKWARD);
break;
} }
} }
}); });
@ -2709,7 +2750,9 @@ public class DroidFish extends Activity implements GUIInterface {
final int GOTO_END_VAR = 0; final int GOTO_END_VAR = 0;
final int GOTO_NEXT_VAR = 1; final int GOTO_NEXT_VAR = 1;
final int LOAD_NEXT_GAME = 2; final int LOAD_NEXT_GAME = 2;
final int AUTO_FORWARD = 3;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>(); List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>(); List<Integer> actions = new ArrayList<Integer>();
lst.add(getString(R.string.goto_end_variation)); actions.add(GOTO_END_VAR); lst.add(getString(R.string.goto_end_variation)); actions.add(GOTO_END_VAR);
@ -2721,6 +2764,9 @@ public class DroidFish extends Activity implements GUIInterface {
if ((currFT != FT_NONE) && !gameMode.clocksActive()) { if ((currFT != FT_NONE) && !gameMode.clocksActive()) {
lst.add(getString(R.string.load_next_game)); actions.add(LOAD_NEXT_GAME); lst.add(getString(R.string.load_next_game)); actions.add(LOAD_NEXT_GAME);
} }
if (!gameMode.clocksActive()) {
lst.add(getString(R.string.auto_forward)); actions.add(AUTO_FORWARD);
}
final List<Integer> finalActions = actions; final List<Integer> finalActions = actions;
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.go_forward); builder.setTitle(R.string.go_forward);
@ -2748,6 +2794,9 @@ public class DroidFish extends Activity implements GUIInterface {
startActivityForResult(i, RESULT_LOAD_FEN); startActivityForResult(i, RESULT_LOAD_FEN);
} }
break; break;
case AUTO_FORWARD:
setAutoMode(AutoMode.FORWARD);
break;
} }
} }
}); });
@ -3089,6 +3138,7 @@ public class DroidFish extends Activity implements GUIInterface {
/** Open a load/save file dialog. Uses OI file manager if available. */ /** Open a load/save file dialog. Uses OI file manager if available. */
private void selectFile(int titleMsg, int buttonMsg, String settingsName, String defaultDir, private void selectFile(int titleMsg, int buttonMsg, String settingsName, String defaultDir,
int dialog, int result) { int dialog, int result) {
setAutoMode(AutoMode.OFF);
String action = "org.openintents.action.PICK_FILE"; String action = "org.openintents.action.PICK_FILE";
Intent i = new Intent(action); Intent i = new Intent(action);
String currentFile = settings.getString(settingsName, ""); String currentFile = settings.getString(settingsName, "");
@ -3116,6 +3166,7 @@ public class DroidFish extends Activity implements GUIInterface {
} }
private final void selectScidFile() { private final void selectScidFile() {
setAutoMode(AutoMode.OFF);
Intent intent = new Intent(); Intent intent = new Intent();
intent.setComponent(new ComponentName("org.scid.android", intent.setComponent(new ComponentName("org.scid.android",
"org.scid.android.SelectFileActivity")); "org.scid.android.SelectFileActivity"));
@ -3386,6 +3437,48 @@ public class DroidFish extends Activity implements GUIInterface {
handlerTimer.postDelayed(r, nextUpdate); handlerTimer.postDelayed(r, nextUpdate);
} }
private Handler autoModeTimer = new Handler();
private Runnable amRunnable = new Runnable() {
@Override
public void run() {
switch (autoMode) {
case BACKWARD:
ctrl.undoMove();
setAutoMode(autoMode);
break;
case FORWARD:
ctrl.redoMove();
setAutoMode(autoMode);
break;
case OFF:
break;
}
}
};
/** Set automatic move forward/backward mode. */
void setAutoMode(AutoMode am) {
// System.out.printf("%.3f DroidFish.setAutoMode(): %s\n",
// System.currentTimeMillis() * 1e-3, am.toString());
autoMode = am;
switch (am) {
case BACKWARD:
case FORWARD:
if (autoMoveDelay > 0)
autoModeTimer.postDelayed(amRunnable, autoMoveDelay);
break;
case OFF:
autoModeTimer.removeCallbacks(amRunnable);
break;
}
}
/** Disable automatic move mode if clocks are active. */
void maybeAutoModeOff(GameMode gm) {
if (gm.clocksActive())
setAutoMode(AutoMode.OFF);
}
/** PngTokenReceiver implementation that renders PGN data for screen display. */ /** PngTokenReceiver implementation that renders PGN data for screen display. */
static class PgnScreenText implements PgnToken.PgnTokenReceiver { static class PgnScreenText implements PgnToken.PgnTokenReceiver {
private SpannableStringBuilder sb = new SpannableStringBuilder(); private SpannableStringBuilder sb = new SpannableStringBuilder();
@ -3397,6 +3490,7 @@ public class DroidFish extends Activity implements GUIInterface {
int currPos = 0, endPos = 0; int currPos = 0, endPos = 0;
boolean upToDate = false; boolean upToDate = false;
PGNOptions options; PGNOptions options;
DroidFish df;
private static class NodeInfo { private static class NodeInfo {
int l0, l1; int l0, l1;
@ -3407,7 +3501,8 @@ public class DroidFish extends Activity implements GUIInterface {
} }
HashMap<Node, NodeInfo> nodeToCharPos; HashMap<Node, NodeInfo> nodeToCharPos;
PgnScreenText(PGNOptions options) { PgnScreenText(DroidFish df, PGNOptions options) {
this.df = df;
nodeToCharPos = new HashMap<Node, NodeInfo>(); nodeToCharPos = new HashMap<Node, NodeInfo>();
this.options = options; this.options = options;
} }
@ -3452,7 +3547,7 @@ public class DroidFish extends Activity implements GUIInterface {
boolean pendingNewLine = false; boolean pendingNewLine = false;
/** Makes moves in the move list clickable. */ /** Makes moves in the move list clickable. */
private final static class MoveLink extends ClickableSpan { private final class MoveLink extends ClickableSpan {
private Node node; private Node node;
MoveLink(Node n) { MoveLink(Node n) {
node = n; node = n;
@ -3464,8 +3559,10 @@ public class DroidFish extends Activity implements GUIInterface {
// even when you long click the move list. The test // even when you long click the move list. The test
// below works around the problem. // below works around the problem.
Dialog mlmd = moveListMenuDlg; Dialog mlmd = moveListMenuDlg;
if ((mlmd == null) || !mlmd.isShowing()) if ((mlmd == null) || !mlmd.isShowing()) {
df.setAutoMode(AutoMode.OFF);
ctrl.goNode(node); ctrl.goNode(node);
}
} }
} }
@Override @Override