mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-14 18:02:43 +01:00
DroidFish: Split the DroidFish.onCreateDialog function into one function per dialog type.
This commit is contained in:
@@ -1483,7 +1483,59 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case NEW_GAME_DIALOG: {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Dialog newGameDialog() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.option_new_game);
|
builder.setTitle(R.string.option_new_game);
|
||||||
builder.setMessage(R.string.start_new_game);
|
builder.setMessage(R.string.start_new_game);
|
||||||
@@ -1507,7 +1559,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
case PROMOTE_DIALOG: {
|
|
||||||
|
private final Dialog promoteDialog() {
|
||||||
final CharSequence[] items = {
|
final CharSequence[] items = {
|
||||||
getString(R.string.queen), getString(R.string.rook),
|
getString(R.string.queen), getString(R.string.rook),
|
||||||
getString(R.string.bishop), getString(R.string.knight)
|
getString(R.string.bishop), getString(R.string.knight)
|
||||||
@@ -1522,7 +1575,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case BOARD_MENU_DIALOG: {
|
|
||||||
|
private final Dialog boardMenuDialog() {
|
||||||
final int COPY_GAME = 0;
|
final int COPY_GAME = 0;
|
||||||
final int COPY_POSITION = 1;
|
final int COPY_POSITION = 1;
|
||||||
final int PASTE = 2;
|
final int PASTE = 2;
|
||||||
@@ -1592,7 +1646,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case FILE_MENU_DIALOG: {
|
|
||||||
|
private final Dialog fileMenuDialog() {
|
||||||
final int LOAD_GAME = 0;
|
final int LOAD_GAME = 0;
|
||||||
final int SAVE_GAME = 1;
|
final int SAVE_GAME = 1;
|
||||||
final int LOAD_SCID_GAME = 2;
|
final int LOAD_SCID_GAME = 2;
|
||||||
@@ -1625,7 +1680,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case ABOUT_DIALOG: {
|
|
||||||
|
private final Dialog aboutDialog() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
String title = getString(R.string.app_name);
|
String title = getString(R.string.app_name);
|
||||||
WebView wv = new WebView(this);
|
WebView wv = new WebView(this);
|
||||||
@@ -1656,7 +1712,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case SELECT_MOVE_DIALOG: {
|
|
||||||
|
private final Dialog selectMoveDialog() {
|
||||||
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);
|
||||||
@@ -1694,7 +1751,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
});
|
});
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
case SELECT_BOOK_DIALOG: {
|
|
||||||
|
private final Dialog selectBookDialog() {
|
||||||
String[] fileNames = findFilesInDirectory(bookDir, new FileNameFilter() {
|
String[] fileNames = findFilesInDirectory(bookDir, new FileNameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(String filename) {
|
public boolean accept(String filename) {
|
||||||
@@ -1736,7 +1794,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case SELECT_ENGINE_DIALOG: {
|
|
||||||
|
private final Dialog selectEngineDialog() {
|
||||||
String[] fileNames = findFilesInDirectory(engineDir, new FileNameFilter() {
|
String[] fileNames = findFilesInDirectory(engineDir, new FileNameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(String filename) {
|
public boolean accept(String filename) {
|
||||||
@@ -1787,7 +1846,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case SELECT_PGN_FILE_DIALOG: {
|
|
||||||
|
private final Dialog selectPgnFileDialog() {
|
||||||
final String[] fileNames = findFilesInDirectory(pgnDir, null);
|
final String[] fileNames = findFilesInDirectory(pgnDir, null);
|
||||||
final int numFiles = fileNames.length;
|
final int numFiles = fileNames.length;
|
||||||
if (numFiles == 0) {
|
if (numFiles == 0) {
|
||||||
@@ -1819,7 +1879,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case SELECT_PGN_FILE_SAVE_DIALOG: {
|
|
||||||
|
private final Dialog selectPgnFileSaveDialog() {
|
||||||
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;
|
||||||
@@ -1856,7 +1917,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case SELECT_PGN_SAVE_NEWFILE_DIALOG: {
|
|
||||||
|
private final Dialog selectPgnSaveNewFileDialog() {
|
||||||
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);
|
||||||
@@ -1894,7 +1956,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SET_COLOR_THEME_DIALOG: {
|
private final Dialog setColorThemeDialog() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.select_color_theme);
|
builder.setTitle(R.string.select_color_theme);
|
||||||
builder.setSingleChoiceItems(ColorTheme.themeNames, -1, new DialogInterface.OnClickListener() {
|
builder.setSingleChoiceItems(ColorTheme.themeNames, -1, new DialogInterface.OnClickListener() {
|
||||||
@@ -1908,7 +1970,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
case GAME_MODE_DIALOG: {
|
|
||||||
|
private final Dialog gameModeDialog() {
|
||||||
final CharSequence[] items = {
|
final CharSequence[] items = {
|
||||||
getString(R.string.analysis_mode),
|
getString(R.string.analysis_mode),
|
||||||
getString(R.string.edit_replay_game),
|
getString(R.string.edit_replay_game),
|
||||||
@@ -1948,7 +2011,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case MOVELIST_MENU_DIALOG: {
|
|
||||||
|
private final Dialog moveListMenuDialog() {
|
||||||
final int EDIT_HEADERS = 0;
|
final int EDIT_HEADERS = 0;
|
||||||
final int EDIT_COMMENTS = 1;
|
final int EDIT_COMMENTS = 1;
|
||||||
final int REMOVE_SUBTREE = 2;
|
final int REMOVE_SUBTREE = 2;
|
||||||
@@ -2080,7 +2144,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case THINKING_MENU_DIALOG: {
|
|
||||||
|
private final Dialog thinkingMenuDialog() {
|
||||||
final int ADD_ANALYSIS = 0;
|
final int ADD_ANALYSIS = 0;
|
||||||
final int MULTIPV_DEC = 1;
|
final int MULTIPV_DEC = 1;
|
||||||
final int MULTIPV_INC = 2;
|
final int MULTIPV_INC = 2;
|
||||||
@@ -2154,7 +2219,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case GO_BACK_MENU_DIALOG: {
|
|
||||||
|
private final Dialog goBackMenuDialog() {
|
||||||
final int GOTO_START_GAME = 0;
|
final int GOTO_START_GAME = 0;
|
||||||
final int GOTO_START_VAR = 1;
|
final int GOTO_START_VAR = 1;
|
||||||
final int GOTO_PREV_VAR = 2;
|
final int GOTO_PREV_VAR = 2;
|
||||||
@@ -2200,7 +2266,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
case GO_FORWARD_MENU_DIALOG: {
|
|
||||||
|
private final Dialog goForwardMenuDialog() {
|
||||||
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;
|
||||||
@@ -2243,23 +2310,6 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static boolean internalEngine(String name) {
|
private final static boolean internalEngine(String name) {
|
||||||
return "cuckoochess".equals(name) ||
|
return "cuckoochess".equals(name) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user