diff options
| author | Yohei Yukawa <yukawa@google.com> | 2016-04-10 20:28:40 -0700 |
|---|---|---|
| committer | Yohei Yukawa <yukawa@google.com> | 2016-04-10 20:28:40 -0700 |
| commit | d39ae854820edebe3f1cb8580117c451ffa5c4ec (patch) | |
| tree | 932863c8d16591e73ac9621b4d5da1ec3e782e6b /core/java | |
| parent | cf45224a81272d783314a77fd8671d711f4c6a68 (diff) | |
Shift+Meta+Space should reverse-rotate subtypes.
This is a follow up CL to my previous CL [1], which added a new key
binding Meta+Space to rotate enabled IME subtypes. With this CL,
Shift+Meta+Space starts reverse-rotating enabled IME subtypes as
originally planed.
[1]: I4005692215edfcf8bed3e86b1e07000148f986f5
ae61f7118a92e097e854c840d5726c0920f5db0e
Bug: 25753404
Bug: 28103839
Change-Id: I3694edd80be6dfe18b90360e24ae4d451b331928
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java b/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java index 85cc841379cf..46b49de7fc80 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java +++ b/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java @@ -285,7 +285,7 @@ public class InputMethodSubtypeSwitchingController { } public ImeSubtypeListItem getNextInputMethodLocked(boolean onlyCurrentIme, - InputMethodInfo imi, InputMethodSubtype subtype) { + InputMethodInfo imi, InputMethodSubtype subtype, boolean forward) { if (imi == null) { return null; } @@ -297,8 +297,9 @@ public class InputMethodSubtypeSwitchingController { return null; } final int N = mImeSubtypeList.size(); - for (int offset = 1; offset < N; ++offset) { + for (int i = 1; i < N; ++i) { // Start searching the next IME/subtype from the next of the current index. + final int offset = forward ? i : N - i; final int candidateIndex = (currentIndex + offset) % N; final ImeSubtypeListItem candidate = mImeSubtypeList.get(candidateIndex); // Skip if searching inside the current IME only, but the candidate is not @@ -371,7 +372,7 @@ public class InputMethodSubtypeSwitchingController { } public ImeSubtypeListItem getNextInputMethodLocked(boolean onlyCurrentIme, - InputMethodInfo imi, InputMethodSubtype subtype) { + InputMethodInfo imi, InputMethodSubtype subtype, boolean forward) { int currentUsageRank = getUsageRank(imi, subtype); if (currentUsageRank < 0) { if (DEBUG) { @@ -381,7 +382,8 @@ public class InputMethodSubtypeSwitchingController { } final int N = mUsageHistoryOfSubtypeListItemIndex.length; for (int i = 1; i < N; i++) { - final int subtypeListItemRank = (currentUsageRank + i) % N; + final int offset = forward ? i : N - i; + final int subtypeListItemRank = (currentUsageRank + offset) % N; final int subtypeListItemIndex = mUsageHistoryOfSubtypeListItemIndex[subtypeListItemRank]; final ImeSubtypeListItem subtypeListItem = @@ -455,16 +457,16 @@ public class InputMethodSubtypeSwitchingController { } public ImeSubtypeListItem getNextInputMethod(boolean onlyCurrentIme, InputMethodInfo imi, - InputMethodSubtype subtype) { + InputMethodSubtype subtype, boolean forward) { if (imi == null) { return null; } if (imi.supportsSwitchingToNextInputMethod()) { return mSwitchingAwareRotationList.getNextInputMethodLocked(onlyCurrentIme, imi, - subtype); + subtype, forward); } else { return mSwitchingUnawareRotationList.getNextInputMethodLocked(onlyCurrentIme, imi, - subtype); + subtype, forward); } } @@ -532,14 +534,14 @@ public class InputMethodSubtypeSwitchingController { } public ImeSubtypeListItem getNextInputMethodLocked(boolean onlyCurrentIme, InputMethodInfo imi, - InputMethodSubtype subtype) { + InputMethodSubtype subtype, boolean forward) { if (mController == null) { if (DEBUG) { Log.e(TAG, "mController shouldn't be null."); } return null; } - return mController.getNextInputMethod(onlyCurrentIme, imi, subtype); + return mController.getNextInputMethod(onlyCurrentIme, imi, subtype, forward); } public List<ImeSubtypeListItem> getSortedInputMethodAndSubtypeListLocked( |
