mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-21 13:12:17 +01:00
DroidFish: UI improvements from Aaro Korhonen.
- All the menu items are now using standard Android system icons. - Removed the edit.png & start.png files as they're now obsolete. - Dialogs are now using standard Ok / Cancel buttons. - EditText views (in dialogs, 'Goto move' for instance) are now using standard Android background. - The dialog for selecting the game mode now has a title. - The dialog for selecting the player to move now uses radio boxes instead of buttons for a logical consistency. - The dialog for selecting the en passant file now closes itself after an item has been chosen. - The custom title bar (for clocks etc.) now uses the system style 'windowTitleStyle' for a visual consistency with non-custom titles. - The header and comment editors are now wrapped in a ScrollView to provide landscape support.
This commit is contained in:
@@ -1081,43 +1081,41 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
return alert;
|
||||
}
|
||||
case SELECT_MOVE_DIALOG: {
|
||||
final Dialog dialog = new Dialog(this);
|
||||
dialog.setContentView(R.layout.select_move_number);
|
||||
dialog.setTitle(R.string.goto_move);
|
||||
final EditText moveNrView = (EditText)dialog.findViewById(R.id.selmove_number);
|
||||
Button ok = (Button)dialog.findViewById(R.id.selmove_ok);
|
||||
Button cancel = (Button)dialog.findViewById(R.id.selmove_cancel);
|
||||
View content = View.inflate(this, R.layout.select_move_number, null);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setView(content);
|
||||
builder.setTitle(R.string.goto_move);
|
||||
final EditText moveNrView = (EditText)content.findViewById(R.id.selmove_number);
|
||||
moveNrView.setText("1");
|
||||
final Runnable gotoMove = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
int moveNr = Integer.parseInt(moveNrView.getText().toString());
|
||||
ctrl.gotoMove(moveNr);
|
||||
dialog.cancel();
|
||||
} catch (NumberFormatException nfe) {
|
||||
Toast.makeText(getApplicationContext(), R.string.invalid_number_format, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
builder.setPositiveButton("Ok", new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
gotoMove.run();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
|
||||
moveNrView.setOnKeyListener(new OnKeyListener() {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
|
||||
gotoMove.run();
|
||||
dialog.cancel();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
ok.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
gotoMove.run();
|
||||
}
|
||||
});
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
case SELECT_BOOK_DIALOG: {
|
||||
@@ -1300,6 +1298,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
getString(R.string.comp_vs_comp)
|
||||
};
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.select_game_mode);
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
int gameModeType = -1;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.petero.droidfish;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
@@ -13,7 +15,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnKeyListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
@@ -86,8 +87,9 @@ public class SeekBarPreference extends Preference
|
||||
currValBox.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Dialog dialog = new Dialog(getContext());
|
||||
dialog.setContentView(R.layout.select_percentage);
|
||||
View content = View.inflate(SeekBarPreference.this.getContext(), R.layout.select_percentage, null);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(SeekBarPreference.this.getContext());
|
||||
builder.setView(content);
|
||||
String title = "";
|
||||
String key = getKey();
|
||||
if (key.equals("strength")) {
|
||||
@@ -95,10 +97,8 @@ public class SeekBarPreference extends Preference
|
||||
} else if (key.equals("bookRandom")) {
|
||||
title = getContext().getString(R.string.edit_randomization);
|
||||
}
|
||||
dialog.setTitle(title);
|
||||
final EditText valueView = (EditText)dialog.findViewById(R.id.selpercentage_number);
|
||||
Button ok = (Button)dialog.findViewById(R.id.selpercentage_ok);
|
||||
Button cancel = (Button)dialog.findViewById(R.id.selpercentage_cancel);
|
||||
builder.setTitle(title);
|
||||
final EditText valueView = (EditText)content.findViewById(R.id.selpercentage_number);
|
||||
valueView.setText(currValBox.getText().toString().replaceAll("%", ""));
|
||||
final Runnable selectValue = new Runnable() {
|
||||
public void run() {
|
||||
@@ -107,7 +107,6 @@ public class SeekBarPreference extends Preference
|
||||
int value = (int)(Double.parseDouble(txt) * 10 + 0.5);
|
||||
if (value < 0) value = 0;
|
||||
if (value > maxValue) value = maxValue;
|
||||
dialog.cancel();
|
||||
onProgressChanged(bar, value, false);
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
@@ -122,18 +121,14 @@ public class SeekBarPreference extends Preference
|
||||
return false;
|
||||
}
|
||||
});
|
||||
ok.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
selectValue.run();
|
||||
}
|
||||
});
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
builder.setPositiveButton("Ok", new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
selectValue.run();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
|
||||
dialog.show();
|
||||
builder.create().show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -307,21 +307,21 @@ public class EditBoard extends Activity {
|
||||
}
|
||||
case SIDE_DIALOG: {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(R.string.select_side_to_move_first)
|
||||
.setPositiveButton(R.string.white, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
cb.pos.setWhiteMove(true);
|
||||
checkValid();
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.black, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
cb.pos.setWhiteMove(false);
|
||||
checkValid();
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
builder.setTitle(R.string.select_side_to_move_first);
|
||||
final int selectedItem = (cb.pos.whiteMove) ? 0 : 1;
|
||||
builder.setSingleChoiceItems(new String[]{getString(R.string.white), getString(R.string.black)}, selectedItem, new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
if (id == 0) { // white to move
|
||||
cb.pos.setWhiteMove(true);
|
||||
checkValid();
|
||||
dialog.cancel();
|
||||
} else {
|
||||
cb.pos.setWhiteMove(false);
|
||||
checkValid();
|
||||
dialog.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
return alert;
|
||||
}
|
||||
@@ -372,19 +372,20 @@ public class EditBoard extends Activity {
|
||||
builder.setSingleChoiceItems(items, getEPFile(), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
setEPFile(item);
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
return alert;
|
||||
}
|
||||
case MOVCNT_DIALOG: {
|
||||
final Dialog dialog = new Dialog(this);
|
||||
dialog.setContentView(R.layout.edit_move_counters);
|
||||
dialog.setTitle(R.string.edit_move_counters);
|
||||
final EditText halfMoveClock = (EditText)dialog.findViewById(R.id.ed_cnt_halfmove);
|
||||
final EditText fullMoveCounter = (EditText)dialog.findViewById(R.id.ed_cnt_fullmove);
|
||||
Button ok = (Button)dialog.findViewById(R.id.ed_cnt_ok);
|
||||
Button cancel = (Button)dialog.findViewById(R.id.ed_cnt_cancel);
|
||||
View content = View.inflate(this, R.layout.edit_move_counters, null);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
builder.setView(content);
|
||||
builder.setTitle(R.string.edit_move_counters);
|
||||
final EditText halfMoveClock = (EditText)content.findViewById(R.id.ed_cnt_halfmove);
|
||||
final EditText fullMoveCounter = (EditText)content.findViewById(R.id.ed_cnt_fullmove);
|
||||
halfMoveClock.setText(String.format("%d", cb.pos.halfMoveClock));
|
||||
fullMoveCounter.setText(String.format("%d", cb.pos.fullMoveCounter));
|
||||
final Runnable setCounters = new Runnable() {
|
||||
@@ -394,31 +395,30 @@ public class EditBoard extends Activity {
|
||||
int fullCount = Integer.parseInt(fullMoveCounter.getText().toString());
|
||||
cb.pos.halfMoveClock = halfClock;
|
||||
cb.pos.fullMoveCounter = fullCount;
|
||||
dialog.cancel();
|
||||
} catch (NumberFormatException nfe) {
|
||||
Toast.makeText(getApplicationContext(), R.string.invalid_number_format, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
builder.setPositiveButton("Ok", new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
setCounters.run();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
|
||||
final Dialog dialog = builder.create();
|
||||
|
||||
fullMoveCounter.setOnKeyListener(new OnKeyListener() {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
|
||||
setCounters.run();
|
||||
dialog.cancel();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
ok.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
setCounters.run();
|
||||
}
|
||||
});
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user