blob: 26a1f7ff63f1abe7523394d61a3e8f099fc604ff [file] [log] [blame]
Fan Zhanga96b11f2017-01-21 14:53:01 -08001/*
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
17package com.android.settings.dashboard;
18
19import android.util.ArrayMap;
20
Fan Zhanga96b11f2017-01-21 14:53:01 -080021import com.android.settings.DisplaySettings;
jin.donga3a24be2018-12-20 11:48:20 +080022import com.android.settings.LegalSettings;
Fan Zhang881d5792018-01-26 10:15:56 -080023import com.android.settings.accounts.AccountDashboardFragment;
Fan Zhang970bacd2018-02-14 14:57:51 -080024import com.android.settings.accounts.AccountDetailDashboardFragment;
Yanting Yangba8e5802021-05-25 02:35:58 +080025import com.android.settings.applications.AppDashboardFragment;
Yilin Cai9bcd6ba2023-01-17 21:32:26 +080026import com.android.settings.applications.specialaccess.SpecialAccessSettings;
Darrell Shi65836b12022-12-14 16:46:48 +000027import com.android.settings.communal.CommunalDashboardFragment;
jackqdyulei5ef1f502017-12-15 10:42:15 -080028import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
HJ ChangLiaoc338e262018-04-12 16:29:33 +080029import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
Fan Zhang4c26da92017-09-08 15:29:54 -070030import com.android.settings.development.DevelopmentSettingsDashboardFragment;
Fan Zhanga96b11f2017-01-21 14:53:01 -080031import com.android.settings.deviceinfo.StorageDashboardFragment;
jin.donga3a24be2018-12-20 11:48:20 +080032import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
Doris Ling24827a12018-05-10 13:32:24 -070033import com.android.settings.display.NightDisplaySettings;
Fan Zhang9b1fb772021-01-06 17:26:50 -080034import com.android.settings.emergency.EmergencyDashboardFragment;
Alex Chaueaf78932018-12-03 16:21:03 +000035import com.android.settings.enterprise.EnterprisePrivacySettings;
Kenny Guy1c045db2020-01-13 19:52:08 +000036import com.android.settings.fuelgauge.SmartBatterySettings;
jin.donga3a24be2018-12-20 11:48:20 +080037import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
xuezaiyueac731842022-06-08 21:53:23 +080038import com.android.settings.fuelgauge.batteryusage.PowerUsageSummary;
Doris Ling24827a12018-05-10 13:32:24 -070039import com.android.settings.gestures.GestureSettings;
Fan Zhang130c4772018-10-01 12:14:06 -070040import com.android.settings.homepage.TopLevelSettings;
Fan Zhanga96b11f2017-01-21 14:53:01 -080041import com.android.settings.network.NetworkDashboardFragment;
Julia Reynolds8cf8bf02017-04-17 17:22:09 -040042import com.android.settings.notification.ConfigureNotificationSettings;
Fan Zhanga96b11f2017-01-21 14:53:01 -080043import com.android.settings.notification.SoundSettings;
tmfang80d03d12018-11-02 16:53:47 +080044import com.android.settings.privacy.PrivacyDashboardFragment;
Prabal Singh9463e912023-02-07 16:56:15 +000045import com.android.settings.safetycenter.MoreSecurityPrivacyFragment;
Aena Verma92845332025-08-25 04:54:51 -070046import com.android.settings.safetycenter.ui.PrivacyControlsFragment;
Katsiaryna Naliuka7e4fc2b2017-06-12 17:37:33 +020047import com.android.settings.security.LockscreenDashboardFragment;
Yuri Ufimtsev4eea1262021-12-03 15:43:11 +000048import com.android.settings.security.SecurityAdvancedSettings;
Fan Zhang73dc4792018-01-29 12:06:58 -080049import com.android.settings.security.SecuritySettings;
rashipatilc360a802025-06-05 11:33:11 +000050import com.android.settings.sound.MediaControlsSettings;
Yvonne Jiang484c83f2025-01-30 16:37:38 -080051import com.android.settings.supervision.SupervisionDashboardFragment;
Fan Zhanga96b11f2017-01-21 14:53:01 -080052import com.android.settings.system.SystemDashboardFragment;
53import com.android.settingslib.drawer.CategoryKey;
54
55import java.util.Map;
56
57/**
58 * A registry to keep track of which page hosts which category.
Fan Zhanga96b11f2017-01-21 14:53:01 -080059 */
60public class DashboardFragmentRegistry {
61
62 /**
63 * Map from parent fragment to category key. The parent fragment hosts child with
64 * category_key.
65 */
66 public static final Map<String, String> PARENT_TO_CATEGORY_KEY_MAP;
67
68 /**
69 * Map from category_key to parent. This is a helper to look up which fragment hosts the
70 * category_key.
71 */
72 public static final Map<String, String> CATEGORY_KEY_TO_PARENT_MAP;
73
74 static {
75 PARENT_TO_CATEGORY_KEY_MAP = new ArrayMap<>();
Fan Zhang130c4772018-10-01 12:14:06 -070076 PARENT_TO_CATEGORY_KEY_MAP.put(TopLevelSettings.class.getName(),
77 CategoryKey.CATEGORY_HOMEPAGE);
Fan Zhanga96b11f2017-01-21 14:53:01 -080078 PARENT_TO_CATEGORY_KEY_MAP.put(
79 NetworkDashboardFragment.class.getName(), CategoryKey.CATEGORY_NETWORK);
HJ ChangLiaoc338e262018-04-12 16:29:33 +080080 PARENT_TO_CATEGORY_KEY_MAP.put(ConnectedDeviceDashboardFragment.class.getName(),
81 CategoryKey.CATEGORY_CONNECT);
jackqdyulei5ef1f502017-12-15 10:42:15 -080082 PARENT_TO_CATEGORY_KEY_MAP.put(AdvancedConnectedDeviceDashboardFragment.class.getName(),
83 CategoryKey.CATEGORY_DEVICE);
Yanting Yangba8e5802021-05-25 02:35:58 +080084 PARENT_TO_CATEGORY_KEY_MAP.put(AppDashboardFragment.class.getName(),
Fan Zhanga96b11f2017-01-21 14:53:01 -080085 CategoryKey.CATEGORY_APPS);
Fan Zhang7e6df832017-01-24 14:02:17 -080086 PARENT_TO_CATEGORY_KEY_MAP.put(PowerUsageSummary.class.getName(),
87 CategoryKey.CATEGORY_BATTERY);
Fan Zhanga96b11f2017-01-21 14:53:01 -080088 PARENT_TO_CATEGORY_KEY_MAP.put(DisplaySettings.class.getName(),
89 CategoryKey.CATEGORY_DISPLAY);
Fan Zhang9b1fb772021-01-06 17:26:50 -080090 PARENT_TO_CATEGORY_KEY_MAP.put(EmergencyDashboardFragment.class.getName(),
91 CategoryKey.CATEGORY_EMERGENCY);
Fan Zhanga96b11f2017-01-21 14:53:01 -080092 PARENT_TO_CATEGORY_KEY_MAP.put(SoundSettings.class.getName(),
93 CategoryKey.CATEGORY_SOUND);
94 PARENT_TO_CATEGORY_KEY_MAP.put(StorageDashboardFragment.class.getName(),
95 CategoryKey.CATEGORY_STORAGE);
Fan Zhang73dc4792018-01-29 12:06:58 -080096 PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
Fan Zhanga96b11f2017-01-21 14:53:01 -080097 CategoryKey.CATEGORY_SECURITY);
Yuri Ufimtsev4eea1262021-12-03 15:43:11 +000098 PARENT_TO_CATEGORY_KEY_MAP.put(SecurityAdvancedSettings.class.getName(),
99 CategoryKey.CATEGORY_SECURITY_ADVANCED_SETTINGS);
Fan Zhang7e6df832017-01-24 14:02:17 -0800100 PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
Doris Lingb30ce6f2017-06-14 15:25:24 -0700101 CategoryKey.CATEGORY_ACCOUNT_DETAIL);
Fan Zhang881d5792018-01-26 10:15:56 -0800102 PARENT_TO_CATEGORY_KEY_MAP.put(AccountDashboardFragment.class.getName(),
Fan Zhanga96b11f2017-01-21 14:53:01 -0800103 CategoryKey.CATEGORY_ACCOUNT);
104 PARENT_TO_CATEGORY_KEY_MAP.put(
105 SystemDashboardFragment.class.getName(), CategoryKey.CATEGORY_SYSTEM);
danielwbhuangc9cb6802022-08-17 22:17:08 +0800106 // TODO(b/242680328) Tie new category key to LanguageSettings and KeyboardSettings page
jeffreyhuangcb823d52017-11-17 11:19:44 -0800107 PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettingsDashboardFragment.class.getName(),
108 CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
Julia Reynolds8cf8bf02017-04-17 17:22:09 -0400109 PARENT_TO_CATEGORY_KEY_MAP.put(ConfigureNotificationSettings.class.getName(),
110 CategoryKey.CATEGORY_NOTIFICATIONS);
Katsiaryna Naliuka7e4fc2b2017-06-12 17:37:33 +0200111 PARENT_TO_CATEGORY_KEY_MAP.put(LockscreenDashboardFragment.class.getName(),
112 CategoryKey.CATEGORY_SECURITY_LOCKSCREEN);
Doris Ling24827a12018-05-10 13:32:24 -0700113 PARENT_TO_CATEGORY_KEY_MAP.put(GestureSettings.class.getName(),
Fan Zhang3541dcb2018-08-09 16:50:04 -0700114 CategoryKey.CATEGORY_GESTURES);
Doris Ling24827a12018-05-10 13:32:24 -0700115 PARENT_TO_CATEGORY_KEY_MAP.put(NightDisplaySettings.class.getName(),
Fan Zhang3541dcb2018-08-09 16:50:04 -0700116 CategoryKey.CATEGORY_NIGHT_DISPLAY);
tmfang80d03d12018-11-02 16:53:47 +0800117 PARENT_TO_CATEGORY_KEY_MAP.put(PrivacyDashboardFragment.class.getName(),
118 CategoryKey.CATEGORY_PRIVACY);
Alex Chaueaf78932018-12-03 16:21:03 +0000119 PARENT_TO_CATEGORY_KEY_MAP.put(EnterprisePrivacySettings.class.getName(),
120 CategoryKey.CATEGORY_ENTERPRISE_PRIVACY);
jin.donga3a24be2018-12-20 11:48:20 +0800121 PARENT_TO_CATEGORY_KEY_MAP.put(LegalSettings.class.getName(),
122 CategoryKey.CATEGORY_ABOUT_LEGAL);
123 PARENT_TO_CATEGORY_KEY_MAP.put(MyDeviceInfoFragment.class.getName(),
124 CategoryKey.CATEGORY_MY_DEVICE_INFO);
125 PARENT_TO_CATEGORY_KEY_MAP.put(BatterySaverSettings.class.getName(),
126 CategoryKey.CATEGORY_BATTERY_SAVER_SETTINGS);
Kenny Guy1c045db2020-01-13 19:52:08 +0000127 PARENT_TO_CATEGORY_KEY_MAP.put(SmartBatterySettings.class.getName(),
128 CategoryKey.CATEGORY_SMART_BATTERY_SETTINGS);
Darrell Shi65836b12022-12-14 16:46:48 +0000129 PARENT_TO_CATEGORY_KEY_MAP.put(CommunalDashboardFragment.class.getName(),
130 CategoryKey.CATEGORY_COMMUNAL_SETTINGS);
Yilin Cai9bcd6ba2023-01-17 21:32:26 +0800131 PARENT_TO_CATEGORY_KEY_MAP.put(SpecialAccessSettings.class.getName(),
132 CategoryKey.CATEGORY_SPECIAL_APP_ACCESS);
Prabal Singh9463e912023-02-07 16:56:15 +0000133 PARENT_TO_CATEGORY_KEY_MAP.put(MoreSecurityPrivacyFragment.class.getName(),
134 CategoryKey.CATEGORY_MORE_SECURITY_PRIVACY_SETTINGS);
Yvonne Jiang484c83f2025-01-30 16:37:38 -0800135 PARENT_TO_CATEGORY_KEY_MAP.put(SupervisionDashboardFragment.class.getName(),
136 CategoryKey.CATEGORY_SUPERVISION);
rashipatilc360a802025-06-05 11:33:11 +0000137 PARENT_TO_CATEGORY_KEY_MAP.put(MediaControlsSettings.class.getName(),
138 CategoryKey.CATEGORY_MEDIA_CONTROLS_SETTINGS);
Aena Verma92845332025-08-25 04:54:51 -0700139 PARENT_TO_CATEGORY_KEY_MAP.put(PrivacyControlsFragment.class.getName(),
140 CategoryKey.CATEGORY_PRIVACY_CONTROLS);
Fan Zhanga96b11f2017-01-21 14:53:01 -0800141
142 CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
143
144 for (Map.Entry<String, String> parentToKey : PARENT_TO_CATEGORY_KEY_MAP.entrySet()) {
145 CATEGORY_KEY_TO_PARENT_MAP.put(parentToKey.getValue(), parentToKey.getKey());
146 }
Stanley Wang732514c2020-05-18 20:17:19 +0800147
148 // For injection index, redirect CATEGORY_ACCOUNT_DETAIL to AccountDashboardFragment.
149 CATEGORY_KEY_TO_PARENT_MAP.put(CategoryKey.CATEGORY_ACCOUNT_DETAIL,
150 AccountDashboardFragment.class.getName());
Fan Zhanga96b11f2017-01-21 14:53:01 -0800151 }
152}