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">
|
<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>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<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"
|
a:defaultValue="0;45"
|
||||||
range:steps="5"
|
range:steps="5"
|
||||||
range:boundaries="0;45"/>-->
|
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>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
@ -8,6 +8,7 @@ package org.solovyev.android.calculator;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@ -225,7 +226,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
numeralBaseButtons.addButtonId(R.id.sixDigitButton);
|
numeralBaseButtons.addButtonId(R.id.sixDigitButton);
|
||||||
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
toggleOrientationChange(preferences);
|
||||||
|
|
||||||
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleButtonDirectionText(int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
private void toggleButtonDirectionText(int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
||||||
@ -670,6 +673,10 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
|
||||||
|
toggleOrientationChange(preferences);
|
||||||
|
}
|
||||||
|
|
||||||
if (CalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
if (CalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
||||||
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
||||||
}
|
}
|
||||||
@ -679,7 +686,16 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMultiplicationButton() {
|
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);
|
final View multiplicationButton = findViewById(R.id.multiplicationButton);
|
||||||
if ( multiplicationButton instanceof Button) {
|
if ( multiplicationButton instanceof Button) {
|
||||||
((Button) multiplicationButton).setText(CalculatorEngine.instance.getMultiplicationSign());
|
((Button) multiplicationButton).setText(CalculatorEngine.instance.getMultiplicationSign());
|
||||||
|
@ -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> 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> 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> showEqualsButton = new BooleanPreference("showEqualsButton", true);
|
||||||
|
public static final Preference<Boolean> autoOrientation = new BooleanPreference("autoOrientation", true);
|
||||||
|
|
||||||
public static enum Theme {
|
public static enum Theme {
|
||||||
|
|
||||||
|
1
pom.xml
1
pom.xml
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<android.sdk.path>/home/ssolovyev/projects/org.solovyev/misc/lib/android-sdk-linux_x86</android.sdk.path>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
Loading…
Reference in New Issue
Block a user