aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-02-20 00:11:20 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2014-02-20 00:11:20 -0800
commit4aa83faea0a748d227be2c10bfadeac09d0a6e88 (patch)
treedc0082d85a24c0b8b4b59e56add0234dc45e404c /java/src/com/android/inputmethod/latin/utils
parent63cb2a58537637637f9593552971194107d5a802 (diff)
parent1672ccbbb6167f434842093feaadc2bcd5634eab (diff)
downloadlatinime-4aa83faea0a748d227be2c10bfadeac09d0a6e88.tar.gz
latinime-4aa83faea0a748d227be2c10bfadeac09d0a6e88.tar.xz
latinime-4aa83faea0a748d227be2c10bfadeac09d0a6e88.zip
am 1672ccbb: Change important notice version preference file
* commit '1672ccbbb6167f434842093feaadc2bcd5634eab': Change important notice version preference file
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
index dd418b8cf..6b0bb86ac 100644
--- a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
@@ -30,9 +30,9 @@ public final class ImportantNoticeUtils {
// {@link SharedPreferences} name to save the last important notice version that has been
// displayed to users.
- private static final String PREFERENCE_NAME = "important_notice";
+ private static final String PREFERENCE_NAME = "important_notice_pref";
private static final String KEY_IMPORTANT_NOTICE_VERSION = "important_notice_version";
- public static final int VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS = 2;
+ public static final int VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS = 1;
// Copy of the hidden {@link Settings.Secure#USER_SETUP_COMPLETE} settings key.
// The value is zero until each multiuser completes system setup wizard.
@@ -64,9 +64,16 @@ public final class ImportantNoticeUtils {
return context.getResources().getInteger(R.integer.config_important_notice_version);
}
+ private static int getLastImportantNoticeVersion(final Context context) {
+ return getImportantNoticePreferences(context).getInt(KEY_IMPORTANT_NOTICE_VERSION, 0);
+ }
+
+ private static int getNextImportantNoticeVersion(final Context context) {
+ return getLastImportantNoticeVersion(context) + 1;
+ }
+
private static boolean hasNewImportantNotice(final Context context) {
- final SharedPreferences prefs = getImportantNoticePreferences(context);
- final int lastVersion = prefs.getInt(KEY_IMPORTANT_NOTICE_VERSION, 0);
+ final int lastVersion = getLastImportantNoticeVersion(context);
return getCurrentImportantNoticeVersion(context) > lastVersion;
}
@@ -79,14 +86,15 @@ public final class ImportantNoticeUtils {
}
public static void updateLastImportantNoticeVersion(final Context context) {
- final SharedPreferences prefs = getImportantNoticePreferences(context);
- prefs.edit()
- .putInt(KEY_IMPORTANT_NOTICE_VERSION, getCurrentImportantNoticeVersion(context))
+ getImportantNoticePreferences(context)
+ .edit()
+ .putInt(KEY_IMPORTANT_NOTICE_VERSION, getNextImportantNoticeVersion(context))
.apply();
}
- public static String getImportantNoticeTitle(final Context context) {
- switch (getCurrentImportantNoticeVersion(context)) {
+ // TODO: Make title resource to string array indexed by version.
+ public static String getNextImportantNoticeTitle(final Context context) {
+ switch (getNextImportantNoticeVersion(context)) {
case VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS:
return context.getString(R.string.important_notice_title);
default:
@@ -94,8 +102,9 @@ public final class ImportantNoticeUtils {
}
}
- public static String getImportantNoticeContents(final Context context) {
- switch (getCurrentImportantNoticeVersion(context)) {
+ // TODO: Make content resource to string array indexed by version.
+ public static String getNextImportantNoticeContents(final Context context) {
+ switch (getNextImportantNoticeVersion(context)) {
case VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS:
return context.getString(R.string.important_notice_contents);
default: