Commit MetaInfo

Revisiona7237ea297393ddb1fac6cca311e6417cc6febda (tree)
Time2017-06-30 12:04:46
AuthorAng Iongchun <ang@iong...>
CommiterAng Iongchun

Log Message

flow: Merged <hotfix> 'fix-initial-keyboard' to <master> ('default').

Change Summary

Incremental Difference

diff -r 4719fcbb05af -r a7237ea29739 app/src/main/java/tw/iongchun/taigikbd/TKInputMethodService.java
--- a/app/src/main/java/tw/iongchun/taigikbd/TKInputMethodService.java Fri Jun 30 10:57:54 2017 +0800
+++ b/app/src/main/java/tw/iongchun/taigikbd/TKInputMethodService.java Fri Jun 30 11:04:46 2017 +0800
@@ -421,11 +421,12 @@
421421 }
422422
423423 protected void initViewState() {
424- // default text mode and subtype is TL
425- viewState = new TKViewState().setString(InputTitle, getInputTitleDisplay(SUBTYPE_TL))
426- .setInteger(MainKeyboard, KBD_TL)
427- .setInteger(TextKeyboard, KBD_TL)
428- .setInteger(CurrentKeyboard, KBD_TL);
424+ viewState = new TKViewState().setInteger(MainKeyboard, KBD_NONE)
425+ .setInteger(TextKeyboard, KBD_NONE)
426+ .setInteger(CurrentKeyboard, KBD_NONE)
427+ .setBoolean(MultiLine, false)
428+ .setInteger(AsciiPeriodAlt, KEYCODE_COMMA)
429+ .setBoolean(NumSym1Primes, false);
429430 }
430431
431432 protected void fineViewState() {
@@ -494,6 +495,7 @@
494495 // keyboards and keys
495496
496497 // for TKViewState.MainKeyboard, TextKeyboard, CurrentKeyboard
498+ public static final int KBD_NONE = -1;
497499 public static final int KBD_TL = 0;
498500 public static final int KBD_POJ = 1;
499501 public static final int KBD_ASCII = 2;
@@ -1616,7 +1618,13 @@
16161618
16171619 protected void switchInputType(InputConnection ic, EditorInfo info) {
16181620 if (info.inputType == InputType.TYPE_NULL) {
1619- viewState = viewState.setString(InputTypeDisplay, "(null)");
1621+ // use ASCII keyboard without any text processing
1622+ inputState = inputState.setBoolean(CapState, info.initialCapsMode != 0);
1623+ viewState = viewState.setInteger(TextKeyboard, KBD_ASCII)
1624+ .setInteger(CurrentKeyboard, KBD_ASCII)
1625+ .setBoolean(ShiftState, inputState.getBoolean(CapState))
1626+ .setBoolean(NumSym1Primes, false)
1627+ .setString(InputTypeDisplay, "(null)");
16201628 return;
16211629 }
16221630 boolean fullScreen = isFullscreenMode();
@@ -1669,9 +1677,11 @@
16691677 }
16701678 }
16711679
1680+ inputState = inputState.setBoolean(CapState, false);
16721681 viewState = viewState.setInteger(CurrentKeyboard, KBD_NUMSYM1)
16731682 .setBoolean(ShiftState, false)
1674- .setBoolean(NumSym1Primes, false);
1683+ .setBoolean(NumSym1Primes, false)
1684+ .setInteger(TextKeyboard, KBD_ASCII);
16751685 break;
16761686 case InputType.TYPE_CLASS_DATETIME:
16771687 sb.append("dt");
@@ -1696,9 +1706,11 @@
16961706 sb.append(')');
16971707 }
16981708
1709+ inputState = inputState.setBoolean(CapState, false);
16991710 viewState = viewState.setInteger(CurrentKeyboard, KBD_NUMSYM1)
17001711 .setBoolean(ShiftState, false)
1701- .setBoolean(NumSym1Primes, true);
1712+ .setBoolean(NumSym1Primes, true)
1713+ .setInteger(TextKeyboard, KBD_ASCII);
17021714 break;
17031715 case InputType.TYPE_CLASS_NUMBER:
17041716 sb.append("number");
@@ -1739,9 +1751,11 @@
17391751 sb.append(')');
17401752 }
17411753
1754+ inputState = inputState.setBoolean(CapState, false);
17421755 viewState = viewState.setInteger(CurrentKeyboard, KBD_NUMSYM1)
17431756 .setBoolean(ShiftState, false)
1744- .setBoolean(NumSym1Primes, true);
1757+ .setBoolean(NumSym1Primes, true)
1758+ .setInteger(TextKeyboard, KBD_ASCII);
17451759 break;
17461760 case InputType.TYPE_CLASS_TEXT:
17471761 sb.append("text");
@@ -2196,6 +2210,11 @@
21962210 viewState = viewState.setInteger(ExpSelectionEnd, expEnd);
21972211 }
21982212
2213+ updateKeyboardView();
2214+ viewState = viewState.resetChanged();
2215+ }
2216+
2217+ private void updateKeyboardView() {
21992218 // keyboard
22002219 if (viewState.isChanged(InputTitle))
22012220 inputTitle.setText(viewState.getString(InputTitle));
@@ -2269,35 +2288,36 @@
22692288 }
22702289
22712290 // action key
2272- if (viewState.getInteger(ActionKeyType) == KEY_TYPE_LABEL) {
2273- if (currChanged || viewState.isAnyChanged(ActionKeyType, ActionKeyLabel)) {
2274- String label = viewState.getString(ActionKeyLabel);
2275- Keyboard.Key key = kbdKeys[KEY_ACTION][kbdIdx];
2276- key.label = label;
2277- key.icon = null;
2278- if (!allKeysChanged)
2279- kbdView.invalidateKey(keyIdxActions[kbdIdx]);
2280- }
2281- } else {
2282- if (currChanged || viewState.isAnyChanged(ActionKeyType, ActionKeyIconID)) {
2283- int iconID = viewState.getInteger(ActionKeyIconID);
2284- Drawable icon = getResources().getDrawable(iconID);
2285- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
2286- // TODO: theme
2287- icon.setTint(Color.WHITE);
2291+ if (viewState.contains(ActionKeyType)) {
2292+ if (viewState.getInteger(ActionKeyType) == KEY_TYPE_LABEL) {
2293+ if (currChanged || viewState.isAnyChanged(ActionKeyType, ActionKeyLabel)) {
2294+ String label = viewState.getString(ActionKeyLabel);
2295+ Keyboard.Key key = kbdKeys[KEY_ACTION][kbdIdx];
2296+ key.label = label;
2297+ key.icon = null;
2298+ if (!allKeysChanged)
2299+ kbdView.invalidateKey(keyIdxActions[kbdIdx]);
22882300 }
2289- log("key icon: ", icon);
2290- Keyboard.Key key = kbdKeys[KEY_ACTION][kbdIdx];
2291- key.label = null;
2292- key.icon = icon;
2293- if (!allKeysChanged)
2294- kbdView.invalidateKey(keyIdxActions[kbdIdx]);
2301+ } else {
2302+ if (currChanged || viewState.isAnyChanged(ActionKeyType, ActionKeyIconID)) {
2303+ int iconID = viewState.getInteger(ActionKeyIconID);
2304+ Drawable icon = getResources().getDrawable(iconID);
2305+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
2306+ // TODO: theme
2307+ icon.setTint(Color.WHITE);
2308+ }
2309+ log("key icon: ", icon);
2310+ Keyboard.Key key = kbdKeys[KEY_ACTION][kbdIdx];
2311+ key.label = null;
2312+ key.icon = icon;
2313+ if (!allKeysChanged)
2314+ kbdView.invalidateKey(keyIdxActions[kbdIdx]);
2315+ }
22952316 }
22962317 }
22972318
22982319 if (allKeysChanged)
22992320 kbdView.invalidateAllKeys();
2300- viewState = viewState.resetChanged();
23012321 }
23022322
23032323 @Override
@@ -2321,6 +2341,7 @@
23212341 if (ic == null) { // FIXME: why null?
23222342 log("InputConnection IS NULL!");
23232343 switchInputType(null, info);
2344+ updateKeyboardView();
23242345 } else {
23252346 ic.beginBatchEdit();
23262347 switchInputType(ic, info);
Show on old repository browser