diff options
author | Hans Boehm <hboehm@google.com> | 2015-05-22 01:06:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-22 01:06:51 +0000 |
commit | b75677481375e48ab6e6365fdc343b103f9ec02a (patch) | |
tree | b3e93019d774f5f4f5870e77608e9b66ee2f84d0 /src | |
parent | 61568a15c8d88d86aba14a7800d0bfb46f22c8ba (diff) | |
parent | 425ed0a15c7c755a94701457b671b8b86765dc59 (diff) | |
download | android_packages_apps_ExactCalculator-b75677481375e48ab6e6365fdc343b103f9ec02a.tar.gz android_packages_apps_ExactCalculator-b75677481375e48ab6e6365fdc343b103f9ec02a.tar.bz2 android_packages_apps_ExactCalculator-b75677481375e48ab6e6365fdc343b103f9ec02a.zip |
Merge "Use correct decimal separator in result." into mnc-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calculator2/KeyMaps.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/calculator2/KeyMaps.java b/src/com/android/calculator2/KeyMaps.java index 0f0f54d..670f895 100644 --- a/src/com/android/calculator2/KeyMaps.java +++ b/src/com/android/calculator2/KeyMaps.java @@ -164,13 +164,13 @@ public class KeyMaps { } } - private static char mDecimalPt = - DecimalFormatSymbols.getInstance().getDecimalSeparator(); + // The following two are only used for recognizing additional + // input characters from a physical keyboard. They are not used + // for output internationalization. + private static char mDecimalPt; private static char mPiChar; - private static char mFactChar; - /** * Character used as a placeholder for digits that are currently unknown * in a result that is being computed. We initially generate blanks, and @@ -205,7 +205,7 @@ public class KeyMaps { } // Return the button id corresponding to the supplied character - // or NO_ID + // or return NO_ID. // Called only by UI thread. public static int keyForChar(char c) { validateMaps(); @@ -215,6 +215,7 @@ public class KeyMaps { } switch (c) { case '.': + case ',': return R.id.dec_point; case '-': return R.id.op_sub; @@ -297,17 +298,16 @@ public class KeyMaps { // Set locale-dependent character "constants" mDecimalPt = DecimalFormatSymbols.getInstance().getDecimalSeparator(); + // We recognize this in keyboard input, even if we use + // a different character. Resources res = mActivity.getResources(); - mPiChar = mFactChar = 0; + mPiChar = 0; String piString = res.getString(R.string.const_pi); if (piString.length() == 1) mPiChar = piString.charAt(0); - String factString = res.getString(R.string.op_fact); - if (factString.length() == 1) mFactChar = factString.charAt(0); sOutputForResultChar = new HashMap<Character, String>(); sOutputForResultChar.put('e', "E"); sOutputForResultChar.put('E', "E"); - sOutputForResultChar.put('.', String.valueOf(mDecimalPt)); sOutputForResultChar.put(' ', String.valueOf(CHAR_DIGIT_UNKNOWN)); sOutputForResultChar.put(ELLIPSIS.charAt(0), ELLIPSIS); sOutputForResultChar.put('/', "/"); @@ -315,6 +315,7 @@ public class KeyMaps { // the separating slash, which appears to be // universal. addButtonToOutputMap('-', R.id.op_sub); + addButtonToOutputMap('.', R.id.dec_point); for (int i = 0; i <= 9; ++i) { addButtonToOutputMap((char)('0' + i), keyForDigVal(i)); } |