aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java42
1 files changed, 35 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
index 50a942382..6b0bb86ac 100644
--- a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
@@ -30,8 +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 = 1;
// Copy of the hidden {@link Settings.Secure#USER_SETUP_COMPLETE} settings key.
// The value is zero until each multiuser completes system setup wizard.
@@ -59,13 +60,20 @@ public final class ImportantNoticeUtils {
return context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
}
- private static int getCurrentImportantNoticeVersion(final Context context) {
+ public static int getCurrentImportantNoticeVersion(final Context context) {
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;
}
@@ -78,9 +86,29 @@ 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();
}
+
+ // 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:
+ return null;
+ }
+ }
+
+ // 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:
+ return null;
+ }
+ }
}