am 187d3e93: Improve logic for when to display instant result

* commit '187d3e93b13bf0d8711ad5ecaab2deb9909b5f23':
  Improve logic for when to display instant result
diff --git a/src/com/android/calculator2/CalculatorExpr.java b/src/com/android/calculator2/CalculatorExpr.java
index c5ad301..8b3cb40 100644
--- a/src/com/android/calculator2/CalculatorExpr.java
+++ b/src/com/android/calculator2/CalculatorExpr.java
@@ -305,7 +305,12 @@
             return KeyMaps.translateResult(mShortRep);
         }
         @Override
-        TokenKind kind() { return TokenKind.PRE_EVAL; }
+        TokenKind kind() {
+            return TokenKind.PRE_EVAL;
+        }
+        boolean hasEllipsis() {
+            return mShortRep.lastIndexOf(KeyMaps.ELLIPSIS) != -1;
+        }
     }
 
     static Token newToken(DataInput in) throws IOException {
@@ -916,10 +921,10 @@
         }
         for (int i = first; i < last; ++i) {
             Token t1 = mExpr.get(i);
-            if (!(t1 instanceof Constant)) return true;
-            // We consider preevaluated expressions "interesting",
-            // since the evaluation will usually result in more precision
-            // than the "short representation".
+            if (t1 instanceof Operator
+                    || t1 instanceof PreEval && ((PreEval)t1).hasEllipsis()) {
+                return true;
+            }
         }
         return false;
     }
diff --git a/src/com/android/calculator2/Evaluator.java b/src/com/android/calculator2/Evaluator.java
index 16121f5..8d10210 100644
--- a/src/com/android/calculator2/Evaluator.java
+++ b/src/com/android/calculator2/Evaluator.java
@@ -188,9 +188,8 @@
         // Currently running expression evaluator, if any.
 
     private boolean mChangedValue;
-        // Last insertion or deletion may have changed the display value
-        // of the expression.
-        // We handle deletions very conservatively.
+        // The expression may have changed since the last evaluation in ways that would
+        // affect its value.
 
     Evaluator(Calculator calculator,
               CalculatorResult resultDisplay) {
@@ -791,6 +790,7 @@
         clearCache();
         mEvaluator = new AsyncDisplayResult(mDegreeMode, false);
         mEvaluator.execute();
+        mChangedValue = false;
     }
 
     // Ensure that we either display a result or complain.
@@ -835,6 +835,7 @@
             // Approximation of constructive reals should be thread-safe,
             // so we can let that continue until it notices the cancellation.
             mEvaluator = null;
+            mChangedValue = true;    // Didn't do the expected evaluation.
             return true;
         }
         return false;
@@ -874,9 +875,8 @@
             add10pow();  // Handled as macro expansion.
             return true;
         } else {
-            mChangedValue = (KeyMaps.digVal(id) != KeyMaps.NOT_DIGIT
-                    || KeyMaps.isSuffix(id)
-                    || id == R.id.const_pi || id == R.id.const_e);
+            mChangedValue = mChangedValue || (KeyMaps.digVal(id) != KeyMaps.NOT_DIGIT
+                    || KeyMaps.isSuffix(id) || id == R.id.const_pi || id == R.id.const_e);
             return mExpr.add(id);
         }
     }
@@ -918,6 +918,7 @@
         final CalculatorExpr abbrvExpr = getResultExpr();
         clear();
         mExpr.append(abbrvExpr);
+        mChangedValue = true;
     }
 
     // Same as above, but put result in mSaved, leaving mExpr alone.