From 5b8ffad26c9f6996fda127d0a4ddd40fb0689f0f Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 31 Jan 2014 12:48:35 +0900 Subject: [PATCH] Move important notice version to resource Bug: 10587358 Change-Id: Ie24fc6c53b15880f4ace991a25223056f03f5eda --- .../strings-config-important-notice.xml | 24 +++++++++++++++++++ .../latin/utils/ImportantNoticeUtils.java | 14 ++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 java/res/values/strings-config-important-notice.xml diff --git a/java/res/values/strings-config-important-notice.xml b/java/res/values/strings-config-important-notice.xml new file mode 100644 index 000000000..8ee0b99c3 --- /dev/null +++ b/java/res/values/strings-config-important-notice.xml @@ -0,0 +1,24 @@ + + + + + 0 + + diff --git a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java index 8eff2e6e7..4a0823155 100644 --- a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java @@ -22,13 +22,11 @@ import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.util.Log; +import com.android.inputmethod.latin.R; + public final class ImportantNoticeUtils { private static final String TAG = ImportantNoticeUtils.class.getSimpleName(); - // The current version number of an important notice. - // This number must be incremented whenever users should see a new important notice. - private static final int CURRENT_IMPORTANT_NOTICE_VERSION = 0; - // {@link SharedPreferences} name to save the last important notice version that has been // displayed to users. private static final String PREFERENCE_NAME = "important_notice"; @@ -60,16 +58,20 @@ public final class ImportantNoticeUtils { return context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); } + private static int getCurrentImportantNoticeVersion(final Context context) { + return context.getResources().getInteger(R.integer.config_important_notice_version); + } + public static boolean hasNewImportantNotice(final Context context) { final SharedPreferences prefs = getImportantNoticePreferences(context); final int lastVersion = prefs.getInt(KEY_IMPORTANT_NOTICE_VERSION, 0); - return CURRENT_IMPORTANT_NOTICE_VERSION > lastVersion; + return getCurrentImportantNoticeVersion(context) > lastVersion; } public static void updateLastImportantNoticeVersion(final Context context) { final SharedPreferences prefs = getImportantNoticePreferences(context); prefs.edit() - .putInt(KEY_IMPORTANT_NOTICE_VERSION, CURRENT_IMPORTANT_NOTICE_VERSION) + .putInt(KEY_IMPORTANT_NOTICE_VERSION, getCurrentImportantNoticeVersion(context)) .apply(); } }