From e8d1ef5dd61104a129e495f850d45674f9174444 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sun, 27 Nov 2011 01:24:52 +0000 Subject: [PATCH] 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. --- DroidFish/res/drawable/edit.png | Bin 2277 -> 0 bytes DroidFish/res/drawable/start.png | Bin 2198 -> 0 bytes DroidFish/res/layout/edit_comments.xml | 30 ++++---- DroidFish/res/layout/edit_headers.xml | 25 +++---- DroidFish/res/layout/edit_move_counters.xml | 58 ++++++--------- DroidFish/res/layout/select_move_number.xml | 60 ++++++---------- DroidFish/res/layout/select_percentage.xml | 54 ++++---------- DroidFish/res/layout/title.xml | 9 +-- DroidFish/res/menu/options_menu.xml | 4 +- DroidFish/res/values/strings.xml | 1 + .../src/org/petero/droidfish/DroidFish.java | 33 +++++---- .../petero/droidfish/SeekBarPreference.java | 31 ++++---- .../droidfish/activities/EditBoard.java | 66 +++++++++--------- 13 files changed, 157 insertions(+), 214 deletions(-) delete mode 100644 DroidFish/res/drawable/edit.png delete mode 100644 DroidFish/res/drawable/start.png diff --git a/DroidFish/res/drawable/edit.png b/DroidFish/res/drawable/edit.png deleted file mode 100644 index 6abfeafdc46a672a136beed09416ed6189cea4a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2277 zcmV500004b3#c}2nYxW zd8LbI|0MIsgCw6LdvbbU}4=Xm4@=PHAIx zAVPIxb!=s6_2==V000OqNkl{K zdyBl{u>dw`mo3&ja}^u5_aWMySZ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(+S=ae zsA#Xsi3X_vxUn`SI38fSj6%{A;@8AEB;cXxJnt}QGqG>x~N(5BSXRH?hWyVPp4(w3H%3Cr^2$&;-Xi)Eco z*ZzQIM=ncNtF`AvAftY!&aST4YHr>%d3$?fadb4Bl#~>)WXY0$kV!As2{7l+pSK$f zhOhK`eNRzQ(HD~g=jG*5nM}s8EC-(FohFm%#!N5(P*zqpWVKp{$F>8OVX=1Y+Et~c zr4!DrDHFK0we@6kbMv+7g6_`Fel;gBnu3CY z-%csSY=Y$G=DzV=AzaZ}Um<=-ne|QYhm`*U+Ig#mc@D{700000NkvXXu0mjf(Jncn diff --git a/DroidFish/res/drawable/start.png b/DroidFish/res/drawable/start.png deleted file mode 100644 index 9a9f6618fdc1cd6c40355d8a4520705aee19a86e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2198 zcmV;H2x<3;P)500004b3#c}2nYxW zdn4`v3p{8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H101wmIosc54`b!cwmM2 zQ6)qL1qlhQKo)96;H|V36j7H}Ej3M=*p7eJvG>>O-PxVF_wq2a-m%wi9eSjr8O_{t z?sw0ebALt{V>qhJ%+3kmGr%W-yF(oUG@yVA@H+4>;H7*n`|6RM1L7z!GqZEUz~iA# zC6A}*8yF;(h+`*`*iH=JYva33+HQ+RsYr9X2JklU3*a~TT(`;iwlf4C=I@EsMihkZ9}8cq_(la*772r>uv$x&gZhf{=Z;m zX6L4W-$~nfaQMs=!)GTM8gdvqA&JMu`;O2UsMig*HWZbb&*suHn>VhbeeXr!tNC1Z z`N%LcvvU`LE6H?vbn>42IXRkSd|YB#?+i#=z2|PpRy){MK7k3+rXz(R?oZk3(U?ME!T> z{<^@ShiRC(wRrjKJam-&pMjOmN|8;5Gk4)ZsAE(B;AdR|VebJ{;RagRS z2~zvi*Kbl;y@}sy;#d%~z>(lsAe5o9>akN+T}pxh44<%YY>UZzFClIFA>g~6_cDx1 z0{GtW)H(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qTgdC&~Sih#5-PUZ+tmuK|?;EfJ?yrzyM$o%vmLZKUed>%lTaPrQ7lS YKTK*d^borWXaE2J07*qoM6N<$g5K*F1poj5 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; } }