diff --git a/calculatorpp/res/drawable-hdpi/equals.png b/calculatorpp/res/drawable-hdpi/equals.png
new file mode 100644
index 00000000..a764106c
Binary files /dev/null and b/calculatorpp/res/drawable-hdpi/equals.png differ
diff --git a/calculatorpp/res/drawable-hdpi/equals9.9.png b/calculatorpp/res/drawable-hdpi/equals9.9.png
new file mode 100644
index 00000000..ee2bc0e4
Binary files /dev/null and b/calculatorpp/res/drawable-hdpi/equals9.9.png differ
diff --git a/calculatorpp/res/drawable-ldpi/equals.png b/calculatorpp/res/drawable-ldpi/equals.png
new file mode 100644
index 00000000..f80d4327
Binary files /dev/null and b/calculatorpp/res/drawable-ldpi/equals.png differ
diff --git a/calculatorpp/res/drawable-ldpi/equals9.9.png b/calculatorpp/res/drawable-ldpi/equals9.9.png
new file mode 100644
index 00000000..b47362e7
Binary files /dev/null and b/calculatorpp/res/drawable-ldpi/equals9.9.png differ
diff --git a/calculatorpp/res/drawable-mdpi/equals.png b/calculatorpp/res/drawable-mdpi/equals.png
new file mode 100644
index 00000000..563125c2
Binary files /dev/null and b/calculatorpp/res/drawable-mdpi/equals.png differ
diff --git a/calculatorpp/res/drawable-mdpi/equals9.9.png b/calculatorpp/res/drawable-mdpi/equals9.9.png
new file mode 100644
index 00000000..a71af84f
Binary files /dev/null and b/calculatorpp/res/drawable-mdpi/equals9.9.png differ
diff --git a/calculatorpp/res/drawable-xhdpi/equals.png b/calculatorpp/res/drawable-xhdpi/equals.png
new file mode 100644
index 00000000..9de8a696
Binary files /dev/null and b/calculatorpp/res/drawable-xhdpi/equals.png differ
diff --git a/calculatorpp/res/drawable-xhdpi/equals9.9.png b/calculatorpp/res/drawable-xhdpi/equals9.9.png
new file mode 100644
index 00000000..2c002b9a
Binary files /dev/null and b/calculatorpp/res/drawable-xhdpi/equals9.9.png differ
diff --git a/calculatorpp/res/values/text_preferences.xml b/calculatorpp/res/values/text_preferences.xml
index f58e6a7f..955341ae 100644
--- a/calculatorpp/res/values/text_preferences.xml
+++ b/calculatorpp/res/values/text_preferences.xml
@@ -3,5 +3,5 @@
If turned on calculator will change screen orientation automatically
Show equals button
- Preference hides or shows equals button
+ If turned on equals button is shown
\ No newline at end of file
diff --git a/calculatorpp/res/xml/preferences.xml b/calculatorpp/res/xml/preferences.xml
index e62e9884..1d334547 100644
--- a/calculatorpp/res/xml/preferences.xml
+++ b/calculatorpp/res/xml/preferences.xml
@@ -139,7 +139,14 @@
a:key="autoOrientation"
a:title="@string/c_auto_orientation_title"
a:summary="@string/c_auto_orientation_summary"
- a:defaultValue="false"/>
+ a:defaultValue="true"/>
+
+
+
diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
index 7e2ba01b..3b7cdf68 100644
--- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
+++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
@@ -183,21 +183,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
initMultiplicationButton();
- if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) {
- // for metro themes we should turn off magic flames
- AndroidUtils.processViewsOfType(this.getWindow().getDecorView(), ColorButton.class, new AndroidUtils.ViewProcessor() {
- @Override
- public void process(@NotNull ColorButton colorButton) {
- colorButton.setDrawMagicFlame(false);
- }
- });
+ fixThemeParameters(true);
- fixMargins(2, 2);
- } else {
- fixMargins(1, 1);
- }
-
- if (layout == CalculatorPreferences.Gui.Layout.simple) {
+ if (layout == CalculatorPreferences.Gui.Layout.simple) {
toggleButtonDirectionText(R.id.oneDigitButton, false, DragDirection.up, DragDirection.down);
toggleButtonDirectionText(R.id.twoDigitButton, false, DragDirection.up, DragDirection.down);
toggleButtonDirectionText(R.id.threeDigitButton, false, DragDirection.up, DragDirection.down);
@@ -226,12 +214,33 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
numeralBaseButtons.addButtonId(R.id.sixDigitButton);
numeralBaseButtons.toggleNumericDigits(this, preferences);
+ toggleEqualsButton(preferences);
+
toggleOrientationChange(preferences);
preferences.registerOnSharedPreferenceChangeListener(this);
}
- private void toggleButtonDirectionText(int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
+ private void fixThemeParameters(boolean fixMagicFlames) {
+ if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) {
+
+ if (fixMagicFlames) {
+ // for metro themes we should turn off magic flames
+ AndroidUtils.processViewsOfType(this.getWindow().getDecorView(), ColorButton.class, new AndroidUtils.ViewProcessor() {
+ @Override
+ public void process(@NotNull ColorButton colorButton) {
+ colorButton.setDrawMagicFlame(false);
+ }
+ });
+ }
+
+ fixMargins(2, 2);
+ } else {
+ fixMargins(1, 1);
+ }
+ }
+
+ private void toggleButtonDirectionText(int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
final View v = findViewById(id);
if (v instanceof DirectionDragButton ) {
final DirectionDragButton button = (DirectionDragButton)v;
@@ -250,7 +259,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
final View clearButton = findViewById(R.id.clearButton);
final View eraseButton = findViewById(R.id.eraseButton);
- int orientation = getResources().getConfiguration().orientation;
+ int orientation = AndroidUtils.getScreenOrientation(this);
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
setMarginsForView(equalsButton, marginLeft, marginBottom);
setMarginsForView(calculatorModel.getDisplay(), marginLeft, marginBottom);
@@ -673,8 +682,8 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
}
- if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
- toggleOrientationChange(preferences);
+ if ( CalculatorPreferences.Gui.showEqualsButton.getKey().equals(key) ) {
+ toggleEqualsButton(preferences);
}
if (CalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
@@ -684,8 +693,28 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
if ( CalculatorEngine.Preferences.multiplicationSign.getKey().equals(key) ) {
initMultiplicationButton();
}
+
+ if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
+ toggleOrientationChange(preferences);
+ }
}
+ private void toggleEqualsButton(@Nullable SharedPreferences preferences) {
+ preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
+
+ if (AndroidUtils.getScreenOrientation(this) == Configuration.ORIENTATION_PORTRAIT || !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
+ final DragButton button = (DragButton)findViewById(R.id.equalsButton);
+ if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) {
+ button.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.FILL_PARENT, 1f));
+ calculatorModel.getDisplay().setBackgroundDrawable(null);
+ } else {
+ button.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.FILL_PARENT, 0f));
+ calculatorModel.getDisplay().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.equals9));
+ }
+ fixThemeParameters(false);
+ }
+ }
+
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {