Fix bug about Wi-Fi dialog rotation
When user clicks a Wi-Fi access point in WifiSettings, screen pops up a Wi-Fi point dialog. And then user rotates the screen, Wi-Fi access dialog changes to "Add network" full screen dialog. In old code, we check whether dialog is showing by dialog.isShowing() in onSaveInstanceState. For now, this design is not appropriate. Since isShowing() won't return true anymore when fragment calls onSaveInstanceState. So, we check dialog object whether is null or not now. If dialog is null, it means that there is no dialog was shown, before user rotates the screen. Change-Id: I7dc26369c005f576fe679abc70327f6a02620935 Fixes: 112624846 Test: manual test, robo test
This commit is contained in:
@@ -24,6 +24,7 @@ import android.app.Activity;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
@@ -87,7 +88,7 @@ import java.util.List;
|
|||||||
@SearchIndexable
|
@SearchIndexable
|
||||||
public class WifiSettings extends RestrictedSettingsFragment
|
public class WifiSettings extends RestrictedSettingsFragment
|
||||||
implements Indexable, WifiTracker.WifiListener, AccessPointListener,
|
implements Indexable, WifiTracker.WifiListener, AccessPointListener,
|
||||||
WifiDialog.WifiDialogListener {
|
WifiDialog.WifiDialogListener, DialogInterface.OnDismissListener {
|
||||||
|
|
||||||
private static final String TAG = "WifiSettings";
|
private static final String TAG = "WifiSettings";
|
||||||
|
|
||||||
@@ -432,9 +433,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
// If dialog has been shown, save its state.
|
||||||
// If the dialog is showing, save its state.
|
if (mDialog != null) {
|
||||||
if (mDialog != null && mDialog.isShowing()) {
|
|
||||||
outState.putInt(SAVE_DIALOG_MODE, mDialogMode);
|
outState.putInt(SAVE_DIALOG_MODE, mDialogMode);
|
||||||
if (mDlgAccessPoint != null) {
|
if (mDlgAccessPoint != null) {
|
||||||
mAccessPointSavedState = new Bundle();
|
mAccessPointSavedState = new Bundle();
|
||||||
@@ -623,6 +623,18 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
return super.onCreateDialog(dialogId);
|
return super.onCreateDialog(dialogId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDialogShowing() {
|
||||||
|
super.onDialogShowing();
|
||||||
|
setOnDismissListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
// We don't keep any dialog object when dialog was dismissed.
|
||||||
|
mDialog = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDialogMetricsCategory(int dialogId) {
|
public int getDialogMetricsCategory(int dialogId) {
|
||||||
switch (dialogId) {
|
switch (dialogId) {
|
||||||
|
Reference in New Issue
Block a user