Loading src/com/android/calculator2/CalculatorExpr.java +10 −5 Original line number Diff line number Diff line Loading @@ -305,7 +305,12 @@ class CalculatorExpr { 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 { Loading Loading @@ -916,10 +921,10 @@ class CalculatorExpr { } 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; } Loading src/com/android/calculator2/Evaluator.java +7 −6 Original line number Diff line number Diff line Loading @@ -188,9 +188,8 @@ class Evaluator { // 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) { Loading Loading @@ -791,6 +790,7 @@ class Evaluator { clearCache(); mEvaluator = new AsyncDisplayResult(mDegreeMode, false); mEvaluator.execute(); mChangedValue = false; } // Ensure that we either display a result or complain. Loading Loading @@ -835,6 +835,7 @@ class Evaluator { // 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; Loading Loading @@ -874,9 +875,8 @@ class Evaluator { 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); } } Loading Loading @@ -918,6 +918,7 @@ class Evaluator { final CalculatorExpr abbrvExpr = getResultExpr(); clear(); mExpr.append(abbrvExpr); mChangedValue = true; } // Same as above, but put result in mSaved, leaving mExpr alone. Loading Loading
src/com/android/calculator2/CalculatorExpr.java +10 −5 Original line number Diff line number Diff line Loading @@ -305,7 +305,12 @@ class CalculatorExpr { 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 { Loading Loading @@ -916,10 +921,10 @@ class CalculatorExpr { } 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; } Loading
src/com/android/calculator2/Evaluator.java +7 −6 Original line number Diff line number Diff line Loading @@ -188,9 +188,8 @@ class Evaluator { // 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) { Loading Loading @@ -791,6 +790,7 @@ class Evaluator { clearCache(); mEvaluator = new AsyncDisplayResult(mDegreeMode, false); mEvaluator.execute(); mChangedValue = false; } // Ensure that we either display a result or complain. Loading Loading @@ -835,6 +835,7 @@ class Evaluator { // 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; Loading Loading @@ -874,9 +875,8 @@ class Evaluator { 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); } } Loading Loading @@ -918,6 +918,7 @@ class Evaluator { final CalculatorExpr abbrvExpr = getResultExpr(); clear(); mExpr.append(abbrvExpr); mChangedValue = true; } // Same as above, but put result in mSaved, leaving mExpr alone. Loading