am 784181e2: Merge "Cleanup debug logging code"

* commit '784181e29fc857cd3a628efa102dc84cd629feb8':
  Cleanup debug logging code
main
Tadashi G. Takaoka 2011-12-09 11:00:43 -08:00 committed by Android Git Automerger
commit 7fa66d6b78
4 changed files with 67 additions and 47 deletions

View File

@ -48,7 +48,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
SharedPreferences.OnSharedPreferenceChangeListener { SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = KeyboardSwitcher.class.getSimpleName(); private static final String TAG = KeyboardSwitcher.class.getSimpleName();
private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG; 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"; public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916";
private static final int[] KEYBOARD_THEMES = { private static final int[] KEYBOARD_THEMES = {
@ -355,9 +354,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Toggle keyboard shift state triggered by user touch event. * Toggle keyboard shift state triggered by user touch event.
*/ */
public void toggleShift() { public void toggleShift() {
if (DEBUG_STATE) {
Log.d(TAG, "toggleShift: " + mState);
}
mState.onToggleShift(isAlphabetMode(), isSymbolShifted()); mState.onToggleShift(isAlphabetMode(), isSymbolShifted());
} }
@ -365,9 +361,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Toggle caps lock state triggered by user touch event. * Toggle caps lock state triggered by user touch event.
*/ */
public void toggleCapsLock() { public void toggleCapsLock() {
if (DEBUG_STATE) {
Log.d(TAG, "toggleCapsLock: " + mState);
}
mState.onToggleCapsLock(isAlphabetMode()); mState.onToggleCapsLock(isAlphabetMode());
} }
@ -375,9 +368,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Toggle between alphabet and symbols modes triggered by user touch event. * Toggle between alphabet and symbols modes triggered by user touch event.
*/ */
public void toggleAlphabetAndSymbols() { public void toggleAlphabetAndSymbols() {
if (DEBUG_STATE) {
Log.d(TAG, "toggleAlphabetAndSymbols: " + mState);
}
mState.onToggleAlphabetAndSymbols(isAlphabetMode()); mState.onToggleAlphabetAndSymbols(isAlphabetMode());
} }
@ -385,49 +375,26 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Update keyboard shift state triggered by connected EditText status change. * Update keyboard shift state triggered by connected EditText status change.
*/ */
public void updateShiftState() { public void updateShiftState() {
if (DEBUG_STATE) {
Log.d(TAG, "updateShiftState: " + mState
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState());
}
mState.onUpdateShiftState(isAlphabetMode(), mInputMethodService.getCurrentAutoCapsState()); mState.onUpdateShiftState(isAlphabetMode(), mInputMethodService.getCurrentAutoCapsState());
} }
public void onPressShift(boolean withSliding) { public void onPressShift(boolean withSliding) {
if (!isKeyboardAvailable()) mState.onPressShift(isAlphabetMode(), isSymbolShifted(), withSliding);
return;
if (DEBUG_STATE) {
Log.d(TAG, "onPressShift: " + mState + " sliding=" + withSliding);
}
mState.onPressShift(isAlphabetMode(), isSymbolShifted());
} }
public void onReleaseShift(boolean withSliding) { public void onReleaseShift(boolean withSliding) {
if (!isKeyboardAvailable())
return;
if (DEBUG_STATE) {
Log.d(TAG, "onReleaseShift: " + mState + " sliding=" + withSliding);
}
mState.onReleaseShift(isAlphabetMode(), isSymbolShifted(), withSliding); mState.onReleaseShift(isAlphabetMode(), isSymbolShifted(), withSliding);
} }
public void onPressSymbol() { public void onPressSymbol() {
if (DEBUG_STATE) {
Log.d(TAG, "onPressSymbol: " + mState);
}
mState.onPressSymbol(isAlphabetMode()); mState.onPressSymbol(isAlphabetMode());
} }
public void onReleaseSymbol() { public void onReleaseSymbol() {
if (DEBUG_STATE) {
Log.d(TAG, "onReleaseSymbol: " + mState);
}
mState.onReleaseSymbol(isAlphabetMode()); mState.onReleaseSymbol(isAlphabetMode());
} }
public void onOtherKeyPressed() { public void onOtherKeyPressed() {
if (DEBUG_STATE) {
Log.d(TAG, "onOtherKeyPressed: " + mState);
}
mState.onOtherKeyPressed(); mState.onOtherKeyPressed();
} }
@ -478,10 +445,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
* Updates state machine to figure out when to automatically snap back to the previous mode. * Updates state machine to figure out when to automatically snap back to the previous mode.
*/ */
public void onCodeInput(int code) { public void onCodeInput(int code) {
if (DEBUG_STATE) {
Log.d(TAG, "onCodeInput: code=" + code + " isSinglePointer=" + isSinglePointer()
+ " " + mState);
}
mState.onCodeInput(isAlphabetMode(), isSymbolShifted(), code, isSinglePointer()); mState.onCodeInput(isAlphabetMode(), isSymbolShifted(), code, isSinglePointer());
} }

View File

@ -18,11 +18,9 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
public 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 = false;
private static final int NORMAL = 0; private static final int NORMAL = 0;
private static final int MANUAL_SHIFTED = 1; private static final int MANUAL_SHIFTED = 1;

View File

@ -78,6 +78,9 @@ public class KeyboardState {
} }
public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) { public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) {
if (DEBUG_STATE) {
Log.d(TAG, "onLoadKeyboard");
}
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols; mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
mHasDistinctMultitouch = hasDistinctMultitouch; mHasDistinctMultitouch = hasDistinctMultitouch;
mKeyboardShiftState.setShifted(false); mKeyboardShiftState.setShifted(false);
@ -101,7 +104,7 @@ public class KeyboardState {
} }
state.mIsValid = true; state.mIsValid = true;
if (DEBUG_STATE) { if (DEBUG_STATE) {
Log.d(TAG, "save: alphabet=" + state.mIsAlphabetMode Log.d(TAG, "onSaveKeyboardState: alphabet=" + state.mIsAlphabetMode
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted); + " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
} }
} }
@ -109,7 +112,8 @@ public class KeyboardState {
private void onRestoreKeyboardState() { private void onRestoreKeyboardState() {
final SavedKeyboardState state = mSavedKeyboardState; final SavedKeyboardState state = mSavedKeyboardState;
if (DEBUG_STATE) { 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); + " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
} }
if (!state.mIsValid || state.mIsAlphabetMode) { if (!state.mIsValid || state.mIsAlphabetMode) {
@ -158,6 +162,9 @@ public class KeyboardState {
} }
private void setShifted(int shiftMode) { private void setShifted(int shiftMode) {
if (DEBUG_STATE) {
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
}
if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) { if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) {
mKeyboardShiftState.setAutomaticTemporaryUpperCase(); mKeyboardShiftState.setAutomaticTemporaryUpperCase();
} else { } else {
@ -176,6 +183,9 @@ public class KeyboardState {
} }
private void setShiftLocked(boolean shiftLocked) { private void setShiftLocked(boolean shiftLocked) {
if (DEBUG_STATE) {
Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked);
}
mKeyboardShiftState.setShiftLocked(shiftLocked); mKeyboardShiftState.setShiftLocked(shiftLocked);
mSwitchActions.setShiftLocked(shiftLocked); mSwitchActions.setShiftLocked(shiftLocked);
} }
@ -197,6 +207,9 @@ public class KeyboardState {
} }
private void setAlphabetKeyboard() { private void setAlphabetKeyboard() {
if (DEBUG_STATE) {
Log.d(TAG, "setAlphabetKeyboard");
}
mSwitchActions.setAlphabetKeyboard(); mSwitchActions.setAlphabetKeyboard();
mSwitchState = SWITCH_STATE_ALPHA; mSwitchState = SWITCH_STATE_ALPHA;
setShiftLocked(mPrevMainKeyboardWasShiftLocked); setShiftLocked(mPrevMainKeyboardWasShiftLocked);
@ -204,18 +217,27 @@ public class KeyboardState {
} }
private void setSymbolsKeyboard() { private void setSymbolsKeyboard() {
if (DEBUG_STATE) {
Log.d(TAG, "setSymbolsKeyboard");
}
mPrevMainKeyboardWasShiftLocked = isShiftLocked(); mPrevMainKeyboardWasShiftLocked = isShiftLocked();
mSwitchActions.setSymbolsKeyboard(); mSwitchActions.setSymbolsKeyboard();
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
} }
private void setSymbolsShiftedKeyboard() { private void setSymbolsShiftedKeyboard() {
if (DEBUG_STATE) {
Log.d(TAG, "setSymbolsShiftedKeyboard");
}
mSwitchActions.setSymbolsShiftedKeyboard(); mSwitchActions.setSymbolsShiftedKeyboard();
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
} }
// TODO: Get rid of isAlphabetMode argument. // TODO: Get rid of isAlphabetMode argument.
public void onPressSymbol(boolean isAlphabetMode) { public void onPressSymbol(boolean isAlphabetMode) {
if (DEBUG_STATE) {
Log.d(TAG, "onPressSymbol: " + this);
}
toggleAlphabetAndSymbols(isAlphabetMode); toggleAlphabetAndSymbols(isAlphabetMode);
mSymbolKeyState.onPress(); mSymbolKeyState.onPress();
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL; mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
@ -223,6 +245,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode argument. // TODO: Get rid of isAlphabetMode argument.
public void onReleaseSymbol(boolean isAlphabetMode) { 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 // Snap back to the previous keyboard mode if the user chords the mode change key and
// another key, then releases the mode change key. // another key, then releases the mode change key.
if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) { if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) {
@ -232,12 +257,18 @@ public class KeyboardState {
} }
public void onOtherKeyPressed() { public void onOtherKeyPressed() {
if (DEBUG_STATE) {
Log.d(TAG, "onOtherKeyPressed: " + this);
}
mShiftKeyState.onOtherKeyPressed(); mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed();
} }
// TODO: Get rid of isAlphabetMode argument. // TODO: Get rid of isAlphabetMode argument.
public void onUpdateShiftState(boolean isAlphabetMode, boolean autoCaps) { public void onUpdateShiftState(boolean isAlphabetMode, boolean autoCaps) {
if (DEBUG_STATE) {
Log.d(TAG, "onUpdateShiftState: " + this + " autoCaps=" + autoCaps);
}
if (isAlphabetMode) { if (isAlphabetMode) {
if (!isShiftLocked() && !mShiftKeyState.isIgnoring()) { if (!isShiftLocked() && !mShiftKeyState.isIgnoring()) {
if (mShiftKeyState.isReleasing() && autoCaps) { if (mShiftKeyState.isReleasing() && autoCaps) {
@ -256,7 +287,10 @@ public class KeyboardState {
} }
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments. // 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 (isAlphabetMode) {
if (isShiftLocked()) { if (isShiftLocked()) {
// Shift key is pressed while caps lock state, we will treat this state as shifted // Shift key is pressed while caps lock state, we will treat this state as shifted
@ -288,6 +322,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments. // TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onReleaseShift(boolean isAlphabetMode, boolean isSymbolShifted, public void onReleaseShift(boolean isAlphabetMode, boolean isSymbolShifted,
boolean withSliding) { boolean withSliding) {
if (DEBUG_STATE) {
Log.d(TAG, "onReleaseShift: " + this + " sliding=" + withSliding);
}
if (isAlphabetMode) { if (isAlphabetMode) {
final boolean isShiftLocked = isShiftLocked(); final boolean isShiftLocked = isShiftLocked();
if (mShiftKeyState.isMomentary()) { if (mShiftKeyState.isMomentary()) {
@ -322,6 +359,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments. // TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onCancelInput(boolean isAlphabetMode, boolean isSymbolShifted, public void onCancelInput(boolean isAlphabetMode, boolean isSymbolShifted,
boolean isSinglePointer) { 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. // Snap back to the previous keyboard mode if the user cancels sliding input.
if (isSinglePointer) { if (isSinglePointer) {
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) { if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
@ -350,6 +390,10 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments. // TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onCodeInput(boolean isAlphabetMode, boolean isSymbolShifted, int code, public void onCodeInput(boolean isAlphabetMode, boolean isSymbolShifted, int code,
boolean isSinglePointer) { boolean isSinglePointer) {
if (DEBUG_STATE) {
Log.d(TAG, "onCodeInput: code=" + code + " isSinglePointer=" + isSinglePointer
+ " " + this);
}
switch (mSwitchState) { switch (mSwitchState) {
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
// Only distinct multi touch devices can be in this state. // Only distinct multi touch devices can be in this state.
@ -414,6 +458,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments. // TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
public void onToggleShift(boolean isAlphabetMode, boolean isSymbolShifted) { public void onToggleShift(boolean isAlphabetMode, boolean isSymbolShifted) {
if (DEBUG_STATE) {
Log.d(TAG, "onToggleShift: " + this);
}
if (isAlphabetMode) { if (isAlphabetMode) {
setShifted(isShiftedOrShiftLocked() setShifted(isShiftedOrShiftLocked()
? SwitchActions.UNSHIFT : SwitchActions.MANUAL_SHIFT); ? SwitchActions.UNSHIFT : SwitchActions.MANUAL_SHIFT);
@ -424,6 +471,9 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode arguments. // TODO: Get rid of isAlphabetMode arguments.
public void onToggleCapsLock(boolean isAlphabetMode) { public void onToggleCapsLock(boolean isAlphabetMode) {
if (DEBUG_STATE) {
Log.d(TAG, "onToggleCapsLock: " + this);
}
if (isAlphabetMode) { if (isAlphabetMode) {
if (isShiftLocked()) { if (isShiftLocked()) {
setShiftLocked(false); setShiftLocked(false);
@ -438,9 +488,20 @@ public class KeyboardState {
// TODO: Get rid of isAlphabetMode arguments. // TODO: Get rid of isAlphabetMode arguments.
public void onToggleAlphabetAndSymbols(boolean isAlphabetMode) { public void onToggleAlphabetAndSymbols(boolean isAlphabetMode) {
if (DEBUG_STATE) {
Log.d(TAG, "onToggleAlphabetAndSymbols: " + this);
}
toggleAlphabetAndSymbols(isAlphabetMode); 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) { private static String switchStateToString(int switchState) {
switch (switchState) { switch (switchState) {
case SWITCH_STATE_ALPHA: return "ALPHA"; case SWITCH_STATE_ALPHA: return "ALPHA";

View File

@ -18,11 +18,9 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
/* package */ class ModifierKeyState { /* package */ class ModifierKeyState {
protected static final String TAG = "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 RELEASING = 0;
protected static final int PRESSING = 1; protected static final int PRESSING = 1;