From bdd1bf86eaa9be3ddb3a664a269828501393f28a Mon Sep 17 00:00:00 2001 From: Nicolas Prevot Date: Thu, 23 Jun 2016 14:26:21 +0100 Subject: [PATCH] Don't dismiss remove work profile dialog on orientation change. Use a DialogFragment. BUG:19635753 Change-Id: I6ef34e3eea3e55e0e827b77d4f2cc7d22f7cc8b5 --- .../settings/accounts/AccountSettings.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java index eb740346f4d..9b609e96444 100644 --- a/src/com/android/settings/accounts/AccountSettings.java +++ b/src/com/android/settings/accounts/AccountSettings.java @@ -228,14 +228,8 @@ public class AccountSettings extends SettingsPreferenceFragment } if (preference == profileData.removeWorkProfilePreference) { final int userId = profileData.userInfo.id; - UserDialogs.createRemoveDialog(getActivity(), userId, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - mUm.removeUser(userId); - } - } - ).show(); + RemoveUserFragment.newInstance(userId).show(getActivity().getFragmentManager(), + "removeUser"); return true; } if (preference == profileData.managedProfilePreference) { @@ -621,6 +615,32 @@ public class AccountSettings extends SettingsPreferenceFragment } } + public static class RemoveUserFragment extends DialogFragment { + private static final String ARG_USER_ID = "userId"; + + static RemoveUserFragment newInstance(int userId) { + Bundle args = new Bundle(); + args.putInt(ARG_USER_ID, userId); + RemoveUserFragment fragment = new RemoveUserFragment(); + fragment.setArguments(args); + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final int userId = getArguments().getInt(ARG_USER_ID); + return UserDialogs.createRemoveDialog(getActivity(), userId, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + UserManager um = (UserManager) + getActivity().getSystemService(Context.USER_SERVICE); + um.removeUser(userId); + } + }); + } + } + /** * Dialog to inform user about changing auto-sync setting */