aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-02-20 15:25:07 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-02-21 09:54:08 +0900
commitfe39d576dcd515d7fcd678a2ed6a621185cc69e3 (patch)
treec47f018fe5ae1d7b0e2358ef26a467e57f2a5091 /java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
parent1b3a142cace93ab22064ae5cf5f2d2ff7635ae9e (diff)
downloadlatinime-fe39d576dcd515d7fcd678a2ed6a621185cc69e3.tar.gz
latinime-fe39d576dcd515d7fcd678a2ed6a621185cc69e3.tar.xz
latinime-fe39d576dcd515d7fcd678a2ed6a621185cc69e3.zip
Support versioned important notice
This change must be checked in together with If38a754d00. Bug: 10587358 Change-Id: I91580f9468bc5ee7ed1694d7852a60dc6793dac0
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
index 6b0bb86ac..ca8bef397 100644
--- a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
@@ -60,7 +60,7 @@ public final class ImportantNoticeUtils {
return context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
}
- public static int getCurrentImportantNoticeVersion(final Context context) {
+ private static int getCurrentImportantNoticeVersion(final Context context) {
return context.getResources().getInteger(R.integer.config_important_notice_version);
}
@@ -68,7 +68,7 @@ public final class ImportantNoticeUtils {
return getImportantNoticePreferences(context).getInt(KEY_IMPORTANT_NOTICE_VERSION, 0);
}
- private static int getNextImportantNoticeVersion(final Context context) {
+ public static int getNextImportantNoticeVersion(final Context context) {
return getLastImportantNoticeVersion(context) + 1;
}
@@ -92,23 +92,23 @@ public final class ImportantNoticeUtils {
.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;
+ final int nextVersion = getCurrentImportantNoticeVersion(context);
+ final String[] importantNoticeTitleArray = context.getResources().getStringArray(
+ R.array.important_notice_title_array);
+ if (nextVersion > 0 && nextVersion < importantNoticeTitleArray.length) {
+ return importantNoticeTitleArray[nextVersion];
}
+ 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;
+ final int nextVersion = getNextImportantNoticeVersion(context);
+ final String[] importantNoticeContentsArray = context.getResources().getStringArray(
+ R.array.important_notice_contents_array);
+ if (nextVersion > 0 && nextVersion < importantNoticeContentsArray.length) {
+ return importantNoticeContentsArray[nextVersion];
}
+ return null;
}
}