summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2015-10-11 16:51:56 (GMT)
committerAndroid Git Automerger <android-git-automerger@android.com>2015-10-11 16:51:56 (GMT)
commit17da0e970527961802f25f3e913ea00ee6d13cda (patch)
treea535ab175f96f523434de4ad3dd583e0494a8056
parentefed4d37b5ffa38cbd64c15f11033ef6d4ce8745 (diff)
parent6760288ce5ee061c305555487f45fa633c807404 (diff)
downloadandroid_packages_apps_ExactCalculator-17da0e970527961802f25f3e913ea00ee6d13cda.zip
android_packages_apps_ExactCalculator-17da0e970527961802f25f3e913ea00ee6d13cda.tar.gz
android_packages_apps_ExactCalculator-17da0e970527961802f25f3e913ea00ee6d13cda.tar.bz2
am 6760288c: am d5f67fe2: Merge "Implicitly clear on incomplete keyboard input" into mnc-dr-dev
* commit '6760288ce5ee061c305555487f45fa633c807404': Implicitly clear on incomplete keyboard input
-rw-r--r--src/com/android/calculator2/Calculator.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index 99ef032..c7e14a4 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -445,19 +445,27 @@ public class Calculator extends Activity
}
}
+ /**
+ * Switch to INPUT from RESULT state in response to input of the specified button_id.
+ * View.NO_ID is treated as an incomplete function id.
+ */
+ private void switchToInput(int button_id) {
+ if (KeyMaps.isBinary(button_id) || KeyMaps.isSuffix(button_id)) {
+ mEvaluator.collapse();
+ } else {
+ announceClearedForAccessibility();
+ mEvaluator.clear();
+ }
+ setState(CalculatorState.INPUT);
+ }
+
// Add the given button id to input expression.
// If appropriate, clear the expression before doing so.
private void addKeyToExpr(int id) {
if (mCurrentState == CalculatorState.ERROR) {
setState(CalculatorState.INPUT);
} else if (mCurrentState == CalculatorState.RESULT) {
- if (KeyMaps.isBinary(id) || KeyMaps.isSuffix(id)) {
- mEvaluator.collapse();
- } else {
- announceClearedForAccessibility();
- mEvaluator.clear();
- }
- setState(CalculatorState.INPUT);
+ switchToInput(id);
}
if (!mEvaluator.append(id)) {
// TODO: Some user visible feedback?
@@ -916,6 +924,10 @@ public class Calculator extends Activity
int current = 0;
int len = moreChars.length();
boolean lastWasDigit = false;
+ if (mCurrentState == CalculatorState.RESULT && len != 0) {
+ // Clear display immediately for incomplete function name.
+ switchToInput(KeyMaps.keyForChar(moreChars.charAt(current)));
+ }
while (current < len) {
char c = moreChars.charAt(current);
int k = KeyMaps.keyForChar(c);