Orientation change lock
This commit is contained in:
parent
c42530f534
commit
2171d9dd2c
@ -10,7 +10,9 @@
|
||||
|
||||
<application android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
||||
|
||||
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
|
||||
<activity android:label="@string/c_app_name"
|
||||
android:name=".CalculatorActivity"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
7
calculatorpp/res/values/text_preferences.xml
Normal file
7
calculatorpp/res/values/text_preferences.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
<string name="c_auto_orientation_title">Toggle screen orientation change</string>
|
||||
<string name="c_auto_orientation_summary">If turned on calculator will change screen orientation automatically</string>
|
||||
|
||||
<string name="c_show_equals_button_title">Show equals button</string>
|
||||
<string name="c_show_equals_button_summary">Preference hides or shows equals button</string>
|
||||
</resources>
|
@ -134,6 +134,13 @@
|
||||
a:defaultValue="0;45"
|
||||
range:steps="5"
|
||||
range:boundaries="0;45"/>-->
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="autoOrientation"
|
||||
a:title="@string/c_auto_orientation_title"
|
||||
a:summary="@string/c_auto_orientation_summary"
|
||||
a:defaultValue="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
|
@ -8,6 +8,7 @@ package org.solovyev.android.calculator;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.*;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
@ -225,6 +226,8 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
numeralBaseButtons.addButtonId(R.id.sixDigitButton);
|
||||
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
||||
|
||||
toggleOrientationChange(preferences);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@ -670,6 +673,10 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
}
|
||||
|
||||
if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
|
||||
toggleOrientationChange(preferences);
|
||||
}
|
||||
|
||||
if (CalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
||||
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
||||
}
|
||||
@ -679,6 +686,15 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
|
||||
if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
private void initMultiplicationButton() {
|
||||
final View multiplicationButton = findViewById(R.id.multiplicationButton);
|
||||
if ( multiplicationButton instanceof Button) {
|
||||
|
@ -35,6 +35,7 @@ public final class CalculatorPreferences {
|
||||
public static final Preference<Boolean> showReleaseNotes = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true);
|
||||
public static final Preference<Boolean> usePrevAsBack = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false);
|
||||
public static final Preference<Boolean> showEqualsButton = new BooleanPreference("showEqualsButton", true);
|
||||
public static final Preference<Boolean> autoOrientation = new BooleanPreference("autoOrientation", true);
|
||||
|
||||
public static enum Theme {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user