Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60c4594e authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Get rid of hasDistinctMultitouch reference from KeyboardState

Change-Id: I0a783a425302fbc381d056f5b0d757c27f2a9f14
parent 0f96006f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
+11 −15
Original line number Diff line number Diff line
@@ -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);
    }
+2 −7
Original line number Diff line number Diff line
/*
 * 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.
+1 −6
Original line number Diff line number Diff line
@@ -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.
+1 −3
Original line number Diff line number Diff line
@@ -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);
    }

Loading