From 342e81e7a6cfec8054a8978a9bb84b68e76a01b0 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 3 Feb 2014 14:03:58 +0900 Subject: [PATCH] Show important notice dialog Bug: 10587358 Change-Id: I3b4282a1bb183aa901110a4a2fc1b6ed72818aae --- .../android/inputmethod/latin/LatinIME.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 208cf22a6..1a6d3879d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -79,6 +79,7 @@ import com.android.inputmethod.latin.utils.ApplicationUtils; import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.CompletionInfoUtils; import com.android.inputmethod.latin.utils.CoordinateUtils; +import com.android.inputmethod.latin.utils.ImportantNoticeUtils; import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.JniUtils; import com.android.inputmethod.latin.utils.LatinImeLoggerUtils; @@ -1157,11 +1158,24 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.mSuggest.mDictionaryFacilitator.addWordToUserDictionary(wordToEdit); } + // TODO: Move this method out of {@link LatinIME}. // Callback for the {@link SuggestionStripView}, to call when the important notice strip is // pressed. @Override public void showImportantNoticeContents() { - // TODO: Show dialog to display important notice contents. + final Context context = this; + final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { + @Override + public void onClick(final DialogInterface di, final int position) { + di.dismiss(); + ImportantNoticeUtils.updateLastImportantNoticeVersion(context); + } + }; + 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); + showOptionDialog(builder.create(), false /* cancelable */); } public void displaySettingsDialog() { @@ -1692,17 +1706,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen }; final AlertDialog.Builder builder = new AlertDialog.Builder(this).setItems(items, listener).setTitle(title); - showOptionDialog(builder.create()); + showOptionDialog(builder.create(), true /*cancelable */); } - public void showOptionDialog(final AlertDialog dialog) { + // TODO: Move this method out of {@link LatinIME}. + private void showOptionDialog(final AlertDialog dialog, final boolean cancelable) { final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken(); if (windowToken == null) { return; } - dialog.setCancelable(true); - dialog.setCanceledOnTouchOutside(true); + dialog.setCancelable(cancelable); + dialog.setCanceledOnTouchOutside(cancelable); final Window window = dialog.getWindow(); final WindowManager.LayoutParams lp = window.getAttributes();