android_calculator-55: Error label is very annoying
This commit is contained in:
parent
a49a256ac3
commit
b74bec6cd3
@ -10,6 +10,7 @@
|
|||||||
<color name="button_operator_text_color">#ffffff99</color>
|
<color name="button_operator_text_color">#ffffff99</color>
|
||||||
<color name="button_ce_text_color">#ffffffff</color>
|
<color name="button_ce_text_color">#ffffffff</color>
|
||||||
<color name="default_text_color">#ffffffff</color>
|
<color name="default_text_color">#ffffffff</color>
|
||||||
|
<color name="display_error_text_color">#44ffffff</color>
|
||||||
<color name="selected_angle_unit_text_color">#ffffff99</color>
|
<color name="selected_angle_unit_text_color">#ffffff99</color>
|
||||||
<color name="default_background">#ff000000</color>
|
<color name="default_background">#ff000000</color>
|
||||||
</resources>
|
</resources>
|
@ -133,6 +133,9 @@ public class CalculatorDisplay extends AutoResizeTextView implements ICalculator
|
|||||||
this.valid = valid;
|
this.valid = valid;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
|
setTextColor(getResources().getColor(R.color.default_text_color));
|
||||||
|
} else {
|
||||||
|
setTextColor(getResources().getColor(R.color.display_error_text_color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,9 +172,10 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
|||||||
|
|
||||||
final CalculatorHistoryState localHistoryState;
|
final CalculatorHistoryState localHistoryState;
|
||||||
if (historyState == null) {
|
if (historyState == null) {
|
||||||
this.display.setText("");
|
//this.display.setText("");
|
||||||
localHistoryState = getCurrentHistoryState();
|
localHistoryState = getCurrentHistoryState();
|
||||||
} else {
|
} else {
|
||||||
|
this.display.setText(historyState.getDisplayState().getEditorState().getText());
|
||||||
localHistoryState = historyState;
|
localHistoryState = historyState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +264,12 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
|||||||
@NotNull JsclOperation operation,
|
@NotNull JsclOperation operation,
|
||||||
@NotNull Message e) {
|
@NotNull Message e) {
|
||||||
Log.d(CalculatorModel.class.getName(), "Evaluation failed for : " + expression + ". Error message: " + e);
|
Log.d(CalculatorModel.class.getName(), "Evaluation failed for : " + expression + ". Error message: " + e);
|
||||||
localDisplay.setText(R.string.c_syntax_error);
|
if ( StringUtils.isEmpty(localDisplay.getText()) ) {
|
||||||
|
// if previous display state was empty -> show error
|
||||||
|
localDisplay.setText(R.string.c_syntax_error);
|
||||||
|
} else {
|
||||||
|
// show previous result instead of error caption (actually previous result will be greyed)
|
||||||
|
}
|
||||||
localDisplay.setJsclOperation(operation);
|
localDisplay.setJsclOperation(operation);
|
||||||
localDisplay.setGenericResult(null);
|
localDisplay.setGenericResult(null);
|
||||||
localDisplay.setValid(false);
|
localDisplay.setValid(false);
|
||||||
|
@ -171,6 +171,8 @@ public abstract class AbstractHistoryActivity extends ListActivity {
|
|||||||
|
|
||||||
public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState, @NotNull AbstractHistoryActivity activity) {
|
public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState, @NotNull AbstractHistoryActivity activity) {
|
||||||
|
|
||||||
|
// before evaluating history item - clear display (in order to get Error message in display if evaluation fail)
|
||||||
|
CalculatorModel.instance.getDisplay().setText("");
|
||||||
CalculatorModel.instance.doTextOperation(new CalculatorModel.TextOperation() {
|
CalculatorModel.instance.doTextOperation(new CalculatorModel.TextOperation() {
|
||||||
@Override
|
@Override
|
||||||
public void doOperation(@NotNull EditText editor) {
|
public void doOperation(@NotNull EditText editor) {
|
||||||
|
Loading…
Reference in New Issue
Block a user