1 /*
2  * Copyright (C) 2018 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 
17 package com.android.settings.accounts;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.os.UserHandle;
22 import android.os.UserManager;
23 
24 import com.android.settings.R;
25 import com.android.settings.Utils;
26 import com.android.settings.dashboard.DashboardFragment;
27 
28 /**
29  * Activity asking a user to select an account to be set up.
30  */
31 public class ChooseAccountFragment extends DashboardFragment {
32 
33     private static final String TAG = "ChooseAccountFragment";
34 
35     @Override
getMetricsCategory()36     public int getMetricsCategory() {
37         return SettingsEnums.ACCOUNTS_CHOOSE_ACCOUNT_ACTIVITY;
38     }
39 
40     @Override
onAttach(Context context)41     public void onAttach(Context context) {
42         super.onAttach(context);
43 
44         final String[] authorities = getIntent().getStringArrayExtra(
45                 AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
46         final String[] accountTypesFilter = getIntent().getStringArrayExtra(
47                 AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);
48         final UserManager userManager = UserManager.get(getContext());
49         final UserHandle userHandle = Utils.getSecureTargetUser(getActivity().getActivityToken(),
50                 userManager, null /* arguments */, getIntent().getExtras());
51 
52         use(ChooseAccountPreferenceController.class).initialize(authorities, accountTypesFilter,
53                 userHandle, getActivity());
54     }
55 
56     @Override
getPreferenceScreenResId()57     protected int getPreferenceScreenResId() {
58         return R.xml.add_account_settings;
59     }
60 
61     @Override
getLogTag()62     protected String getLogTag() {
63         return TAG;
64     }
65 }
66