• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.panel;
18 
19 import android.content.Intent;
20 import android.net.Uri;
21 
22 import androidx.core.graphics.drawable.IconCompat;
23 import androidx.fragment.app.FragmentActivity;
24 
25 import com.android.settingslib.core.instrumentation.Instrumentable;
26 
27 import java.util.List;
28 
29 /**
30  * Represents the data class needed to create a Settings Panel. See {@link PanelFragment}.
31  */
32 public interface PanelContent extends Instrumentable {
33 
34     int VIEW_TYPE_SLIDER = 1;
35 
36     /**
37      * @return a icon for the title of the Panel.
38      */
getIcon()39     default IconCompat getIcon() {
40         return null;
41     }
42 
43     /**
44      * @return a string for the subtitle of the Panel.
45      */
getSubTitle()46     default CharSequence getSubTitle() {
47         return null;
48     }
49 
50     /**
51      * @return a string for the title of the Panel.
52      */
getTitle()53     CharSequence getTitle();
54 
55     /**
56      * @return an ordered list of the Slices to be displayed in the Panel. The first item in the
57      * list is shown on top of the Panel.
58      */
getSlices()59     List<Uri> getSlices();
60 
61     /**
62      * @return an {@link Intent} to the full content in Settings that is summarized by the Panel.
63      *
64      * <p>
65      *     For example, for the connectivity panel you would intent to the Network & Internet page.
66      * </p>
67      */
getSeeMoreIntent()68     Intent getSeeMoreIntent();
69 
70     /**
71      * @return an {@link Intent} to the go to the target activity.
72      *
73      * <p>
74      *     A common usage is to go back to previous panel.
75      * </p>
76      */
getHeaderIconIntent()77     default Intent getHeaderIconIntent() {
78         return null;
79     }
80 
81     /**
82      * @return {@code true} to enable custom button to replace see more button,
83      * {@code false} otherwise.
84      */
isCustomizedButtonUsed()85     default boolean isCustomizedButtonUsed() {
86         return false;
87     }
88 
89     /**
90      * @return a string for the title of the customized button.
91      */
getCustomizedButtonTitle()92     default CharSequence getCustomizedButtonTitle() {
93         return null;
94     }
95 
96     /**
97      * Implement the click event for custom button.
98      *
99      * @param panelActivity the FragmentActivity from PanelFragment, the user can decide whether
100      * to finish activity or not.
101      */
onClickCustomizedButton(FragmentActivity panelActivity)102     default void onClickCustomizedButton(FragmentActivity panelActivity) {}
103 
104     /**
105      * Register to start receiving callbacks for custom button events.
106      *
107      * @param callback the callback to add.
108      */
registerCallback(PanelContentCallback callback)109     default void registerCallback(PanelContentCallback callback) {}
110 
111     /**
112      * @return a view type to customized it. 0 for default layout.
113      */
getViewType()114     default int getViewType() {
115         return 0;
116     }
117 
118     /**
119      * @return {@code true} to enable progress bar visibility, {@code false} otherwise.
120      */
isProgressBarVisible()121     default boolean isProgressBarVisible() {
122         return false;
123     }
124 }
125