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
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 @@
      * 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 {