• 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.development.featureflags;
18 
19 import android.content.Context;
20 
21 import com.android.internal.logging.nano.MetricsProto;
22 import com.android.settings.R;
23 import com.android.settings.dashboard.DashboardFragment;
24 import com.android.settingslib.core.AbstractPreferenceController;
25 import com.android.settingslib.core.lifecycle.Lifecycle;
26 
27 import java.util.ArrayList;
28 import java.util.List;
29 
30 public class FeatureFlagsDashboard extends DashboardFragment {
31 
32     private static final String TAG = "FeatureFlagsDashboard";
33 
34     @Override
getMetricsCategory()35     public int getMetricsCategory() {
36         return MetricsProto.MetricsEvent.SETTINGS_FEATURE_FLAGS_DASHBOARD;
37     }
38 
39     @Override
getLogTag()40     protected String getLogTag() {
41         return TAG;
42     }
43 
44     @Override
getPreferenceScreenResId()45     protected int getPreferenceScreenResId() {
46         return R.xml.feature_flags_settings;
47     }
48 
49     @Override
onAttach(Context context)50     public void onAttach(Context context) {
51         super.onAttach(context);
52         use(FeatureFlagFooterPreferenceController.class).setFooterMixin(mFooterPreferenceMixin);
53     }
54 
55     @Override
getHelpResource()56     public int getHelpResource() {
57         return 0;
58     }
59 
60     @Override
createPreferenceControllers(Context context)61     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
62         final List<AbstractPreferenceController> controllers = new ArrayList<>();
63         final Lifecycle lifecycle = getLifecycle();
64         final FeatureFlagFooterPreferenceController footerController =
65                 new FeatureFlagFooterPreferenceController(context);
66         controllers.add(new FeatureFlagsPreferenceController(context, lifecycle));
67         controllers.add(footerController);
68         lifecycle.addObserver(footerController);
69         return controllers;
70     }
71 }
72