1 /*
2  * Copyright (C) 2023 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.intentresolver.emptystate;
18 
19 import android.annotation.Nullable;
20 
21 /**
22  * Model for the "empty state"/"blocker" UI to display instead of a profile tab's normal contents.
23  */
24 public interface EmptyState {
25     /**
26      * Get the title to show on the empty state.
27      */
28     @Nullable
getTitle()29     default String getTitle() {
30         return null;
31     }
32 
33     /**
34      * Get the subtitle string to show underneath the title on the empty state.
35      */
36     @Nullable
getSubtitle()37     default String getSubtitle()  {
38         return null;
39     }
40 
41     /**
42      * Get the handler for an optional button associated with this empty state. If the result is
43      * non-null, the empty-state UI will be built with a button that dispatches this handler.
44      */
45     @Nullable
getButtonClickListener()46     default ClickListener getButtonClickListener()  {
47         return null;
48     }
49 
50     /**
51      * Get whether to show the default UI for the empty state. If true, the UI will show the default
52      * blocker text ('No apps can perform this action') and style; title and subtitle are ignored.
53      */
useDefaultEmptyView()54     default boolean useDefaultEmptyView() {
55         return false;
56     }
57 
58     /**
59      * Returns true if for this empty state we should skip rebuilding of the apps list
60      * for this tab.
61      */
shouldSkipDataRebuild()62     default boolean shouldSkipDataRebuild() {
63         return false;
64     }
65 
66     /**
67      * Called when empty state is shown, could be used e.g. to track analytics events.
68      */
onEmptyStateShown()69     default void onEmptyStateShown() {}
70 
71     interface ClickListener {
onClick(TabControl currentTab)72         void onClick(TabControl currentTab);
73     }
74 
75     interface TabControl {
showSpinner()76         void showSpinner();
77     }
78 }
79