diff --git a/DroidFish/res/drawable/edit.png b/DroidFish/res/drawable/edit.png deleted file mode 100644 index 6abfeaf..0000000 Binary files a/DroidFish/res/drawable/edit.png and /dev/null differ diff --git a/DroidFish/res/drawable/start.png b/DroidFish/res/drawable/start.png deleted file mode 100644 index 9a9f661..0000000 Binary files a/DroidFish/res/drawable/start.png and /dev/null differ diff --git a/DroidFish/res/layout/edit_comments.xml b/DroidFish/res/layout/edit_comments.xml index 26f26d2..f3ed5aa 100644 --- a/DroidFish/res/layout/edit_comments.xml +++ b/DroidFish/res/layout/edit_comments.xml @@ -1,6 +1,10 @@ + + @@ -8,16 +12,17 @@ + android:stretchColumns="1" + android:padding="10dp"> - android:layout_weight="1" - + - + android:minEms="3" + android:inputType="text" + android:enabled="false"> + + \ No newline at end of file diff --git a/DroidFish/res/layout/edit_headers.xml b/DroidFish/res/layout/edit_headers.xml index 1b53da6..49fc2db 100644 --- a/DroidFish/res/layout/edit_headers.xml +++ b/DroidFish/res/layout/edit_headers.xml @@ -1,14 +1,19 @@ + + - + android:stretchColumns="1" + android:padding="10dp"> + android:text="Round" + android:paddingRight="10dp"> + diff --git a/DroidFish/res/layout/edit_move_counters.xml b/DroidFish/res/layout/edit_move_counters.xml index 85d181e..bb8d6f6 100644 --- a/DroidFish/res/layout/edit_move_counters.xml +++ b/DroidFish/res/layout/edit_move_counters.xml @@ -1,62 +1,46 @@ - - + + + + - - + + + + - - - - - - + + \ No newline at end of file diff --git a/DroidFish/res/layout/select_move_number.xml b/DroidFish/res/layout/select_move_number.xml index 3a994de..897b4ee 100644 --- a/DroidFish/res/layout/select_move_number.xml +++ b/DroidFish/res/layout/select_move_number.xml @@ -1,44 +1,24 @@ - - - - - - - - - - - + android:layout_height="wrap_content" + android:orientation="horizontal" + android:padding="10dp"> + + + + + + + + \ No newline at end of file diff --git a/DroidFish/res/layout/select_percentage.xml b/DroidFish/res/layout/select_percentage.xml index 9ec2c55..0fa7f6e 100644 --- a/DroidFish/res/layout/select_percentage.xml +++ b/DroidFish/res/layout/select_percentage.xml @@ -1,44 +1,20 @@ - - - - - - - - - - + android:layout_height="wrap_content" + android:padding="10dp"> + + + + diff --git a/DroidFish/res/layout/title.xml b/DroidFish/res/layout/title.xml index e0a4809..40af70a 100644 --- a/DroidFish/res/layout/title.xml +++ b/DroidFish/res/layout/title.xml @@ -2,27 +2,28 @@ + android:layout_height="wrap_content" + android:layout_gravity="center_vertical"> diff --git a/DroidFish/res/menu/options_menu.xml b/DroidFish/res/menu/options_menu.xml index 92afba6..c66e536 100644 --- a/DroidFish/res/menu/options_menu.xml +++ b/DroidFish/res/menu/options_menu.xml @@ -4,7 +4,7 @@ + android:icon="@android:drawable/ic_menu_add"> + android:icon="@android:drawable/ic_menu_edit"> No files found in directory DroidFish/pgn on the SD card No files found in directory scid on the SD card Select Color Theme + Select Game Mode Edit/re-play Game Analysis Mode Play White diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index c9e2853..589e1a9 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -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; diff --git a/DroidFish/src/org/petero/droidfish/SeekBarPreference.java b/DroidFish/src/org/petero/droidfish/SeekBarPreference.java index 8f61fa3..a36d86c 100644 --- a/DroidFish/src/org/petero/droidfish/SeekBarPreference.java +++ b/DroidFish/src/org/petero/droidfish/SeekBarPreference.java @@ -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(); } }); diff --git a/DroidFish/src/org/petero/droidfish/activities/EditBoard.java b/DroidFish/src/org/petero/droidfish/activities/EditBoard.java index db712c2..cb83ccb 100644 --- a/DroidFish/src/org/petero/droidfish/activities/EditBoard.java +++ b/DroidFish/src/org/petero/droidfish/activities/EditBoard.java @@ -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; } }