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

Commit 10102f02 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Change the batch input methods of KeyboardActionListener

This change also removes the reference of SuggestedWords from
GestureTracker and KeyboardActionListener.

Change-Id: I25ef8756007986abf99a931afd665bbfe6fa387f
parent f39fccbd
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.inputmethod.keyboard;

import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.SuggestedWords;

public interface KeyboardActionListener {

@@ -73,18 +72,17 @@ public interface KeyboardActionListener {
    public void onStartBatchInput();

    /**
     * Sends the batch input points data to get updated suggestions
     * Sends the ongoing batch input points data.
     * @param batchPointers the batch input points representing the user input
     * @return updated suggestions that reflects the user input
     */
    public SuggestedWords onUpdateBatchInput(InputPointers batchPointers);
    public void onUpdateBatchInput(InputPointers batchPointers);

    /**
     * Sends a sequence of characters to the listener as batch input.
     * Sends the final batch input points data.
     *
     * @param text the sequence of characters to be displayed as composing text.
     * @param batchPointers the batch input points representing the user input
     */
    public void onEndBatchInput(CharSequence text);
    public void onEndBatchInput(InputPointers batchPointers);

    /**
     * Called when user released a finger outside any key.
@@ -109,9 +107,9 @@ public interface KeyboardActionListener {
        @Override
        public void onStartBatchInput() {}
        @Override
        public SuggestedWords onUpdateBatchInput(InputPointers batchPointers) { return null; }
        public void onUpdateBatchInput(InputPointers batchPointers) {}
        @Override
        public void onEndBatchInput(CharSequence text) {}
        public void onEndBatchInput(InputPointers batchPointers) {}
        @Override
        public void onCancelInput() {}
        @Override
+8 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.widget.PopupWindow;

import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.R;

/**
@@ -63,8 +64,13 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
        }

        @Override
        public void onEndBatchInput(CharSequence text) {
            mListener.onEndBatchInput(text);
        public void onUpdateBatchInput(InputPointers batchPointers) {
            mListener.onUpdateBatchInput(batchPointers);
        }

        @Override
        public void onEndBatchInput(InputPointers batchPointers) {
            mListener.onEndBatchInput(batchPointers);
        }

        @Override
+6 −9
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.SuggestedWords;

// TODO: Remove this class by consolidating with PointerTracker
public class GestureTracker {
@@ -40,7 +39,6 @@ public class GestureTracker {
    private boolean mInGesture = false;

    private KeyboardActionListener mListener;
    private SuggestedWords mSuggestions;

    private int mLastRecognitionPointSize = 0;
    private long mLastRecognitionTime = 0;
@@ -66,17 +64,16 @@ public class GestureTracker {
        }
        mInGesture = true;
        mListener.onStartBatchInput();
        mSuggestions = null;
    }

    // TODO: The corresponding startBatchInput() is a private method. Reorganize the code.
    public void endBatchInput() {
        if (isInGesture() && mSuggestions != null && mSuggestions.size() > 0) {
            final CharSequence text = mSuggestions.getWord(0);
        if (isInGesture()) {
            final InputPointers batchPoints = PointerTracker.getAllBatchPoints();
            if (DEBUG_LISTENER) {
                Log.d(TAG, "onEndBatchInput: text=" + text);
                Log.d(TAG, "onEndBatchInput: batchPoints=" + batchPoints.getPointerSize());
            }
            mListener.onEndBatchInput(text);
            mListener.onEndBatchInput(batchPoints);
        }
        mInGesture = false;
        clearBatchInputPoints();
@@ -117,7 +114,7 @@ public class GestureTracker {
                if (DEBUG_LISTENER) {
                    Log.d(TAG, "onUpdateBatchInput: batchPoints=" + batchPoints.getPointerSize());
                }
                mSuggestions = mListener.onUpdateBatchInput(batchPoints);
                mListener.onUpdateBatchInput(batchPoints);
            }
        }
    }
@@ -128,7 +125,7 @@ public class GestureTracker {
            if (DEBUG_LISTENER) {
                Log.d(TAG, "onUpdateBatchInput: batchPoints=" + batchPoints.getPointerSize());
            }
            mSuggestions = mListener.onUpdateBatchInput(batchPoints);
            mListener.onUpdateBatchInput(batchPoints);
        }
    }

+12 −3
Original line number Diff line number Diff line
@@ -1329,13 +1329,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    }

    @Override
    public SuggestedWords onUpdateBatchInput(InputPointers batchPointers) {
    public void onUpdateBatchInput(InputPointers batchPointers) {
        mWordComposer.setBatchInputPointers(batchPointers);
        return updateSuggestionsOrPredictions();
        updateSuggestionsOrPredictions();
    }

    @Override
    public void onEndBatchInput(CharSequence text) {
    public void onEndBatchInput(InputPointers batchPointers) {
        mWordComposer.setBatchInputPointers(batchPointers);
        final SuggestedWords suggestedWords = updateSuggestionsOrPredictions();
        if (suggestedWords == null || suggestedWords.size() == 0) {
            return;
        }
        final CharSequence text = suggestedWords.getWord(0);
        if (TextUtils.isEmpty(text)) {
            return;
        }
        mWordComposer.setBatchInputWord(text);
        mConnection.beginBatchEdit();
        if (SPACE_STATE_PHANTOM == mSpaceState) {