From 18ad81cc08a2a879f8acf4ef982710404226165c Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 3 Oct 2012 12:30:49 +0400 Subject: [PATCH] Fix --- .../src/main/java/org/solovyev/android/AndroidUtils2.java | 8 ++++++++ .../solovyev/android/calculator/CalculatorButtons.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/calculatorpp/src/main/java/org/solovyev/android/AndroidUtils2.java b/calculatorpp/src/main/java/org/solovyev/android/AndroidUtils2.java index 9abe58ae..1b073d4d 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/AndroidUtils2.java +++ b/calculatorpp/src/main/java/org/solovyev/android/AndroidUtils2.java @@ -1,5 +1,6 @@ package org.solovyev.android; +import android.content.res.Configuration; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -32,4 +33,11 @@ public final class AndroidUtils2 { dialogFragment.show(ft, fragmentTag); } + + // copied from API-15 + public static boolean isLayoutSizeAtLeast(int size, @NotNull Configuration configuration) { + int cur = configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; + if (cur == Configuration.SCREENLAYOUT_SIZE_UNDEFINED) return false; + return cur >= size; + } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 77b1b474..94478fd2 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -15,6 +15,7 @@ import jscl.NumeralBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.solovyev.android.AndroidUtils; +import org.solovyev.android.AndroidUtils2; import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.view.AngleUnitsButton; import org.solovyev.android.calculator.view.NumeralBasesButton; @@ -59,11 +60,13 @@ public final class CalculatorButtons { } } + + public static void toggleEqualsButton(@Nullable SharedPreferences preferences, @NotNull Activity activity) { preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; - final boolean large = activity.getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE); + final boolean large = AndroidUtils2.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()); if (!large) { if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT