• 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.developeroptions.dashboard;
18 
19 import android.util.ArrayMap;
20 
21 import com.android.car.developeroptions.DisplaySettings;
22 import com.android.car.developeroptions.LegalSettings;
23 import com.android.car.developeroptions.accounts.AccountDashboardFragment;
24 import com.android.car.developeroptions.accounts.AccountDetailDashboardFragment;
25 import com.android.car.developeroptions.applications.AppAndNotificationDashboardFragment;
26 import com.android.car.developeroptions.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
27 import com.android.car.developeroptions.connecteddevice.ConnectedDeviceDashboardFragment;
28 import com.android.car.developeroptions.development.DevelopmentSettingsDashboardFragment;
29 import com.android.car.developeroptions.deviceinfo.StorageDashboardFragment;
30 import com.android.car.developeroptions.deviceinfo.aboutphone.MyDeviceInfoFragment;
31 import com.android.car.developeroptions.display.NightDisplaySettings;
32 import com.android.car.developeroptions.enterprise.EnterprisePrivacySettings;
33 import com.android.car.developeroptions.fuelgauge.PowerUsageSummary;
34 import com.android.car.developeroptions.fuelgauge.batterysaver.BatterySaverSettings;
35 import com.android.car.developeroptions.gestures.GestureSettings;
36 import com.android.car.developeroptions.homepage.TopLevelSettings;
37 import com.android.car.developeroptions.language.LanguageAndInputSettings;
38 import com.android.car.developeroptions.network.NetworkDashboardFragment;
39 import com.android.car.developeroptions.notification.SoundSettings;
40 import com.android.car.developeroptions.notification.ZenModeSettings;
41 import com.android.car.developeroptions.privacy.PrivacyDashboardFragment;
42 import com.android.car.developeroptions.security.LockscreenDashboardFragment;
43 import com.android.car.developeroptions.security.SecuritySettings;
44 import com.android.car.developeroptions.system.SystemDashboardFragment;
45 import com.android.settingslib.drawer.CategoryKey;
46 
47 import java.util.Map;
48 
49 /**
50  * A registry to keep track of which page hosts which category.
51  */
52 public class DashboardFragmentRegistry {
53 
54     /**
55      * Map from parent fragment to category key. The parent fragment hosts child with
56      * category_key.
57      */
58     public static final Map<String, String> PARENT_TO_CATEGORY_KEY_MAP;
59 
60     /**
61      * Map from category_key to parent. This is a helper to look up which fragment hosts the
62      * category_key.
63      */
64     public static final Map<String, String> CATEGORY_KEY_TO_PARENT_MAP;
65 
66     static {
67         PARENT_TO_CATEGORY_KEY_MAP = new ArrayMap<>();
TopLevelSettings.class.getName()68         PARENT_TO_CATEGORY_KEY_MAP.put(TopLevelSettings.class.getName(),
69                 CategoryKey.CATEGORY_HOMEPAGE);
70         PARENT_TO_CATEGORY_KEY_MAP.put(
NetworkDashboardFragment.class.getName()71                 NetworkDashboardFragment.class.getName(), CategoryKey.CATEGORY_NETWORK);
ConnectedDeviceDashboardFragment.class.getName()72         PARENT_TO_CATEGORY_KEY_MAP.put(ConnectedDeviceDashboardFragment.class.getName(),
73                 CategoryKey.CATEGORY_CONNECT);
AdvancedConnectedDeviceDashboardFragment.class.getName()74         PARENT_TO_CATEGORY_KEY_MAP.put(AdvancedConnectedDeviceDashboardFragment.class.getName(),
75                 CategoryKey.CATEGORY_DEVICE);
AppAndNotificationDashboardFragment.class.getName()76         PARENT_TO_CATEGORY_KEY_MAP.put(AppAndNotificationDashboardFragment.class.getName(),
77                 CategoryKey.CATEGORY_APPS);
PowerUsageSummary.class.getName()78         PARENT_TO_CATEGORY_KEY_MAP.put(PowerUsageSummary.class.getName(),
79                 CategoryKey.CATEGORY_BATTERY);
DisplaySettings.class.getName()80         PARENT_TO_CATEGORY_KEY_MAP.put(DisplaySettings.class.getName(),
81                 CategoryKey.CATEGORY_DISPLAY);
SoundSettings.class.getName()82         PARENT_TO_CATEGORY_KEY_MAP.put(SoundSettings.class.getName(),
83                 CategoryKey.CATEGORY_SOUND);
StorageDashboardFragment.class.getName()84         PARENT_TO_CATEGORY_KEY_MAP.put(StorageDashboardFragment.class.getName(),
85                 CategoryKey.CATEGORY_STORAGE);
SecuritySettings.class.getName()86         PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
87                 CategoryKey.CATEGORY_SECURITY);
AccountDetailDashboardFragment.class.getName()88         PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
89                 CategoryKey.CATEGORY_ACCOUNT_DETAIL);
AccountDashboardFragment.class.getName()90         PARENT_TO_CATEGORY_KEY_MAP.put(AccountDashboardFragment.class.getName(),
91                 CategoryKey.CATEGORY_ACCOUNT);
92         PARENT_TO_CATEGORY_KEY_MAP.put(
SystemDashboardFragment.class.getName()93                 SystemDashboardFragment.class.getName(), CategoryKey.CATEGORY_SYSTEM);
LanguageAndInputSettings.class.getName()94         PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndInputSettings.class.getName(),
95                 CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
DevelopmentSettingsDashboardFragment.class.getName()96         PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettingsDashboardFragment.class.getName(),
97                 CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
LockscreenDashboardFragment.class.getName()98         PARENT_TO_CATEGORY_KEY_MAP.put(LockscreenDashboardFragment.class.getName(),
99                 CategoryKey.CATEGORY_SECURITY_LOCKSCREEN);
ZenModeSettings.class.getName()100         PARENT_TO_CATEGORY_KEY_MAP.put(ZenModeSettings.class.getName(),
101                 CategoryKey.CATEGORY_DO_NOT_DISTURB);
GestureSettings.class.getName()102         PARENT_TO_CATEGORY_KEY_MAP.put(GestureSettings.class.getName(),
103                 CategoryKey.CATEGORY_GESTURES);
NightDisplaySettings.class.getName()104         PARENT_TO_CATEGORY_KEY_MAP.put(NightDisplaySettings.class.getName(),
105                 CategoryKey.CATEGORY_NIGHT_DISPLAY);
PrivacyDashboardFragment.class.getName()106         PARENT_TO_CATEGORY_KEY_MAP.put(PrivacyDashboardFragment.class.getName(),
107                 CategoryKey.CATEGORY_PRIVACY);
EnterprisePrivacySettings.class.getName()108         PARENT_TO_CATEGORY_KEY_MAP.put(EnterprisePrivacySettings.class.getName(),
109                 CategoryKey.CATEGORY_ENTERPRISE_PRIVACY);
LegalSettings.class.getName()110         PARENT_TO_CATEGORY_KEY_MAP.put(LegalSettings.class.getName(),
111                 CategoryKey.CATEGORY_ABOUT_LEGAL);
MyDeviceInfoFragment.class.getName()112         PARENT_TO_CATEGORY_KEY_MAP.put(MyDeviceInfoFragment.class.getName(),
113                 CategoryKey.CATEGORY_MY_DEVICE_INFO);
BatterySaverSettings.class.getName()114         PARENT_TO_CATEGORY_KEY_MAP.put(BatterySaverSettings.class.getName(),
115                 CategoryKey.CATEGORY_BATTERY_SAVER_SETTINGS);
116 
117         CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
118 
119         for (Map.Entry<String, String> parentToKey : PARENT_TO_CATEGORY_KEY_MAP.entrySet()) {
parentToKey.getKey()120             CATEGORY_KEY_TO_PARENT_MAP.put(parentToKey.getValue(), parentToKey.getKey());
121         }
122     }
123 }
124