Preferences fixes

This commit is contained in:
Sergey Solovyev 2012-10-12 21:16:53 +04:00
parent 86b68f2562
commit 66d5d20465
3 changed files with 137 additions and 137 deletions

View File

@ -157,6 +157,8 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
CalculatorButtons.processButtons(true, theme, root); CalculatorButtons.processButtons(true, theme, root);
CalculatorButtons.toggleEqualsButton(preferences, activity); CalculatorButtons.toggleEqualsButton(preferences, activity);
CalculatorButtons.initMultiplicationButton(root);
NumeralBaseButtons.toggleNumericDigits(activity, preferences);
} }
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) { private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {

View File

@ -18,9 +18,6 @@ import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
*/ */
public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@NotNull
private NumeralBaseButtons numeralBaseButtons = new NumeralBaseButtons();
@NotNull @NotNull
private CalculatorPreferences.Gui.Theme theme; private CalculatorPreferences.Gui.Theme theme;
@ -102,8 +99,9 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (AndroidCalculatorEngine.Preferences.numeralBase.getKey().equals(key)) { if (AndroidCalculatorEngine.Preferences.numeralBase.getKey().equals(key) ||
numeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences); CalculatorPreferences.Gui.hideNumeralBaseDigits.getKey().equals(key) ) {
NumeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences);
} }
if ( CalculatorPreferences.Gui.showEqualsButton.getKey().equals(key) ) { if ( CalculatorPreferences.Gui.showEqualsButton.getKey().equals(key) ) {

View File

@ -13,7 +13,7 @@ import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
*/ */
public class NumeralBaseButtons { public class NumeralBaseButtons {
public synchronized void toggleNumericDigits(@NotNull Activity activity, @NotNull NumeralBase currentNumeralBase) { public static void toggleNumericDigits(@NotNull Activity activity, @NotNull NumeralBase currentNumeralBase) {
for (NumeralBase numeralBase : NumeralBase.values()) { for (NumeralBase numeralBase : NumeralBase.values()) {
if ( currentNumeralBase != numeralBase ) { if ( currentNumeralBase != numeralBase ) {
AndroidNumeralBase.valueOf(numeralBase).toggleButtons(false, activity); AndroidNumeralBase.valueOf(numeralBase).toggleButtons(false, activity);
@ -23,10 +23,10 @@ public class NumeralBaseButtons {
AndroidNumeralBase.valueOf(currentNumeralBase).toggleButtons(true, activity); AndroidNumeralBase.valueOf(currentNumeralBase).toggleButtons(true, activity);
} }
public synchronized void toggleNumericDigits(@NotNull Activity activity, @NotNull SharedPreferences preferences) { public static void toggleNumericDigits(@NotNull Activity activity, @NotNull SharedPreferences preferences) {
if (CalculatorPreferences.Gui.hideNumeralBaseDigits.getPreference(preferences)) { if (CalculatorPreferences.Gui.hideNumeralBaseDigits.getPreference(preferences)) {
final NumeralBase nb = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences); final NumeralBase nb = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
this.toggleNumericDigits(activity, nb); toggleNumericDigits(activity, nb);
} else { } else {
// set HEX to show all digits // set HEX to show all digits
AndroidNumeralBase.valueOf(NumeralBase.hex).toggleButtons(true, activity); AndroidNumeralBase.valueOf(NumeralBase.hex).toggleButtons(true, activity);