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

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

Rename and consolidate some constants

Change-Id: I7863936cca18b28bf0117afcbcf544a5fd7f185d
parent 18f69b02
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

package com.android.inputmethod.keyboard;

import com.android.inputmethod.latin.Constants;

public class KeyDetector {
    public static final int NOT_A_CODE = -1;

public class KeyDetector {
    private final int mKeyHysteresisDistanceSquared;

    private Keyboard mKeyboard;
@@ -103,7 +103,7 @@ public class KeyDetector {
        final StringBuilder sb = new StringBuilder();
        boolean addDelimiter = false;
        for (final int code : codes) {
            if (code == NOT_A_CODE) break;
            if (code == Constants.NOT_A_CODE) break;
            if (addDelimiter) sb.append(", ");
            sb.append(Keyboard.printableCode(code));
            addDelimiter = true;
+10 −14
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.inputmethod.keyboard;

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

public interface KeyboardActionListener {
@@ -44,21 +45,16 @@ public interface KeyboardActionListener {
     *
     * @param primaryCode this is the code of the key that was pressed
     * @param x x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
     *            {@link PointerTracker} or so, the value should be {@link #NOT_A_TOUCH_COORDINATE}.
     *            If it's called on insertion from the suggestion strip, it should be
     *            {@link #SUGGESTION_STRIP_COORDINATE}.
     *            {@link PointerTracker} or so, the value should be
     *            {@link Constants#NOT_A_COORDINATE}. If it's called on insertion from the
     *            suggestion strip, it should be {@link Constants#SUGGESTION_STRIP_COORDINATE}.
     * @param y y-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
     *            {@link PointerTracker} or so, the value should be {@link #NOT_A_TOUCH_COORDINATE}.
     *            If it's called on insertion from the suggestion strip, it should be
     *            {@link #SUGGESTION_STRIP_COORDINATE}.
     *            {@link PointerTracker} or so, the value should be
     *            {@link Constants#NOT_A_COORDINATE}.If it's called on insertion from the
     *            suggestion strip, it should be {@link Constants#SUGGESTION_STRIP_COORDINATE}.
     */
    public void onCodeInput(int primaryCode, int x, int y);

    // See {@link Adapter#isInvalidCoordinate(int)}.
    public static final int NOT_A_TOUCH_COORDINATE = -1;
    public static final int SUGGESTION_STRIP_COORDINATE = -2;
    public static final int SPELL_CHECKER_COORDINATE = -3;

    /**
     * Sends a sequence of characters to the listener.
     *
@@ -119,9 +115,9 @@ public interface KeyboardActionListener {

        // TODO: Remove this method when the vertical correction is removed.
        public static boolean isInvalidCoordinate(int coordinate) {
            // Detect {@link KeyboardActionListener#NOT_A_TOUCH_COORDINATE},
            // {@link KeyboardActionListener#SUGGESTION_STRIP_COORDINATE}, and
            // {@link KeyboardActionListener#SPELL_CHECKER_COORDINATE}.
            // Detect {@link Constants#NOT_A_COORDINATE},
            // {@link Constants#SUGGESTION_STRIP_COORDINATE}, and
            // {@link Constants#SPELL_CHECKER_COORDINATE}.
            return coordinate < 0;
        }
    }
+2 −3
Original line number Diff line number Diff line
@@ -608,9 +608,8 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    private void invokeCodeInput(int primaryCode) {
        mKeyboardActionListener.onCodeInput(primaryCode,
                KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
                KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
        mKeyboardActionListener.onCodeInput(
                primaryCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
    }

    private void invokeReleaseKey(int primaryCode) {
+3 −1
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.Constants;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.R;

@@ -50,7 +51,8 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
        public void onCodeInput(int primaryCode, int x, int y) {
            // Because a more keys keyboard doesn't need proximity characters correction, we don't
            // send touch event coordinates.
            mListener.onCodeInput(primaryCode, NOT_A_TOUCH_COORDINATE, NOT_A_TOUCH_COORDINATE);
            mListener.onCodeInput(
                    primaryCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
        }

        @Override
+3 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.Rect;
import android.text.TextUtils;

import com.android.inputmethod.keyboard.Keyboard.Params.TouchPositionCorrection;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.JniUtils;

import java.util.Arrays;
@@ -111,7 +112,7 @@ public class ProximityInfo {
        final Key[] keys = mKeys;
        final TouchPositionCorrection touchPositionCorrection = mTouchPositionCorrection;
        final int[] proximityCharsArray = new int[mGridSize * MAX_PROXIMITY_CHARS_SIZE];
        Arrays.fill(proximityCharsArray, KeyDetector.NOT_A_CODE);
        Arrays.fill(proximityCharsArray, Constants.NOT_A_CODE);
        for (int i = 0; i < mGridSize; ++i) {
            final int proximityCharsLength = gridNeighborKeys[i].length;
            for (int j = 0; j < proximityCharsLength; ++j) {
@@ -234,7 +235,7 @@ public class ProximityInfo {
            dest[index++] = code;
        }
        if (index < destLength) {
            dest[index] = KeyDetector.NOT_A_CODE;
            dest[index] = Constants.NOT_A_CODE;
        }
    }

Loading