android_calculator-55: Error label is very annoying

This commit is contained in:
Sergey Solovyev 2012-02-10 23:54:03 +04:00
parent a49a256ac3
commit b74bec6cd3
4 changed files with 14 additions and 2 deletions

View File

@ -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>

View File

@ -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));
}
}

View File

@ -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);
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);

View File

@ -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) {