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

Commit 96b22200 authored by Ken Wakasa's avatar Ken Wakasa
Browse files

Privatize a few constants in BinaryDictionary.java

Change-Id: I7defaf1f577fd67e678cac83ff935e8181dd0a48
parent 4b39f000
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -41,9 +41,9 @@ public final class BinaryDictionary extends Dictionary {
     * It is necessary to keep it at this value because some languages e.g. German have
     * really long words.
     */
    public static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
    public static final int MAX_WORDS = 18;
    public static final int MAX_SPACES = 16;
    private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
    private static final int MAX_WORDS = 18;
    private static final int MAX_SPACES = 16;

    private static final int MAX_PREDICTIONS = 60;
    private static final int MAX_RESULTS = Math.max(MAX_PREDICTIONS, MAX_WORDS);
+2 −3
Original line number Diff line number Diff line
@@ -51,10 +51,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
    private static boolean DEBUG = false;

    /**
     * The maximum length of a word in this dictionary. This is the same value as the binary
     * dictionary.
     * The maximum length of a word in this dictionary.
     */
    protected static final int MAX_WORD_LENGTH = BinaryDictionary.MAX_WORD_LENGTH;
    protected static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;

    /**
     * A static map of locks, each of which controls access to a single binary dictionary file. They
+8 −8
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class ExpandableDictionary extends Dictionary {
    protected static final int BIGRAM_MAX_FREQUENCY = 255;

    private Context mContext;
    private char[] mWordBuilder = new char[BinaryDictionary.MAX_WORD_LENGTH];
    private char[] mWordBuilder = new char[Constants.Dictionary.MAX_WORD_LENGTH];
    private int mMaxDepth;
    private int mInputLength;

@@ -158,7 +158,7 @@ public class ExpandableDictionary extends Dictionary {
        super(dictType);
        mContext = context;
        clearDictionary();
        mCodes = new int[BinaryDictionary.MAX_WORD_LENGTH][];
        mCodes = new int[Constants.Dictionary.MAX_WORD_LENGTH][];
    }

    public void loadDictionary() {
@@ -195,11 +195,11 @@ public class ExpandableDictionary extends Dictionary {
    }

    public int getMaxWordLength() {
        return BinaryDictionary.MAX_WORD_LENGTH;
        return Constants.Dictionary.MAX_WORD_LENGTH;
    }

    public void addWord(final String word, final String shortcutTarget, final int frequency) {
        if (word.length() >= BinaryDictionary.MAX_WORD_LENGTH) {
        if (word.length() >= Constants.Dictionary.MAX_WORD_LENGTH) {
            return;
        }
        addWordRec(mRoots, word, 0, shortcutTarget, frequency, null);
@@ -254,7 +254,7 @@ public class ExpandableDictionary extends Dictionary {
            final String prevWord, final ProximityInfo proximityInfo) {
        if (reloadDictionaryIfRequired()) return null;
        if (composer.size() > 1) {
            if (composer.size() >= BinaryDictionary.MAX_WORD_LENGTH) {
            if (composer.size() >= Constants.Dictionary.MAX_WORD_LENGTH) {
                return null;
            }
            final ArrayList<SuggestedWordInfo> suggestions =
@@ -620,7 +620,7 @@ public class ExpandableDictionary extends Dictionary {
    }

    // Local to reverseLookUp, but do not allocate each time.
    private final char[] mLookedUpString = new char[BinaryDictionary.MAX_WORD_LENGTH];
    private final char[] mLookedUpString = new char[Constants.Dictionary.MAX_WORD_LENGTH];

    /**
     * reverseLookUp retrieves the full word given a list of terminal nodes and adds those words
@@ -635,7 +635,7 @@ public class ExpandableDictionary extends Dictionary {
        for (NextWord nextWord : terminalNodes) {
            node = nextWord.getWordNode();
            freq = nextWord.getFrequency();
            int index = BinaryDictionary.MAX_WORD_LENGTH;
            int index = Constants.Dictionary.MAX_WORD_LENGTH;
            do {
                --index;
                mLookedUpString[index] = node.mCode;
@@ -647,7 +647,7 @@ public class ExpandableDictionary extends Dictionary {
            // to ignore the word in this case.
            if (freq >= 0 && node == null) {
                suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index,
                        BinaryDictionary.MAX_WORD_LENGTH - index),
                        Constants.Dictionary.MAX_WORD_LENGTH - index),
                        freq, SuggestedWordInfo.KIND_CORRECTION, mDictType));
            }
        }
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ public final class LastComposedWord {
    public final String mCommittedWord;
    public final String mSeparatorString;
    public final String mPrevWord;
    public final InputPointers mInputPointers = new InputPointers(BinaryDictionary.MAX_WORD_LENGTH);
    public final InputPointers mInputPointers =
            new InputPointers(Constants.Dictionary.MAX_WORD_LENGTH);

    private boolean mActive;

+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public final class RichInputConnection {
    private static final boolean DEBUG_PREVIOUS_TEXT = false;
    private static final boolean DEBUG_BATCH_NESTING = false;
    // Provision for a long word pair and a separator
    private static final int LOOKBACK_CHARACTER_NUM = BinaryDictionary.MAX_WORD_LENGTH * 2 + 1;
    private static final int LOOKBACK_CHARACTER_NUM = Constants.Dictionary.MAX_WORD_LENGTH * 2 + 1;
    private static final Pattern spaceRegex = Pattern.compile("\\s+");
    private static final int INVALID_CURSOR_POSITION = -1;

Loading