diff options
author | Hans Boehm <hboehm@google.com> | 2015-04-13 20:29:47 -0700 |
---|---|---|
committer | Hans Boehm <hboehm@google.com> | 2015-04-15 18:02:18 -0700 |
commit | 013969e98ce9e3eb4f87ec6159b06a74d07b2592 (patch) | |
tree | 4fb362ab9e18841dad2f5934d74af971a7df17dc /src/com/android/calculator2/Evaluator.java | |
parent | 4a6b7cb235c305761af5d7f40e74d4704e5058c8 (diff) | |
download | android_packages_apps_ExactCalculator-013969e98ce9e3eb4f87ec6159b06a74d07b2592.tar.gz android_packages_apps_ExactCalculator-013969e98ce9e3eb4f87ec6159b06a74d07b2592.tar.bz2 android_packages_apps_ExactCalculator-013969e98ce9e3eb4f87ec6159b06a74d07b2592.zip |
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
Diffstat (limited to 'src/com/android/calculator2/Evaluator.java')
-rw-r--r-- | src/com/android/calculator2/Evaluator.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/com/android/calculator2/Evaluator.java b/src/com/android/calculator2/Evaluator.java index 8b162c2..6af3043 100644 --- a/src/com/android/calculator2/Evaluator.java +++ b/src/com/android/calculator2/Evaluator.java @@ -14,9 +14,6 @@ * limitations under the License. */ -// TODO: Replace explicit BigInteger arithmetic with BoundedRational. -// Let UI query the required number of digits to display exactly. - // // This implements the calculator evaluation logic. // An evaluation is started with a call to evaluateAndShowResult(). @@ -469,17 +466,28 @@ class Evaluator { // the string cache (presumed to contain at least 5 characters) // and possibly the exact integer i. private String getShortString(String cache, BigInteger i) { + // The result is internationalized; we only display it. + String res; + boolean need_ellipsis = false; + if (i != null && i.abs().compareTo(BIG_MILLION) < 0) { - return(i.toString()); + res = i.toString(); } else { - String res = cache.substring(0,5); + res = cache.substring(0,5); // Avoid a trailing period; doesn't work with ellipsis if (res.charAt(3) != '.') { res = res.substring(0,4); } - return res + mCalculator.getResources() - .getString(R.string.ellipsis); + // TODO: Don't do this in the unlikely case this is the + // full representation. + need_ellipsis = true; } + res = KeyMaps.translateResult(res); + if (need_ellipsis) { + res += mCalculator.getResources() + .getString(R.string.ellipsis); + } + return res; } // Return the most significant digit position in the given string @@ -680,9 +688,6 @@ class Evaluator { res = mCalculator.getResources().getString(R.string.ellipsis) + res.substring(1, res.length()); } - // TODO: This and/or CR formatting needs to deal with - // internationalization. - // Probably use java.text.DecimalFormatSymbols directly return res; } |