• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.dashboard;
18 
19 import android.util.ArrayMap;
20 
21 import com.android.settings.DisplaySettings;
22 import com.android.settings.SecuritySettings;
23 import com.android.settings.accounts.AccountDetailDashboardFragment;
24 import com.android.settings.accounts.UserAndAccountDashboardFragment;
25 import com.android.settings.applications.AppAndNotificationDashboardFragment;
26 import com.android.settings.applications.DefaultAppSettings;
27 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
28 import com.android.settings.development.DevelopmentSettings;
29 import com.android.settings.deviceinfo.StorageDashboardFragment;
30 import com.android.settings.fuelgauge.PowerUsageSummary;
31 import com.android.settings.language.LanguageAndInputSettings;
32 import com.android.settings.network.NetworkDashboardFragment;
33 import com.android.settings.notification.ConfigureNotificationSettings;
34 import com.android.settings.notification.SoundSettings;
35 import com.android.settings.security.LockscreenDashboardFragment;
36 import com.android.settings.system.SystemDashboardFragment;
37 import com.android.settingslib.drawer.CategoryKey;
38 
39 import java.util.Map;
40 
41 /**
42  * A registry to keep track of which page hosts which category.
43  */
44 public class DashboardFragmentRegistry {
45 
46     /**
47      * Map from parent fragment to category key. The parent fragment hosts child with
48      * category_key.
49      */
50     public static final Map<String, String> PARENT_TO_CATEGORY_KEY_MAP;
51 
52     /**
53      * Map from category_key to parent. This is a helper to look up which fragment hosts the
54      * category_key.
55      */
56     public static final Map<String, String> CATEGORY_KEY_TO_PARENT_MAP;
57 
58     static {
59         PARENT_TO_CATEGORY_KEY_MAP = new ArrayMap<>();
60         PARENT_TO_CATEGORY_KEY_MAP.put(
NetworkDashboardFragment.class.getName()61                 NetworkDashboardFragment.class.getName(), CategoryKey.CATEGORY_NETWORK);
ConnectedDeviceDashboardFragment.class.getName()62         PARENT_TO_CATEGORY_KEY_MAP.put(ConnectedDeviceDashboardFragment.class.getName(),
63                 CategoryKey.CATEGORY_DEVICE);
AppAndNotificationDashboardFragment.class.getName()64         PARENT_TO_CATEGORY_KEY_MAP.put(AppAndNotificationDashboardFragment.class.getName(),
65                 CategoryKey.CATEGORY_APPS);
PowerUsageSummary.class.getName()66         PARENT_TO_CATEGORY_KEY_MAP.put(PowerUsageSummary.class.getName(),
67                 CategoryKey.CATEGORY_BATTERY);
DefaultAppSettings.class.getName()68         PARENT_TO_CATEGORY_KEY_MAP.put(DefaultAppSettings.class.getName(),
69                 CategoryKey.CATEGORY_APPS_DEFAULT);
DisplaySettings.class.getName()70         PARENT_TO_CATEGORY_KEY_MAP.put(DisplaySettings.class.getName(),
71                 CategoryKey.CATEGORY_DISPLAY);
SoundSettings.class.getName()72         PARENT_TO_CATEGORY_KEY_MAP.put(SoundSettings.class.getName(),
73                 CategoryKey.CATEGORY_SOUND);
StorageDashboardFragment.class.getName()74         PARENT_TO_CATEGORY_KEY_MAP.put(StorageDashboardFragment.class.getName(),
75                 CategoryKey.CATEGORY_STORAGE);
SecuritySettings.class.getName()76         PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
77                 CategoryKey.CATEGORY_SECURITY);
AccountDetailDashboardFragment.class.getName()78         PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
79                 CategoryKey.CATEGORY_ACCOUNT_DETAIL);
UserAndAccountDashboardFragment.class.getName()80         PARENT_TO_CATEGORY_KEY_MAP.put(UserAndAccountDashboardFragment.class.getName(),
81                 CategoryKey.CATEGORY_ACCOUNT);
82         PARENT_TO_CATEGORY_KEY_MAP.put(
SystemDashboardFragment.class.getName()83                 SystemDashboardFragment.class.getName(), CategoryKey.CATEGORY_SYSTEM);
LanguageAndInputSettings.class.getName()84         PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndInputSettings.class.getName(),
85                 CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
DevelopmentSettings.class.getName()86         PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettings.class.getName(),
87                 CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
ConfigureNotificationSettings.class.getName()88         PARENT_TO_CATEGORY_KEY_MAP.put(ConfigureNotificationSettings.class.getName(),
89                 CategoryKey.CATEGORY_NOTIFICATIONS);
LockscreenDashboardFragment.class.getName()90         PARENT_TO_CATEGORY_KEY_MAP.put(LockscreenDashboardFragment.class.getName(),
91                 CategoryKey.CATEGORY_SECURITY_LOCKSCREEN);
92 
93         CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
94 
95         for (Map.Entry<String, String> parentToKey : PARENT_TO_CATEGORY_KEY_MAP.entrySet()) {
parentToKey.getKey()96             CATEGORY_KEY_TO_PARENT_MAP.put(parentToKey.getValue(), parentToKey.getKey());
97         }
98     }
99 }
100