Allow OnCancelListener and OnDismissListener in Settings app

for the framework-managed dialogs.

DialogFragment acts as both listeners so the application cannot set both
listeners in the embedded dialog. New hooks are added in SettingsDialogFragment
so that settings apps can do so for the framework-managed dialogs.

Bug: 3386670
Change-Id: I144e7c4ccf7f86c61f6079fa86d830c709335af1
This commit is contained in:
Hung-ying Tyan
2011-01-25 16:42:14 +08:00
parent 0385cf14a1
commit 0ee51e04fb
3 changed files with 74 additions and 27 deletions

View File

@@ -311,19 +311,29 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
}})
.setNegativeButton(R.string.cancel, null)
.setMessage(R.string.dlg_confirm_unmount_text)
.setOnCancelListener(this)
.create();
case DLG_ERROR_UNMOUNT:
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.dlg_error_unmount_title)
.setNeutralButton(R.string.dlg_ok, null)
.setMessage(R.string.dlg_error_unmount_text)
.setOnCancelListener(this)
.create();
}
return null;
}
@Override
protected void showDialog(int id) {
super.showDialog(id);
switch (id) {
case DLG_CONFIRM_UNMOUNT:
case DLG_ERROR_UNMOUNT:
setOnCancelListener(this);
break;
}
}
private void doUnmount(boolean force) {
// Present a toast here
Toast.makeText(getActivity(), R.string.unmount_inform_text, Toast.LENGTH_SHORT).show();