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

Commit 543d25d7 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Sort keys from top-left to bottom-right order"

parents 3acbf7d0 c13c1adf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public final class AccessibilityEntityProvider extends AccessibilityNodeProvider

            // Add the virtual children of the root View.
            final Keyboard keyboard = mKeyboardView.getKeyboard();
            for (final Key key : keyboard.getKeys()) {
            for (final Key key : keyboard.getSortedKeys()) {
                final int childVirtualViewId = generateVirtualViewIdForKey(key);
                rootInfo.addChild(mKeyboardView, childVirtualViewId);
            }
@@ -307,7 +307,7 @@ public final class AccessibilityEntityProvider extends AccessibilityNodeProvider
        }
        mVirtualViewIdToKey.clear();

        for (final Key key : keyboard.getKeys()) {
        for (final Key key : keyboard.getSortedKeys()) {
            final int virtualViewId = generateVirtualViewIdForKey(key);
            mVirtualViewIdToKey.put(virtualViewId, key);
        }
+3 −2
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange

        private int getCategoryPageCount(final int categoryId) {
            final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
            return (keyboard.getKeys().size() - 1) / mMaxPageKeyCount + 1;
            return (keyboard.getSortedKeys().size() - 1) / mMaxPageKeyCount + 1;
        }

        // Returns a pair of the category id and the category page id from the view pager's page
@@ -347,7 +347,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
                }

                final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
                final Key[][] sortedKeys = sortKeysIntoPages(keyboard.getKeys(), mMaxPageKeyCount);
                final Key[][] sortedKeys = sortKeysIntoPages(
                        keyboard.getSortedKeys(), mMaxPageKeyCount);
                for (int pageId = 0; pageId < sortedKeys.length; ++pageId) {
                    final DynamicGridKeyboard tempKeyboard = new DynamicGridKeyboard(mPrefs,
                            mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
+17 −9
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class Keyboard {
    public final int mMaxMoreKeysKeyboardColumn;

    /** List of keys in this keyboard */
    private final List<Key> mKeys;
    private final List<Key> mSortedKeys;
    public final List<Key> mShiftKeys;
    public final List<Key> mAltCodeKeysWhileTyping;
    public final KeyboardIconsSet mIconsSet;
@@ -103,14 +103,16 @@ public class Keyboard {
        mTopPadding = params.mTopPadding;
        mVerticalGap = params.mVerticalGap;

        mKeys = Collections.unmodifiableList(CollectionUtils.newArrayList(params.mKeys));
        mSortedKeys = Collections.unmodifiableList(
                CollectionUtils.newArrayList(params.mSortedKeys));
        mShiftKeys = Collections.unmodifiableList(params.mShiftKeys);
        mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping);
        mIconsSet = params.mIconsSet;

        mProximityInfo = new ProximityInfo(params.mId.mLocale.toString(),
                params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight,
                mMostCommonKeyWidth, mMostCommonKeyHeight, mKeys, params.mTouchPositionCorrection);
                mMostCommonKeyWidth, mMostCommonKeyHeight, mSortedKeys,
                params.mTouchPositionCorrection);
        mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled;
    }

@@ -129,7 +131,7 @@ public class Keyboard {
        mTopPadding = keyboard.mTopPadding;
        mVerticalGap = keyboard.mVerticalGap;

        mKeys = keyboard.mKeys;
        mSortedKeys = keyboard.mSortedKeys;
        mShiftKeys = keyboard.mShiftKeys;
        mAltCodeKeysWhileTyping = keyboard.mAltCodeKeysWhileTyping;
        mIconsSet = keyboard.mIconsSet;
@@ -154,12 +156,18 @@ public class Keyboard {
        return mProximityInfo;
    }

    public List<Key> getKeys() {
        return mKeys;
    /**
     * Return the sorted list of keys of this keyboard.
     * The keys are sorted from top-left to bottom-right order.
     * The list may contain {@link Spacer} object as well.
     * @return the sorted unmodifiable list of {@link Key}s of this keyboard.
     */
    public List<Key> getSortedKeys() {
        return mSortedKeys;
    }

    public Key getKeyFromOutputText(final String outputText) {
        for (final Key key : getKeys()) {
        for (final Key key : getSortedKeys()) {
            if (outputText.equals(key.getOutputText())) {
                return key;
            }
@@ -177,7 +185,7 @@ public class Keyboard {
                return mKeyCache.valueAt(index);
            }

            for (final Key key : getKeys()) {
            for (final Key key : getSortedKeys()) {
                if (key.getCode() == code) {
                    mKeyCache.put(code, key);
                    return key;
@@ -193,7 +201,7 @@ public class Keyboard {
            return true;
        }

        for (final Key key : getKeys()) {
        for (final Key key : getSortedKeys()) {
            if (key == aKey) {
                mKeyCache.put(key.getCode(), key);
                return true;
+1 −1
Original line number Diff line number Diff line
@@ -289,7 +289,7 @@ public class KeyboardView extends View {
        // TODO: Confirm if it's really required to draw all keys when hardware acceleration is on.
        if (drawAllKeys || isHardwareAccelerated) {
            // Draw all keys.
            for (final Key key : mKeyboard.getKeys()) {
            for (final Key key : mKeyboard.getSortedKeys()) {
                onDrawKey(key, canvas, paint);
            }
        } else {
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public final class MoreKeysDetector extends KeyDetector {

        Key nearestKey = null;
        int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
        for (final Key key : keyboard.getKeys()) {
        for (final Key key : keyboard.getSortedKeys()) {
            final int dist = key.squaredDistanceToEdge(touchX, touchY);
            if (dist < nearestDist) {
                nearestKey = key;
Loading