summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2015-05-19 01:49:15 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-05-19 01:49:15 +0000
commit1da5a770ae98001d90d3a54ad9f689252a646cf1 (patch)
treec7028034e54aeb716e5463be967f3930a68a1264
parent7cb769ef9ddb31ea46292fda30db89ce2706f7f9 (diff)
parentffda52845ca6cca5f72795706988a11f6bcf5b03 (diff)
downloadandroid_packages_apps_ExactCalculator-1da5a770ae98001d90d3a54ad9f689252a646cf1.tar.gz
android_packages_apps_ExactCalculator-1da5a770ae98001d90d3a54ad9f689252a646cf1.tar.bz2
android_packages_apps_ExactCalculator-1da5a770ae98001d90d3a54ad9f689252a646cf1.zip
am ffda5284: Handle placeholder characters during translation
* commit 'ffda52845ca6cca5f72795706988a11f6bcf5b03': Handle placeholder characters during translation
-rw-r--r--src/com/android/calculator2/Evaluator.java11
-rw-r--r--src/com/android/calculator2/KeyMaps.java32
2 files changed, 24 insertions, 19 deletions
diff --git a/src/com/android/calculator2/Evaluator.java b/src/com/android/calculator2/Evaluator.java
index ad232db..6f508c4 100644
--- a/src/com/android/calculator2/Evaluator.java
+++ b/src/com/android/calculator2/Evaluator.java
@@ -131,15 +131,6 @@ class Evaluator {
static final BigInteger BIG_MILLION = BigInteger.valueOf(1000000);
- /**
- * Character used as a placeholder for digits that are currently unknown in a result that is
- * being computed.
- * <p/>
- * Note: the character must correspond closely to the width of a digit, otherwise the UI will
- * visibly shift once the computation is finished.
- */
- private static final char CHAR_DIGIT_UNKNOWN = '\u2007';
-
private static final int EXTRA_DIGITS = 20;
// Extra computed digits to minimize probably we will have
// to change our minds about digits we already displayed.
@@ -583,7 +574,7 @@ class Evaluator {
private String getPadding(int n) {
StringBuilder padding = new StringBuilder();
for (int i = 0; i < n; ++i) {
- padding.append(CHAR_DIGIT_UNKNOWN);
+ padding.append(' '); // To be replaced during final translation.
}
return padding.toString();
}
diff --git a/src/com/android/calculator2/KeyMaps.java b/src/com/android/calculator2/KeyMaps.java
index 493ec01..0f0f54d 100644
--- a/src/com/android/calculator2/KeyMaps.java
+++ b/src/com/android/calculator2/KeyMaps.java
@@ -27,6 +27,9 @@ import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
+// This is a collection of various mapping functions between key ids,
+// characters, internationalized and noninternationalized characters, etc.
+//
// KeyMap instances are not meaningful; everything here is static.
// All functions are either pure, or are assumed to be called only from
// a single UI thread.
@@ -161,30 +164,40 @@ public class KeyMaps {
}
}
- static char mDecimalPt =
- DecimalFormatSymbols.getInstance().getDecimalSeparator();
+ private static char mDecimalPt =
+ DecimalFormatSymbols.getInstance().getDecimalSeparator();
+
+ private static char mPiChar;
- static char mPiChar;
+ private static char mFactChar;
- 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
+ * then use this as a replacement during final translation.
+ * <p/>
+ * Note: the character must correspond closely to the width of a digit,
+ * otherwise the UI will visibly shift once the computation is finished.
+ */
+ private static final char CHAR_DIGIT_UNKNOWN = '\u2007';
- static HashMap<String, Integer> sKeyValForFun;
+ private static HashMap<String, Integer> sKeyValForFun;
// Key value corresponding to given function name.
// We include both localized and English names.
- static HashMap<Character, String> sOutputForResultChar;
+ private static HashMap<Character, String> sOutputForResultChar;
// Result string corresponding to a character in the
// calculator result.
// The string values in the map are expected to be one character
// long.
- static String sLocaleForMaps = "none";
+ private static String sLocaleForMaps = "none";
// Locale string corresponding to preceding map and character
// constants.
// We recompute the map if this is not the current locale.
- static Activity mActivity; // Activity to use for looking up
- // buttons.
+ private static Activity mActivity; // Activity to use for looking up
+ // buttons.
// Called only by UI thread.
public static void setActivity(Activity a) {
@@ -295,6 +308,7 @@ public class KeyMaps {
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('/', "/");
// Translate numbers for fraction display, but not