1 /*
2  * Copyright (C) 2019 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.packageinstaller.role.ui.auto;
18 
19 import android.content.Context;
20 import android.os.Bundle;
21 
22 import androidx.annotation.NonNull;
23 import androidx.annotation.Nullable;
24 
25 import com.android.packageinstaller.auto.AutoSettingsFrameFragment;
26 import com.android.packageinstaller.role.ui.DefaultAppListChildFragment;
27 import com.android.packageinstaller.role.ui.TwoTargetPreference;
28 import com.android.permissioncontroller.R;
29 
30 /** Shows various roles for which a default app can be picked. */
31 public class AutoDefaultAppListFragment extends AutoSettingsFrameFragment implements
32         DefaultAppListChildFragment.Parent {
33 
34     /** Create a new instance of this fragment. */
35     @NonNull
newInstance()36     public static AutoDefaultAppListFragment newInstance() {
37         return new AutoDefaultAppListFragment();
38     }
39 
40     @Override
onCreatePreferences(Bundle bundle, String s)41     public void onCreatePreferences(Bundle bundle, String s) {
42         // Preferences will be added via shared logic in {@link DefaultAppListChildFragment}.
43     }
44 
45     @Override
onActivityCreated(@ullable Bundle savedInstanceState)46     public void onActivityCreated(@Nullable Bundle savedInstanceState) {
47         super.onActivityCreated(savedInstanceState);
48 
49         if (savedInstanceState == null) {
50             DefaultAppListChildFragment fragment = DefaultAppListChildFragment.newInstance();
51             getChildFragmentManager().beginTransaction()
52                     .add(fragment, null)
53                     .commit();
54         }
55 
56         setHeaderLabel(getString(R.string.default_apps));
57     }
58 
59     @NonNull
60     @Override
createPreference(@onNull Context context)61     public TwoTargetPreference createPreference(@NonNull Context context) {
62         return new AutoSettingsPreference(context);
63     }
64 
65     @Override
onPreferenceScreenChanged()66     public void onPreferenceScreenChanged() {
67     }
68 }
69