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

Commit 433ca6a4 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Cleanup redundant methods of KeyboardSwitcher

Change-Id: I2ebeb8852177f6c6e30578d0bb3f372f488dc6c1
parent 30964843
Loading
Loading
Loading
Loading
+21 −19
Original line number Diff line number Diff line
@@ -16,23 +16,6 @@

package com.android.inputmethod.deprecated;

import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.compat.SharedPreferencesCompat;
import com.android.inputmethod.deprecated.voice.FieldContext;
import com.android.inputmethod.deprecated.voice.Hints;
import com.android.inputmethod.deprecated.voice.SettingsUtil;
import com.android.inputmethod.deprecated.voice.VoiceInput;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.latin.EditingUtils;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinIME.UIHandler;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.Utils;

import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
@@ -63,6 +46,24 @@ import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.widget.TextView;

import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.compat.SharedPreferencesCompat;
import com.android.inputmethod.deprecated.voice.FieldContext;
import com.android.inputmethod.deprecated.voice.Hints;
import com.android.inputmethod.deprecated.voice.SettingsUtil;
import com.android.inputmethod.deprecated.voice.VoiceInput;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.latin.EditingUtils;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinIME.UIHandler;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.Utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -747,8 +748,9 @@ public class VoiceProxy implements VoiceInput.UiListener {
        // keep showing the warning.
        if (mSubtypeSwitcher.isVoiceMode() && windowToken != null) {
            // Close keyboard view if it is been shown.
            if (KeyboardSwitcher.getInstance().isInputViewShown())
                KeyboardSwitcher.getInstance().getKeyboardView().purgeKeyboardAndClosing();
            final LatinKeyboardView keyboardView = KeyboardSwitcher.getInstance().getKeyboardView();
            if (keyboardView != null && keyboardView.isShown())
                keyboardView.purgeKeyboardAndClosing();
            startListening(false, windowToken);
        }
        // If we have no token, onAttachedToWindow will take care of showing dialog and start
+0 −17
Original line number Diff line number Diff line
@@ -179,23 +179,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
        mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
    }

    // TODO: Remove this method.
    public boolean isAlphabetMode() {
        final Keyboard keyboard = getKeyboard();
        return keyboard != null && keyboard.mId.isAlphabetKeyboard();
    }

    // TODO: Remove this method.
    public boolean isInputViewShown() {
        return mCurrentInputView != null && mCurrentInputView.isShown();
    }

    // TODO: Remove this method.
    public boolean isShiftedOrShiftLocked() {
        final Keyboard keyboard = getKeyboard();
        return keyboard != null && keyboard.isShiftedOrShiftLocked();
    }

    public Keyboard getKeyboard() {
        if (mKeyboardView != null) {
            return mKeyboardView.getKeyboard();
+11 −5
Original line number Diff line number Diff line
@@ -291,8 +291,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
                latinIme.updateBigramPredictions();
                break;
            case MSG_VOICE_RESULTS:
                final Keyboard keyboard = switcher.getKeyboard();
                latinIme.mVoiceProxy.handleVoiceResults(latinIme.preferCapitalization()
                        || (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
                        || (keyboard != null && keyboard.isShiftedOrShiftLocked()));
                break;
            case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
                setSpacebarTextFadeFactor(inputView,
@@ -987,8 +988,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
    private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
        // TODO: Modify this if we support suggestions with hard keyboard
        if (onEvaluateInputViewShown() && mSuggestionsContainer != null) {
            final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
            final boolean inputViewShown = (keyboardView != null) ? keyboardView.isShown() : false;
            final boolean shouldShowSuggestions = shown
                    && (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
                    && (needsInputViewShown ? inputViewShown : true);
            if (isFullscreenMode()) {
                mSuggestionsContainer.setVisibility(
                        shouldShowSuggestions ? View.VISIBLE : View.GONE);
@@ -1020,7 +1023,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
        final int extraHeight = extractHeight + backingHeight + suggestionsHeight;
        int touchY = extraHeight;
        // Need to set touchable region only if input view is being shown
        if (mKeyboardSwitcher.isInputViewShown()) {
        final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
        if (keyboardView != null && keyboardView.isShown()) {
            if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
                touchY -= suggestionsHeight;
            }
@@ -1081,9 +1085,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
            final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
            // Enable shift key and DPAD to do selections
            if (mKeyboardSwitcher.isInputViewShown()
                    && mKeyboardSwitcher.isShiftedOrShiftLocked()) {
            if ((keyboardView != null && keyboardView.isShown())
                    && (keyboard != null && keyboard.isShiftedOrShiftLocked())) {
                KeyEvent newEvent = new KeyEvent(event.getDownTime(), event.getEventTime(),
                        event.getAction(), event.getKeyCode(), event.getRepeatCount(),
                        event.getDeviceId(), event.getScanCode(),