diff options
author | 2014-02-20 15:47:54 +0900 | |
---|---|---|
committer | 2014-02-20 16:50:34 +0900 | |
commit | 1672ccbbb6167f434842093feaadc2bcd5634eab (patch) | |
tree | dc215cea5bb77d5707f23d6744fd31f3c04579c9 /java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java | |
parent | 78db739cdbc9a92ec836f4dc97c6b97de8535a33 (diff) | |
download | latinime-1672ccbbb6167f434842093feaadc2bcd5634eab.tar.gz latinime-1672ccbbb6167f434842093feaadc2bcd5634eab.tar.xz latinime-1672ccbbb6167f434842093feaadc2bcd5634eab.zip |
Change important notice version preference file
This CL also reset the notice version to 1.
This CL must be checked in together with Iea8d9ff038.
Change-Id: I838f7b5b295388d64d6aba90f50b06654eba16e5
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java | 31 |
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: |