aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
diff options
context:
space:
mode:
authorJatin Matani <jatinm@google.com>2014-11-24 13:48:16 -0800
committerJatin Matani <jatinm@google.com>2014-12-16 15:56:00 -0800
commitbc4ae6bdc0249f9282efea5d1fe7ccfefd6f93b0 (patch)
treec6b34da6729328cd1cab530c5134135a079f09a8 /java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
parent2c826fd28eb48bd44e8c3e465f90e99bb22649ac (diff)
downloadlatinime-bc4ae6bdc0249f9282efea5d1fe7ccfefd6f93b0.tar.gz
latinime-bc4ae6bdc0249f9282efea5d1fe7ccfefd6f93b0.tar.xz
latinime-bc4ae6bdc0249f9282efea5d1fe7ccfefd6f93b0.zip
Passing account info to dictionaryFacilitator
Attempt to use dictionary facilitor without invoking preference manager. Instead use account from settings only when things are being reset/changed. Discussion forked from ag/591663 Overall, the idea here is to maintain an account information inside dictionary groups. Reset the dictionary groups if account changes (the way we do for locale). Since only user history dictionary is currently affected, the check to reset user history dictionary also includes the check to verify the account. For other things remain the same. SettingsValues holds the current account (and is updated if prefs change due to change in account settings). The updated settings are then propagated to dictionary facilitator via LatinIME#loadSettings. Bug:18104749,18469539 Change-Id: I553e776e7ea125d0fb7a1fe70a4c7eb0b2277fb8
Diffstat (limited to 'java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java32
1 files changed, 10 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
index 946835cbc..2e41027a4 100644
--- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
@@ -37,20 +37,18 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
- * Locally gathers stats about the words user types and various other signals like auto-correction
- * cancellation or manual picks. This allows the keyboard to adapt to the typist over time.
+ * Locally gathers statistics about the words user types and various other signals like
+ * auto-correction cancellation or manual picks. This allows the keyboard to adapt to the
+ * typist over time.
*/
public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBase {
static final String NAME = UserHistoryDictionary.class.getSimpleName();
// 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 /* dictFile */,
- context),
+ getUserHistoryDictName(NAME, locale, null /* dictFile */, account),
locale,
Dictionary.TYPE_USER_HISTORY,
null /* dictFile */);
@@ -61,24 +59,21 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
*/
@UsedForTesting
static String getUserHistoryDictName(final String name, final Locale locale,
- @Nullable final File dictFile, final Context context) {
+ @Nullable final File dictFile, @Nullable final String account) {
if (!ProductionFlags.ENABLE_PER_ACCOUNT_USER_HISTORY_DICTIONARY) {
return getDictName(name, locale, dictFile);
}
- return getUserHistoryDictNamePerAccount(name, locale, dictFile, context);
+ return getUserHistoryDictNamePerAccount(name, locale, dictFile, account);
}
/**
* Uses the currently signed in account to determine the dictionary name.
*/
private static String getUserHistoryDictNamePerAccount(final String name, final Locale locale,
- @Nullable final File dictFile, final Context context) {
+ @Nullable final File dictFile, @Nullable final String account) {
if (dictFile != null) {
return dictFile.getName();
}
- final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- final String account = prefs.getString(LocalSettingsConstants.PREF_ACCOUNT_NAME,
- null /* default */);
String dictName = name + "." + locale.toString();
if (account != null) {
dictName += "." + account;
@@ -90,14 +85,7 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
@SuppressWarnings("unused")
@ExternallyReferenced
public static UserHistoryDictionary getDictionary(final Context context, final Locale locale,
- final File dictFile, final String dictNamePrefix) {
- final String account;
- if (ProductionFlags.ENABLE_PER_ACCOUNT_USER_HISTORY_DICTIONARY) {
- account = PreferenceManager.getDefaultSharedPreferences(context)
- .getString(LocalSettingsConstants.PREF_ACCOUNT_NAME, null /* default */);
- } else {
- account = null;
- }
+ final File dictFile, final String dictNamePrefix, @Nullable final String account) {
return PersonalizationHelper.getUserHistoryDictionary(context, locale, account);
}