From b74bec6cd3fa92b1ccbf3f3da68e54fe7c889bd7 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Fri, 10 Feb 2012 23:54:03 +0400 Subject: [PATCH] android_calculator-55: Error label is very annoying --- res/values/colors.xml | 1 + .../solovyev/android/calculator/CalculatorDisplay.java | 3 +++ .../solovyev/android/calculator/CalculatorModel.java | 10 ++++++++-- .../calculator/history/AbstractHistoryActivity.java | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index b1e5576f..c45dbe16 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -10,6 +10,7 @@ #ffffff99 #ffffffff #ffffffff + #44ffffff #ffffff99 #ff000000 \ No newline at end of file diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorDisplay.java b/src/main/java/org/solovyev/android/calculator/CalculatorDisplay.java index e4992d08..7e684d3a 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorDisplay.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorDisplay.java @@ -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)); } } diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java index a7c7871f..29c7c441 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java @@ -172,9 +172,10 @@ public enum CalculatorModel implements CursorControl, HistoryControl 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); diff --git a/src/main/java/org/solovyev/android/calculator/history/AbstractHistoryActivity.java b/src/main/java/org/solovyev/android/calculator/history/AbstractHistoryActivity.java index 7acdee4c..fea99c8d 100644 --- a/src/main/java/org/solovyev/android/calculator/history/AbstractHistoryActivity.java +++ b/src/main/java/org/solovyev/android/calculator/history/AbstractHistoryActivity.java @@ -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) {