aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tv/ui')
-rw-r--r--src/com/android/tv/ui/BlockScreenView.java15
-rw-r--r--src/com/android/tv/ui/EmptyInputStatusBlockView.java68
-rw-r--r--src/com/android/tv/ui/InputBannerView.java38
-rw-r--r--src/com/android/tv/ui/InputBannerViewBase.java69
-rw-r--r--src/com/android/tv/ui/InputBannerViewV2.java84
-rw-r--r--src/com/android/tv/ui/TunableTvView.java13
-rw-r--r--src/com/android/tv/ui/TvOverlayManager.java11
-rw-r--r--src/com/android/tv/ui/TvTransitionManager.java8
8 files changed, 273 insertions, 33 deletions
diff --git a/src/com/android/tv/ui/BlockScreenView.java b/src/com/android/tv/ui/BlockScreenView.java
index b7a2dd95..9f61bf02 100644
--- a/src/com/android/tv/ui/BlockScreenView.java
+++ b/src/com/android/tv/ui/BlockScreenView.java
@@ -16,12 +16,15 @@
package com.android.tv.ui;
+import static com.android.tv.R.animator.tvview_block_screen_fade_out;
+
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.media.tv.TvInputInfo;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -30,6 +33,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
+
import com.android.tv.R;
import com.android.tv.ui.TunableTvView.BlockScreenType;
@@ -42,6 +46,8 @@ public class BlockScreenView extends FrameLayout {
private TextView mBlockingInfoTextView;
private ImageView mBackgroundImageView;
+ private EmptyInputStatusBlockView mEmptyInputStatusBlockView;
+
private final int mSpacingNormal;
private final int mSpacingShrunken;
@@ -79,6 +85,7 @@ public class BlockScreenView extends FrameLayout {
mSpace = findViewById(R.id.space);
mBlockingInfoTextView = (TextView) findViewById(R.id.block_screen_text);
mBackgroundImageView = (ImageView) findViewById(R.id.background_image);
+ mEmptyInputStatusBlockView = findViewById(R.id.empty_input_status_block_view);
mFadeOut =
AnimatorInflater.loadAnimator(
getContext(), R.animator.tvview_block_screen_fade_out);
@@ -261,4 +268,12 @@ public class BlockScreenView extends FrameLayout {
public void setInfoTextClickable(boolean clickable) {
mBlockingInfoTextView.setClickable(clickable);
}
+
+ public void setEmptyInputStatusInputInfo(TvInputInfo inputInfo) {
+ mEmptyInputStatusBlockView.setIconAndLabelByInputInfo(inputInfo);
+ }
+
+ public void setEmptyInputStatusBlockVisibility(boolean visible) {
+ mEmptyInputStatusBlockView.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
}
diff --git a/src/com/android/tv/ui/EmptyInputStatusBlockView.java b/src/com/android/tv/ui/EmptyInputStatusBlockView.java
new file mode 100644
index 00000000..a7f91661
--- /dev/null
+++ b/src/com/android/tv/ui/EmptyInputStatusBlockView.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tv.ui;
+
+import android.content.Context;
+import android.media.tv.TvInputInfo;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.tv.R;
+
+public class EmptyInputStatusBlockView extends FrameLayout {
+ private ImageView mEmptyInputStatusIcon;
+ private TextView mEmptyInputTitleTextView;
+
+ public EmptyInputStatusBlockView(Context context) {
+ this(context, null, 0);
+ }
+
+ public EmptyInputStatusBlockView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public EmptyInputStatusBlockView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ inflate(context, R.layout.empty_input_status_block, this);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ mEmptyInputStatusIcon = findViewById(R.id.empty_input_status_icon);
+ mEmptyInputTitleTextView = findViewById(R.id.empty_input_status_title_text);
+ }
+
+ public void setIconAndLabelByInputInfo(TvInputInfo inputInfo) {
+ CharSequence label = inputInfo.loadLabel(getContext());
+ String title = getResources().getString(R.string.empty_input_status_title_format, label);
+ mEmptyInputTitleTextView.setText(title);
+
+ if (inputInfo.isPassthroughInput()) {
+ mEmptyInputStatusIcon.setImageDrawable(
+ getResources().getDrawable(R.drawable.ic_empty_input_hdmi, null)
+ );
+ } else {
+ mEmptyInputStatusIcon.setImageDrawable(
+ getResources().getDrawable(R.drawable.ic_empty_input_tuner, null)
+ );
+ }
+ }
+}
diff --git a/src/com/android/tv/ui/InputBannerView.java b/src/com/android/tv/ui/InputBannerView.java
index d0609186..598d18ac 100644
--- a/src/com/android/tv/ui/InputBannerView.java
+++ b/src/com/android/tv/ui/InputBannerView.java
@@ -21,49 +21,38 @@ import android.media.tv.TvInputInfo;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
-import android.widget.LinearLayout;
import android.widget.TextView;
+
import com.android.tv.MainActivity;
import com.android.tv.R;
import com.android.tv.data.api.Channel;
-public class InputBannerView extends LinearLayout implements TvTransitionManager.TransitionLayout {
- private final long mShowDurationMillis;
+public class InputBannerView extends InputBannerViewBase
+ implements TvTransitionManager.TransitionLayout {
- private final Runnable mHideRunnable =
- () ->
- ((MainActivity) getContext())
- .getOverlayManager()
- .hideOverlays(
- TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG
- | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS
- | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_PROGRAM_GUIDE
- | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_MENU
- | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT);
private TextView mInputLabelTextView;
private TextView mSecondaryInputLabelTextView;
public InputBannerView(Context context) {
- this(context, null, 0);
+ super(context);
}
public InputBannerView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
+ super(context, attrs);
}
public InputBannerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mShowDurationMillis =
- context.getResources().getInteger(R.integer.select_input_show_duration);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mInputLabelTextView = (TextView) findViewById(R.id.input_label);
- mSecondaryInputLabelTextView = (TextView) findViewById(R.id.secondary_input_label);
+ mInputLabelTextView = findViewById(R.id.input_label);
+ mSecondaryInputLabelTextView = findViewById(R.id.secondary_input_label);
}
+ @Override
public void updateLabel() {
MainActivity mainActivity = (MainActivity) getContext();
Channel channel = mainActivity.getCurrentChannel();
@@ -83,15 +72,4 @@ public class InputBannerView extends LinearLayout implements TvTransitionManager
mSecondaryInputLabelTextView.setVisibility(View.VISIBLE);
}
}
-
- @Override
- public void onEnterAction(boolean fromEmptyScene) {
- removeCallbacks(mHideRunnable);
- postDelayed(mHideRunnable, mShowDurationMillis);
- }
-
- @Override
- public void onExitAction() {
- removeCallbacks(mHideRunnable);
- }
}
diff --git a/src/com/android/tv/ui/InputBannerViewBase.java b/src/com/android/tv/ui/InputBannerViewBase.java
new file mode 100644
index 00000000..c20e1da7
--- /dev/null
+++ b/src/com/android/tv/ui/InputBannerViewBase.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tv.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.LinearLayout;
+
+import com.android.tv.MainActivity;
+import com.android.tv.R;
+import com.android.tv.data.StreamInfo;
+
+public abstract class InputBannerViewBase extends LinearLayout
+ implements TvTransitionManager.TransitionLayout {
+ protected final long mShowDurationMillis;
+ protected final Runnable mHideRunnable =
+ () ->
+ ((MainActivity) getContext())
+ .getOverlayManager()
+ .hideOverlays(
+ TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG
+ | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS
+ | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_PROGRAM_GUIDE
+ | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_MENU
+ | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT);
+ public InputBannerViewBase(Context context) {
+ this(context, null, 0);
+ }
+
+ public InputBannerViewBase(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public InputBannerViewBase(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mShowDurationMillis =
+ context.getResources().getInteger(R.integer.select_input_show_duration);
+
+ }
+
+ public abstract void updateLabel();
+
+ @Override
+ public void onEnterAction(boolean fromEmptyScene) {
+ removeCallbacks(mHideRunnable);
+ postDelayed(mHideRunnable, mShowDurationMillis);
+ }
+
+ @Override
+ public void onExitAction() {
+ removeCallbacks(mHideRunnable);
+ }
+
+ public void onStreamInfoUpdated(StreamInfo info) {}
+}
diff --git a/src/com/android/tv/ui/InputBannerViewV2.java b/src/com/android/tv/ui/InputBannerViewV2.java
new file mode 100644
index 00000000..e340819b
--- /dev/null
+++ b/src/com/android/tv/ui/InputBannerViewV2.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tv.ui;
+
+import android.content.Context;
+import android.media.tv.TvInputInfo;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.widget.TextView;
+
+import com.android.tv.MainActivity;
+import com.android.tv.R;
+import com.android.tv.data.StreamInfo;
+import com.android.tv.data.api.Channel;
+
+public class InputBannerViewV2 extends InputBannerViewBase
+ implements TvTransitionManager.TransitionLayout {
+ private static final String TAG = "InputBannerViewV2";
+
+ private TextView mInputLabelTextView;
+ public InputBannerViewV2(Context context) {
+ super(context);
+ }
+
+ public InputBannerViewV2(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public InputBannerViewV2(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mInputLabelTextView = findViewById(R.id.input_label);
+ }
+
+ @Override
+ public void updateLabel() {
+ MainActivity mainActivity = (MainActivity) getContext();
+ Channel channel = mainActivity.getCurrentChannel();
+ if (channel == null || !channel.isPassthrough()) {
+ return;
+ }
+
+ TvInputInfo input =
+ mainActivity.getTvInputManagerHelper().getTvInputInfo(channel.getInputId());
+ if (input == null) {
+ Log.e(TAG, "unable to get TvInputInfo of id " + channel.getInputId());
+ return;
+ }
+
+ updateInputLabel(input);
+ }
+
+ private void updateInputLabel(TvInputInfo input) {
+ CharSequence customLabel = input.loadCustomLabel(getContext());
+ CharSequence label = input.loadLabel(getContext());
+
+ if (customLabel == null) {
+ mInputLabelTextView.setText(label);
+ } else {
+ String inputLabel = getResources().getString(
+ R.string.input_banner_v2_input_label_format, label, customLabel);
+ mInputLabelTextView.setText(inputLabel);
+ }
+
+ }
+}
diff --git a/src/com/android/tv/ui/TunableTvView.java b/src/com/android/tv/ui/TunableTvView.java
index 3ac841c2..76fb0a12 100644
--- a/src/com/android/tv/ui/TunableTvView.java
+++ b/src/com/android/tv/ui/TunableTvView.java
@@ -1017,6 +1017,12 @@ public class TunableTvView extends FrameLayout implements StreamInfo, TunableTvV
return;
}
mBlockScreenView.setVisibility(VISIBLE);
+ if (shouldShowEmptyInputStatusBlock()){
+ mBlockScreenView.setEmptyInputStatusInputInfo(mInputInfo);
+ mBlockScreenView.setEmptyInputStatusBlockVisibility(true);
+ } else {
+ mBlockScreenView.setEmptyInputStatusBlockVisibility(false);
+ }
if (mTvIAppView != null) {
mTvIAppView.setVisibility(INVISIBLE);
}
@@ -1255,6 +1261,13 @@ public class TunableTvView extends FrameLayout implements StreamInfo, TunableTvV
}
}
+ private boolean shouldShowEmptyInputStatusBlock() {
+ return TvFeatures.USE_GTV_LIVETV_V2.isEnabled(getContext()) &&
+ (mVideoUnavailableReason == TvInputManager.VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL ||
+ mVideoUnavailableReason ==
+ CommonConstants.VIDEO_UNAVAILABLE_REASON_NOT_CONNECTED);
+ }
+
private boolean isBundledInput() {
return mInputInfo != null
&& mInputInfo.getType() == TvInputInfo.TYPE_TUNER
diff --git a/src/com/android/tv/ui/TvOverlayManager.java b/src/com/android/tv/ui/TvOverlayManager.java
index 19af23b9..dc4a27a8 100644
--- a/src/com/android/tv/ui/TvOverlayManager.java
+++ b/src/com/android/tv/ui/TvOverlayManager.java
@@ -49,6 +49,7 @@ import com.android.tv.common.ui.setup.SetupFragment;
import com.android.tv.common.ui.setup.SetupMultiPaneFragment;
import com.android.tv.data.ChannelDataManager;
import com.android.tv.data.ProgramDataManager;
+import com.android.tv.data.StreamInfo;
import com.android.tv.dialog.DvrHistoryDialogFragment;
import com.android.tv.dialog.FullscreenDialogFragment;
import com.android.tv.dialog.HalfSizedDialogFragment;
@@ -212,6 +213,7 @@ public class TvOverlayManager implements AccessibilityStateChangeListener {
private final SideFragmentManager mSideFragmentManager;
private final ProgramGuide mProgramGuide;
private final ChannelBannerView mChannelBannerView;
+ private final InputBannerViewBase mInputBannerView;
private final KeypadChannelSwitchView mKeypadChannelSwitchView;
private final SelectInputView mSelectInputView;
private final ProgramGuideSearchFragment mSearchFragment;
@@ -237,7 +239,7 @@ public class TvOverlayManager implements AccessibilityStateChangeListener {
TvOptionsManager optionsManager,
KeypadChannelSwitchView keypadChannelSwitchView,
ChannelBannerView channelBannerView,
- InputBannerView inputBannerView,
+ InputBannerViewBase inputBannerView,
SelectInputView selectInputView,
ViewGroup sceneContainer,
ProgramGuideSearchFragment searchFragment,
@@ -253,6 +255,7 @@ public class TvOverlayManager implements AccessibilityStateChangeListener {
mInputManager = tvInputManager;
mTvView = tvView;
mChannelBannerView = channelBannerView;
+ mInputBannerView = inputBannerView;
mKeypadChannelSwitchView = keypadChannelSwitchView;
mSelectInputView = selectInputView;
mSearchFragment = searchFragment;
@@ -875,6 +878,12 @@ public class TvOverlayManager implements AccessibilityStateChangeListener {
}
}
+ public void updateInputBannerIfNeeded(StreamInfo info) {
+ if (mTransitionManager.isInputBannerActive()) {
+ mInputBannerView.onStreamInfoUpdated(info);
+ }
+ }
+
@TvOverlayType
private int convertSceneToOverlayType(@SceneType int sceneType) {
switch (sceneType) {
diff --git a/src/com/android/tv/ui/TvTransitionManager.java b/src/com/android/tv/ui/TvTransitionManager.java
index f60337f1..579fcfce 100644
--- a/src/com/android/tv/ui/TvTransitionManager.java
+++ b/src/com/android/tv/ui/TvTransitionManager.java
@@ -56,7 +56,7 @@ public class TvTransitionManager extends TransitionManager {
private final MainActivity mMainActivity;
private final ViewGroup mSceneContainer;
private final ChannelBannerView mChannelBannerView;
- private final InputBannerView mInputBannerView;
+ private final InputBannerViewBase mInputBannerView;
private final KeypadChannelSwitchView mKeypadChannelSwitchView;
private final SelectInputView mSelectInputView;
private final FrameLayout mEmptyView;
@@ -78,7 +78,7 @@ public class TvTransitionManager extends TransitionManager {
MainActivity mainActivity,
ViewGroup sceneContainer,
ChannelBannerView channelBannerView,
- InputBannerView inputBannerView,
+ InputBannerViewBase inputBannerView,
KeypadChannelSwitchView keypadChannelSwitchView,
SelectInputView selectInputView) {
mMainActivity = mainActivity;
@@ -159,6 +159,10 @@ public class TvTransitionManager extends TransitionManager {
return mCurrentScene != null && mCurrentScene == mSelectInputScene;
}
+ public boolean isInputBannerActive() {
+ return mCurrentScene != null && mCurrentScene == mInputBannerScene;
+ }
+
public void setListener(Listener listener) {
mListener = listener;
}