Show equals button preferences
BIN
calculatorpp/res/drawable-hdpi/equals.png
Normal file
After Width: | Height: | Size: 344 B |
BIN
calculatorpp/res/drawable-hdpi/equals9.9.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
calculatorpp/res/drawable-ldpi/equals.png
Normal file
After Width: | Height: | Size: 347 B |
BIN
calculatorpp/res/drawable-ldpi/equals9.9.png
Normal file
After Width: | Height: | Size: 211 B |
BIN
calculatorpp/res/drawable-mdpi/equals.png
Normal file
After Width: | Height: | Size: 321 B |
BIN
calculatorpp/res/drawable-mdpi/equals9.9.png
Normal file
After Width: | Height: | Size: 199 B |
BIN
calculatorpp/res/drawable-xhdpi/equals.png
Normal file
After Width: | Height: | Size: 239 B |
BIN
calculatorpp/res/drawable-xhdpi/equals9.9.png
Normal file
After Width: | Height: | Size: 185 B |
@ -3,5 +3,5 @@
|
||||
<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>
|
||||
<string name="c_show_equals_button_summary">If turned on equals button is shown</string>
|
||||
</resources>
|
@ -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"/>
|
||||
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:key="showEqualsButton"
|
||||
a:title="@string/c_show_equals_button_title"
|
||||
a:summary="@string/c_show_equals_button_summary"
|
||||
a:defaultValue="true"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
|
@ -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<ColorButton>() {
|
||||
@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<ColorButton>() {
|
||||
@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)) {
|
||||
|