From 62e3ace1abc08e4c02d6b41e30b15fbe90e62367 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Mon, 28 Nov 2011 17:22:00 +0000 Subject: [PATCH] DroidFish: UI improvements from Aaro Korhonen. - SeekBarPreference now uses Android system style (textAppearanceLarge) instead of custom attribute values. - The dialog for filename has now the same visual style as the other dialogs. - Added colons to the rest of the dialog labels. - Added some padding to select_game.xml. --- DroidFish/res/layout/create_pgn_file.xml | 40 ++++------------- DroidFish/res/layout/edit_comments.xml | 7 ++- DroidFish/res/layout/edit_headers.xml | 12 +++--- DroidFish/res/layout/edit_move_counters.xml | 4 +- DroidFish/res/layout/select_game.xml | 6 +-- DroidFish/res/layout/select_move_number.xml | 2 +- DroidFish/res/layout/select_percentage.xml | 2 +- DroidFish/res/values/strings.xml | 7 +++ .../src/org/petero/droidfish/DroidFish.java | 43 +++++++++---------- .../petero/droidfish/SeekBarPreference.java | 3 +- 10 files changed, 52 insertions(+), 74 deletions(-) diff --git a/DroidFish/res/layout/create_pgn_file.xml b/DroidFish/res/layout/create_pgn_file.xml index 7a58479..f1200ea 100644 --- a/DroidFish/res/layout/create_pgn_file.xml +++ b/DroidFish/res/layout/create_pgn_file.xml @@ -1,45 +1,21 @@ - + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:padding="10dp"> + android:paddingRight="10dp" + android:text="@string/filename"> - - - - - - + \ No newline at end of file diff --git a/DroidFish/res/layout/edit_comments.xml b/DroidFish/res/layout/edit_comments.xml index 2b77945..b6717c5 100644 --- a/DroidFish/res/layout/edit_comments.xml +++ b/DroidFish/res/layout/edit_comments.xml @@ -15,7 +15,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingRight="10dp" - android:text="Before"> + android:text="Before:"> + android:text="Move:"> + android:text="After:"> + android:text="Event:"> + android:text="Site:"> + android:text="Date:"> + android:text="White:"> + android:text="Black:"> + android:text="@string/halfmove"> + android:text="@string/fullmove"> + android:inputType="text" + android:layout_margin="10dp"> diff --git a/DroidFish/res/layout/select_percentage.xml b/DroidFish/res/layout/select_percentage.xml index 0fa7f6e..6086a89 100644 --- a/DroidFish/res/layout/select_percentage.xml +++ b/DroidFish/res/layout/select_percentage.xml @@ -8,7 +8,7 @@ Load Next Game No previous game No next game + Ok + Cancel + Move number: + Filename: + Halfmove clock: + Fullmove counter: + Filter text diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index 7190749..1b60404 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -1078,12 +1078,12 @@ public class DroidFish extends Activity implements GUIInterface { } } }; - builder.setPositiveButton("Ok", new Dialog.OnClickListener() { + builder.setPositiveButton(R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { gotoMove.run(); } }); - builder.setNegativeButton("Cancel", null); + builder.setNegativeButton(R.string.cancel, null); final AlertDialog dialog = builder.create(); @@ -1217,12 +1217,11 @@ public class DroidFish extends Activity implements GUIInterface { return alert; } case SELECT_PGN_SAVE_NEWFILE_DIALOG: { - final Dialog dialog = new Dialog(this); - dialog.setContentView(R.layout.create_pgn_file); - dialog.setTitle(R.string.select_pgn_file_save); - final EditText fileNameView = (EditText)dialog.findViewById(R.id.create_pgn_filename); - Button ok = (Button)dialog.findViewById(R.id.create_pgn_ok); - Button cancel = (Button)dialog.findViewById(R.id.create_pgn_cancel); + View content = View.inflate(this, R.layout.create_pgn_file, null); + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setView(content); + builder.setTitle(R.string.select_pgn_file_save); + final EditText fileNameView = (EditText)content.findViewById(R.id.create_pgn_filename); fileNameView.setText(""); final Runnable savePGN = new Runnable() { public void run() { @@ -1230,28 +1229,26 @@ public class DroidFish extends Activity implements GUIInterface { if ((pgnFile.length() > 0) && !pgnFile.contains(".")) pgnFile += ".pgn"; savePGNToFile(ctrl.getPGN(), pgnFile, false); - dialog.cancel(); } }; + builder.setPositiveButton(R.string.ok, new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + savePGN.run(); + } + }); + builder.setNegativeButton(R.string.cancel, null); + + final Dialog dialog = builder.create(); fileNameView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { savePGN.run(); + dialog.cancel(); return true; } return false; } }); - ok.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - savePGN.run(); - } - }); - cancel.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - dialog.cancel(); - } - }); return dialog; } @@ -1363,8 +1360,8 @@ public class DroidFish extends Activity implements GUIInterface { white.setText(headers.get("White")); black.setText(headers.get("Black")); - builder.setNegativeButton("Cancel", null); - builder.setPositiveButton("Ok", new Dialog.OnClickListener() { + builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { headers.put("Event", event.getText().toString().trim()); headers.put("Site", site .getText().toString().trim()); @@ -1401,8 +1398,8 @@ public class DroidFish extends Activity implements GUIInterface { nagStr = String.format("%d", commInfo.nag); nag.setText(nagStr); - builder.setNegativeButton("Cancel", null); - builder.setPositiveButton("Ok", new Dialog.OnClickListener() { + builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String pre = preComment.getText().toString().trim(); String post = postComment.getText().toString().trim(); diff --git a/DroidFish/src/org/petero/droidfish/SeekBarPreference.java b/DroidFish/src/org/petero/droidfish/SeekBarPreference.java index a36d86c..f3f4b6a 100644 --- a/DroidFish/src/org/petero/droidfish/SeekBarPreference.java +++ b/DroidFish/src/org/petero/droidfish/SeekBarPreference.java @@ -43,8 +43,7 @@ public class SeekBarPreference extends Preference protected View onCreateView(ViewGroup parent) { TextView name = new TextView(getContext()); name.setText(getTitle()); - name.setTextSize(20); - name.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); + name.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); name.setGravity(Gravity.LEFT); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,