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

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

Merge "Filter Spacer before keyboard layout test"

parents a103e29d 8c6b34e5
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import com.android.inputmethod.latin.utils.StringUtils;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Collections;
import java.util.Comparator;
import java.util.Comparator;


@@ -44,15 +43,27 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
        }
        }
    };
    };


    private static ArrayList<Key> filterOutSpacerAndSortKeys(final Key[] keys) {
        final ArrayList<Key> filteredKeys = CollectionUtils.newArrayList();
        for (final Key key : keys) {
            if (key.isSpacer()) {
                continue;
            }
            filteredKeys.add(key);
        }
        Collections.sort(filteredKeys, ROW_COLUMN_COMPARATOR);
        return filteredKeys;
    }

    /**
    /**
     * Create the keyboard that consists of the array of rows of the actual keyboard's keys.
     * Create the keyboard that consists of the array of rows of the actual keyboard's keys.
     * @param keys the array of keys of the actual keyboard.
     * @param keys the array of keys of the actual keyboard.
     * @return the actual keyboard grouped with rows.
     * @return the actual keyboard grouped with rows.
     */
     */
    public static Key[][] buildKeyboard(final Key[] keys) {
    public static Key[][] buildKeyboard(final Key[] keys) {
        // Sort keys from top-left to bottom-right order to prepare to create rows.
        // Filter out spacer and sort keys from top-left to bottom-right order to prepare to
        final ArrayList<Key> sortedKeys = CollectionUtils.newArrayList(Arrays.asList(keys));
        // create rows.
        Collections.sort(sortedKeys, ROW_COLUMN_COMPARATOR);
        final ArrayList<Key> sortedKeys = filterOutSpacerAndSortKeys(keys);


        // Grouping keys into rows.
        // Grouping keys into rows.
        final ArrayList<ArrayList<Key>> rows = CollectionUtils.newArrayList();
        final ArrayList<ArrayList<Key>> rows = CollectionUtils.newArrayList();