From ee617bc4c3f7909ad9bab70964ee19afbe094941 Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Tue, 2 Feb 2016 04:50:05 +0100 Subject: [PATCH] Added a custom style for the RatingBar. Fixed some layout issues with tablets and very small screens. --- .../ui/GameActivity.java | 4 +- .../ui/view/SudokuKeyboardLayout.java | 12 +- .../ui/view/SudokuSpecialButtonLayout.java | 3 + .../res/drawable-xhdpi/ic_star_black_48dp.png | Bin 0 -> 887 bytes .../ic_star_half_black_48dp.png | Bin 0 -> 712 bytes .../main/res/drawable/ic_star_black_48dp.png | Bin 0 -> 668 bytes .../res/drawable/ic_star_half_black_48dp.png | Bin 0 -> 537 bytes app/src/main/res/drawable/ratingbar.xml | 34 +++ .../res/layout-land/activity_main_menu.xml | 5 +- .../res/layout-small/activity_main_menu.xml | 238 ++++++++++++++++++ .../res/layout-xlarge/activity_main_menu.xml | 12 +- .../win_screen_layout.xml | 25 +- app/src/main/res/layout/activity_about.xml | 1 + .../main/res/layout/activity_main_menu.xml | 13 +- app/src/main/res/layout/win_screen_layout.xml | 20 +- app/src/main/res/values-small/dimens.xml | 11 + app/src/main/res/values-w820dp/dimens.xml | 7 - app/src/main/res/values-xlarge/dimens.xml | 2 +- app/src/main/res/values-xlarge/styles.xml | 9 + app/src/main/res/values-zh/strings.xml | 65 ++++- app/src/main/res/values/dimens.xml | 2 +- app/src/main/res/values/styles.xml | 11 +- 22 files changed, 416 insertions(+), 58 deletions(-) create mode 100644 app/src/main/res/drawable-xhdpi/ic_star_black_48dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_star_half_black_48dp.png create mode 100644 app/src/main/res/drawable/ic_star_black_48dp.png create mode 100644 app/src/main/res/drawable/ic_star_half_black_48dp.png create mode 100644 app/src/main/res/drawable/ratingbar.xml create mode 100644 app/src/main/res/layout-small/activity_main_menu.xml rename app/src/main/res/{layout-xlarge-land => layout-xlarge}/win_screen_layout.xml (91%) create mode 100644 app/src/main/res/values-small/dimens.xml delete mode 100644 app/src/main/res/values-w820dp/dimens.xml create mode 100644 app/src/main/res/values-xlarge/styles.xml diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java index a52d49d..479f3fa 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -308,7 +308,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On dialog.show(); final Activity activity = this; - ((Button)dialog.findViewById(R.id.win_button)).setOnClickListener(new View.OnClickListener() { + ((Button)dialog.findViewById(R.id.win_continue_button)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); @@ -318,7 +318,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On activity.finish(); } }); - ((Button)dialog.findViewById(R.id.win_button2)).setOnClickListener(new View.OnClickListener() { + ((Button)dialog.findViewById(R.id.win_showGame_button)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java index 39fa61a..b39366b 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuKeyboardLayout.java @@ -6,6 +6,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; import android.util.TypedValue; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; @@ -26,7 +27,7 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan SudokuButton [] buttons; GameController gameController; Symbol symbolsToUse = Symbol.Default; - float normalTextSize = 30; // in sp + float normalTextSize = 20; // in sp LinearLayout [] layouts = new LinearLayout[2]; OnClickListener listener = new OnClickListener() { @@ -61,6 +62,8 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan int numberOfButtonsPerRow = (size % 2 == 0) ? size/2 :(size+1)/2; int numberOfButtons = numberOfButtonsPerRow * 2; + normalTextSize = (int) getResources().getDimension(R.dimen.text_size) / getResources().getDisplayMetrics().scaledDensity; + buttons = new SudokuButton[numberOfButtons]; //set layout parameters and init Layouts @@ -71,7 +74,7 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan p = new LayoutParams(0, LayoutParams.MATCH_PARENT, 1); } //if (i == 0) p.bottomMargin=10; else p.topMargin=10; - p.setMargins(0,5,0,5); + p.setMargins(0, 5, 0, 5); layouts[i] = new LinearLayout(getContext(),null); layouts[i].setLayoutParams(p); layouts[i].setWeightSum(numberOfButtonsPerRow); @@ -110,12 +113,13 @@ public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChan */ // buttons[number].setLayoutParams(p); - //buttons[number].setGravity(Gravity.CENTER); buttons[buttonIndex].setType(SudokuButtonType.Value); buttons[buttonIndex].setTextColor(getResources().getColor(R.color.white)); buttons[buttonIndex].setBackgroundResource(R.drawable.mnenomic_numpad_button); + buttons[buttonIndex].setPadding(0, 0, 0, 0); + buttons[buttonIndex].setGravity(Gravity.CENTER); buttons[buttonIndex].setText(Symbol.getSymbol(symbolsToUse, buttonIndex)); - buttons[buttonIndex].setTextSize(TypedValue.COMPLEX_UNIT_SP,normalTextSize); + buttons[buttonIndex].setTextSize(TypedValue.COMPLEX_UNIT_SP, normalTextSize); buttons[buttonIndex].setValue(buttonIndex + 1); buttons[buttonIndex].setOnClickListener(listener); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java index f431f55..ea02006 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java @@ -171,6 +171,9 @@ public class SudokuSpecialButtonLayout extends LinearLayout implements IHighligh fixedButtons[i].setImageBitmap(bitResult); fixedButtons[i].setBackgroundResource(gameController.getNoteStatus() ? R.drawable.numpad_highlighted_three : R.drawable.numpad_highlighted_four); + + keyboard.updateNotesEnabled(); + break; default: break; diff --git a/app/src/main/res/drawable-xhdpi/ic_star_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_star_black_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7be22806f0e1a339cea85fc7bc45ab72d99859fd GIT binary patch literal 887 zcmV--1Bm>IP))Ds3BGE_75> zPOm1pw?+)nYB^WuJ26Dx$hk$LN_Wb&Zc(M}a%`qPQKf%Pms`(^8tRZ!V;mMWbjbN~ zX_ct4R=M*&;+|hhV3$5!baOBGHR<)Qc!23$e?GX=;4&7 z-YKn8wkXA^*K58ETJwf>f2fnG>qWxNlBvf; z!aX8WZ;FK5B2&o^>U}aaU8K-dnR!6e)IqIU9TYWnpUiZMs`YuAYD$nzfRq6~@XO%-$enM!HiMxh8I9(>7vWvYk~)nr@6+1{46v%}ykw@b<$z7|6GP0Fqk z!cmWFl%z)OjtSv%sah#)GesJvc}sXus@lzyrUlxRN~Kb%R4SEf^dI`@Fkg>}l(ql> N002ovPDHLkV1i1ArFsAW literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_star_half_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_star_half_black_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..348d4d84f097899f88e0eb481904ed693457bd39 GIT binary patch literal 712 zcmV;(0yq7MP)*VT! zI>5ZP{eWH9r-(cK_q((x$G?g1gvtODgxUaav;l?)wE>=J10>n04}h!7XqMB;?HlLY ze*8sCXgqIU6yTLMz&ZBn2jHTK9}rV+;C8kP;xCwiTeK_3KgO4$_{%l%^+WdM0A6SV z^pmSM!0|TmeaDZej@8O~N&KZUaFZ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/res/drawable/ratingbar.xml b/app/src/main/res/drawable/ratingbar.xml new file mode 100644 index 0000000..5c66e0e --- /dev/null +++ b/app/src/main/res/drawable/ratingbar.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-land/activity_main_menu.xml b/app/src/main/res/layout-land/activity_main_menu.xml index ef58358..46bc53b 100644 --- a/app/src/main/res/layout-land/activity_main_menu.xml +++ b/app/src/main/res/layout-land/activity_main_menu.xml @@ -109,11 +109,10 @@ android:id="@+id/difficultyBar" android:layout_gravity="center_horizontal" android:clickable="true" - android:numStars="4" + android:numStars="3" android:rating="1" android:stepSize="1" - android:scaleX="1.2" - android:scaleY="1.2"/> + style="@style/RatingBar"/>