am 61fe2883: Merge "Create factory methods for sub dicts."
* commit '61fe28831d93a829f67694a342b6c94bdc7732ea': Create factory methods for sub dicts.main
commit
fc6b370560
|
@ -61,9 +61,6 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
/** The number of contacts in the most recent dictionary rebuild. */
|
/** The number of contacts in the most recent dictionary rebuild. */
|
||||||
static private int sContactCountAtLastRebuild = 0;
|
static private int sContactCountAtLastRebuild = 0;
|
||||||
|
|
||||||
/** The locale for this contacts dictionary. Controls name bigram predictions. */
|
|
||||||
public final Locale mLocale;
|
|
||||||
|
|
||||||
private ContentObserver mObserver;
|
private ContentObserver mObserver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,11 +68,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
*/
|
*/
|
||||||
private final boolean mUseFirstLastBigrams;
|
private final boolean mUseFirstLastBigrams;
|
||||||
|
|
||||||
public ContactsBinaryDictionary(final Context context, final Locale locale) {
|
private ContactsBinaryDictionary(final Context context, final Locale locale,
|
||||||
this(context, locale, null /* dictFile */);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactsBinaryDictionary(final Context context, final Locale locale,
|
|
||||||
final File dictFile) {
|
final File dictFile) {
|
||||||
this(context, locale, dictFile, NAME);
|
this(context, locale, dictFile, NAME);
|
||||||
}
|
}
|
||||||
|
@ -84,12 +77,16 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
final File dictFile, final String name) {
|
final File dictFile, final String name) {
|
||||||
super(context, getDictName(name, locale, dictFile), locale, Dictionary.TYPE_CONTACTS,
|
super(context, getDictName(name, locale, dictFile), locale, Dictionary.TYPE_CONTACTS,
|
||||||
dictFile);
|
dictFile);
|
||||||
mLocale = locale;
|
|
||||||
mUseFirstLastBigrams = useFirstLastBigramsForLocale(locale);
|
mUseFirstLastBigrams = useFirstLastBigramsForLocale(locale);
|
||||||
registerObserver(context);
|
registerObserver(context);
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ContactsBinaryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
|
final File dictFile) {
|
||||||
|
return new ContactsBinaryDictionary(context, locale, dictFile);
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void registerObserver(final Context context) {
|
private synchronized void registerObserver(final Context context) {
|
||||||
if (mObserver != null) return;
|
if (mObserver != null) return;
|
||||||
ContentResolver cres = context.getContentResolver();
|
ContentResolver cres = context.getContentResolver();
|
||||||
|
|
|
@ -23,8 +23,7 @@ import android.util.Log;
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.personalization.DecayingExpandableBinaryDictionaryBase;
|
import com.android.inputmethod.latin.personalization.PersonalizationDictionary;
|
||||||
import com.android.inputmethod.latin.personalization.PersonalizationHelper;
|
|
||||||
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
||||||
|
@ -147,13 +146,13 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
private static ExpandableBinaryDictionary getSubDict(final String dictType,
|
private static ExpandableBinaryDictionary getSubDict(final String dictType,
|
||||||
final Context context, final Locale locale, final File dictFile) {
|
final Context context, final Locale locale, final File dictFile) {
|
||||||
if (Dictionary.TYPE_CONTACTS.equals(dictType)) {
|
if (Dictionary.TYPE_CONTACTS.equals(dictType)) {
|
||||||
return new ContactsBinaryDictionary(context, locale, dictFile);
|
return ContactsBinaryDictionary.getDictionary(context, locale, dictFile);
|
||||||
} else if (Dictionary.TYPE_USER.equals(dictType)) {
|
} else if (Dictionary.TYPE_USER.equals(dictType)) {
|
||||||
return new UserBinaryDictionary(context, locale, dictFile);
|
return UserBinaryDictionary.getDictionary(context, locale, dictFile);
|
||||||
} else if (Dictionary.TYPE_USER_HISTORY.equals(dictType)) {
|
} else if (Dictionary.TYPE_USER_HISTORY.equals(dictType)) {
|
||||||
return PersonalizationHelper.getUserHistoryDictionary(context, locale);
|
return UserHistoryDictionary.getDictionary(context, locale, dictFile);
|
||||||
} else if (Dictionary.TYPE_PERSONALIZATION.equals(dictType)) {
|
} else if (Dictionary.TYPE_PERSONALIZATION.equals(dictType)) {
|
||||||
return PersonalizationHelper.getPersonalizationDictionary(context, locale);
|
return PersonalizationDictionary.getDictionary(context, locale, dictFile);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,17 +66,8 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
final private String mLocale;
|
final private String mLocale;
|
||||||
final private boolean mAlsoUseMoreRestrictiveLocales;
|
final private boolean mAlsoUseMoreRestrictiveLocales;
|
||||||
|
|
||||||
public UserBinaryDictionary(final Context context, final Locale locale) {
|
private UserBinaryDictionary(final Context context, final Locale locale, final File dictFile) {
|
||||||
this(context, locale, false /* alsoUseMoreRestrictiveLocales */, null /* dictFile */);
|
this(context, locale, false /* alsoUseMoreRestrictiveLocales */, dictFile, NAME);
|
||||||
}
|
|
||||||
|
|
||||||
public UserBinaryDictionary(final Context context, final Locale locale, final File dictFile) {
|
|
||||||
this(context, locale, false /* alsoUseMoreRestrictiveLocales */, dictFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserBinaryDictionary(final Context context, final Locale locale,
|
|
||||||
final boolean alsoUseMoreRestrictiveLocales, final File dictFile) {
|
|
||||||
this(context, locale, alsoUseMoreRestrictiveLocales, dictFile, NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UserBinaryDictionary(final Context context, final Locale locale,
|
protected UserBinaryDictionary(final Context context, final Locale locale,
|
||||||
|
@ -113,6 +104,11 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UserBinaryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
|
final File dictFile) {
|
||||||
|
return new UserBinaryDictionary(context, locale, dictFile);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
if (mObserver != null) {
|
if (mObserver != null) {
|
||||||
|
|
|
@ -26,14 +26,15 @@ import java.util.Locale;
|
||||||
public class PersonalizationDictionary extends DecayingExpandableBinaryDictionaryBase {
|
public class PersonalizationDictionary extends DecayingExpandableBinaryDictionaryBase {
|
||||||
/* package */ static final String NAME = PersonalizationDictionary.class.getSimpleName();
|
/* package */ static final String NAME = PersonalizationDictionary.class.getSimpleName();
|
||||||
|
|
||||||
|
// TODO: Make this constructor private
|
||||||
/* package */ PersonalizationDictionary(final Context context, final Locale locale) {
|
/* package */ PersonalizationDictionary(final Context context, final Locale locale) {
|
||||||
this(context, locale, null /* dictFile */);
|
super(context, getDictName(NAME, locale, null /* dictFile */), locale,
|
||||||
|
Dictionary.TYPE_PERSONALIZATION, null /* dictFile */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersonalizationDictionary(final Context context, final Locale locale,
|
public static PersonalizationDictionary getDictionary(final Context context,
|
||||||
final File dictFile) {
|
final Locale locale, final File dictFile) {
|
||||||
super(context, getDictName(NAME, locale, dictFile), locale, Dictionary.TYPE_PERSONALIZATION,
|
return PersonalizationHelper.getPersonalizationDictionary(context, locale);
|
||||||
dictFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,14 +32,15 @@ import java.util.Locale;
|
||||||
public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBase {
|
public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBase {
|
||||||
/* package */ static final String NAME = UserHistoryDictionary.class.getSimpleName();
|
/* package */ static final String NAME = UserHistoryDictionary.class.getSimpleName();
|
||||||
|
|
||||||
|
// TODO: Make this constructor private
|
||||||
/* package */ UserHistoryDictionary(final Context context, final Locale locale) {
|
/* package */ UserHistoryDictionary(final Context context, final Locale locale) {
|
||||||
this(context, locale, null /* dictFile */);
|
super(context, getDictName(NAME, locale, null /* dictFile */), locale,
|
||||||
|
Dictionary.TYPE_USER_HISTORY, null /* dictFile */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserHistoryDictionary(final Context context, final Locale locale,
|
public static UserHistoryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile) {
|
final File dictFile) {
|
||||||
super(context, getDictName(NAME, locale, dictFile), locale, Dictionary.TYPE_USER_HISTORY,
|
return PersonalizationHelper.getUserHistoryDictionary(context, locale);
|
||||||
dictFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue