aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSungsoo Lim <sungsoo@google.com>2014-07-23 01:37:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-23 01:14:26 +0000
commitcae427515858a935d4425caaaf8cdf4b26d48d72 (patch)
tree3ffa3636bbb04ab372ce0642a0c46efbac690b33 /src
parent5c80dd46d7b8806579af016b47c118a69f2d7378 (diff)
parent2be00440937254386dae3a1c0c02a7ac76ad92ca (diff)
downloadTV-cae427515858a935d4425caaaf8cdf4b26d48d72.tar.gz
Merge "Show rating information in the channel banner" into lmp-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/tv/data/Program.java15
-rw-r--r--src/com/android/tv/ui/ChannelBannerView.java10
-rw-r--r--src/com/android/tv/util/Utils.java35
3 files changed, 57 insertions, 3 deletions
diff --git a/src/com/android/tv/data/Program.java b/src/com/android/tv/data/Program.java
index cee2a2e6..9035adec 100644
--- a/src/com/android/tv/data/Program.java
+++ b/src/com/android/tv/data/Program.java
@@ -17,6 +17,7 @@
package com.android.tv.data;
import android.content.ContentValues;
+import android.media.tv.TvContentRating;
import android.media.tv.TvContract;
/**
@@ -34,6 +35,7 @@ public final class Program {
private String mVideoDefinitionLevel;
private String mPosterArtUri;
private String mThumbnailUri;
+ private TvContentRating[] mContentRatings;
private Program() {
// Do nothing.
@@ -95,6 +97,14 @@ public final class Program {
mVideoDefinitionLevel = videoDefinitionLevel;
}
+ public TvContentRating[] getContentRatings() {
+ return mContentRatings;
+ }
+
+ public void setContentRatings(TvContentRating[] contentRatings) {
+ mContentRatings = contentRatings;
+ }
+
public String getPosterArtUri() {
return mPosterArtUri;
}
@@ -211,6 +221,11 @@ public final class Program {
return this;
}
+ public Builder setContentRatings(TvContentRating[] contentRatings) {
+ mProgram.mContentRatings = contentRatings;
+ return this;
+ }
+
public Builder setPosterArtUri(String posterArtUri) {
mProgram.mPosterArtUri = posterArtUri;
return this;
diff --git a/src/com/android/tv/ui/ChannelBannerView.java b/src/com/android/tv/ui/ChannelBannerView.java
index 7da44399..e7822754 100644
--- a/src/com/android/tv/ui/ChannelBannerView.java
+++ b/src/com/android/tv/ui/ChannelBannerView.java
@@ -23,6 +23,7 @@ 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.TvInputInfo;
import android.net.Uri;
import android.os.Handler;
@@ -49,6 +50,8 @@ import com.android.tv.util.Utils;
*/
public class ChannelBannerView extends RelativeLayout implements Channel.LoadLogoCallback {
private static final int CACHE_SIZE = 10;
+ // 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;
@@ -118,6 +121,7 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
protected void onFinishInflate() {
super.onFinishInflate();
+ 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);
@@ -328,6 +332,12 @@ public class ChannelBannerView extends RelativeLayout implements Channel.LoadLog
} 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/util/Utils.java b/src/com/android/tv/util/Utils.java
index f3c0c49e..d60ee325 100644
--- a/src/com/android/tv/util/Utils.java
+++ b/src/com/android/tv/util/Utils.java
@@ -24,8 +24,8 @@ import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
import android.database.Cursor;
+import android.media.tv.TvContentRating;
import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
import android.net.Uri;
@@ -176,6 +176,7 @@ public class Utils {
TvContract.Programs.COLUMN_START_TIME_UTC_MILLIS,
TvContract.Programs.COLUMN_END_TIME_UTC_MILLIS,
TvContract_Programs_COLUMN_VIDEO_RESOLUTION,
+ TvContract.Programs.COLUMN_CONTENT_RATING,
TvContract.Programs.COLUMN_POSTER_ART_URI,
TvContract.Programs.COLUMN_THUMBNAIL_URI };
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
@@ -186,14 +187,16 @@ public class Utils {
String posterArtUri = null;
String thumbnailUri = null;
String videoDefinitionLevel = "";
+ String contentRatings = "";
if (cursor.moveToNext()) {
title = cursor.getString(0);
description = cursor.getString(1);
startTime = cursor.getLong(2);
endTime = cursor.getLong(3);
videoDefinitionLevel = cursor.getString(4);
- posterArtUri = cursor.getString(5);
- thumbnailUri = cursor.getString(6);
+ contentRatings = cursor.getString(5);
+ posterArtUri = cursor.getString(6);
+ thumbnailUri = cursor.getString(7);
}
cursor.close();
@@ -204,6 +207,7 @@ public class Utils {
.setStartTimeUtcMillis(startTime)
.setEndTimeUtcMillis(endTime)
.setVideoDefinitionLevel(videoDefinitionLevel)
+ .setContentRatings(stringToContentRatings(contentRatings))
.setPosterArtUri(posterArtUri)
.setThumbnailUri(thumbnailUri).build();
}
@@ -326,6 +330,31 @@ public class Utils {
return "";
}
+ public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) {
+ if (TextUtils.isEmpty(commaSeparatedRatings)) {
+ return null;
+ }
+ String[] ratings = commaSeparatedRatings.split("\\s*,\\s*");
+ TvContentRating[] contentRatings = new TvContentRating[ratings.length];
+ for (int i = 0; i < contentRatings.length; ++i) {
+ contentRatings[i] = TvContentRating.unflattenFromString(ratings[i]);
+ }
+ return contentRatings;
+ }
+
+ public static String contentRatingsToString(TvContentRating[] contentRatings) {
+ if (contentRatings == null || contentRatings.length == 0) {
+ return null;
+ }
+ final String DELIMITER = ",";
+ StringBuilder ratings = new StringBuilder(contentRatings[0].flattenToString());
+ for (int i = 1; i < contentRatings.length; ++i) {
+ ratings.append(DELIMITER);
+ ratings.append(contentRatings[i].flattenToString());
+ }
+ return ratings.toString();
+ }
+
private static ActivityInfo getActivityInfo(Context context, TvInputInfo input, String action) {
if (input == null) {
return null;