aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/settings
diff options
context:
space:
mode:
authorSandeep Siddhartha <sansid@google.com>2014-10-09 12:21:56 -0700
committerSandeep Siddhartha <sansid@google.com>2014-10-10 10:49:32 -0700
commit1e10d29bc8975ea45ca5e3bdf1936aa418161bcb (patch)
tree5335837308f4be45cab40477313534fde9001323 /java/src/com/android/inputmethod/latin/settings
parent6e565332df385d67d58543879f9d81263e667c06 (diff)
downloadlatinime-1e10d29bc8975ea45ca5e3bdf1936aa418161bcb.tar.gz
latinime-1e10d29bc8975ea45ca5e3bdf1936aa418161bcb.tar.xz
latinime-1e10d29bc8975ea45ca5e3bdf1936aa418161bcb.zip
Don't restore device specific preferences
There are two categories of preferences: 1. That are part of the default shared preference They were all getting backed up and restored. Added a blacklist to not restore some of these. e.g. current account 2. That are in a non-default shared preference file. These are not getting backed up currently, but added a specific local preference file for all such preferences. Bug: 17288591 Change-Id: I2f748be971a2337543e5014434aa39313fd1e1d8
Diffstat (limited to 'java/src/com/android/inputmethod/latin/settings')
-rw-r--r--java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java6
-rw-r--r--java/src/com/android/inputmethod/latin/settings/LocalSettingsConstants.java41
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java2
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsValues.java4
4 files changed, 44 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
index 45792fe0e..fa716457c 100644
--- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
@@ -167,7 +167,7 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
@Nullable
private String getCurrentlySelectedAccount() {
- return getSharedPreferences().getString(Settings.PREF_ACCOUNT_NAME, null);
+ return getSharedPreferences().getString(LocalSettingsConstants.PREF_ACCOUNT_NAME, null);
}
/**
@@ -219,7 +219,7 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
final Object selectedItem = lv.getItemAtPosition(lv.getCheckedItemPosition());
getSharedPreferences()
.edit()
- .putString(Settings.PREF_ACCOUNT_NAME, (String) selectedItem)
+ .putString(LocalSettingsConstants.PREF_ACCOUNT_NAME, (String) selectedItem)
.apply();
}
}
@@ -233,7 +233,7 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
public void onClick(DialogInterface dialog, int which) {
getSharedPreferences()
.edit()
- .remove(Settings.PREF_ACCOUNT_NAME)
+ .remove(LocalSettingsConstants.PREF_ACCOUNT_NAME)
.apply();
}
}
diff --git a/java/src/com/android/inputmethod/latin/settings/LocalSettingsConstants.java b/java/src/com/android/inputmethod/latin/settings/LocalSettingsConstants.java
new file mode 100644
index 000000000..71d6065e0
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/settings/LocalSettingsConstants.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 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.settings;
+
+/**
+ * Collection of device specific preference constants.
+ */
+public class LocalSettingsConstants {
+ // Preference file for storing preferences that are tied to a device
+ // and are not backed up.
+ public static final String PREFS_FILE = "local_prefs";
+
+ // Preference key for the current account.
+ // Do not restore.
+ public static final String PREF_ACCOUNT_NAME = "pref_account_name";
+
+ // List of preference keys to skip from being restored by backup agent.
+ // These preferences are tied to a device and hence should not be restored.
+ // e.g. account name.
+ // Ideally they could have been kept in a separate file that wasn't backed up
+ // however the preference UI currently only deals with the default
+ // shared preferences which makes it non-trivial to move these out to
+ // a different shared preferences file.
+ public static final String[] PREFS_TO_SKIP_RESTORING = new String[] {
+ PREF_ACCOUNT_NAME
+ };
+}
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index 84596b4ad..103033c16 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -106,8 +106,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEY_IS_INTERNAL = "pref_key_is_internal";
public static final String PREF_ENABLE_METRICS_LOGGING = "pref_enable_metrics_logging";
- public static final String PREF_ACCOUNT_NAME = "pref_account_name";
-
// This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.
// This is being used only for the backward compatibility.
private static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index ce8a0ab9c..660b4e095 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -64,7 +64,6 @@ public class SettingsValues {
public final boolean mSoundOn;
public final boolean mKeyPreviewPopupOn;
public final boolean mShowsVoiceInputKey;
- public final String mAccountName;
public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mShowsLanguageSwitchKey;
public final boolean mUseContactsDict;
@@ -141,7 +140,6 @@ public class SettingsValues {
mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res)
&& mInputAttributes.mShouldShowVoiceInputKey
&& SubtypeSwitcher.getInstance().isShortcutImeEnabled();
- mAccountName = prefs.getString(Settings.PREF_ACCOUNT_NAME, null);
final String autoCorrectionThresholdRawValue = prefs.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
res.getString(R.string.auto_correction_threshold_mode_index_modest));
@@ -385,8 +383,6 @@ public class SettingsValues {
sb.append("" + mKeyPreviewPopupOn);
sb.append("\n mShowsVoiceInputKey = ");
sb.append("" + mShowsVoiceInputKey);
- sb.append("\n mAccountName = ");
- sb.append("" + mAccountName);
sb.append("\n mIncludesOtherImesInLanguageSwitchList = ");
sb.append("" + mIncludesOtherImesInLanguageSwitchList);
sb.append("\n mShowsLanguageSwitchKey = ");