This commit is contained in:
serso 2012-10-03 12:30:49 +04:00
parent f2eca251f8
commit 18ad81cc08
2 changed files with 12 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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