• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.car.settings.applications;
18 
19 import android.content.Context;
20 import android.os.Bundle;
21 import android.provider.Settings;
22 
23 import androidx.annotation.XmlRes;
24 
25 import com.android.car.settings.R;
26 import com.android.car.settings.common.SettingsFragment;
27 import com.android.car.settings.search.CarBaseSearchIndexProvider;
28 import com.android.settingslib.search.SearchIndexable;
29 
30 /** Shows subsettings related to apps. */
31 @SearchIndexable
32 public class AppsFragment extends SettingsFragment {
33 
34     private RecentAppsItemManager mRecentAppsItemManager;
35     private InstalledAppCountItemManager mInstalledAppCountItemManager;
36     private HibernatedAppsItemManager mHibernatedAppsItemManager;
37 
38     @Override
39     @XmlRes
getPreferenceScreenResId()40     protected int getPreferenceScreenResId() {
41         return R.xml.apps_fragment;
42     }
43 
44     @Override
onAttach(Context context)45     public void onAttach(Context context) {
46         super.onAttach(context);
47         mRecentAppsItemManager = new RecentAppsItemManager(context,
48                 context.getResources().getInteger(R.integer.recent_apps_max_count));
49         mRecentAppsItemManager.addListener(use(AllAppsPreferenceController.class,
50                 R.string.pk_applications_settings_screen_entry));
51         mRecentAppsItemManager.addListener(use(RecentAppsGroupPreferenceController.class,
52                 R.string.pk_recent_apps_group));
53         mRecentAppsItemManager.addListener(use(RecentAppsListPreferenceController.class,
54                 R.string.pk_recent_apps_list));
55 
56         mInstalledAppCountItemManager = new InstalledAppCountItemManager(context);
57         mInstalledAppCountItemManager.addListener(use(AllAppsPreferenceController.class,
58                 R.string.pk_applications_settings_screen_entry));
59         mInstalledAppCountItemManager.addListener(use(RecentAppsViewAllPreferenceController.class,
60                 R.string.pk_recent_apps_view_all));
61 
62         mHibernatedAppsItemManager = new HibernatedAppsItemManager(context);
63         mHibernatedAppsItemManager.setListener(use(HibernatedAppsPreferenceController.class,
64                 R.string.pk_hibernated_apps));
65     }
66 
67     @Override
onCreate(Bundle savedInstanceState)68     public void onCreate(Bundle savedInstanceState) {
69         super.onCreate(savedInstanceState);
70         mRecentAppsItemManager.startLoading();
71         mInstalledAppCountItemManager.startLoading();
72         mHibernatedAppsItemManager.startLoading();
73     }
74 
75     /**
76      * Data provider for Settings Search.
77      */
78     public static final CarBaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
79             new CarBaseSearchIndexProvider(R.xml.apps_fragment,
80                     Settings.ACTION_APPLICATION_SETTINGS);
81 }
82