blob: 0524b6317e3143be896c03c5f788338e70a4bfe6 [file] [log] [blame]
Doris Lingbfac31b2016-11-10 15:12:52 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings.accounts;
18
19import android.app.Dialog;
Fan Zhang31b21002019-01-16 13:49:47 -080020import android.app.settings.SettingsEnums;
Doris Lingbfac31b2016-11-10 15:12:52 -080021import android.content.Context;
22import android.content.DialogInterface;
23import android.os.Bundle;
24import android.os.UserManager;
25
Doris Lingbfac31b2016-11-10 15:12:52 -080026import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
27import com.android.settings.users.UserDialogs;
28
Fan Zhange97c91e2016-11-22 08:53:53 -080029public class RemoveUserFragment extends InstrumentedDialogFragment {
Doris Lingbfac31b2016-11-10 15:12:52 -080030 private static final String ARG_USER_ID = "userId";
31
32 static RemoveUserFragment newInstance(int userId) {
33 Bundle args = new Bundle();
34 args.putInt(ARG_USER_ID, userId);
35 RemoveUserFragment fragment = new RemoveUserFragment();
36 fragment.setArguments(args);
37 return fragment;
38 }
39
40 @Override
41 public Dialog onCreateDialog(Bundle savedInstanceState) {
42 final int userId = getArguments().getInt(ARG_USER_ID);
43 return UserDialogs.createRemoveDialog(getActivity(), userId,
44 new DialogInterface.OnClickListener() {
45 @Override
46 public void onClick(DialogInterface dialog, int which) {
47 UserManager um = (UserManager)
48 getActivity().getSystemService(Context.USER_SERVICE);
49 um.removeUser(userId);
50 }
51 });
52 }
53
54 @Override
55 public int getMetricsCategory() {
Fan Zhang31b21002019-01-16 13:49:47 -080056 return SettingsEnums.DIALOG_REMOVE_USER;
Doris Lingbfac31b2016-11-10 15:12:52 -080057 }
58}