Skip to content

Commit 3b2beee

Browse files
rkkrwittmane
andauthored
Remove alphabetShiftLockShifted state and check exit state from auto-capitalization (#239)
* Remove alphabetShiftLockShifted * don't mark the keyboard as manual shifted while pressing the shift key when it is already auto-shifted (#240) * don't mark the keyboard as manual shifted while pressing the shift key when it is already auto-shifted (#240) * Revert check for exit of auto shift Co-authored-by: wittmane <[email protected]>
1 parent a53ff30 commit 3b2beee

File tree

65 files changed

+80
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+80
-133
lines changed

app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/Key.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ private static boolean needsToUpcase(final int labelFlags, final int keyboardEle
423423
case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
424424
case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
425425
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
426-
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
427426
return true;
428427
default:
429428
return false;

app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/KeyboardId.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public final class KeyboardId {
4747
public static final int ELEMENT_ALPHABET_MANUAL_SHIFTED = 1;
4848
public static final int ELEMENT_ALPHABET_AUTOMATIC_SHIFTED = 2;
4949
public static final int ELEMENT_ALPHABET_SHIFT_LOCKED = 3;
50-
public static final int ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED = 4;
5150
public static final int ELEMENT_SYMBOLS = 5;
5251
public static final int ELEMENT_SYMBOLS_SHIFTED = 6;
5352
public static final int ELEMENT_PHONE = 7;
@@ -194,7 +193,6 @@ public static String elementIdToName(final int elementId) {
194193
case ELEMENT_ALPHABET_MANUAL_SHIFTED: return "alphabetManualShifted";
195194
case ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: return "alphabetAutomaticShifted";
196195
case ELEMENT_ALPHABET_SHIFT_LOCKED: return "alphabetShiftLocked";
197-
case ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: return "alphabetShiftLockShifted";
198196
case ELEMENT_SYMBOLS: return "symbols";
199197
case ELEMENT_SYMBOLS_SHIFTED: return "symbolsShifted";
200198
case ELEMENT_PHONE: return "phone";

app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/KeyboardSwitcher.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,6 @@ public void setAlphabetShiftLockedKeyboard() {
217217
setKeyboard(KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED, KeyboardSwitchState.OTHER);
218218
}
219219

220-
// Implements {@link KeyboardState.SwitchActions}.
221-
@Override
222-
public void setAlphabetShiftLockShiftedKeyboard() {
223-
if (DEBUG_ACTION) {
224-
Log.d(TAG, "setAlphabetShiftLockShiftedKeyboard");
225-
}
226-
setKeyboard(KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED, KeyboardSwitchState.OTHER);
227-
}
228-
229220
// Implements {@link KeyboardState.SwitchActions}.
230221
@Override
231222
public void setSymbolsKeyboard() {

app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/internal/AlphabetShiftState.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ public final class AlphabetShiftState {
2424

2525
private static final int UNSHIFTED = 0;
2626
private static final int MANUAL_SHIFTED = 1;
27-
private static final int MANUAL_SHIFTED_FROM_AUTO = 2;
28-
private static final int AUTOMATIC_SHIFTED = 3;
29-
private static final int SHIFT_LOCKED = 4;
30-
private static final int SHIFT_LOCK_SHIFTED = 5;
27+
private static final int AUTOMATIC_SHIFTED = 2;
28+
private static final int SHIFT_LOCKED = 3;
29+
private static final int SHIFT_LOCK_SHIFTED = 4;
3130

3231
private int mState = UNSHIFTED;
3332

@@ -38,17 +37,13 @@ public void setShifted(boolean newShiftState) {
3837
case UNSHIFTED:
3938
mState = MANUAL_SHIFTED;
4039
break;
41-
case AUTOMATIC_SHIFTED:
42-
mState = MANUAL_SHIFTED_FROM_AUTO;
43-
break;
4440
case SHIFT_LOCKED:
4541
mState = SHIFT_LOCK_SHIFTED;
4642
break;
4743
}
4844
} else {
4945
switch (oldState) {
5046
case MANUAL_SHIFTED:
51-
case MANUAL_SHIFTED_FROM_AUTO:
5247
case AUTOMATIC_SHIFTED:
5348
mState = UNSHIFTED;
5449
break;
@@ -67,7 +62,6 @@ public void setShiftLocked(boolean newShiftLockState) {
6762
switch (oldState) {
6863
case UNSHIFTED:
6964
case MANUAL_SHIFTED:
70-
case MANUAL_SHIFTED_FROM_AUTO:
7165
case AUTOMATIC_SHIFTED:
7266
mState = SHIFT_LOCKED;
7367
break;
@@ -101,12 +95,7 @@ public boolean isAutomaticShifted() {
10195
}
10296

10397
public boolean isManualShifted() {
104-
return mState == MANUAL_SHIFTED || mState == MANUAL_SHIFTED_FROM_AUTO
105-
|| mState == SHIFT_LOCK_SHIFTED;
106-
}
107-
108-
public boolean isManualShiftedFromAutomaticShifted() {
109-
return mState == MANUAL_SHIFTED_FROM_AUTO;
98+
return mState == MANUAL_SHIFTED || mState == SHIFT_LOCK_SHIFTED;
11099
}
111100

112101
@Override
@@ -118,7 +107,6 @@ private static String toString(int state) {
118107
switch (state) {
119108
case UNSHIFTED: return "UNSHIFTED";
120109
case MANUAL_SHIFTED: return "MANUAL_SHIFTED";
121-
case MANUAL_SHIFTED_FROM_AUTO: return "MANUAL_SHIFTED_FROM_AUTO";
122110
case AUTOMATIC_SHIFTED: return "AUTOMATIC_SHIFTED";
123111
case SHIFT_LOCKED: return "SHIFT_LOCKED";
124112
case SHIFT_LOCK_SHIFTED: return "SHIFT_LOCK_SHIFTED";

app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/internal/KeyboardState.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public interface SwitchActions {
4848
void setAlphabetManualShiftedKeyboard();
4949
void setAlphabetAutomaticShiftedKeyboard();
5050
void setAlphabetShiftLockedKeyboard();
51-
void setAlphabetShiftLockShiftedKeyboard();
5251
void setSymbolsKeyboard();
5352
void setSymbolsShiftedKeyboard();
5453

@@ -215,7 +214,6 @@ private void setShifted(final int shiftMode) {
215214
break;
216215
case SHIFT_LOCK_SHIFTED:
217216
mAlphabetShiftState.setShifted(true);
218-
mSwitchActions.setAlphabetShiftLockShiftedKeyboard();
219217
break;
220218
}
221219
}
@@ -353,7 +351,8 @@ public void onPressKey(final int code, final boolean isSinglePointer, final int
353351
// shifted mode.
354352
if (!isSinglePointer && mIsAlphabetMode
355353
&& autoCapsFlags != TextUtils.CAP_MODE_CHARACTERS) {
356-
final boolean needsToResetAutoCaps = mAlphabetShiftState.isAutomaticShifted()
354+
final boolean needsToResetAutoCaps =
355+
(mAlphabetShiftState.isAutomaticShifted() && !mShiftKeyState.isChording())
357356
|| (mAlphabetShiftState.isManualShifted() && mShiftKeyState.isReleasing());
358357
if (needsToResetAutoCaps) {
359358
mSwitchActions.setAlphabetKeyboard();
@@ -485,9 +484,8 @@ private void onPressShift() {
485484
setShifted(SHIFT_LOCK_SHIFTED);
486485
mShiftKeyState.onPress();
487486
} else if (mAlphabetShiftState.isAutomaticShifted()) {
488-
// Shift key is pressed while automatic shifted, we have to move to manual
489-
// shifted.
490-
setShifted(MANUAL_SHIFT);
487+
// Shift key pressed while automatic shifted isn't considered a manual shift
488+
// since it doesn't change the keyboard into a shifted state.
491489
mShiftKeyState.onPress();
492490
} else if (mAlphabetShiftState.isShiftedOrShiftLocked()) {
493491
// In manual shifted state, we just record shift key has been pressing while
@@ -545,10 +543,9 @@ private void onReleaseShift(final boolean withSliding, final int autoCapsFlags,
545543
// Shift has been pressed without chording while shifted state.
546544
setShifted(UNSHIFT);
547545
mIsInAlphabetUnshiftedFromShifted = true;
548-
} else if (mAlphabetShiftState.isManualShiftedFromAutomaticShifted()
549-
&& mShiftKeyState.isPressing() && !withSliding) {
550-
// Shift has been pressed without chording while manual shifted transited from
551-
// automatic shifted
546+
} else if (mAlphabetShiftState.isAutomaticShifted() && mShiftKeyState.isPressing()
547+
&& !withSliding) {
548+
// Shift has been pressed without chording while automatic shifted
552549
setShifted(UNSHIFT);
553550
mIsInAlphabetUnshiftedFromShifted = true;
554551
}

app/src/main/res/values/attrs.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@
322322
<enum name="alphabetManualShifted" value="1" />
323323
<enum name="alphabetAutomaticShifted" value="2" />
324324
<enum name="alphabetShiftLocked" value="3" />
325-
<enum name="alphabetShiftLockShifted" value="4" />
326325
<enum name="symbols" value="5" />
327326
<enum name="symbolsShifted" value="6" />
328327
<enum name="phone" value="7" />
@@ -391,7 +390,6 @@
391390
<enum name="alphabetManualShifted" value="1" />
392391
<enum name="alphabetAutomaticShifted" value="2" />
393392
<enum name="alphabetShiftLocked" value="3" />
394-
<enum name="alphabetShiftLockShifted" value="4" />
395393
<enum name="symbols" value="5" />
396394
<enum name="symbolsShifted" value="6" />
397395
<enum name="phone" value="7" />

app/src/main/res/xml-sw600dp/key_styles_common.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
>
2424
<switch>
2525
<case
26-
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLockShifted"
26+
latin:keyboardLayoutSetElement="alphabetManualShifted"
2727
>
2828
<key-style
2929
latin:styleName="hasShiftedLetterHintStyle"
@@ -55,7 +55,7 @@
5555
latin:parentStyle="baseForShiftKeyStyle" />
5656
</case>
5757
<case
58-
latin:keyboardLayoutSetElement="alphabetShiftLocked|alphabetShiftLockShifted"
58+
latin:keyboardLayoutSetElement="alphabetShiftLocked"
5959
>
6060
<key-style
6161
latin:styleName="shiftKeyStyle"
@@ -110,7 +110,7 @@
110110
latin:backgroundType="functional" />
111111
<switch>
112112
<case
113-
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLockShifted"
113+
latin:keyboardLayoutSetElement="alphabetManualShifted"
114114
latin:navigatePrevious="true"
115115
>
116116
<key-style

app/src/main/res/xml-sw600dp/key_styles_enter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<!-- Shift + Enter in textMultiLine field. -->
3737
<case
3838
latin:isMultiLine="true"
39-
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLockShifted"
39+
latin:keyboardLayoutSetElement="alphabetManualShifted"
4040
>
4141
<key-style
4242
latin:styleName="enterKeyStyle"

app/src/main/res/xml-sw600dp/keys_dvorak_123.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
latin:showExtraChars="true">
2828
<switch>
2929
<case
30-
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted"
30+
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked"
3131
>
3232
<Key
3333
latin:keySpec="&quot;"
@@ -64,7 +64,7 @@
6464
<case latin:showNumberRow="true">
6565
<switch>
6666
<case
67-
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted"
67+
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked"
6868
>
6969
<Key
7070
latin:keySpec="&quot;" />
@@ -89,7 +89,7 @@
8989
<default>
9090
<switch>
9191
<case
92-
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted"
92+
latin:keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked"
9393
>
9494
<Key
9595
latin:keySpec="&quot;"

app/src/main/res/xml-sw600dp/keys_pcqwerty2_right3.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
latin:additionalMoreKeys="\\|"
4242
latin:keyStyle="hasShiftedLetterHintStyle" />
4343
</case>
44-
<!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
44+
<!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked" -->
4545
<default>
4646
<Key
4747
latin:keySpec="{" />

0 commit comments

Comments
 (0)