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.tv.ui;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.widget.LinearLayout;
22 
23 import com.android.tv.MainActivity;
24 import com.android.tv.R;
25 import com.android.tv.data.StreamInfo;
26 
27 public abstract class InputBannerViewBase extends LinearLayout
28         implements TvTransitionManager.TransitionLayout {
29     protected final long mShowDurationMillis;
30     protected final Runnable mHideRunnable =
31             () ->
32                     ((MainActivity) getContext())
33                             .getOverlayManager()
34                             .hideOverlays(
35                                     TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG
36                                             | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS
37                                             | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_PROGRAM_GUIDE
38                                             | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_MENU
39                                             | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT);
InputBannerViewBase(Context context)40     public InputBannerViewBase(Context context) {
41         this(context, null, 0);
42     }
43 
InputBannerViewBase(Context context, AttributeSet attrs)44     public InputBannerViewBase(Context context, AttributeSet attrs) {
45         this(context, attrs, 0);
46     }
47 
InputBannerViewBase(Context context, AttributeSet attrs, int defStyle)48     public InputBannerViewBase(Context context, AttributeSet attrs, int defStyle) {
49         super(context, attrs, defStyle);
50         mShowDurationMillis =
51                 context.getResources().getInteger(R.integer.select_input_show_duration);
52 
53     }
54 
updateLabel()55     public abstract void updateLabel();
56 
57     @Override
onEnterAction(boolean fromEmptyScene)58     public void onEnterAction(boolean fromEmptyScene) {
59         removeCallbacks(mHideRunnable);
60         postDelayed(mHideRunnable, mShowDurationMillis);
61     }
62 
63     @Override
onExitAction()64     public void onExitAction() {
65         removeCallbacks(mHideRunnable);
66     }
67 
onStreamInfoUpdated(StreamInfo info)68     public void onStreamInfoUpdated(StreamInfo info) {}
69 }
70