Keep ImportantNoticeDialog showing after orientation changed
Bug: 13951402 Change-Id: Ia6340d48843abca68ebadd299827cbe43516cc39main
parent
da498229f4
commit
30d5ed67d6
|
@ -20,8 +20,6 @@ import android.app.AlertDialog;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.DialogInterface.OnShowListener;
|
||||
|
||||
import com.android.inputmethod.latin.utils.DialogUtils;
|
||||
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
||||
|
@ -29,11 +27,10 @@ import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
|||
/**
|
||||
* The dialog box that shows the important notice contents.
|
||||
*/
|
||||
public final class ImportantNoticeDialog extends AlertDialog implements OnShowListener,
|
||||
OnClickListener, OnDismissListener {
|
||||
public final class ImportantNoticeDialog extends AlertDialog implements OnClickListener {
|
||||
public interface ImportantNoticeDialogListener {
|
||||
public void onUserAcknowledgmentOfImportantNoticeDialog(final int nextVersion);
|
||||
public void onClickSettingsOfImportantNoticeDialog(final int nextVersion);
|
||||
public void onDismissImportantNoticeDialog(final int nextVersion);
|
||||
}
|
||||
|
||||
private final ImportantNoticeDialogListener mListener;
|
||||
|
@ -50,9 +47,9 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi
|
|||
if (shouldHaveSettingsButton()) {
|
||||
setButton(BUTTON_NEGATIVE, context.getString(R.string.go_to_settings), this);
|
||||
}
|
||||
// Set listeners.
|
||||
setOnShowListener(this);
|
||||
setOnDismissListener(this);
|
||||
// This dialog is cancelable by pressing back key. See {@link #onBackPress()}.
|
||||
setCancelable(true /* cancelable */);
|
||||
setCanceledOnTouchOutside(false /* cancelable */);
|
||||
}
|
||||
|
||||
private boolean shouldHaveSettingsButton() {
|
||||
|
@ -60,9 +57,9 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi
|
|||
== ImportantNoticeUtils.VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
private void userAcknowledged() {
|
||||
ImportantNoticeUtils.updateLastImportantNoticeVersion(getContext());
|
||||
mListener.onUserAcknowledgmentOfImportantNoticeDialog(mNextImportantNoticeVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,10 +67,12 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi
|
|||
if (shouldHaveSettingsButton() && which == BUTTON_NEGATIVE) {
|
||||
mListener.onClickSettingsOfImportantNoticeDialog(mNextImportantNoticeVersion);
|
||||
}
|
||||
userAcknowledged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(final DialogInterface dialog) {
|
||||
mListener.onDismissImportantNoticeDialog(mNextImportantNoticeVersion);
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
userAcknowledged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -657,9 +657,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
|
||||
mInputLogic.mConnection.finishComposingText();
|
||||
mInputLogic.mConnection.endBatchEdit();
|
||||
if (isShowingOptionDialog()) {
|
||||
mOptionsDialog.dismiss();
|
||||
}
|
||||
}
|
||||
PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this, conf,
|
||||
mInputLogic.mSuggest.mDictionaryFacilitator);
|
||||
|
@ -990,7 +987,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
|
||||
if (TRACE) Debug.stopMethodTracing();
|
||||
if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
|
||||
if (isShowingOptionDialog()) {
|
||||
mOptionsDialog.dismiss();
|
||||
mOptionsDialog = null;
|
||||
}
|
||||
|
@ -1186,7 +1183,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
|
||||
// Implement {@link ImportantNoticeDialog.ImportantNoticeDialogListener}
|
||||
@Override
|
||||
public void onDismissImportantNoticeDialog(final int nextVersion) {
|
||||
public void onUserAcknowledgmentOfImportantNoticeDialog(final int nextVersion) {
|
||||
setNeutralSuggestionStrip();
|
||||
}
|
||||
|
||||
|
@ -1694,7 +1691,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
final AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
DialogUtils.getPlatformDialogThemeContext(this));
|
||||
builder.setItems(items, listener).setTitle(title);
|
||||
showOptionDialog(builder.create());
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setCancelable(true /* cancelable */);
|
||||
dialog.setCanceledOnTouchOutside(true /* cancelable */);
|
||||
showOptionDialog(dialog);
|
||||
}
|
||||
|
||||
// TODO: Move this method out of {@link LatinIME}.
|
||||
|
@ -1704,9 +1704,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
return;
|
||||
}
|
||||
|
||||
dialog.setCancelable(true /* cancelable */);
|
||||
dialog.setCanceledOnTouchOutside(true /* cancelable */);
|
||||
|
||||
final Window window = dialog.getWindow();
|
||||
final WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.token = windowToken;
|
||||
|
|
Loading…
Reference in New Issue