Hex digits are not shown in not HEX mode
This commit is contained in:
parent
891b8abc50
commit
c42530f534
@ -77,6 +77,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
|
|
||||||
private boolean useBackAsPrev;
|
private boolean useBackAsPrev;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private NumeralBaseButtons numeralBaseButtons = new NumeralBaseButtons();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the activity is first created.
|
* Called when the activity is first created.
|
||||||
*/
|
*/
|
||||||
@ -194,26 +197,34 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (layout == CalculatorPreferences.Gui.Layout.simple) {
|
if (layout == CalculatorPreferences.Gui.Layout.simple) {
|
||||||
toggleButtonDirectionText(R.id.oneDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.oneDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(R.id.twoDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.twoDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(R.id.threeDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.threeDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
|
|
||||||
toggleButtonDirectionText(R.id.sixDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.sixDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(R.id.sevenDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.sevenDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(R.id.eightDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.eightDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||||
|
|
||||||
toggleButtonDirectionText(R.id.clearButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(R.id.clearButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||||
|
|
||||||
toggleButtonDirectionText(R.id.fourDigitButton, false, DragDirection.left, DragDirection.down);
|
toggleButtonDirectionText(R.id.fourDigitButton, false, DragDirection.down);
|
||||||
toggleButtonDirectionText(R.id.fiveDigitButton, false, DragDirection.left, DragDirection.down);
|
toggleButtonDirectionText(R.id.fiveDigitButton, false, DragDirection.down);
|
||||||
|
|
||||||
toggleButtonDirectionText(R.id.nineDigitButton, false, DragDirection.left);
|
toggleButtonDirectionText(R.id.nineDigitButton, false, DragDirection.left);
|
||||||
|
|
||||||
toggleButtonDirectionText(R.id.multiplicationButton, false, DragDirection.left);
|
toggleButtonDirectionText(R.id.multiplicationButton, false, DragDirection.left);
|
||||||
toggleButtonDirectionText(R.id.plusButton, false, DragDirection.down, DragDirection.up);
|
toggleButtonDirectionText(R.id.plusButton, false, DragDirection.down, DragDirection.up);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numeralBaseButtons.clear();
|
||||||
|
numeralBaseButtons.addButtonId(R.id.oneDigitButton);
|
||||||
|
numeralBaseButtons.addButtonId(R.id.twoDigitButton);
|
||||||
|
numeralBaseButtons.addButtonId(R.id.threeDigitButton);
|
||||||
|
numeralBaseButtons.addButtonId(R.id.fourDigitButton);
|
||||||
|
numeralBaseButtons.addButtonId(R.id.fiveDigitButton);
|
||||||
|
numeralBaseButtons.addButtonId(R.id.sixDigitButton);
|
||||||
|
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,6 +670,10 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
||||||
|
numeralBaseButtons.toggleNumericDigits(this, preferences);
|
||||||
|
}
|
||||||
|
|
||||||
if ( CalculatorEngine.Preferences.multiplicationSign.getKey().equals(key) ) {
|
if ( CalculatorEngine.Preferences.multiplicationSign.getKey().equals(key) ) {
|
||||||
initMultiplicationButton();
|
initMultiplicationButton();
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public final class CalculatorPreferences {
|
|||||||
public static final Preference<Boolean> feedbackWindowShown = new BooleanPreference("feedback_window_shown", false);
|
public static final Preference<Boolean> feedbackWindowShown = new BooleanPreference("feedback_window_shown", false);
|
||||||
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 enum Theme {
|
public static enum Theme {
|
||||||
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import jscl.NumeralBase;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||||
|
import org.solovyev.android.view.drag.DirectionDragButton;
|
||||||
|
import org.solovyev.android.view.drag.DragDirection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 4/20/12
|
||||||
|
* Time: 5:03 PM
|
||||||
|
*/
|
||||||
|
public class NumeralBaseButtons {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private final List<Integer> buttonIds = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
public void addButton(@NotNull DirectionDragButton button) {
|
||||||
|
buttonIds.add(button.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addButtonId(@NotNull Integer buttonId) {
|
||||||
|
buttonIds.add(buttonId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeNumeralDigits(@NotNull Activity activity) {
|
||||||
|
for (Integer id : buttonIds) {
|
||||||
|
final DirectionDragButton button = (DirectionDragButton) activity.findViewById(id);
|
||||||
|
if (button != null) {
|
||||||
|
button.showDirectionText(false, DragDirection.left);
|
||||||
|
button.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void showNumeralDigits(@NotNull Activity activity) {
|
||||||
|
for (Integer id : buttonIds) {
|
||||||
|
final DirectionDragButton button = (DirectionDragButton) activity.findViewById(id);
|
||||||
|
if (button != null) {
|
||||||
|
button.showDirectionText(true, DragDirection.left);
|
||||||
|
button.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
buttonIds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void toggleNumericDigits(@NotNull Activity activity, @NotNull SharedPreferences preferences) {
|
||||||
|
if (CalculatorEngine.Preferences.numeralBase.getPreference(preferences) != NumeralBase.hex) {
|
||||||
|
this.removeNumeralDigits(activity);
|
||||||
|
} else {
|
||||||
|
this.showNumeralDigits(activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user