summaryrefslogtreecommitdiffstats
path: root/src/com/android/calculator2/CalculatorText.java
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2015-07-09 10:41:25 -0700
committerHans Boehm <hboehm@google.com>2015-07-20 16:30:43 -0700
commit8a4f81c5b30edd4e62d222a17f4e0e2140bfd99d (patch)
treeef2d97689c3e94231222a3ceb88df04c206b2477 /src/com/android/calculator2/CalculatorText.java
parent22c0a189febb3ee2d0149f6babc3a84e25e3594d (diff)
downloadandroid_packages_apps_ExactCalculator-8a4f81c5b30edd4e62d222a17f4e0e2140bfd99d.tar.gz
android_packages_apps_ExactCalculator-8a4f81c5b30edd4e62d222a17f4e0e2140bfd99d.tar.bz2
android_packages_apps_ExactCalculator-8a4f81c5b30edd4e62d222a17f4e0e2140bfd99d.zip
More correctly pronounce advanced operators in Talkback
Bug: 19190211 Bug: 19202945 Bug: 21052751 Bug: 19165054 Bug: 22594908 Add TtsSpans for operators that are otherwise misread by TalkBack. Force correct reading for some individual characters. This greatly improves Talkback for advanced operators in Calculator. This is imperfect. There is no guarantee that the strings I'm using will work in all languages. But they're almost certainly better than what we have now. And it makes parentheses and factorial usable, though perhaps a bit verbose. We also no longer pronounce "sine" as "sin". Removed some now obsolete TODO comments. Change-Id: I5236f682be828699e08dca04ee6fa073269964f6
Diffstat (limited to 'src/com/android/calculator2/CalculatorText.java')
-rw-r--r--src/com/android/calculator2/CalculatorText.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/com/android/calculator2/CalculatorText.java b/src/com/android/calculator2/CalculatorText.java
index 4b0b0c9..109c2af 100644
--- a/src/com/android/calculator2/CalculatorText.java
+++ b/src/com/android/calculator2/CalculatorText.java
@@ -224,11 +224,22 @@ public class CalculatorText extends AlignedTextView implements View.OnLongClickL
* Otherwise, e.g. after deletion, announce the entire new text.
*/
public void changeTextTo(CharSequence newText) {
- CharSequence oldText = getText();
+ final CharSequence oldText = getText();
if (startsWith(newText, oldText)) {
- int newLen = newText.length();
- int oldLen = oldText.length();
- if (oldLen != newLen) {
+ final int newLen = newText.length();
+ final int oldLen = oldText.length();
+ if (newLen == oldLen + 1) {
+ // The algorithm for pronouncing a single character doesn't seem
+ // to respect our hints. Don't give it the choice.
+ final char c = newText.charAt(oldLen);
+ final int id = KeyMaps.keyForChar(c);
+ final String descr = KeyMaps.toDescriptiveString(getContext(), id);
+ if (descr != null) {
+ announceForAccessibility(descr);
+ } else {
+ announceForAccessibility(String.valueOf(c));
+ }
+ } else if (newLen > oldLen) {
announceForAccessibility(newText.subSequence(oldLen, newLen));
}
} else {