From 9399172ff125cac3494662d093d864e49780949a Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Tue, 25 Jun 2013 13:26:45 +0400 Subject: [PATCH] fix for simple layout --- .../calculator/AndroidCalculatorDisplayView.java | 2 +- .../android/calculator/CalculatorButtons.java | 4 ++-- .../calculator/CalculatorDisplayFragment.java | 2 +- .../calculator/CalculatorEditorFragment.java | 2 +- .../calculator/CalculatorKeyboardFragment.java | 2 +- .../calculator/wizard/CalculatorLayout.java | 14 ++++---------- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java b/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java index e2b34a16..7bedef5c 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java @@ -180,7 +180,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(preferences); - if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) { + if (!layout.isOptimized()) { setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.cpp_display_text_size_mobile)); } diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 6909c290..93fa13ba 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -40,7 +40,7 @@ public final class CalculatorButtons { public static void processButtons(@Nonnull CalculatorPreferences.Gui.Theme theme, @Nonnull CalculatorPreferences.Gui.Layout layout, @Nonnull View root) { - if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) { + if (!layout.isOptimized()) { final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile); @@ -70,7 +70,7 @@ public final class CalculatorButtons { preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) && - CalculatorPreferences.Gui.getLayout(preferences) != CalculatorPreferences.Gui.Layout.main_calculator_mobile; + CalculatorPreferences.Gui.getLayout(preferences).isOptimized(); if (!large) { if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java index 07294898..285fc444 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java @@ -25,7 +25,7 @@ public class CalculatorDisplayFragment extends SherlockFragment { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(prefs); - if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) { + if (!layout.isOptimized()) { fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display_mobile, R.string.result); } else { fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display, R.string.result); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorEditorFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorEditorFragment.java index b22d6f52..b2afa350 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorEditorFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorEditorFragment.java @@ -52,7 +52,7 @@ public class CalculatorEditorFragment extends SherlockFragment { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(prefs); - if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) { + if (!layout.isOptimized()) { fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_editor_mobile, R.string.editor); } else { fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_editor, R.string.editor); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java index 241e8cb8..2434e664 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardFragment.java @@ -31,7 +31,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(preferences); - if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) { + if (!layout.isOptimized()) { fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_keyboard_mobile); } else { fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_keyboard); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorLayout.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorLayout.java index cbca4125..758dcf74 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorLayout.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorLayout.java @@ -49,16 +49,10 @@ enum CalculatorLayout { @Nonnull static CalculatorLayout fromGuiLayout(@Nonnull CalculatorPreferences.Gui.Layout layout) { - switch (layout) { - case main_calculator: - case main_cellphone: - case simple: - return optimized; - case main_calculator_mobile: - case simple_mobile: - return big_buttons; - default: - return getDefaultLayout(); + if(layout.isOptimized()) { + return optimized; + } else { + return big_buttons; } } }