Get rid of hasDistinctMultitouch reference from KeyboardState

Change-Id: I0a783a425302fbc381d056f5b0d757c27f2a9f14
main
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();
final KeyboardId mainKeyboardId = mKeyboardSet.getMainKeyboardId();
try {
mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols),
hasDistinctMultitouch());
mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols));
} catch (RuntimeException e) {
Log.w(TAG, "loading keyboard failed: " + mainKeyboardId, 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.
*
* 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 #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
* {@link #onUpdateShiftState(boolean)}.
@ -74,7 +74,6 @@ public class KeyboardState {
private int mSwitchState = SWITCH_STATE_ALPHA;
private String mLayoutSwitchBackSymbols;
private boolean mHasDistinctMultitouch;
private final SwitchActions mSwitchActions;
@ -95,12 +94,11 @@ public class KeyboardState {
mSwitchActions = switchActions;
}
public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) {
public void onLoadKeyboard(String layoutSwitchBackSymbols) {
if (DEBUG_EVENT) {
Log.d(TAG, "onLoadKeyboard");
}
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
mHasDistinctMultitouch = hasDistinctMultitouch;
mKeyboardShiftState.setShifted(false);
mKeyboardShiftState.setShiftLocked(false);
mShiftKeyState.onRelease();
@ -164,18 +162,16 @@ public class KeyboardState {
if (DEBUG_ACTION) {
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
}
if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) {
switch (shiftMode) {
case SwitchActions.AUTOMATIC_SHIFT:
mKeyboardShiftState.setAutomaticTemporaryUpperCase();
} else {
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 && mKeyboardShiftState.isShiftLocked()) {
mSwitchActions.setShiftLocked(false);
}
mKeyboardShiftState.setShifted(shifted);
break;
case SwitchActions.MANUAL_SHIFT:
mKeyboardShiftState.setShifted(true);
break;
case SwitchActions.UNSHIFT:
mKeyboardShiftState.setShifted(false);
break;
}
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
* 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;
public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
@Override
public boolean hasDistinctMultitouch() {
return true;
}
public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Shift key chording input.
public void testShiftChording() {
// Press shift key and hold, enter into choring shift state.

View File

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

View File

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

View File

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