Clear mDialogFragment when it's detached
and re-associate it when it's re-created. Before this CL, the association is gone when fragment goes through the pause-resume cycle. Similarly, restore onDismiss and onCancel listeners in VpnSettings.onCreateDialog(), restore states in onCreate() instead of onActivityCreated() so that screen rotation can be handled correctly. Now that profiles are shared between Settings instances, always handle state change in VpnSettings.changeState() so that state changed in one instance can be conveyed to the other and preferences can be correctly enabled/disabled. In additions, fix some trivial mistakes in VpnSettings. Bug: 3396394 Change-Id: I242e1ed6c6d410b4dfefb373d8f98266fc9b46d0
This commit is contained in:
@@ -182,6 +182,8 @@ public class SettingsPreferenceFragment extends PreferenceFragment
|
||||
+ DialogCreatable.class.getName());
|
||||
}
|
||||
}
|
||||
// restore mDialogFragment in mParentFragment
|
||||
((SettingsPreferenceFragment) mParentFragment).mDialogFragment = this;
|
||||
}
|
||||
return ((DialogCreatable) mParentFragment).onCreateDialog(mDialogId);
|
||||
}
|
||||
@@ -204,6 +206,16 @@ public class SettingsPreferenceFragment extends PreferenceFragment
|
||||
public int getDialogId() {
|
||||
return mDialogId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
|
||||
// in case the dialog is not explicitly removed by removeDialog()
|
||||
if (((SettingsPreferenceFragment) mParentFragment).mDialogFragment == this) {
|
||||
((SettingsPreferenceFragment) mParentFragment).mDialogFragment = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean hasNextButton() {
|
||||
|
Reference in New Issue
Block a user