aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-02-19 13:17:36 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-02-19 18:36:32 +0900
commit6abc852255072e9c5741a7d8f264bec99b0ce14e (patch)
tree597ecaeab2e964100c9f557b45571357a5c9cd56 /java/src/com/android/inputmethod/latin/LatinIME.java
parent0a4ac795d6fdd117b590902d7f5901f0db12d25c (diff)
downloadlatinime-6abc852255072e9c5741a7d8f264bec99b0ce14e.tar.gz
latinime-6abc852255072e9c5741a7d8f264bec99b0ce14e.tar.xz
latinime-6abc852255072e9c5741a7d8f264bec99b0ce14e.zip
Turn personalization on when important notice dialog is displayed
This change must be checked in together with Ifde70b1d3b. Bug: 10587358 Change-Id: I9dc48f9d521e0e6f6269e4f184389ba805f3053f
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java62
1 files changed, 43 insertions, 19 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 75ba24d75..fa035ddaf 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -25,6 +25,9 @@ import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnDismissListener;
+import android.content.DialogInterface.OnShowListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -1163,27 +1166,48 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void showImportantNoticeContents() {
final Context context = this;
- final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ final OnShowListener onShowListener = new OnShowListener() {
@Override
- public void onClick(final DialogInterface di, final int position) {
- di.dismiss();
+ public void onShow(final DialogInterface dialog) {
ImportantNoticeUtils.updateLastImportantNoticeVersion(context);
- if (position == DialogInterface.BUTTON_POSITIVE) {
- setNeutralSuggestionStrip();
- return;
- }
+ onShowImportantNoticeDialog(
+ ImportantNoticeUtils.getCurrentImportantNoticeVersion(context));
+ }
+ };
+ final OnClickListener onClickListener = new OnClickListener() {
+ @Override
+ public void onClick(final DialogInterface dialog, final int position) {
if (position == DialogInterface.BUTTON_NEGATIVE) {
launchSettings();
- return;
}
}
};
- final AlertDialog.Builder builder =
- new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_DARK);
- builder.setMessage(R.string.important_notice_contents)
- .setPositiveButton(android.R.string.ok, listener)
- .setNegativeButton(R.string.go_to_settings, listener);
- showOptionDialog(builder.create(), true /* cancelable */);
+ final OnDismissListener onDismissListener = new OnDismissListener() {
+ @Override
+ public void onDismiss(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)
+ .setOnDismissListener(onDismissListener);
+ final AlertDialog importantNoticeDialog = builder.create();
+ importantNoticeDialog.setOnShowListener(onShowListener);
+ 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() {
@@ -1637,7 +1661,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
getString(R.string.language_selection_title),
getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class)),
};
- final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ final OnClickListener listener = new OnClickListener() {
@Override
public void onClick(DialogInterface di, int position) {
di.dismiss();
@@ -1658,18 +1682,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
};
final AlertDialog.Builder builder =
new AlertDialog.Builder(this).setItems(items, listener).setTitle(title);
- showOptionDialog(builder.create(), true /*cancelable */);
+ showOptionDialog(builder.create());
}
// TODO: Move this method out of {@link LatinIME}.
- private void showOptionDialog(final AlertDialog dialog, final boolean cancelable) {
+ private void showOptionDialog(final AlertDialog dialog) {
final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
if (windowToken == null) {
return;
}
- dialog.setCancelable(cancelable);
- dialog.setCanceledOnTouchOutside(cancelable);
+ dialog.setCancelable(true /* cancelable */);
+ dialog.setCanceledOnTouchOutside(true /* cancelable */);
final Window window = dialog.getWindow();
final WindowManager.LayoutParams lp = window.getAttributes();