From c1e638902483a59155fd9be457c712a067b45a90 Mon Sep 17 00:00:00 2001 From: serso Date: Tue, 25 Sep 2012 14:29:26 +0400 Subject: [PATCH] Styles --- calculatorpp/res/values/styles-common.xml | 86 +++++++++---------- .../res/values/styles-metro-blue-theme.xml | 52 ++++++----- .../res/values/styles-metro-green-theme.xml | 52 ++++++----- .../res/values/styles-metro-purple-theme.xml | 52 ++++++----- .../calculator/CalculatorActivity.java | 2 +- .../CalculatorKeyboardFragment.java | 42 ++------- 6 files changed, 127 insertions(+), 159 deletions(-) diff --git a/calculatorpp/res/values/styles-common.xml b/calculatorpp/res/values/styles-common.xml index 5d74735c..a0561d73 100644 --- a/calculatorpp/res/values/styles-common.xml +++ b/calculatorpp/res/values/styles-common.xml @@ -1,43 +1,43 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/calculatorpp/res/values/styles-metro-blue-theme.xml b/calculatorpp/res/values/styles-metro-blue-theme.xml index 12adb288..1328c18c 100644 --- a/calculatorpp/res/values/styles-metro-blue-theme.xml +++ b/calculatorpp/res/values/styles-metro-blue-theme.xml @@ -1,28 +1,26 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/calculatorpp/res/values/styles-metro-green-theme.xml b/calculatorpp/res/values/styles-metro-green-theme.xml index 8c70e489..758ae18f 100644 --- a/calculatorpp/res/values/styles-metro-green-theme.xml +++ b/calculatorpp/res/values/styles-metro-green-theme.xml @@ -1,28 +1,26 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/calculatorpp/res/values/styles-metro-purple-theme.xml b/calculatorpp/res/values/styles-metro-purple-theme.xml index eefd801e..27e27d8d 100644 --- a/calculatorpp/res/values/styles-metro-purple-theme.xml +++ b/calculatorpp/res/values/styles-metro-purple-theme.xml @@ -1,28 +1,26 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 25204a40..78c32c59 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -74,7 +74,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh super.onCreate(savedInstanceState); setLayout(preferences); - CalculatorKeyboardFragment.fixThemeParameters(findViewById(R.id.main_layout), true, this, theme); + CalculatorKeyboardFragment.fixThemeParameters(true, theme, this.getWindow().getDecorView()); final FragmentManager fragmentManager = getFragmentManager(); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java index 710955bf..982d1132 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java @@ -8,7 +8,6 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.Vibrator; import android.preference.PreferenceManager; -import android.util.DisplayMetrics; import android.util.Log; import android.view.*; import android.widget.Button; @@ -156,7 +155,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer numeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences); - fixThemeParameters(root, true, this.getActivity(), theme); + fixThemeParameters(true, theme, this.getView()); toggleEqualsButton(preferences, this.getActivity(), theme, root); @@ -172,45 +171,20 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer preferences.unregisterOnSharedPreferenceChangeListener(this); } - public static void fixThemeParameters(@NotNull View root, boolean fixMagicFlames, @NotNull Activity activity, @NotNull CalculatorPreferences.Gui.Theme theme) { + public static void fixThemeParameters(boolean fixMagicFlames, + @NotNull CalculatorPreferences.Gui.Theme theme, + @NotNull View root) { if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) { if (fixMagicFlames) { // for metro themes we should turn off magic flames - AndroidUtils.processViewsOfType(activity.getWindow().getDecorView(), ColorButton.class, new AndroidUtils.ViewProcessor() { + AndroidUtils.processViewsOfType(root, ColorButton.class, new AndroidUtils.ViewProcessor() { @Override public void process(@NotNull ColorButton colorButton) { colorButton.setDrawMagicFlame(false); } }); } - - fixMargins(root, 2, 2, activity); - } else { - fixMargins(root, 1, 1, activity); - } - } - - public static void fixMargins(@NotNull View root, int marginLeft, int marginBottom, @NotNull Activity activity) { - // sad but true - - final View equalsButton = root.findViewById(R.id.equalsButton); - final View rightButton = root.findViewById(R.id.rightButton); - final View leftButton = root.findViewById(R.id.leftButton); - final View clearButton = root.findViewById(R.id.clearButton); - final View eraseButton = root.findViewById(R.id.eraseButton); - - int orientation = AndroidUtils.getScreenOrientation(activity); - if (orientation == Configuration.ORIENTATION_PORTRAIT) { - setMarginsForView(equalsButton, marginLeft, marginBottom, activity); - setMarginsForView(getCalculatorDisplayView(), marginLeft, marginBottom, activity); - } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - setMarginsForView(leftButton, marginLeft, marginBottom, activity); - setMarginsForView(eraseButton, marginLeft, marginBottom, activity); - setMarginsForView(clearButton, marginLeft, marginBottom, activity); - setMarginsForView(rightButton, marginLeft, marginBottom, activity); - // magic magic magic - setMarginsForView(getCalculatorDisplayView(), 3 * marginLeft, marginBottom, activity); } } @@ -221,7 +195,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer } } - private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) { +/* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) { // IMPORTANT: this is workaround for probably android bug // currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually @@ -234,7 +208,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer view.setLayoutParams(newParams); } } - } + }*/ @Override public void onActivityCreated(Bundle savedInstanceState) { @@ -338,7 +312,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer } } - fixThemeParameters(root, false, activity, theme); + fixThemeParameters(false, theme, root); } }