aboutsummaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorJaewan Kim <jaewan@google.com>2014-07-25 01:08:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-24 16:04:26 +0000
commit0c53fed1e83119ba11e214d2f62f5d5068062801 (patch)
tree6ed4de9c2bfa0344ae66b062d1715369a80bb1ae /src/com
parent1f08b6de78fbf4cc554304d9d1df0a0f826f9fd5 (diff)
parent4e5a6a47adb40039a27536236656204f9ad12df3 (diff)
downloadTV-0c53fed1e83119ba11e214d2f62f5d5068062801.tar.gz
Merge "Show video unavailability status on the channel banner" into lmp-dev
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/tv/data/StreamInfo.java2
-rw-r--r--src/com/android/tv/ui/ChannelBannerView.java135
-rw-r--r--src/com/android/tv/ui/TunableTvView.java36
3 files changed, 106 insertions, 67 deletions
diff --git a/src/com/android/tv/data/StreamInfo.java b/src/com/android/tv/data/StreamInfo.java
index cce9786e..9b348d77 100644
--- a/src/com/android/tv/data/StreamInfo.java
+++ b/src/com/android/tv/data/StreamInfo.java
@@ -34,4 +34,6 @@ public interface StreamInfo {
int getVideoDefinitionLevel();
int getAudioChannelCount();
boolean hasClosedCaption();
+ boolean isVideoAvailable();
+ int getVideoUnavailableReason();
}
diff --git a/src/com/android/tv/ui/ChannelBannerView.java b/src/com/android/tv/ui/ChannelBannerView.java
index e7822754..a2ee2549 100644
--- a/src/com/android/tv/ui/ChannelBannerView.java
+++ b/src/com/android/tv/ui/ChannelBannerView.java
@@ -22,9 +22,10 @@ import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
-import android.media.tv.TvContract;
import android.media.tv.TvContentRating;
+import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
+import android.media.tv.TvInputManager;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
@@ -50,20 +51,21 @@ import com.android.tv.util.Utils;
*/
public class ChannelBannerView extends RelativeLayout implements Channel.LoadLogoCallback {
private static final int CACHE_SIZE = 10;
+ private TextView mChannelTextView;
+ private ImageView mChannelLogoImageView;
+ private TextView mProgramTextView;
+ private ImageView mTvInputLogoImageView;
+ private TextView mChannelNameTextView;
+ private TextView mProgramTimeTextView;
+ private ProgressBar mRemainingTimeView;
+ private TextView mVideoStatus;
// TODO: Need to get UX design for how to show ratings in the channel banner.
private TextView mRatingTextView;
private TextView mClosedCaptionTextView;
- private TextView mResolutionTextView;
private TextView mAspectRatioTextView;
+ private TextView mResolutionTextView;
private TextView mAudioChannelTextView;
- private ProgressBar mRemainingTimeView;
private TextView mProgrameDescriptionTextView;
- private TextView mChannelTextView;
- private TextView mChannelNameTextView;
- private ImageView mTvInputLogoImageView;
- private ImageView mChannelLogoImageView;
- private TextView mProgramTextView;
- private TextView mProgramTimeTextView;
private View mAnchorView;
private Uri mCurrentChannelUri;
private final LruCache<TvInputInfo, Drawable> mChannelInfoLogoCache =
@@ -121,19 +123,20 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
protected void onFinishInflate() {
super.onFinishInflate();
+ mChannelTextView = (TextView) findViewById(R.id.channel_text);
+ mChannelLogoImageView = (ImageView) findViewById(R.id.channel_logo);
+ mProgramTextView = (TextView) findViewById(R.id.program_text);
+ mTvInputLogoImageView = (ImageView) findViewById(R.id.tvinput_logo);
+ mChannelNameTextView = (TextView) findViewById(R.id.channel_name);
+ mProgramTimeTextView = (TextView) findViewById(R.id.program_time_text);
+ mRemainingTimeView = (ProgressBar) findViewById(R.id.remaining_time);
+ mVideoStatus = (TextView) findViewById(R.id.video_status);
mRatingTextView = (TextView) findViewById(R.id.rating);
mClosedCaptionTextView = (TextView) findViewById(R.id.closed_caption);
- mResolutionTextView = (TextView) findViewById(R.id.resolution);
mAspectRatioTextView = (TextView) findViewById(R.id.aspect_ratio);
+ mResolutionTextView = (TextView) findViewById(R.id.resolution);
mAudioChannelTextView = (TextView) findViewById(R.id.audio_channel);
- mRemainingTimeView = (ProgressBar) findViewById(R.id.remaining_time);
- mChannelTextView = (TextView) findViewById(R.id.channel_text);
- mChannelNameTextView = (TextView) findViewById(R.id.channel_name);
- mTvInputLogoImageView = (ImageView) findViewById(R.id.tvinput_logo);
- mChannelLogoImageView = (ImageView) findViewById(R.id.channel_logo);
- mProgramTimeTextView = (TextView) findViewById(R.id.program_time_text);
mProgrameDescriptionTextView = (TextView) findViewById(R.id.program_description);
- mProgramTextView = (TextView) findViewById(R.id.program_text);
mAnchorView = findViewById(R.id.anchor);
}
@@ -142,47 +145,6 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
return;
}
- TvInputInfo inputInfo = (info == null) ? null : info.getCurrentTvInputInfo();
- Drawable tvInputLogo = (inputInfo == null) ? null : mChannelInfoLogoCache.get(inputInfo);
- if (tvInputLogo != null) {
- mTvInputLogoImageView.setVisibility(View.VISIBLE);
- mTvInputLogoImageView.setImageDrawable(tvInputLogo);
- } else {
- mTvInputLogoImageView.setVisibility(View.GONE);
- }
-
- if (info.hasClosedCaption()) {
- mClosedCaptionTextView.setVisibility(View.VISIBLE);
- mClosedCaptionTextView.setText("CC");
- mClosedCaptionTextView.setVisibility(View.VISIBLE);
- } else {
- mClosedCaptionTextView.setVisibility(View.GONE);
- }
- if (info.getVideoDefinitionLevel() != StreamInfo.VIDEO_DEFINITION_LEVEL_UNKNOWN) {
- mResolutionTextView.setVisibility(View.VISIBLE);
- mResolutionTextView.setText(Utils.getVideoDefinitionLevelString(
- info.getVideoDefinitionLevel()));
- mResolutionTextView.setVisibility(View.VISIBLE);
- } else {
- mResolutionTextView.setVisibility(View.GONE);
- }
-
- String aspectRatio =
- Utils.getAspectRatioString(info.getVideoWidth(), info.getVideoHeight());
- if (!TextUtils.isEmpty(aspectRatio)) {
- mAspectRatioTextView.setVisibility(View.VISIBLE);
- mAspectRatioTextView.setText(aspectRatio);
- } else {
- mAspectRatioTextView.setVisibility(View.GONE);
- }
-
- if (!TextUtils.isEmpty(Utils.getAudioChannelString(info.getAudioChannelCount()))) {
- mAudioChannelTextView.setVisibility(View.VISIBLE);
- mAudioChannelTextView.setText(Utils.getAudioChannelString(info.getAudioChannelCount()));
- } else {
- mAudioChannelTextView.setVisibility(View.GONE);
- }
-
String displayNumber = channelMap.getCurrentDisplayNumber();
if (displayNumber == null) {
displayNumber = "";
@@ -206,12 +168,51 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
}
mChannelTextView.setText(displayNumber);
+ TvInputInfo inputInfo = (info == null) ? null : info.getCurrentTvInputInfo();
+ Drawable tvInputLogo = (inputInfo == null) ? null : mChannelInfoLogoCache.get(inputInfo);
+ if (tvInputLogo != null) {
+ mTvInputLogoImageView.setVisibility(View.VISIBLE);
+ mTvInputLogoImageView.setImageDrawable(tvInputLogo);
+ } else {
+ mTvInputLogoImageView.setVisibility(View.GONE);
+ }
+
String displayName = channelMap.getCurrentDisplayName();
if (displayName == null) {
displayName = "";
}
mChannelNameTextView.setText(displayName);
+ int resId = 0;
+ if (!info.isVideoAvailable()) {
+ switch (info.getVideoUnavailableReason()) {
+ case TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNE:
+ // We don't need to tell we're tuning.
+ break;
+ case TvInputManager.VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL:
+ resId = R.string.channel_banner_video_unavailable_weak_signal;
+ break;
+ case TvInputManager.VIDEO_UNAVAILABLE_REASON_BUFFERING:
+ resId = R.string.channel_banner_video_unavailable_buffering;
+ break;
+ default:
+ resId = R.string.channel_banner_video_unavailable_unknown;
+ break;
+ }
+ }
+ updateText(mVideoStatus, (resId == 0) ? null : getContext().getString(resId));
+
+ updateText(mClosedCaptionTextView, info.hasClosedCaption() ? "CC" : "");
+
+ updateText(mAspectRatioTextView,
+ Utils.getAspectRatioString(info.getVideoWidth(), info.getVideoHeight()));
+
+ updateText(mResolutionTextView,
+ Utils.getVideoDefinitionLevelString(info.getVideoDefinitionLevel()));
+
+ updateText(mAudioChannelTextView,
+ Utils.getAudioChannelString(info.getAudioChannelCount()));
+
mCurrentChannelUri = channelMap.getCurrentChannelUri();
if (channelMap.getCurrentChannel() != null) {
channelMap.getCurrentChannel().loadLogo(getContext(), this);
@@ -220,6 +221,15 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
updateProgramInfo();
}
+ private void updateText(TextView view, String text) {
+ if (TextUtils.isEmpty(text)) {
+ view.setVisibility(View.GONE);
+ } else {
+ view.setVisibility(View.VISIBLE);
+ view.setText(text);
+ }
+ }
+
private void updateTextView(TextView textView, int sizeRes, int marginTopRes) {
float textSize = getContext().getResources().getDimension(sizeRes);
if (textView.getTextSize() != textSize) {
@@ -326,18 +336,15 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
mProgramTimeTextView.setVisibility(View.GONE);
mRemainingTimeView.setVisibility(View.GONE);
}
+
+ updateText(mRatingTextView, Utils.contentRatingsToString(program.getContentRatings()));
+
if (!TextUtils.isEmpty(program.getDescription())) {
mProgrameDescriptionTextView.setVisibility(View.VISIBLE);
mProgrameDescriptionTextView.setText(program.getDescription());
} else {
mProgrameDescriptionTextView.setVisibility(View.GONE);
}
- if (program.getContentRatings() != null) {
- mRatingTextView.setText(Utils.contentRatingsToString(program.getContentRatings()));
- mRatingTextView.setVisibility(View.VISIBLE);
- } else {
- mRatingTextView.setVisibility(View.GONE);
- }
}
private void handleNoProgramInformation() {
diff --git a/src/com/android/tv/ui/TunableTvView.java b/src/com/android/tv/ui/TunableTvView.java
index 639e4c54..6ff38626 100644
--- a/src/com/android/tv/ui/TunableTvView.java
+++ b/src/com/android/tv/ui/TunableTvView.java
@@ -1,10 +1,9 @@
package com.android.tv.ui;
-import static android.media.tv.TvInputManager.INPUT_STATE_DISCONNECTED;
-
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.tv.TvInputInfo;
+import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
import android.media.tv.TvView;
import android.net.Uri;
@@ -15,6 +14,7 @@ import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import com.android.tv.R;
import com.android.tv.data.Channel;
import com.android.tv.data.StreamInfo;
import com.android.tv.util.TvInputManagerHelper;
@@ -40,6 +40,8 @@ public class TunableTvView extends TvView implements StreamInfo {
private int mVideoFormat = StreamInfo.VIDEO_DEFINITION_LEVEL_UNKNOWN;
private int mAudioChannelCount = StreamInfo.AUDIO_CHANNEL_COUNT_UNKNOWN;
private boolean mHasClosedCaption = false;
+ private boolean mIsVideoAvailable;
+ private int mVideoUnavailableReason;
private SurfaceView mSurface;
private boolean mCanReceiveInputEvent;
@@ -123,6 +125,23 @@ public class TunableTvView extends TvView implements StreamInfo {
mOnTuneListener.onStreamInfoChanged(TunableTvView.this);
}
}
+
+ @Override
+ public void onVideoAvailable(String inputId) {
+ mIsVideoAvailable = true;
+ if (mOnTuneListener != null) {
+ mOnTuneListener.onStreamInfoChanged(TunableTvView.this);
+ }
+ }
+
+ @Override
+ public void onVideoUnavailable(String inputId, int reason) {
+ mIsVideoAvailable = false;
+ mVideoUnavailableReason = reason;
+ if (mOnTuneListener != null) {
+ mOnTuneListener.onStreamInfoChanged(TunableTvView.this);
+ }
+ }
};
public TunableTvView(Context context) {
@@ -182,7 +201,8 @@ public class TunableTvView extends TvView implements StreamInfo {
String inputId = Utils.getInputIdForChannel(getContext(), channelId);
TvInputInfo inputInfo = mInputManagerHelper.getTvInputInfo(inputId);
if (inputInfo == null
- || mInputManagerHelper.getInputState(inputInfo) == INPUT_STATE_DISCONNECTED) {
+ || mInputManagerHelper.getInputState(inputInfo) ==
+ TvInputManager.INPUT_STATE_DISCONNECTED) {
return false;
}
mOnTuneListener = listener;
@@ -284,4 +304,14 @@ public class TunableTvView extends TvView implements StreamInfo {
public boolean hasClosedCaption() {
return mHasClosedCaption;
}
+
+ @Override
+ public boolean isVideoAvailable() {
+ return mIsVideoAvailable;
+ }
+
+ @Override
+ public int getVideoUnavailableReason() {
+ return mVideoUnavailableReason;
+ }
}