From 447e8de9c70ed8c5ab12cc8b75398f64a77f41e5 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sat, 1 Sep 2012 21:15:48 +0000 Subject: [PATCH] DroidFish: Cosmetic changes. --- .../src/org/petero/droidfish/DroidFish.java | 140 ++++++++---------- 1 file changed, 58 insertions(+), 82 deletions(-) diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index 4ab0f27..9bec589 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -1483,54 +1483,30 @@ public class DroidFish extends Activity implements GUIInterface { @Override protected Dialog onCreateDialog(int id) { switch (id) { - case NEW_GAME_DIALOG: - return newGameDialog(); - case PROMOTE_DIALOG: - return promoteDialog(); - case BOARD_MENU_DIALOG: - return boardMenuDialog(); - case FILE_MENU_DIALOG: - return fileMenuDialog(); - case ABOUT_DIALOG: - return aboutDialog(); - case SELECT_MOVE_DIALOG: - return selectMoveDialog(); - case SELECT_BOOK_DIALOG: - return selectBookDialog(); - case SELECT_ENGINE_DIALOG: - return selectEngineDialog(); - case SELECT_PGN_FILE_DIALOG: - return selectPgnFileDialog(); - case SELECT_PGN_FILE_SAVE_DIALOG: - return selectPgnFileSaveDialog(); - case SELECT_PGN_SAVE_NEWFILE_DIALOG: - return selectPgnSaveNewFileDialog(); - case SET_COLOR_THEME_DIALOG: - return setColorThemeDialog(); - case GAME_MODE_DIALOG: - return gameModeDialog(); - case MOVELIST_MENU_DIALOG: - return moveListMenuDialog(); - case THINKING_MENU_DIALOG: - return thinkingMenuDialog(); - case GO_BACK_MENU_DIALOG: - return goBackMenuDialog(); - case GO_FORWARD_MENU_DIALOG: - return goForwardMenuDialog(); - case CUSTOM1_BUTTON_DIALOG: - return makeButtonDialog(custom1ButtonActions); - case CUSTOM2_BUTTON_DIALOG: - return makeButtonDialog(custom2ButtonActions); - case CUSTOM3_BUTTON_DIALOG: - return makeButtonDialog(custom3ButtonActions); - case MANAGE_ENGINES_DIALOG: - return manageEnginesDialog(); - case NETWORK_ENGINE_DIALOG: - return networkEngineDialog(); - case NEW_NETWORK_ENGINE_DIALOG: - return newNetworkEngineDialog(); - case NETWORK_ENGINE_CONFIG_DIALOG: - return networkEngineConfigDialog(); + case NEW_GAME_DIALOG: return newGameDialog(); + case PROMOTE_DIALOG: return promoteDialog(); + case BOARD_MENU_DIALOG: return boardMenuDialog(); + case FILE_MENU_DIALOG: return fileMenuDialog(); + case ABOUT_DIALOG: return aboutDialog(); + case SELECT_MOVE_DIALOG: return selectMoveDialog(); + case SELECT_BOOK_DIALOG: return selectBookDialog(); + case SELECT_ENGINE_DIALOG: return selectEngineDialog(); + case SELECT_PGN_FILE_DIALOG: return selectPgnFileDialog(); + case SELECT_PGN_FILE_SAVE_DIALOG: return selectPgnFileSaveDialog(); + case SELECT_PGN_SAVE_NEWFILE_DIALOG: return selectPgnSaveNewFileDialog(); + case SET_COLOR_THEME_DIALOG: return setColorThemeDialog(); + case GAME_MODE_DIALOG: return gameModeDialog(); + case MOVELIST_MENU_DIALOG: return moveListMenuDialog(); + case THINKING_MENU_DIALOG: return thinkingMenuDialog(); + case GO_BACK_MENU_DIALOG: return goBackMenuDialog(); + case GO_FORWARD_MENU_DIALOG: return goForwardMenuDialog(); + case CUSTOM1_BUTTON_DIALOG: return makeButtonDialog(custom1ButtonActions); + case CUSTOM2_BUTTON_DIALOG: return makeButtonDialog(custom2ButtonActions); + case CUSTOM3_BUTTON_DIALOG: return makeButtonDialog(custom3ButtonActions); + case MANAGE_ENGINES_DIALOG: return manageEnginesDialog(); + case NETWORK_ENGINE_DIALOG: return networkEngineDialog(); + case NEW_NETWORK_ENGINE_DIALOG: return newNetworkEngineDialog(); + case NETWORK_ENGINE_CONFIG_DIALOG: return networkEngineConfigDialog(); } return null; } @@ -1647,6 +1623,14 @@ public class DroidFish extends Activity implements GUIInterface { return alert; } + private final void shareGame() { + Intent i = new Intent(Intent.ACTION_SEND); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + i.setType("text/plain"); + i.putExtra(Intent.EXTRA_TEXT, ctrl.getPGN()); + startActivity(Intent.createChooser(i, getString(R.string.share_pgn_game))); + } + private final Dialog fileMenuDialog() { final int LOAD_GAME = 0; final int SAVE_GAME = 1; @@ -1795,6 +1779,11 @@ public class DroidFish extends Activity implements GUIInterface { return alert; } + private final static boolean internalEngine(String name) { + return "cuckoochess".equals(name) || + "stockfish".equals(name); + } + private final Dialog selectEngineDialog() { String[] fileNames = findFilesInDirectory(engineDir, new FileNameFilter() { @Override @@ -2311,9 +2300,27 @@ public class DroidFish extends Activity implements GUIInterface { return alert; } - private final static boolean internalEngine(String name) { - return "cuckoochess".equals(name) || - "stockfish".equals(name); + private Dialog makeButtonDialog(ButtonActions buttonActions) { + List names = new ArrayList(); + final List actions = new ArrayList(); + + HashSet used = new HashSet(); + for (UIAction a : buttonActions.getMenuActions()) { + if ((a != null) && a.enabled() && !used.contains(a.getId())) { + names.add(getString(a.getName())); + actions.add(a); + used.add(a.getId()); + } + } + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(buttonActions.getMenuTitle()); + builder.setItems(names.toArray(new CharSequence[names.size()]), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int item) { + UIAction a = actions.get(item); + a.run(); + } + }); + return builder.create(); } private final Dialog manageEnginesDialog() { @@ -2522,37 +2529,6 @@ public class DroidFish extends Activity implements GUIInterface { return dialog; } - private final void shareGame() { - Intent i = new Intent(Intent.ACTION_SEND); - i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); - i.setType("text/plain"); - i.putExtra(Intent.EXTRA_TEXT, ctrl.getPGN()); - startActivity(Intent.createChooser(i, getString(R.string.share_pgn_game))); - } - - private Dialog makeButtonDialog(ButtonActions buttonActions) { - List names = new ArrayList(); - final List actions = new ArrayList(); - - HashSet used = new HashSet(); - for (UIAction a : buttonActions.getMenuActions()) { - if ((a != null) && a.enabled() && !used.contains(a.getId())) { - names.add(getString(a.getName())); - actions.add(a); - used.add(a.getId()); - } - } - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(buttonActions.getMenuTitle()); - builder.setItems(names.toArray(new CharSequence[names.size()]), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int item) { - UIAction a = actions.get(item); - a.run(); - } - }); - return builder.create(); - } - /** Open a load/save file dialog. Uses OI file manager if available. */ private void selectPgnFile(boolean save) { String action = "org.openintents.action.PICK_FILE";