Fix caps lock key behavior
Fix the issue introduced by Idfe69978. Bug: 5708602 Change-Id: I4265822b7d33417b87b3e7e3f49250ac5d2ecdda
This commit is contained in:
parent
8a70e70c84
commit
e466583ddc
2 changed files with 11 additions and 22 deletions
|
@ -21,6 +21,7 @@ import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeyboardShiftState;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -114,13 +115,8 @@ public class Keyboard {
|
||||||
|
|
||||||
private final ProximityInfo mProximityInfo;
|
private final ProximityInfo mProximityInfo;
|
||||||
|
|
||||||
// TODO: Remove these variables.
|
// TODO: Remove this variable.
|
||||||
private static final int UNSHIFT = 0;
|
private final KeyboardShiftState mShiftState = new KeyboardShiftState();
|
||||||
private static final int MANUAL_SHIFT = 1;
|
|
||||||
private static final int AUTOMATIC_SHIFT = 2;
|
|
||||||
private int mShiftMode;
|
|
||||||
private boolean mShifted;
|
|
||||||
private boolean mShiftLocked;
|
|
||||||
|
|
||||||
public Keyboard(KeyboardParams params) {
|
public Keyboard(KeyboardParams params) {
|
||||||
mId = params.mId;
|
mId = params.mId;
|
||||||
|
@ -181,44 +177,37 @@ public class Keyboard {
|
||||||
key.setHighlightOn(newShiftLockState);
|
key.setHighlightOn(newShiftLockState);
|
||||||
key.setIcon(newShiftLockState ? mShiftedIcons.get(key) : mUnshiftedIcons.get(key));
|
key.setIcon(newShiftLockState ? mShiftedIcons.get(key) : mUnshiftedIcons.get(key));
|
||||||
}
|
}
|
||||||
mShiftLocked = newShiftLockState;
|
mShiftState.setShiftLocked(newShiftLockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this method to KeyboardId.
|
// TODO: Move this method to KeyboardId.
|
||||||
public boolean isShiftLocked() {
|
public boolean isShiftLocked() {
|
||||||
return mShiftLocked;
|
return mShiftState.isShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this method.
|
// TODO: Remove this method.
|
||||||
public void setShifted(boolean newShiftState) {
|
public void setShifted(boolean newShiftState) {
|
||||||
mShiftMode = (newShiftState ? MANUAL_SHIFT : UNSHIFT);
|
if (!mShiftState.isShiftLocked()) {
|
||||||
setShiftedInternal(newShiftState);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Remove this method
|
|
||||||
private void setShiftedInternal(boolean newShiftState) {
|
|
||||||
if (!mShiftLocked) {
|
|
||||||
for (final Key key : mShiftKeys) {
|
for (final Key key : mShiftKeys) {
|
||||||
key.setIcon(newShiftState ? mShiftedIcons.get(key) : mUnshiftedIcons.get(key));
|
key.setIcon(newShiftState ? mShiftedIcons.get(key) : mUnshiftedIcons.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mShifted = newShiftState;
|
mShiftState.setShifted(newShiftState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this method to KeyboardId.
|
// TODO: Move this method to KeyboardId.
|
||||||
public boolean isShiftedOrShiftLocked() {
|
public boolean isShiftedOrShiftLocked() {
|
||||||
return mShifted || mShiftLocked;
|
return mShiftState.isShiftedOrShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this method
|
// TODO: Remove this method
|
||||||
public void setAutomaticTemporaryUpperCase() {
|
public void setAutomaticTemporaryUpperCase() {
|
||||||
mShiftMode = AUTOMATIC_SHIFT;
|
mShiftState.setAutomaticTemporaryUpperCase();
|
||||||
setShiftedInternal(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this method to KeyboardId.
|
// TODO: Move this method to KeyboardId.
|
||||||
public boolean isManualTemporaryUpperCase() {
|
public boolean isManualTemporaryUpperCase() {
|
||||||
return mShiftMode == MANUAL_SHIFT;
|
return mShiftState.isManualTemporaryUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this method.
|
// TODO: Remove this method.
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
|
|
||||||
/* package */ class KeyboardShiftState {
|
public class KeyboardShiftState {
|
||||||
private static final String TAG = KeyboardShiftState.class.getSimpleName();
|
private static final String TAG = KeyboardShiftState.class.getSimpleName();
|
||||||
private static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
|
private static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue