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