1a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu/*
2a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * Copyright (C) 2016 The Android Open Source Project
3a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu *
4a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * in compliance with the License. You may obtain a copy of the License at
6a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu *
7a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * http://www.apache.org/licenses/LICENSE-2.0
8a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu *
9a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * Unless required by applicable law or agreed to in writing, software distributed under the License
10a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * or implied. See the License for the specific language governing permissions and limitations under
12a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * the License.
13a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu */
14a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gupackage android.support.v17.leanback.widget;
15a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
16a373804d10f93a9488adc35cf6ce44dce09b3778Dake Guimport android.content.Context;
17a373804d10f93a9488adc35cf6ce44dce09b3778Dake Guimport android.graphics.drawable.Drawable;
18a373804d10f93a9488adc35cf6ce44dce09b3778Dake Guimport android.support.v17.leanback.R;
19a373804d10f93a9488adc35cf6ce44dce09b3778Dake Guimport android.util.AttributeSet;
20a373804d10f93a9488adc35cf6ce44dce09b3778Dake Guimport android.view.LayoutInflater;
21a373804d10f93a9488adc35cf6ce44dce09b3778Dake Guimport android.view.View;
22a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
23a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu/**
24a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * This class allows a customized widget class to implement {@link TitleViewAdapter.Provider}
25a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * and expose {@link TitleViewAdapter} methods to containing fragment (e.g. BrowseFragment or
26a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * DetailsFragment).
27a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * The title view must have a search orb view ({@link #getSearchAffordanceView()} aligned to start
28a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * and can typically have a branding Drawable and or title text aligned to end.  The branding part
29a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu * is fully open to customization: not necessary to be a drawable or text.
30a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu */
31a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gupublic abstract class TitleViewAdapter {
32a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
33a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
34a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Interface to be implemented by a customized widget class to implement
35a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * {@link TitleViewAdapter}.
36a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
37a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public interface Provider {
38a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu        /**
39a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu         * Returns {@link TitleViewAdapter} to be implemented by the customized widget class.
40a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu         * @return {@link TitleViewAdapter} to be implemented by the customized widget class.
41a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu         */
42a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu        TitleViewAdapter getTitleViewAdapter();
43a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
44a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
45a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public static final int BRANDING_VIEW_VISIBLE = 0x02;
46a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public static final int SEARCH_VIEW_VISIBLE = 0x04;
47a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public static final int FULL_VIEW_VISIBLE = BRANDING_VIEW_VISIBLE | SEARCH_VIEW_VISIBLE;
48a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
49a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
50a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Sets the title text.
51a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @param titleText The text to set as title.
52a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
53a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public void setTitle(CharSequence titleText) {
54a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
55a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
56a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
57a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Returns the title text.
58a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @return The title text.
59a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
60a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public CharSequence getTitle() {
61a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu        return null;
62a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
63a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
64a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
65a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Sets the badge drawable.
66a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * If non-null, the drawable is displayed instead of the title text.
67a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @param drawable The badge drawable to set on title view.
68a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
69a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public void setBadgeDrawable(Drawable drawable) {
70a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
71a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
72a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
73a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Returns the badge drawable.
74a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @return The badge drawable.
75a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
76a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public Drawable getBadgeDrawable() {
77a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu        return null;
78a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
79a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
80a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
81a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *  Returns the view for the search affordance.
82a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *  @return The view for search affordance.
83a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
84a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public abstract View getSearchAffordanceView();
85a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
86a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
87a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Sets a click listener for the search affordance view.
88a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *
89a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * <p>The presence of a listener will change the visibility of the search
90a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * affordance in the fragment title. When set to non-null, the title will
91a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * contain an element that a user may click to begin a search.
92a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *
93a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * <p>The listener's {@link View.OnClickListener#onClick onClick} method
94a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * will be invoked when the user clicks on the search element.
95a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *
96a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @param listener The listener to call when the search element is clicked.
97a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
98a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public void setOnSearchClickedListener(View.OnClickListener listener) {
99a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
100a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
101a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
102a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Sets the {@link android.support.v17.leanback.widget.SearchOrbView.Colors} used to draw the
103a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * search affordance.
104a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *
105a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @param colors Colors used to draw search affordance.
106a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
107a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public void setSearchAffordanceColors(SearchOrbView.Colors colors) {
108a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
109a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
110a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
111a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Returns the {@link android.support.v17.leanback.widget.SearchOrbView.Colors} used to draw the
112a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * search affordance.
113a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *
114a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @return Colors used to draw search affordance.
115a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
116a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public SearchOrbView.Colors getSearchAffordanceColors() {
117a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu        return null;
118a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
119a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
120a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
121a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Enables or disables any view animations.  This method is called to save CPU cycle for example
122a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * stop search view breathing animation when containing fragment is paused.
123a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @param enable True to enable animation, false otherwise.
124a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
125a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public void setAnimationEnabled(boolean enable) {
126a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
127a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu
128a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    /**
129a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Based on the flag, it updates the visibility of the individual components -
130a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * Branding views (badge drawable and/or title) and search affordance view.
131a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     *
132a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @param flags integer representing the visibility of TitleView components.
133a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @see #BRANDING_VIEW_VISIBLE
134a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @see #SEARCH_VIEW_VISIBLE
135a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     * @see #FULL_VIEW_VISIBLE
136a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu     */
137a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    public void updateComponentsVisibility(int flags) {
138a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu    }
139a373804d10f93a9488adc35cf6ce44dce09b3778Dake Gu}
140