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:
Peter Osterlund 2011-11-27 01:24:52 +00:00
parent c8b0b8a1d3
commit e8d1ef5dd6
13 changed files with 157 additions and 214 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
@ -8,16 +12,17 @@
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
android:stretchColumns="1"
android:padding="10dp">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:text="Before">
</TextView>
<EditText
android:id="@+id/ed_comments_pre"
android:background="@android:drawable/editbox_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -30,25 +35,26 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Move">
</TextView>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_weight="1"
<TextView
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/ed_comments_move"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:inputType="text">
</TextView>
android:minEms="3"
android:inputType="text"
android:enabled="false">
</EditText>
<EditText
android:id="@+id/ed_comments_nag"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
@ -66,7 +72,6 @@
</TextView>
<EditText
android:id="@+id/ed_comments_post"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -97,3 +102,4 @@
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
android:stretchColumns="1"
android:padding="10dp">
<TableRow>
<TextView
android:layout_width="wrap_content"
@ -17,7 +22,6 @@
</TextView>
<EditText
android:id="@+id/ed_header_event"
android:background="@android:drawable/editbox_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -32,7 +36,6 @@
</TextView>
<EditText
android:id="@+id/ed_header_site"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -47,7 +50,6 @@
</TextView>
<EditText
android:id="@+id/ed_header_date"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -58,11 +60,11 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Round">
android:text="Round"
android:paddingRight="10dp">
</TextView>
<EditText
android:id="@+id/ed_header_round"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -77,7 +79,6 @@
</TextView>
<EditText
android:id="@+id/ed_header_white"
android:background="@android:drawable/editbox_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -92,7 +93,6 @@
</TextView>
<EditText
android:id="@+id/ed_header_black"
android:background="@android:drawable/editbox_background"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
@ -122,3 +122,4 @@
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,62 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:padding="10dp">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:text="Halfmove clock">
</TextView>
<EditText
android:id="@+id/ed_cnt_halfmove"
android:background="@android:drawable/editbox_background"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:minEms="3"
android:inputType="number">
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="fill_parent"
android:paddingRight="10dp"
android:text="Fullmove counter">
</TextView>
<EditText
android:id="@+id/ed_cnt_fullmove"
android:background="@android:drawable/editbox_background"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:minEms="3"
android:inputType="number">
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/ed_cnt_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel">
</Button>
<Button
android:id="@+id/ed_cnt_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ok">
</Button>
</LinearLayout>
</LinearLayout>
</TableRow>
</TableLayout>

View File

@ -1,44 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:text="Move number">
</TextView>
<EditText
android:id="@+id/selmove_number"
android:background="@android:drawable/editbox_background"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:inputType="number">
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/selmove_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel">
</Button>
<Button
android:id="@+id/selmove_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ok">
</Button>
</LinearLayout>
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Move number"
android:paddingRight="10dp">
</TextView>
<EditText
android:id="@+id/selmove_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="3"
android:inputType="number">
</EditText>
</LinearLayout>

View File

@ -1,44 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:text="Value (%)">
</TextView>
<EditText
android:id="@+id/selpercentage_number"
android:background="@android:drawable/editbox_background"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:inputType="numberDecimal">
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/selpercentage_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel">
</Button>
<Button
android:id="@+id/selpercentage_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ok">
</Button>
</LinearLayout>
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Value (%)"
android:paddingRight="10dp">
</TextView>
<EditText
android:id="@+id/selpercentage_number"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:inputType="numberDecimal">
</EditText>
</LinearLayout>

View File

@ -2,27 +2,28 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
style="?android:attr/windowTitleStyle"
android:id="@+id/white_clock"
android:text="White: 0:00"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
</TextView>
<TextView
style="?android:attr/windowTitleStyle"
android:id="@+id/title_text"
android:text="@string/app_name"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
</TextView>
<TextView
style="?android:attr/windowTitleStyle"
android:id="@+id/black_clock"
android:text="Black: 0:00"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">

View File

@ -4,7 +4,7 @@
<item
android:id="@+id/item_new_game"
android:title="New Game"
android:icon="@drawable/start">
android:icon="@android:drawable/ic_menu_add">
</item>
<item
android:id="@+id/item_file_menu"
@ -19,7 +19,7 @@
<item
android:id="@+id/item_editboard"
android:title="Edit Board"
android:icon="@drawable/edit">
android:icon="@android:drawable/ic_menu_edit">
</item>
<item
android:id="@+id/item_settings"

View File

@ -297,6 +297,7 @@ you are not actively using the program.\
<string name="no_pgn_files">No files found in directory DroidFish/pgn on the SD card</string>
<string name="no_scid_files">No files found in directory scid on the SD card</string>
<string name="select_color_theme">Select Color Theme</string>
<string name="select_game_mode">Select Game Mode</string>
<string name="edit_replay_game">Edit/re-play Game</string>
<string name="analysis_mode">Analysis Mode</string>
<string name="play_white">Play White</string>

View File

@ -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;

View File

@ -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();
}
});

View File

@ -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;
}
}