Skip to content
Snippets Groups Projects
  • Jean Chalard's avatar
    cfed2739
    Add an option to user dict to match more precise locales · cfed2739
    Jean Chalard authored
    This should not be used lightly, as it violates the general
    contract of locale, and does kill some legitimate (albeit
    alledgedly rare) use patterns.
    Currently, the spell checker uses this because it uses a
    negative logic: it should match broadly, and when in doubt,
    match even more broadly, which is almost never the case of
    something that uses the locale.
    In other words: don't use this option unless you are
    very, VERY sure that's what you want. Hint: it isn't
    
    Bug: 5280929
    Change-Id: Ib3cae319c692161d653630038c5bcde1f4340c05
    cfed2739
    History
    Add an option to user dict to match more precise locales
    Jean Chalard authored
    This should not be used lightly, as it violates the general
    contract of locale, and does kill some legitimate (albeit
    alledgedly rare) use patterns.
    Currently, the spell checker uses this because it uses a
    negative logic: it should match broadly, and when in doubt,
    match even more broadly, which is almost never the case of
    something that uses the locale.
    In other words: don't use this option unless you are
    very, VERY sure that's what you want. Hint: it isn't
    
    Bug: 5280929
    Change-Id: Ib3cae319c692161d653630038c5bcde1f4340c05
SynchronouslyLoadedUserDictionary.java 1.57 KiB
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.inputmethod.latin;

import android.content.Context;

import com.android.inputmethod.keyboard.ProximityInfo;

public class SynchronouslyLoadedUserDictionary extends UserDictionary {

    public SynchronouslyLoadedUserDictionary(final Context context, final String locale) {
        this(context, locale, false);
    }

    public SynchronouslyLoadedUserDictionary(final Context context, final String locale,
            final boolean alsoUseMoreRestrictiveLocales) {
        super(context, locale, alsoUseMoreRestrictiveLocales);
    }

    @Override
    public void getWords(final WordComposer codes, final WordCallback callback,
            final ProximityInfo proximityInfo) {
        blockingReloadDictionaryIfRequired();
        getWordsInner(codes, callback, proximityInfo);
    }

    @Override
    public synchronized boolean isValidWord(CharSequence word) {
        blockingReloadDictionaryIfRequired();
        return getWordFrequency(word) > -1;
    }
}