aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-02-20 15:47:54 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-02-20 16:50:34 +0900
commit1672ccbbb6167f434842093feaadc2bcd5634eab (patch)
treedc215cea5bb77d5707f23d6744fd31f3c04579c9
parent78db739cdbc9a92ec836f4dc97c6b97de8535a33 (diff)
downloadlatinime-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
-rw-r--r--java/res/values/strings-config-important-notice.xml3
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java45
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java4
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java2
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java31
5 files changed, 38 insertions, 47 deletions
diff --git a/java/res/values/strings-config-important-notice.xml b/java/res/values/strings-config-important-notice.xml
index 6a9fe28f7..3be95d333 100644
--- a/java/res/values/strings-config-important-notice.xml
+++ b/java/res/values/strings-config-important-notice.xml
@@ -20,7 +20,8 @@
<resources>
<integer name="config_important_notice_version">0</integer>
- <!-- The title of the important notice displayed on the suggestion strip. -->
+ <!-- TODO: Make title and contents resource to string array indexed by version. -->
+ <!-- The text of the important notice displayed on the suggestion strip. -->
<string name="important_notice_title"></string>
<!-- The contents of the important notice. -->
<string name="important_notice_contents"></string>
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 5d90e10a0..94e3e7418 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1183,14 +1183,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void showImportantNoticeContents() {
final Context context = this;
- final OnShowListener onShowListener = new OnShowListener() {
- @Override
- public void onShow(final DialogInterface dialog) {
- ImportantNoticeUtils.updateLastImportantNoticeVersion(context);
- onShowImportantNoticeDialog(
- ImportantNoticeUtils.getCurrentImportantNoticeVersion(context));
- }
- };
+ final AlertDialog.Builder builder =
+ new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_DARK);
+ builder.setMessage(ImportantNoticeUtils.getNextImportantNoticeContents(context));
+ builder.setPositiveButton(android.R.string.ok, null /* listener */);
final OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int position) {
@@ -1199,34 +1195,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
};
- final OnDismissListener onDismissListener = new OnDismissListener() {
+ builder.setNegativeButton(R.string.go_to_settings, onClickListener);
+ final AlertDialog importantNoticeDialog = builder.create();
+ importantNoticeDialog.setOnShowListener(new OnShowListener() {
+ @Override
+ public void onShow(final DialogInterface dialog) {
+ ImportantNoticeUtils.updateLastImportantNoticeVersion(context);
+ }
+ });
+ importantNoticeDialog.setOnDismissListener(new OnDismissListener() {
@Override
- public void onDismiss(DialogInterface dialog) {
+ public void onDismiss(final DialogInterface dialog) {
setNeutralSuggestionStrip();
}
- };
- final String importantNoticeContents = ImportantNoticeUtils.getImportantNoticeContents(
- context);
- final AlertDialog.Builder builder = new AlertDialog.Builder(
- context, AlertDialog.THEME_HOLO_DARK);
- builder.setMessage(importantNoticeContents)
- .setPositiveButton(android.R.string.ok, null /* listener */)
- .setNegativeButton(R.string.go_to_settings, onClickListener);
- final AlertDialog importantNoticeDialog = builder.create();
- importantNoticeDialog.setOnShowListener(onShowListener);
- importantNoticeDialog.setOnDismissListener(onDismissListener);
+ });
showOptionDialog(importantNoticeDialog);
}
- private void onShowImportantNoticeDialog(final int importantNoticeVersion) {
- if (importantNoticeVersion ==
- ImportantNoticeUtils.VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS) {
- mSettings.writeUsePersonalizationDictionary(true /* enabled */);
- loadSettings();
- initSuggest();
- }
- }
-
public void displaySettingsDialog() {
if (isShowingOptionDialog()) {
return;
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index a0c8ec045..b51c765f0 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -421,10 +421,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return mPrefs.getStringSet(PREF_CORPUS_HANDLES_FOR_PERSONALIZATION, emptySet);
}
- public void writeUsePersonalizationDictionary(final boolean enabled) {
- mPrefs.edit().putBoolean(PREF_KEY_USE_PERSONALIZED_DICTS, enabled).apply();
- }
-
public static void writeEmojiRecentKeys(final SharedPreferences prefs, String str) {
prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply();
}
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 2966a8bba..4ef562d8f 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -237,7 +237,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
if (width <= 0) {
return false;
}
- final String importantNoticeTitle = ImportantNoticeUtils.getImportantNoticeTitle(
+ final String importantNoticeTitle = ImportantNoticeUtils.getNextImportantNoticeTitle(
getContext());
if (TextUtils.isEmpty(importantNoticeTitle)) {
return false;
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: