diff --git a/DroidFish/res/raw/open_last_file.svg b/DroidFish/res/raw/open_last_file.svg new file mode 100644 index 0000000..93a968b --- /dev/null +++ b/DroidFish/res/raw/open_last_file.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index f993e99..f8c1d2c 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -35,6 +35,7 @@ you are not actively using the program.\ Paste from Clipboard Share Share PGN game + Load from last file Load game from PGN file Load game from Scid file Save game to PGN file @@ -615,7 +616,8 @@ you are not actively using the program.\ @string/toggle_pgn_headers @string/toggle_large_buttons @string/toggle_blind_mode - + @string/load_last_file + flipboard @@ -627,5 +629,6 @@ you are not actively using the program.\ viewHeaders largeButtons blindMode + loadLastFile diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index a92f9ad..cf356bb 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -335,6 +335,15 @@ public class DroidFish extends Activity implements GUIInterface { cb.setBlindMode(blindMode); } }); + addAction(new UIAction() { + public String getId() { return "loadLastFile"; } + public int getName() { return R.string.load_last_file; } + public int getIcon() { return R.raw.open_last_file; } + public boolean enabled() { return currFileType() != FT_NONE; } + public void run() { + loadLastFile(); + } + }); } @Override @@ -1828,12 +1837,16 @@ public class DroidFish extends Activity implements GUIInterface { } private final Dialog fileMenuDialog() { - final int LOAD_GAME = 0; - final int SAVE_GAME = 1; - final int LOAD_SCID_GAME = 2; + final int LOAD_LAST_FILE = 0; + final int LOAD_GAME = 1; + final int SAVE_GAME = 2; + final int LOAD_SCID_GAME = 3; List lst = new ArrayList(); List actions = new ArrayList(); + if (currFileType() != FT_NONE) { + lst.add(getString(R.string.load_last_file)); actions.add(LOAD_LAST_FILE); + } lst.add(getString(R.string.load_game)); actions.add(LOAD_GAME); lst.add(getString(R.string.save_game)); actions.add(SAVE_GAME); if (hasScidProvider()) { @@ -1844,7 +1857,13 @@ public class DroidFish extends Activity implements GUIInterface { builder.setTitle(R.string.load_save_menu); builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { + String path = currPathName(); + if (path.length() == 0) + return; switch (finalActions.get(item)) { + case LOAD_LAST_FILE: + loadLastFile(); + break; case LOAD_GAME: selectPgnFile(false); break; @@ -1861,6 +1880,26 @@ public class DroidFish extends Activity implements GUIInterface { return alert; } + /** Open dialog to select a game/position from the last used file. */ + final private void loadLastFile() { + String path = currPathName(); + if (path.length() == 0) + return; + switch (currFileType()) { + case FT_PGN: + loadPGNFromFile(path); + break; + case FT_SCID: { + Intent data = new Intent(path); + onActivityResult(RESULT_SELECT_SCID, RESULT_OK, data); + break; + } + case FT_FEN: + loadFENFromFile(path); + break; + } + } + private final Dialog aboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); String title = getString(R.string.app_name);