Internationalize display again. Plus minor cleanups.
Adds code for internationalization of numeric results, both in the
result and formula displays.
Update some now obsolete TODO comments.
Change-Id: I42731bf87f5488375457f1c5c094c7f0d17b71da
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index f5b9247..8298a44 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -24,9 +24,15 @@
// result, and formatting of exponent etc. is done separately.
// TODO: Better indication of when the result is known to be exact.
// TODO: Fix placement of inverse trig buttons.
-// TODO: Fix internationalization, particularly for result.
// TODO: Check and possibly fix accessability issues.
-// TODO: Copy & more general paste in formula?
+// TODO: Copy & more general paste in formula? Note that this requires
+// great care: Currently the text version of a displayed formula
+// is not directly useful for re-evaluating the formula later, since
+// it contains ellipses representing subexpressions evaluated with
+// a different degree mode. Rather than supporting copy from the
+// formula window, we may eventually want to support generation of a
+// more useful text version in a separate window. It's not clear
+// this is worth the added (code and user) complexity.
package com.android.calculator2;
@@ -210,6 +216,7 @@
mEvaluator = new Evaluator(this, mResult);
mResult.setEvaluator(mEvaluator);
+ KeyMaps.setActivity(this);
if (savedInstanceState != null) {
setState(CalculatorState.values()[
@@ -748,7 +755,7 @@
private void displayFraction() {
BoundedRational result = mEvaluator.getRational();
- displayMessage(result.toNiceString());
+ displayMessage(KeyMaps.translateResult(result.toNiceString()));
}
// Display full result to currently evaluated precision
@@ -787,7 +794,7 @@
int len = moreChars.length();
while (current < len) {
char c = moreChars.charAt(current);
- int k = KeyMaps.keyForChar(c, this);
+ int k = KeyMaps.keyForChar(c);
if (k != View.NO_ID) {
mCurrentButton = findViewById(k);
addKeyToExpr(k);
@@ -798,7 +805,7 @@
}
continue;
}
- int f = KeyMaps.funForString(moreChars, current, this);
+ int f = KeyMaps.funForString(moreChars, current);
if (f != View.NO_ID) {
mCurrentButton = findViewById(f);
addKeyToExpr(f);