aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java48
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java138
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java4
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
-rw-r--r--java/src/com/android/inputmethod/latin/LatinImeLogger.java4
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java31
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java36
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java34
9 files changed, 174 insertions, 129 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 7e7f2b871..a3f03f828 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -48,7 +48,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG;
- public static final boolean DEBUG_STATE = false;
public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916";
private static final int[] KEYBOARD_THEMES = {
@@ -138,7 +137,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mMainKeyboardId = getKeyboardId(editorInfo, false, false, settingsValues);
mSymbolsKeyboardId = getKeyboardId(editorInfo, true, false, settingsValues);
mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues);
- mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols));
+ mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols),
+ hasDistinctMultitouch());
} catch (RuntimeException e) {
Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e);
LatinImeLogger.logOnException(mMainKeyboardId.toString(), e);
@@ -318,7 +318,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
if (latinKeyboard == null)
return;
if (shiftMode == AUTOMATIC_SHIFT) {
- mState.setAutomaticTemporaryUpperCase();
latinKeyboard.setAutomaticTemporaryUpperCase();
} else {
final boolean shifted = (shiftMode == MANUAL_SHIFT);
@@ -326,11 +325,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
// state when shift key is pressed to go to normal mode.
// On the other hand, on distinct multi touch panel device, turning off the shift
// locked state with shift key pressing is handled by onReleaseShift().
- if (!hasDistinctMultitouch() && !shifted && latinKeyboard.isShiftLocked()) {
- mState.setShiftLocked(false);
+ if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) {
latinKeyboard.setShiftLocked(false);
}
- mState.setShifted(shifted);
latinKeyboard.setShifted(shifted);
}
mKeyboardView.invalidateAllKeys();
@@ -343,7 +340,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard == null)
return;
- mState.setShiftLocked(shiftLocked);
latinKeyboard.setShiftLocked(shiftLocked);
mKeyboardView.invalidateAllKeys();
if (!shiftLocked) {
@@ -358,9 +354,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Toggle keyboard shift state triggered by user touch event.
*/
public void toggleShift() {
- if (DEBUG_STATE) {
- Log.d(TAG, "toggleShift: " + mState);
- }
mState.onToggleShift(isAlphabetMode(), isSymbolShifted());
}
@@ -368,9 +361,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Toggle caps lock state triggered by user touch event.
*/
public void toggleCapsLock() {
- if (DEBUG_STATE) {
- Log.d(TAG, "toggleCapsLock: " + mState);
- }
mState.onToggleCapsLock(isAlphabetMode());
}
@@ -378,9 +368,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Toggle between alphabet and symbols modes triggered by user touch event.
*/
public void toggleAlphabetAndSymbols() {
- if (DEBUG_STATE) {
- Log.d(TAG, "toggleAlphabetAndSymbols: " + mState);
- }
mState.onToggleAlphabetAndSymbols(isAlphabetMode());
}
@@ -388,49 +375,26 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Update keyboard shift state triggered by connected EditText status change.
*/
public void updateShiftState() {
- if (DEBUG_STATE) {
- Log.d(TAG, "updateShiftState: " + mState
- + " autoCaps=" + mInputMethodService.getCurrentAutoCapsState());
- }
mState.onUpdateShiftState(isAlphabetMode(), mInputMethodService.getCurrentAutoCapsState());
}
public void onPressShift(boolean withSliding) {
- if (!isKeyboardAvailable())
- return;
- if (DEBUG_STATE) {
- Log.d(TAG, "onPressShift: " + mState + " sliding=" + withSliding);
- }
- mState.onPressShift(isAlphabetMode(), isSymbolShifted());
+ mState.onPressShift(isAlphabetMode(), isSymbolShifted(), withSliding);
}
public void onReleaseShift(boolean withSliding) {
- if (!isKeyboardAvailable())
- return;
- if (DEBUG_STATE) {
- Log.d(TAG, "onReleaseShift: " + mState + " sliding=" + withSliding);
- }
mState.onReleaseShift(isAlphabetMode(), isSymbolShifted(), withSliding);
}
public void onPressSymbol() {
- if (DEBUG_STATE) {
- Log.d(TAG, "onPressSymbol: " + mState);
- }
mState.onPressSymbol(isAlphabetMode());
}
public void onReleaseSymbol() {
- if (DEBUG_STATE) {
- Log.d(TAG, "onReleaseSymbol: " + mState);
- }
mState.onReleaseSymbol(isAlphabetMode());
}
public void onOtherKeyPressed() {
- if (DEBUG_STATE) {
- Log.d(TAG, "onOtherKeyPressed: " + mState);
- }
mState.onOtherKeyPressed();
}
@@ -481,10 +445,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Updates state machine to figure out when to automatically snap back to the previous mode.
*/
public void onCodeInput(int code) {
- if (DEBUG_STATE) {
- Log.d(TAG, "onCodeInput: code=" + code + " isSinglePointer=" + isSinglePointer()
- + " " + mState);
- }
mState.onCodeInput(isAlphabetMode(), isSymbolShifted(), code, isSinglePointer());
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
index 4a77e0735..11fb91a8c 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
@@ -18,11 +18,9 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log;
-import com.android.inputmethod.keyboard.KeyboardSwitcher;
-
public class KeyboardShiftState {
private static final String TAG = KeyboardShiftState.class.getSimpleName();
- private static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
+ private static final boolean DEBUG = false;
private static final int NORMAL = 0;
private static final int MANUAL_SHIFTED = 1;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
index c952ea62a..f7ec08dab 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
@@ -22,6 +22,12 @@ import android.util.Log;
import com.android.inputmethod.keyboard.Keyboard;
// TODO: Add unit tests
+/**
+ * Keyboard state machine.
+ *
+ * This class contains all keyboard state transition logic.
+ * TODO: List up input events and actions.
+ */
public class KeyboardState {
private static final String TAG = KeyboardState.class.getSimpleName();
private static final boolean DEBUG_STATE = false;
@@ -53,6 +59,7 @@ public class KeyboardState {
private int mSwitchState = SWITCH_STATE_ALPHA;
private String mLayoutSwitchBackSymbols;
+ private boolean mHasDistinctMultitouch;
private final SwitchActions mSwitchActions;
@@ -70,8 +77,12 @@ public class KeyboardState {
mSwitchActions = switchActions;
}
- public void onLoadKeyboard(String layoutSwitchBackSymbols) {
+ public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onLoadKeyboard");
+ }
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
+ mHasDistinctMultitouch = hasDistinctMultitouch;
mKeyboardShiftState.setShifted(false);
mKeyboardShiftState.setShiftLocked(false);
mShiftKeyState.onRelease();
@@ -93,7 +104,7 @@ public class KeyboardState {
}
state.mIsValid = true;
if (DEBUG_STATE) {
- Log.d(TAG, "save: alphabet=" + state.mIsAlphabetMode
+ Log.d(TAG, "onSaveKeyboardState: alphabet=" + state.mIsAlphabetMode
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
}
}
@@ -101,7 +112,8 @@ public class KeyboardState {
private void onRestoreKeyboardState() {
final SavedKeyboardState state = mSavedKeyboardState;
if (DEBUG_STATE) {
- Log.d(TAG, "restore: valid=" + state.mIsValid + " alphabet=" + state.mIsAlphabetMode
+ Log.d(TAG, "onRestoreKeyboardState: valid=" + state.mIsValid
+ + " alphabet=" + state.mIsAlphabetMode
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
}
if (!state.mIsValid || state.mIsAlphabetMode) {
@@ -118,10 +130,9 @@ public class KeyboardState {
state.mIsValid = false;
if (state.mIsAlphabetMode) {
- mSwitchActions.setShiftLocked(state.mIsShiftLocked);
+ setShiftLocked(state.mIsShiftLocked);
if (!state.mIsShiftLocked) {
- mSwitchActions.setShifted(
- state.mIsShifted ? SwitchActions.MANUAL_SHIFT : SwitchActions.UNSHIFT);
+ setShifted(state.mIsShifted ? SwitchActions.MANUAL_SHIFT : SwitchActions.UNSHIFT);
}
}
}
@@ -150,19 +161,33 @@ public class KeyboardState {
return mKeyboardShiftState.isManualTemporaryUpperCaseFromAuto();
}
- // TODO: Get rid of this method
- public void setShifted(boolean shifted) {
- mKeyboardShiftState.setShifted(shifted);
+ private void setShifted(int shiftMode) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
+ }
+ if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) {
+ mKeyboardShiftState.setAutomaticTemporaryUpperCase();
+ } else {
+ // TODO: Duplicated logic in KeyboardSwitcher#setShifted()
+ final boolean shifted = (shiftMode == SwitchActions.MANUAL_SHIFT);
+ // On non-distinct multi touch panel device, we should also turn off the shift locked
+ // state when shift key is pressed to go to normal mode.
+ // On the other hand, on distinct multi touch panel device, turning off the shift
+ // locked state with shift key pressing is handled by onReleaseShift().
+ if (!mHasDistinctMultitouch && !shifted && isShiftLocked()) {
+ mKeyboardShiftState.setShiftLocked(false);
+ }
+ mKeyboardShiftState.setShifted(shifted);
+ }
+ mSwitchActions.setShifted(shiftMode);
}
- // TODO: Get rid of this method
- public void setShiftLocked(boolean shiftLocked) {
+ private void setShiftLocked(boolean shiftLocked) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked);
+ }
mKeyboardShiftState.setShiftLocked(shiftLocked);
- }
-
- // TODO: Get rid of this method
- public void setAutomaticTemporaryUpperCase() {
- mKeyboardShiftState.setAutomaticTemporaryUpperCase();
+ mSwitchActions.setShiftLocked(shiftLocked);
}
private void toggleAlphabetAndSymbols(boolean isAlphabetMode) {
@@ -182,25 +207,37 @@ public class KeyboardState {
}
private void setAlphabetKeyboard() {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "setAlphabetKeyboard");
+ }
mSwitchActions.setAlphabetKeyboard();
mSwitchState = SWITCH_STATE_ALPHA;
- mSwitchActions.setShiftLocked(mPrevMainKeyboardWasShiftLocked);
+ setShiftLocked(mPrevMainKeyboardWasShiftLocked);
mPrevMainKeyboardWasShiftLocked = false;
}
private void setSymbolsKeyboard() {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "setSymbolsKeyboard");
+ }
mPrevMainKeyboardWasShiftLocked = isShiftLocked();
mSwitchActions.setSymbolsKeyboard();
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
}
private void setSymbolsShiftedKeyboard() {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "setSymbolsShiftedKeyboard");
+ }
mSwitchActions.setSymbolsShiftedKeyboard();
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
}
// TODO: Get rid of isAlphabetMode argument.
public void onPressSymbol(boolean isAlphabetMode) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onPressSymbol: " + this);
+ }
toggleAlphabetAndSymbols(isAlphabetMode);
mSymbolKeyState.onPress();
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
@@ -208,6 +245,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode argument.
public void onReleaseSymbol(boolean isAlphabetMode) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onReleaseSymbol: " + this);
+ }
// Snap back to the previous keyboard mode if the user chords the mode change key and
// another key, then releases the mode change key.
if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) {
@@ -217,19 +257,25 @@ public class KeyboardState {
}
public void onOtherKeyPressed() {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onOtherKeyPressed: " + this);
+ }
mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed();
}
// TODO: Get rid of isAlphabetMode argument.
public void onUpdateShiftState(boolean isAlphabetMode, boolean autoCaps) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onUpdateShiftState: " + this + " autoCaps=" + autoCaps);
+ }
if (isAlphabetMode) {
if (!isShiftLocked() && !mShiftKeyState.isIgnoring()) {
if (mShiftKeyState.isReleasing() && autoCaps) {
// Only when shift key is releasing, automatic temporary upper case will be set.
- mSwitchActions.setShifted(SwitchActions.AUTOMATIC_SHIFT);
+ setShifted(SwitchActions.AUTOMATIC_SHIFT);
} else {
- mSwitchActions.setShifted(mShiftKeyState.isMomentary()
+ setShifted(mShiftKeyState.isMomentary()
? SwitchActions.MANUAL_SHIFT : SwitchActions.UNSHIFT);
}
}
@@ -241,17 +287,20 @@ public class KeyboardState {
}
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
- public void onPressShift(boolean isAlphabetMode, boolean isSymbolShifted) {
+ public void onPressShift(boolean isAlphabetMode, boolean isSymbolShifted, boolean withSliding) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onPressShift: " + this + " sliding=" + withSliding);
+ }
if (isAlphabetMode) {
if (isShiftLocked()) {
// Shift key is pressed while caps lock state, we will treat this state as shifted
// caps lock state and mark as if shift key pressed while normal state.
- mSwitchActions.setShifted(SwitchActions.MANUAL_SHIFT);
+ setShifted(SwitchActions.MANUAL_SHIFT);
mShiftKeyState.onPress();
} else if (isAutomaticTemporaryUpperCase()) {
// Shift key is pressed while automatic temporary upper case, we have to move to
// manual temporary upper case.
- mSwitchActions.setShifted(SwitchActions.MANUAL_SHIFT);
+ setShifted(SwitchActions.MANUAL_SHIFT);
mShiftKeyState.onPress();
} else if (isShiftedOrShiftLocked()) {
// In manual upper case state, we just record shift key has been pressing while
@@ -259,7 +308,7 @@ public class KeyboardState {
mShiftKeyState.onPressOnShifted();
} else {
// In base layout, chording or manual temporary upper case mode is started.
- mSwitchActions.setShifted(SwitchActions.MANUAL_SHIFT);
+ setShifted(SwitchActions.MANUAL_SHIFT);
mShiftKeyState.onPress();
}
} else {
@@ -273,26 +322,29 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onReleaseShift(boolean isAlphabetMode, boolean isSymbolShifted,
boolean withSliding) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onReleaseShift: " + this + " sliding=" + withSliding);
+ }
if (isAlphabetMode) {
final boolean isShiftLocked = isShiftLocked();
if (mShiftKeyState.isMomentary()) {
// After chording input while normal state.
- mSwitchActions.setShifted(SwitchActions.UNSHIFT);
+ setShifted(SwitchActions.UNSHIFT);
} else if (isShiftLocked && !isShiftLockShifted() && (mShiftKeyState.isPressing()
|| mShiftKeyState.isPressingOnShifted()) && !withSliding) {
// Shift has been long pressed, ignore this release.
} else if (isShiftLocked && !mShiftKeyState.isIgnoring() && !withSliding) {
// Shift has been pressed without chording while caps lock state.
- mSwitchActions.setShiftLocked(false);
+ setShiftLocked(false);
} else if (isShiftedOrShiftLocked() && mShiftKeyState.isPressingOnShifted()
&& !withSliding) {
// Shift has been pressed without chording while shifted state.
- mSwitchActions.setShifted(SwitchActions.UNSHIFT);
+ setShifted(SwitchActions.UNSHIFT);
} else if (isManualTemporaryUpperCaseFromAuto() && mShiftKeyState.isPressing()
&& !withSliding) {
// Shift has been pressed without chording while manual temporary upper case
// transited from automatic temporary upper case.
- mSwitchActions.setShifted(SwitchActions.UNSHIFT);
+ setShifted(SwitchActions.UNSHIFT);
}
} else {
// In symbol mode, snap back to the previous keyboard mode if the user chords the shift
@@ -307,6 +359,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onCancelInput(boolean isAlphabetMode, boolean isSymbolShifted,
boolean isSinglePointer) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onCancelInput: isSinglePointer=" + isSinglePointer + " " + this);
+ }
// Snap back to the previous keyboard mode if the user cancels sliding input.
if (isSinglePointer) {
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
@@ -335,6 +390,10 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onCodeInput(boolean isAlphabetMode, boolean isSymbolShifted, int code,
boolean isSinglePointer) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onCodeInput: code=" + code + " isSinglePointer=" + isSinglePointer
+ + " " + this);
+ }
switch (mSwitchState) {
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
// Only distinct multi touch devices can be in this state.
@@ -399,9 +458,12 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onToggleShift(boolean isAlphabetMode, boolean isSymbolShifted) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onToggleShift: " + this);
+ }
if (isAlphabetMode) {
- mSwitchActions.setShifted(
- isShiftedOrShiftLocked() ? SwitchActions.UNSHIFT : SwitchActions.MANUAL_SHIFT);
+ setShifted(isShiftedOrShiftLocked()
+ ? SwitchActions.UNSHIFT : SwitchActions.MANUAL_SHIFT);
} else {
toggleShiftInSymbols(isSymbolShifted);
}
@@ -409,23 +471,37 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode arguments.
public void onToggleCapsLock(boolean isAlphabetMode) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onToggleCapsLock: " + this);
+ }
if (isAlphabetMode) {
if (isShiftLocked()) {
- mSwitchActions.setShiftLocked(false);
+ setShiftLocked(false);
// Shift key is long pressed while caps lock state, we will toggle back to normal
// state. And mark as if shift key is released.
mShiftKeyState.onRelease();
} else {
- mSwitchActions.setShiftLocked(true);
+ setShiftLocked(true);
}
}
}
// TODO: Get rid of isAlphabetMode arguments.
public void onToggleAlphabetAndSymbols(boolean isAlphabetMode) {
+ if (DEBUG_STATE) {
+ Log.d(TAG, "onToggleAlphabetAndSymbols: " + this);
+ }
toggleAlphabetAndSymbols(isAlphabetMode);
}
+ private static String shiftModeToString(int shiftMode) {
+ switch (shiftMode) {
+ case SwitchActions.UNSHIFT: return "UNSHIFT";
+ case SwitchActions.MANUAL_SHIFT: return "MANUAL";
+ case SwitchActions.AUTOMATIC_SHIFT: return "AUTOMATIC";
+ default: return null;
+ }
+ }
private static String switchStateToString(int switchState) {
switch (switchState) {
case SWITCH_STATE_ALPHA: return "ALPHA";
diff --git a/java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java b/java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java
index f8620910a..f95c91636 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java
@@ -18,11 +18,9 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log;
-import com.android.inputmethod.keyboard.KeyboardSwitcher;
-
/* package */ class ModifierKeyState {
protected static final String TAG = "ModifierKeyState";
- protected static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
+ protected static final boolean DEBUG = false;
protected static final int RELEASING = 0;
protected static final int PRESSING = 1;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3023ebc1f..985793ef3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2323,7 +2323,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// update keypress sound volume
private void updateSoundEffectVolume() {
- mFxVolume = Utils.getCurrentKeypressSoundVolume(mPrefs, mResources);
+ mFxVolume = SettingsValues.getCurrentKeypressSoundVolume(mPrefs, mResources);
}
// update flags for silent mode
@@ -2336,7 +2336,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
private void updateKeypressVibrationDuration() {
- mKeypressVibrationDuration = Utils.getCurrentVibrationDuration(mPrefs, mResources);
+ mKeypressVibrationDuration = SettingsValues.getCurrentVibrationDuration(mPrefs, mResources);
}
private void playKeyClick(int primaryCode) {
diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
index ae8eb374b..9903209dd 100644
--- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java
+++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
@@ -78,4 +78,8 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
public static void onPrintAllUsabilityStudyLogs() {
}
+
+ public static boolean isResearcherPackage() {
+ return false;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 27003280c..6558c3ca3 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -242,12 +242,21 @@ public class Settings extends InputMethodSettingsActivity
textCorrectionGroup.removePreference(dictionaryLink);
}
- final boolean showUsabilityModeStudyOption = res.getBoolean(
- R.bool.config_enable_usability_study_mode_option);
- if (!showUsabilityModeStudyOption || !ENABLE_EXPERIMENTAL_SETTINGS) {
- final Preference pref = findPreference(PREF_USABILITY_STUDY_MODE);
- if (pref != null) {
- miscSettings.removePreference(pref);
+ final boolean isResearcherPackage = LatinImeLogger.isResearcherPackage();
+ final boolean showUsabilityStudyModeOption =
+ res.getBoolean(R.bool.config_enable_usability_study_mode_option)
+ || isResearcherPackage || ENABLE_EXPERIMENTAL_SETTINGS;
+ final Preference usabilityStudyPref = findPreference(PREF_USABILITY_STUDY_MODE);
+ if (!showUsabilityStudyModeOption) {
+ if (usabilityStudyPref != null) {
+ miscSettings.removePreference(usabilityStudyPref);
+ }
+ }
+ if (isResearcherPackage) {
+ if (usabilityStudyPref instanceof CheckBoxPreference) {
+ CheckBoxPreference checkbox = (CheckBoxPreference)usabilityStudyPref;
+ checkbox.setChecked(prefs.getBoolean(PREF_USABILITY_STUDY_MODE, true));
+ checkbox.setSummary(R.string.settings_warning_researcher_mode);
}
}
@@ -447,7 +456,7 @@ public class Settings extends InputMethodSettingsActivity
SharedPreferences sp, Resources res) {
if (mKeypressVibrationDurationSettingsPref != null) {
mKeypressVibrationDurationSettingsPref.setSummary(
- Utils.getCurrentVibrationDuration(sp, res)
+ SettingsValues.getCurrentVibrationDuration(sp, res)
+ res.getString(R.string.settings_ms));
}
}
@@ -475,7 +484,7 @@ public class Settings extends InputMethodSettingsActivity
});
final View v = context.getLayoutInflater().inflate(
R.layout.vibration_settings_dialog, null);
- final int currentMs = Utils.getCurrentVibrationDuration(
+ final int currentMs = SettingsValues.getCurrentVibrationDuration(
getPreferenceManager().getSharedPreferences(), getResources());
mKeypressVibrationDurationSettingsTextView = (TextView)v.findViewById(R.id.vibration_value);
final SeekBar sb = (SeekBar)v.findViewById(R.id.vibration_settings);
@@ -504,8 +513,8 @@ public class Settings extends InputMethodSettingsActivity
private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) {
if (mKeypressSoundVolumeSettingsPref != null) {
- mKeypressSoundVolumeSettingsPref.setSummary(
- String.valueOf((int)(Utils.getCurrentKeypressSoundVolume(sp, res) * 100)));
+ mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf(
+ (int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100)));
}
}
@@ -534,7 +543,7 @@ public class Settings extends InputMethodSettingsActivity
});
final View v = context.getLayoutInflater().inflate(
R.layout.sound_effect_volume_dialog, null);
- final int currentVolumeInt = (int)(Utils.getCurrentKeypressSoundVolume(
+ final int currentVolumeInt = (int)(SettingsValues.getCurrentKeypressSoundVolume(
getPreferenceManager().getSharedPreferences(), getResources()) * 100);
mKeypressSoundVolumeSettingsTextView =
(TextView)v.findViewById(R.id.sound_effect_volume_value);
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 4aa683abe..50fa69401 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -19,11 +19,13 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
+import android.os.Build;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.compat.VibratorCompatWrapper;
+import com.android.inputmethod.latin.R.array;
import java.util.Arrays;
import java.util.Locale;
@@ -241,4 +243,36 @@ public class SettingsValues {
public boolean isVoiceKeyOnMain() {
return mVoiceKeyOnMain;
}
-} \ No newline at end of file
+
+ public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) {
+ final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f);
+ if (volume >= 0) {
+ return volume;
+ }
+
+ final String[] volumePerHardwareList = res.getStringArray(R.array.keypress_volumes);
+ final String hardwarePrefix = Build.HARDWARE + ",";
+ for (final String element : volumePerHardwareList) {
+ if (element.startsWith(hardwarePrefix)) {
+ return Float.parseFloat(element.substring(element.lastIndexOf(',') + 1));
+ }
+ }
+ return -1.0f;
+ }
+
+ public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) {
+ final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1);
+ if (ms >= 0) {
+ return ms;
+ }
+ final String[] durationPerHardwareList = res.getStringArray(
+ R.array.keypress_vibration_durations);
+ final String hardwarePrefix = Build.HARDWARE + ",";
+ for (final String element : durationPerHardwareList) {
+ if (element.startsWith(hardwarePrefix)) {
+ return (int)Long.parseLong(element.substring(element.lastIndexOf(',') + 1));
+ }
+ }
+ return -1;
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index 3d0aa09f1..7f507fe02 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -17,11 +17,9 @@
package com.android.inputmethod.latin;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.os.AsyncTask;
-import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Process;
@@ -778,38 +776,6 @@ public class Utils {
return s.toUpperCase(locale).charAt(0) + s.substring(1);
}
- public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) {
- final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1);
- if (ms >= 0) {
- return ms;
- }
- final String[] durationPerHardwareList = res.getStringArray(
- R.array.keypress_vibration_durations);
- final String hardwarePrefix = Build.HARDWARE + ",";
- for (final String element : durationPerHardwareList) {
- if (element.startsWith(hardwarePrefix)) {
- return (int)Long.parseLong(element.substring(element.lastIndexOf(',') + 1));
- }
- }
- return -1;
- }
-
- public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) {
- final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f);
- if (volume >= 0) {
- return volume;
- }
-
- final String[] volumePerHardwareList = res.getStringArray(R.array.keypress_volumes);
- final String hardwarePrefix = Build.HARDWARE + ",";
- for (final String element : volumePerHardwareList) {
- if (element.startsWith(hardwarePrefix)) {
- return Float.parseFloat(element.substring(element.lastIndexOf(',') + 1));
- }
- }
- return -1.0f;
- }
-
public static boolean willAutoCorrect(SuggestedWords suggestions) {
return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
&& !suggestions.shouldBlockAutoCorrection();