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_ce_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="default_background">#ff000000</color>
|
||||
</resources>
|
@ -133,6 +133,9 @@ public class CalculatorDisplay extends AutoResizeTextView implements ICalculator
|
||||
this.valid = valid;
|
||||
if (valid) {
|
||||
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;
|
||||
if (historyState == null) {
|
||||
this.display.setText("");
|
||||
//this.display.setText("");
|
||||
localHistoryState = getCurrentHistoryState();
|
||||
} else {
|
||||
this.display.setText(historyState.getDisplayState().getEditorState().getText());
|
||||
localHistoryState = historyState;
|
||||
}
|
||||
|
||||
@ -263,7 +264,12 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
||||
@NotNull JsclOperation operation,
|
||||
@NotNull 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.setGenericResult(null);
|
||||
localDisplay.setValid(false);
|
||||
|
@ -171,6 +171,8 @@ public abstract class AbstractHistoryActivity extends ListActivity {
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void doOperation(@NotNull EditText editor) {
|
||||
|
Loading…
Reference in New Issue
Block a user