Get rid of hasDistinctMultitouch reference from KeyboardState

Change-Id: I0a783a425302fbc381d056f5b0d757c27f2a9f14
This commit is contained in:
Tadashi G. Takaoka 2012-01-18 18:01:53 +09:00
parent 0f96006f77
commit 60c4594ee6
6 changed files with 18 additions and 36 deletions

View file

@ -137,8 +137,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardSet = builder.build(); mKeyboardSet = builder.build();
final KeyboardId mainKeyboardId = mKeyboardSet.getMainKeyboardId(); final KeyboardId mainKeyboardId = mKeyboardSet.getMainKeyboardId();
try { try {
mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols), mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols));
hasDistinctMultitouch());
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.w(TAG, "loading keyboard failed: " + mainKeyboardId, e); Log.w(TAG, "loading keyboard failed: " + mainKeyboardId, e);
LatinImeLogger.logOnException(mainKeyboardId.toString(), e); LatinImeLogger.logOnException(mainKeyboardId.toString(), e);

View file

@ -26,7 +26,7 @@ import com.android.inputmethod.keyboard.Keyboard;
* *
* This class contains all keyboard state transition logic. * This class contains all keyboard state transition logic.
* *
* The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()}, * The input events are {@link #onLoadKeyboard(String)}, {@link #onSaveKeyboardState()},
* {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)}, * {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)},
* {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)}, * {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
* {@link #onUpdateShiftState(boolean)}. * {@link #onUpdateShiftState(boolean)}.
@ -74,7 +74,6 @@ public class KeyboardState {
private int mSwitchState = SWITCH_STATE_ALPHA; private int mSwitchState = SWITCH_STATE_ALPHA;
private String mLayoutSwitchBackSymbols; private String mLayoutSwitchBackSymbols;
private boolean mHasDistinctMultitouch;
private final SwitchActions mSwitchActions; private final SwitchActions mSwitchActions;
@ -95,12 +94,11 @@ public class KeyboardState {
mSwitchActions = switchActions; mSwitchActions = switchActions;
} }
public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) { public void onLoadKeyboard(String layoutSwitchBackSymbols) {
if (DEBUG_EVENT) { if (DEBUG_EVENT) {
Log.d(TAG, "onLoadKeyboard"); Log.d(TAG, "onLoadKeyboard");
} }
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols; mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
mHasDistinctMultitouch = hasDistinctMultitouch;
mKeyboardShiftState.setShifted(false); mKeyboardShiftState.setShifted(false);
mKeyboardShiftState.setShiftLocked(false); mKeyboardShiftState.setShiftLocked(false);
mShiftKeyState.onRelease(); mShiftKeyState.onRelease();
@ -164,18 +162,16 @@ public class KeyboardState {
if (DEBUG_ACTION) { if (DEBUG_ACTION) {
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode)); Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
} }
if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) { switch (shiftMode) {
case SwitchActions.AUTOMATIC_SHIFT:
mKeyboardShiftState.setAutomaticTemporaryUpperCase(); mKeyboardShiftState.setAutomaticTemporaryUpperCase();
} else { break;
final boolean shifted = (shiftMode == SwitchActions.MANUAL_SHIFT); case SwitchActions.MANUAL_SHIFT:
// On non-distinct multi touch panel device, we should also turn off the shift locked mKeyboardShiftState.setShifted(true);
// state when shift key is pressed to go to normal mode. break;
// On the other hand, on distinct multi touch panel device, turning off the shift case SwitchActions.UNSHIFT:
// locked state with shift key pressing is handled by onReleaseShift(). mKeyboardShiftState.setShifted(false);
if (!mHasDistinctMultitouch && !shifted && mKeyboardShiftState.isShiftLocked()) { break;
mSwitchActions.setShiftLocked(false);
}
mKeyboardShiftState.setShifted(shifted);
} }
mSwitchActions.setShifted(shiftMode); mSwitchActions.setShifted(shiftMode);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2012 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of * use this file except in compliance with the License. You may obtain a copy of
@ -16,12 +16,7 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
public class KeyboardStateTests extends KeyboardStateNonDistinctTests { public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
@Override
public boolean hasDistinctMultitouch() {
return true;
}
// Shift key chording input. // Shift key chording input.
public void testShiftChording() { public void testShiftChording() {
// Press shift key and hold, enter into choring shift state. // Press shift key and hold, enter into choring shift state.

View file

@ -16,12 +16,7 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
public class KeyboardStateNonDistinctTests extends KeyboardStateTestsBase { public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
@Override
public boolean hasDistinctMultitouch() {
return false;
}
// Shift key in alphabet mode. // Shift key in alphabet mode.
public void testShift() { public void testShift() {
// Press/release shift key, enter into shift state. // Press/release shift key, enter into shift state.

View file

@ -22,8 +22,6 @@ public abstract class KeyboardStateTestsBase extends AndroidTestCase
implements MockKeyboardSwitcher.Constants { implements MockKeyboardSwitcher.Constants {
protected MockKeyboardSwitcher mSwitcher; protected MockKeyboardSwitcher mSwitcher;
public abstract boolean hasDistinctMultitouch();
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
@ -45,7 +43,7 @@ public abstract class KeyboardStateTestsBase extends AndroidTestCase
} }
public void loadKeyboard(String layoutSwitchBackSymbols, int afterLoad) { public void loadKeyboard(String layoutSwitchBackSymbols, int afterLoad) {
mSwitcher.loadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch()); mSwitcher.loadKeyboard(layoutSwitchBackSymbols);
updateShiftState(afterLoad); updateShiftState(afterLoad);
} }

View file

@ -104,9 +104,8 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState); mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
} }
public void loadKeyboard(String layoutSwitchBackSymbols, public void loadKeyboard(String layoutSwitchBackSymbols) {
boolean hasDistinctMultitouch) { mState.onLoadKeyboard(layoutSwitchBackSymbols);
mState.onLoadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch);
} }
public void onPressKey(int code) { public void onPressKey(int code) {