Merge "Show important notice dialog"

This commit is contained in:
Tadashi G. Takaoka 2014-02-03 08:04:03 +00:00 committed by Android (Google) Code Review
commit a2d83dfdc7

View file

@ -79,6 +79,7 @@ import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.CapsModeUtils;
import com.android.inputmethod.latin.utils.CompletionInfoUtils; import com.android.inputmethod.latin.utils.CompletionInfoUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; 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.IntentUtils;
import com.android.inputmethod.latin.utils.JniUtils; import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils; import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
@ -1157,11 +1158,24 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mInputLogic.mSuggest.mDictionaryFacilitator.addWordToUserDictionary(wordToEdit); 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 // Callback for the {@link SuggestionStripView}, to call when the important notice strip is
// pressed. // pressed.
@Override @Override
public void showImportantNoticeContents() { 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() { public void displaySettingsDialog() {
@ -1694,17 +1708,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}; };
final AlertDialog.Builder builder = final AlertDialog.Builder builder =
new AlertDialog.Builder(this).setItems(items, listener).setTitle(title); 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(); final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
if (windowToken == null) { if (windowToken == null) {
return; return;
} }
dialog.setCancelable(true); dialog.setCancelable(cancelable);
dialog.setCanceledOnTouchOutside(true); dialog.setCanceledOnTouchOutside(cancelable);
final Window window = dialog.getWindow(); final Window window = dialog.getWindow();
final WindowManager.LayoutParams lp = window.getAttributes(); final WindowManager.LayoutParams lp = window.getAttributes();