mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-08 15:47:43 +00:00
remove unused "account"
This commit is contained in:
parent
900dfa1b9c
commit
27a2300631
10 changed files with 37 additions and 79 deletions
|
@ -4,8 +4,6 @@ package helium314.keyboard.latin;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.android.inputmethod.latin.BinaryDictionary;
|
import com.android.inputmethod.latin.BinaryDictionary;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -35,7 +33,7 @@ public class AppsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AppsBinaryDictionary getDictionary(final Context context, final Locale locale,
|
public static AppsBinaryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix, @Nullable final String account) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return new AppsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
return new AppsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.provider.ContactsContract.Contacts;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.android.inputmethod.latin.BinaryDictionary;
|
import com.android.inputmethod.latin.BinaryDictionary;
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContactsBinaryDictionary getDictionary(final Context context, @NonNull final Locale locale,
|
public static ContactsBinaryDictionary getDictionary(final Context context, @NonNull final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix, @Nullable final String account) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return new ContactsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
return new ContactsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that facilitates interaction with different kinds of dictionaries. Provides APIs to
|
* Interface that facilitates interaction with different kinds of dictionaries. Provides APIs to
|
||||||
* instantiate and select the correct dictionaries (based on language or account), update entries
|
* instantiate and select the correct dictionaries (based on language and settings), update entries
|
||||||
* and fetch suggestions. Currently AndroidSpellCheckerService and LatinIME both use
|
* and fetch suggestions. Currently AndroidSpellCheckerService and LatinIME both use
|
||||||
* DictionaryFacilitator as a client for interacting with dictionaries.
|
* DictionaryFacilitator as a client for interacting with dictionaries.
|
||||||
*/
|
*/
|
||||||
|
@ -90,12 +90,9 @@ public interface DictionaryFacilitator {
|
||||||
@NonNull final List<Locale> locales,
|
@NonNull final List<Locale> locales,
|
||||||
final boolean contacts,
|
final boolean contacts,
|
||||||
final boolean apps,
|
final boolean apps,
|
||||||
final boolean personalization,
|
final boolean personalization
|
||||||
@Nullable final String account
|
|
||||||
);
|
);
|
||||||
|
|
||||||
String getAccount();
|
|
||||||
|
|
||||||
void resetDictionaries(
|
void resetDictionaries(
|
||||||
final Context context,
|
final Context context,
|
||||||
final Locale newLocale,
|
final Locale newLocale,
|
||||||
|
@ -103,7 +100,6 @@ public interface DictionaryFacilitator {
|
||||||
final boolean useAppsDict,
|
final boolean useAppsDict,
|
||||||
final boolean usePersonalizedDicts,
|
final boolean usePersonalizedDicts,
|
||||||
final boolean forceReloadMainDictionary,
|
final boolean forceReloadMainDictionary,
|
||||||
@Nullable final String account,
|
|
||||||
final String dictNamePrefix,
|
final String dictNamePrefix,
|
||||||
@Nullable final DictionaryInitializationListener listener);
|
@Nullable final DictionaryInitializationListener listener);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ import kotlin.concurrent.Volatile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Facilitates interaction with different kinds of dictionaries. Provides APIs
|
* Facilitates interaction with different kinds of dictionaries. Provides APIs
|
||||||
* to instantiate and select the correct dictionaries (based on language or account),
|
* to instantiate and select the correct dictionaries (based on language and settings),
|
||||||
* update entries and fetch suggestions.
|
* update entries and fetch suggestions.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -110,18 +110,11 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
return currentlyPreferredDictionaryGroup.locale
|
return currentlyPreferredDictionaryGroup.locale
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAccount(): String? {
|
override fun usesSameSettings(locales: List<Locale>, contacts: Boolean, apps: Boolean, personalization: Boolean): Boolean {
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun usesSameSettings(
|
|
||||||
locales: List<Locale>, contacts: Boolean, apps: Boolean, personalization: Boolean, account: String?
|
|
||||||
): Boolean {
|
|
||||||
val dictGroup = dictionaryGroups[0] // settings are the same for all groups
|
val dictGroup = dictionaryGroups[0] // settings are the same for all groups
|
||||||
return contacts == dictGroup.hasDict(Dictionary.TYPE_CONTACTS, account)
|
return contacts == dictGroup.hasDict(Dictionary.TYPE_CONTACTS)
|
||||||
&& apps == dictGroup.hasDict(Dictionary.TYPE_APPS, account)
|
&& apps == dictGroup.hasDict(Dictionary.TYPE_APPS)
|
||||||
&& personalization == dictGroup.hasDict(Dictionary.TYPE_USER_HISTORY, account)
|
&& personalization == dictGroup.hasDict(Dictionary.TYPE_USER_HISTORY)
|
||||||
&& account == dictGroup.account
|
|
||||||
&& locales.size == dictionaryGroups.size
|
&& locales.size == dictionaryGroups.size
|
||||||
&& locales.none { findDictionaryGroupWithLocale(dictionaryGroups, it) == null }
|
&& locales.none { findDictionaryGroupWithLocale(dictionaryGroups, it) == null }
|
||||||
}
|
}
|
||||||
|
@ -135,7 +128,6 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
useAppsDict: Boolean,
|
useAppsDict: Boolean,
|
||||||
usePersonalizedDicts: Boolean,
|
usePersonalizedDicts: Boolean,
|
||||||
forceReloadMainDictionary: Boolean,
|
forceReloadMainDictionary: Boolean,
|
||||||
account: String?,
|
|
||||||
dictNamePrefix: String,
|
dictNamePrefix: String,
|
||||||
listener: DictionaryInitializationListener?
|
listener: DictionaryInitializationListener?
|
||||||
) {
|
) {
|
||||||
|
@ -191,7 +183,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
val existingDictsToCleanup = HashMap<Locale, MutableList<String>>()
|
val existingDictsToCleanup = HashMap<Locale, MutableList<String>>()
|
||||||
for (dictGroup in dictionaryGroups) {
|
for (dictGroup in dictionaryGroups) {
|
||||||
existingDictsToCleanup[dictGroup.locale] = DictionaryFacilitator.ALL_DICTIONARY_TYPES
|
existingDictsToCleanup[dictGroup.locale] = DictionaryFacilitator.ALL_DICTIONARY_TYPES
|
||||||
.filterTo(mutableListOf()) { dictGroup.hasDict(it, account) }
|
.filterTo(mutableListOf()) { dictGroup.hasDict(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new dictionary groups and remove dictionaries to re-use from existingDictsToCleanup
|
// create new dictionary groups and remove dictionaries to re-use from existingDictsToCleanup
|
||||||
|
@ -204,7 +196,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
// create new or re-use already loaded main dict
|
// create new or re-use already loaded main dict
|
||||||
val mainDict: Dictionary?
|
val mainDict: Dictionary?
|
||||||
if (forceReload || oldDictGroupForLocale == null
|
if (forceReload || oldDictGroupForLocale == null
|
||||||
|| !oldDictGroupForLocale.hasDict(Dictionary.TYPE_MAIN, account)
|
|| !oldDictGroupForLocale.hasDict(Dictionary.TYPE_MAIN)
|
||||||
) {
|
) {
|
||||||
mainDict = null // null main dicts will be loaded later in asyncReloadUninitializedMainDictionaries
|
mainDict = null // null main dicts will be loaded later in asyncReloadUninitializedMainDictionaries
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,10 +209,10 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
for (subDictType in newSubDictTypes) {
|
for (subDictType in newSubDictTypes) {
|
||||||
val subDict: ExpandableBinaryDictionary
|
val subDict: ExpandableBinaryDictionary
|
||||||
if (forceReload || oldDictGroupForLocale == null
|
if (forceReload || oldDictGroupForLocale == null
|
||||||
|| !oldDictGroupForLocale.hasDict(subDictType, account)
|
|| !oldDictGroupForLocale.hasDict(subDictType)
|
||||||
) {
|
) {
|
||||||
// Create a new dictionary.
|
// Create a new dictionary.
|
||||||
subDict = getSubDict(subDictType, context, locale, null, dictNamePrefix, account) ?: continue
|
subDict = getSubDict(subDictType, context, locale, null, dictNamePrefix) ?: continue
|
||||||
} else {
|
} else {
|
||||||
// Reuse the existing dictionary.
|
// Reuse the existing dictionary.
|
||||||
subDict = oldDictGroupForLocale.getSubDict(subDictType) ?: continue
|
subDict = oldDictGroupForLocale.getSubDict(subDictType) ?: continue
|
||||||
|
@ -228,7 +220,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
}
|
}
|
||||||
subDicts[subDictType] = subDict
|
subDicts[subDictType] = subDict
|
||||||
}
|
}
|
||||||
val newDictGroup = DictionaryGroup(locale, mainDict, account, subDicts, context)
|
val newDictGroup = DictionaryGroup(locale, mainDict, subDicts, context)
|
||||||
newDictionaryGroups.add(newDictGroup)
|
newDictionaryGroups.add(newDictGroup)
|
||||||
}
|
}
|
||||||
return newDictionaryGroups to existingDictsToCleanup
|
return newDictionaryGroups to existingDictsToCleanup
|
||||||
|
@ -305,7 +297,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
val sv = Settings.getValues()
|
val sv = Settings.getValues()
|
||||||
if (sv.mAddToPersonalDictionary // require the opt-in
|
if (sv.mAddToPersonalDictionary // require the opt-in
|
||||||
&& sv.mAutoCorrectEnabled == sv.mAutoCorrectionEnabledPerUserSettings // don't add if user wants autocorrect but input field does not, see https://github.com/Helium314/HeliBoard/issues/427#issuecomment-1905438000
|
&& sv.mAutoCorrectEnabled == sv.mAutoCorrectionEnabledPerUserSettings // don't add if user wants autocorrect but input field does not, see https://github.com/Helium314/HeliBoard/issues/427#issuecomment-1905438000
|
||||||
&& dictionaryGroups[0].hasDict(Dictionary.TYPE_USER_HISTORY, dictionaryGroups[0].account) // require personalized suggestions
|
&& dictionaryGroups[0].hasDict(Dictionary.TYPE_USER_HISTORY) // require personalized suggestions
|
||||||
&& !wasAutoCapitalized // we can't be 100% sure about what the user intended to type, so better don't add it
|
&& !wasAutoCapitalized // we can't be 100% sure about what the user intended to type, so better don't add it
|
||||||
&& words.size == 1 // only single words
|
&& words.size == 1 // only single words
|
||||||
) {
|
) {
|
||||||
|
@ -602,15 +594,15 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
// HACK: This threshold is being used when adding a capitalized entry in the User History dictionary.
|
// HACK: This threshold is being used when adding a capitalized entry in the User History dictionary.
|
||||||
private const val CAPITALIZED_FORM_MAX_PROBABILITY_FOR_INSERT = 140
|
private const val CAPITALIZED_FORM_MAX_PROBABILITY_FOR_INSERT = 140
|
||||||
|
|
||||||
private fun getSubDict(dictType: String, context: Context, locale: Locale, dictFile: File?,
|
private fun getSubDict(
|
||||||
dictNamePrefix: String, account: String?
|
dictType: String, context: Context, locale: Locale, dictFile: File?, dictNamePrefix: String
|
||||||
): ExpandableBinaryDictionary? {
|
): ExpandableBinaryDictionary? {
|
||||||
try {
|
try {
|
||||||
return when (dictType) {
|
return when (dictType) {
|
||||||
Dictionary.TYPE_USER_HISTORY -> UserHistoryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix, account)
|
Dictionary.TYPE_USER_HISTORY -> UserHistoryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix)
|
||||||
Dictionary.TYPE_USER -> UserBinaryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix, account)
|
Dictionary.TYPE_USER -> UserBinaryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix)
|
||||||
Dictionary.TYPE_CONTACTS -> ContactsBinaryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix, account)
|
Dictionary.TYPE_CONTACTS -> ContactsBinaryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix)
|
||||||
Dictionary.TYPE_APPS -> AppsBinaryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix, account)
|
Dictionary.TYPE_APPS -> AppsBinaryDictionary.getDictionary(context, locale, dictFile, dictNamePrefix)
|
||||||
else -> throw IllegalArgumentException("unknown dictionary type $dictType")
|
else -> throw IllegalArgumentException("unknown dictionary type $dictType")
|
||||||
}
|
}
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
|
@ -649,7 +641,6 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
private class DictionaryGroup(
|
private class DictionaryGroup(
|
||||||
val locale: Locale = Locale(""),
|
val locale: Locale = Locale(""),
|
||||||
private var mainDict: Dictionary? = null,
|
private var mainDict: Dictionary? = null,
|
||||||
val account: String? = null, // todo: not used, simply remove
|
|
||||||
subDicts: Map<String, ExpandableBinaryDictionary> = emptyMap(),
|
subDicts: Map<String, ExpandableBinaryDictionary> = emptyMap(),
|
||||||
context: Context? = null
|
context: Context? = null
|
||||||
) {
|
) {
|
||||||
|
@ -798,16 +789,10 @@ private class DictionaryGroup(
|
||||||
return subDicts[dictType]
|
return subDicts[dictType]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasDict(dictType: String, forAccount: String?): Boolean {
|
fun hasDict(dictType: String): Boolean {
|
||||||
if (dictType == Dictionary.TYPE_MAIN) {
|
if (dictType == Dictionary.TYPE_MAIN) {
|
||||||
return mainDict != null
|
return mainDict != null
|
||||||
}
|
}
|
||||||
if (dictType == Dictionary.TYPE_USER_HISTORY && forAccount != account) {
|
|
||||||
// If the dictionary type is user history, & if the account doesn't match,
|
|
||||||
// return immediately. If the account matches, continue looking it up in the
|
|
||||||
// sub dictionary map.
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return subDicts.containsKey(dictType)
|
return subDicts.containsKey(dictType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,8 @@ public class DictionaryFacilitatorLruCache {
|
||||||
// Nothing to do if the locale is null. This would be the case before any get() calls.
|
// Nothing to do if the locale is null. This would be the case before any get() calls.
|
||||||
if (mLocale != null) {
|
if (mLocale != null) {
|
||||||
// Note: Given that personalized dictionaries are not used here; we can pass null account.
|
// Note: Given that personalized dictionaries are not used here; we can pass null account.
|
||||||
mDictionaryFacilitator.resetDictionaries(mContext, mLocale,
|
mDictionaryFacilitator.resetDictionaries(mContext, mLocale, mUseContactsDictionary,
|
||||||
mUseContactsDictionary, mUseAppsDictionary, false /* usePersonalizedDicts */,
|
mUseAppsDictionary, false, false, mDictionaryNamePrefix, null);
|
||||||
false /* forceReloadMainDictionary */, null /* account */,
|
|
||||||
mDictionaryNamePrefix, null /* listener */);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -738,8 +738,7 @@ public class LatinIME extends InputMethodService implements
|
||||||
locales,
|
locales,
|
||||||
mSettings.getCurrent().mUseContactsDictionary,
|
mSettings.getCurrent().mUseContactsDictionary,
|
||||||
mSettings.getCurrent().mUseAppsDictionary,
|
mSettings.getCurrent().mUseAppsDictionary,
|
||||||
mSettings.getCurrent().mUsePersonalizedDicts,
|
mSettings.getCurrent().mUsePersonalizedDicts
|
||||||
mSettings.getCurrent().mAccount
|
|
||||||
)) {
|
)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +756,7 @@ public class LatinIME extends InputMethodService implements
|
||||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||||
mDictionaryFacilitator.resetDictionaries(this, locale,
|
mDictionaryFacilitator.resetDictionaries(this, locale,
|
||||||
settingsValues.mUseContactsDictionary, settingsValues.mUseAppsDictionary,
|
settingsValues.mUseContactsDictionary, settingsValues.mUseAppsDictionary,
|
||||||
settingsValues.mUsePersonalizedDicts, false, settingsValues.mAccount, "", this);
|
settingsValues.mUsePersonalizedDicts, false, "", this);
|
||||||
mInputLogic.mSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold);
|
mInputLogic.mSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,12 +765,9 @@ public class LatinIME extends InputMethodService implements
|
||||||
*/
|
*/
|
||||||
/* package private */ void resetSuggestMainDict() {
|
/* package private */ void resetSuggestMainDict() {
|
||||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||||
mDictionaryFacilitator.resetDictionaries(this /* context */,
|
mDictionaryFacilitator.resetDictionaries(this, mDictionaryFacilitator.getMainLocale(),
|
||||||
mDictionaryFacilitator.getMainLocale(), settingsValues.mUseContactsDictionary,
|
settingsValues.mUseContactsDictionary, settingsValues.mUseAppsDictionary,
|
||||||
settingsValues.mUseAppsDictionary, settingsValues.mUsePersonalizedDicts,
|
settingsValues.mUsePersonalizedDicts, true, "", this);
|
||||||
true /* forceReloadMainDictionary */,
|
|
||||||
settingsValues.mAccount, "" /* dictNamePrefix */,
|
|
||||||
this /* DictionaryInitializationListener */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// used for debug
|
// used for debug
|
||||||
|
|
|
@ -82,8 +82,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserBinaryDictionary getDictionary(
|
public static UserBinaryDictionary getDictionary(
|
||||||
final Context context, final Locale locale, final File dictFile,
|
final Context context, final Locale locale, final File dictFile, final String dictNamePrefix) {
|
||||||
final String dictNamePrefix, @Nullable final String account) {
|
|
||||||
return new UserBinaryDictionary(context, locale, false, dictFile, dictNamePrefix + NAME);
|
return new UserBinaryDictionary(context, locale, false, dictFile, dictNamePrefix + NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.content.Context;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import helium314.keyboard.latin.common.FileUtils;
|
import helium314.keyboard.latin.common.FileUtils;
|
||||||
|
|
||||||
|
@ -31,12 +30,8 @@ public class PersonalizationHelper {
|
||||||
sLangUserHistoryDictCache = new ConcurrentHashMap<>();
|
sLangUserHistoryDictCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static UserHistoryDictionary getUserHistoryDictionary(
|
public static UserHistoryDictionary getUserHistoryDictionary(final Context context, final Locale locale) {
|
||||||
final Context context, final Locale locale, @Nullable final String accountName) {
|
|
||||||
String lookupStr = locale.toString();
|
String lookupStr = locale.toString();
|
||||||
if (accountName != null) {
|
|
||||||
lookupStr += "." + accountName;
|
|
||||||
}
|
|
||||||
synchronized (sLangUserHistoryDictCache) {
|
synchronized (sLangUserHistoryDictCache) {
|
||||||
if (sLangUserHistoryDictCache.containsKey(lookupStr)) {
|
if (sLangUserHistoryDictCache.containsKey(lookupStr)) {
|
||||||
final SoftReference<UserHistoryDictionary> ref =
|
final SoftReference<UserHistoryDictionary> ref =
|
||||||
|
@ -50,8 +45,7 @@ public class PersonalizationHelper {
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final UserHistoryDictionary dict = new UserHistoryDictionary(
|
final UserHistoryDictionary dict = new UserHistoryDictionary(context, locale);
|
||||||
context, locale, accountName);
|
|
||||||
sLangUserHistoryDictCache.put(lookupStr, new SoftReference<>(dict));
|
sLangUserHistoryDictCache.put(lookupStr, new SoftReference<>(dict));
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,8 @@ public class UserHistoryDictionary extends ExpandableBinaryDictionary {
|
||||||
static final String NAME = UserHistoryDictionary.class.getSimpleName();
|
static final String NAME = UserHistoryDictionary.class.getSimpleName();
|
||||||
|
|
||||||
// TODO: Make this constructor private
|
// TODO: Make this constructor private
|
||||||
UserHistoryDictionary(final Context context, final Locale locale,
|
UserHistoryDictionary(final Context context, final Locale locale) {
|
||||||
@Nullable final String account) {
|
super(context, getUserHistoryDictName(NAME, locale, null), locale, Dictionary.TYPE_USER_HISTORY, null);
|
||||||
super(context, getUserHistoryDictName(NAME, locale, null /* dictFile */, account), locale, Dictionary.TYPE_USER_HISTORY, null);
|
|
||||||
if (mLocale != null && mLocale.toString().length() > 1) {
|
if (mLocale != null && mLocale.toString().length() > 1) {
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
}
|
}
|
||||||
|
@ -41,14 +40,13 @@ public class UserHistoryDictionary extends ExpandableBinaryDictionary {
|
||||||
/**
|
/**
|
||||||
* @returns the name of the {@link UserHistoryDictionary}.
|
* @returns the name of the {@link UserHistoryDictionary}.
|
||||||
*/
|
*/
|
||||||
static String getUserHistoryDictName(final String name, final Locale locale,
|
static String getUserHistoryDictName(final String name, final Locale locale, @Nullable final File dictFile) {
|
||||||
@Nullable final File dictFile, @Nullable final String account) {
|
|
||||||
return getDictName(name, locale, dictFile);
|
return getDictName(name, locale, dictFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserHistoryDictionary getDictionary(final Context context, final Locale locale,
|
public static UserHistoryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix, @Nullable final String account) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return PersonalizationHelper.getUserHistoryDictionary(context, locale, account);
|
return PersonalizationHelper.getUserHistoryDictionary(context, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.util.TypedValueCompat;
|
import androidx.core.util.TypedValueCompat;
|
||||||
|
|
||||||
import helium314.keyboard.compat.ConfigurationCompatKt;
|
import helium314.keyboard.compat.ConfigurationCompatKt;
|
||||||
|
@ -150,9 +149,6 @@ public class SettingsValues {
|
||||||
// User-defined colors
|
// User-defined colors
|
||||||
public final Colors mColors;
|
public final Colors mColors;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public final String mAccount; // todo: always null, remove?
|
|
||||||
|
|
||||||
// creation of Colors and SpacingAndPunctuations are the slowest parts in here, but still ok
|
// creation of Colors and SpacingAndPunctuations are the slowest parts in here, but still ok
|
||||||
public SettingsValues(final Context context, final SharedPreferences prefs, final Resources res,
|
public SettingsValues(final Context context, final SharedPreferences prefs, final Resources res,
|
||||||
@NonNull final InputAttributes inputAttributes) {
|
@NonNull final InputAttributes inputAttributes) {
|
||||||
|
@ -228,7 +224,6 @@ public class SettingsValues {
|
||||||
mGestureFloatingPreviewDynamicEnabled = Settings.readGestureDynamicPreviewEnabled(prefs);
|
mGestureFloatingPreviewDynamicEnabled = Settings.readGestureDynamicPreviewEnabled(prefs);
|
||||||
mGestureFastTypingCooldown = prefs.getInt(Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN, Defaults.PREF_GESTURE_FAST_TYPING_COOLDOWN);
|
mGestureFastTypingCooldown = prefs.getInt(Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN, Defaults.PREF_GESTURE_FAST_TYPING_COOLDOWN);
|
||||||
mGestureTrailFadeoutDuration = prefs.getInt(Settings.PREF_GESTURE_TRAIL_FADEOUT_DURATION, Defaults.PREF_GESTURE_TRAIL_FADEOUT_DURATION);
|
mGestureTrailFadeoutDuration = prefs.getInt(Settings.PREF_GESTURE_TRAIL_FADEOUT_DURATION, Defaults.PREF_GESTURE_TRAIL_FADEOUT_DURATION);
|
||||||
mAccount = null; // remove? or can it be useful somewhere?
|
|
||||||
mOverrideShowingSuggestions = mInputAttributes.mMayOverrideShowingSuggestions
|
mOverrideShowingSuggestions = mInputAttributes.mMayOverrideShowingSuggestions
|
||||||
&& prefs.getBoolean(Settings.PREF_ALWAYS_SHOW_SUGGESTIONS, Defaults.PREF_ALWAYS_SHOW_SUGGESTIONS)
|
&& prefs.getBoolean(Settings.PREF_ALWAYS_SHOW_SUGGESTIONS, Defaults.PREF_ALWAYS_SHOW_SUGGESTIONS)
|
||||||
&& ((inputAttributes.mInputType & InputType.TYPE_MASK_VARIATION) != InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
|
&& ((inputAttributes.mInputType & InputType.TYPE_MASK_VARIATION) != InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue