Skip to content
This repository has been archived by the owner on Sep 28, 2019. It is now read-only.

Commit

Permalink
Inital commit
Browse files Browse the repository at this point in the history
Copied project from engineering.
Renamed string "TV Launcher Sample" to "Home Screen Channels".

Change-Id: I4f7013a979f5da3957db0a869cc77c7486828fd9
  • Loading branch information
benbaxter committed Sep 29, 2017
1 parent 1d423f2 commit 36d4ba4
Show file tree
Hide file tree
Showing 49 changed files with 4,098 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
*.idea
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'com.android.application'

android {
defaultConfig {
applicationId "com.google.android.tvhomescreenchannels"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:leanback-v17:26.0.2'
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.github.bumptech.glide:glide:4.1.1'
compile 'com.android.support:support-tv-provider:26.0.2'
}
25 changes: 25 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/benbaxter/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
114 changes: 114 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.tvhomescreenchannels">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" />
<uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" />

<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />

<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/Theme.Leanback">

<activity
android:name=".MainActivity"
android:banner="@drawable/app_banner"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:logo="@drawable/app_icon"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="tvhomescreenchannels"
android:host="com.google.android.tvhomescreenchannels"
android:path="/startapp" />
</intent-filter>
</activity>

<activity android:name=".PlaybackActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="tvhomescreenchannels"
android:host="com.google.android.tvhomescreenchannels"
android:path="/resumevideo" />
</intent-filter>
</activity>

<activity android:name=".TvSearchActivity" />

<activity
android:name=".RecommendationReceiverActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="tvhomescreenchannels"
android:host="com.google.android.tvhomescreenchannels"
android:pathPrefix="/playvideo"
/>
</intent-filter>
</activity>

<service
android:name=".SynchronizeDatabaseJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true"/>

<receiver
android:name=".RunOnInstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>

<receiver
android:name=".LauncherNotificationReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.media.tv.action.PREVIEW_PROGRAM_BROWSABLE_DISABLED" />
<action android:name="android.media.tv.action.WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED" />
<action android:name="android.media.tv.action.PREVIEW_PROGRAM_ADDED_TO_WATCH_NEXT" />
<action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>

<service android:name=".scheduler.AddWatchNextService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true">
</service>

<service android:name=".scheduler.DeleteWatchNextService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true">
</service>

</application>

</manifest>
183 changes: 183 additions & 0 deletions app/src/main/java/com/google/android/tvlaunchersample/Clip.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
* Copyright (C) 2017 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.google.android.tvlaunchersample;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.media.tv.TvContractCompat;

import java.net.URI;
import java.net.URISyntaxException;

/**
* Clip class represents video entity with title, description, image thumbs and video url.
*/
public class Clip implements Parcelable {
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public Clip createFromParcel(Parcel in) {
return new Clip(in);
}

public Clip[] newArray(int size) {
return new Clip[size];
}
};
private final String mClipId;
private final String mContentId;
private final String mTitle;
private final String mDescription;
private final String mBgImageUrl;
private final String mCardImageUrl;
private final String mVideoUrl;
private final String mPreviewVideoUrl;
private final String mCategory;
private int mAspectRatio;
private long mProgramId;
private int mViewCount;

Clip(String title, String description, String bgImageUrl, String cardImageUrl,
String videoUrl, String previewVideoUrl, String category,
String clipId, String contentId, int aspectRatio) {
mClipId = clipId;
mContentId = contentId;
mTitle = title;
mDescription = description;
mBgImageUrl = bgImageUrl;
mCardImageUrl = cardImageUrl;
mVideoUrl = videoUrl;
mPreviewVideoUrl = previewVideoUrl;
mCategory = category;
mAspectRatio = aspectRatio;
}

private Clip(Parcel in) {
mClipId = in.readString();
mContentId = in.readString();
mTitle = in.readString();
mDescription = in.readString();
mBgImageUrl = in.readString();
mCardImageUrl = in.readString();
mVideoUrl = in.readString();
mPreviewVideoUrl = in.readString();
mCategory = in.readString();
mProgramId = in.readLong();
mViewCount = in.readInt();
}

long getProgramId() {
return mProgramId;
}

void setProgramId(long programId) {
mProgramId = programId;
}

public String getClipId() {
return mClipId;
}

public String getContentId() {
return mContentId;
}

public String getTitle() {
return mTitle;
}

public String getDescription() {
return mDescription;
}

String getVideoUrl() {
return mVideoUrl;
}

String getPreviewVideoUrl() {
return mPreviewVideoUrl;
}

String getBackgroundImageUrl() {
return mBgImageUrl;
}

public String getCardImageUrl() {
return mCardImageUrl;
}

URI getBackgroundImageURI() {
try {
return new URI(mBgImageUrl);
} catch (URISyntaxException e) {
return null;
}
}

URI getCardImageURI() {
try {
return new URI(getCardImageUrl());
} catch (URISyntaxException e) {
return null;
}
}

int incrementViewCount() {
return mViewCount += 1;
}

void setViewCount(int viewCount) {
mViewCount = viewCount;
}

@TvContractCompat.PreviewProgramColumns.AspectRatio
public int getAspectRatio() {
return mAspectRatio;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mClipId);
dest.writeString(mContentId);
dest.writeString(mTitle);
dest.writeString(mDescription);
dest.writeString(mBgImageUrl);
dest.writeString(mCardImageUrl);
dest.writeString(mVideoUrl);
dest.writeString(mPreviewVideoUrl);
dest.writeString(mCategory);
dest.writeLong(mProgramId);
dest.writeInt(mViewCount);
}

@Override
public String toString() {
return "Clip{" +
"clipId=" + mClipId +
", contentId='" + mContentId + '\'' +
", title='" + mTitle + '\'' +
", videoUrl='" + mVideoUrl + '\'' +
", backgroundImageUrl='" + mBgImageUrl + '\'' +
", backgroundImageURI='" + getBackgroundImageURI().toString() + '\'' +
", cardImageUrl='" + mCardImageUrl + '\'' +
", aspectRatio='" + mAspectRatio + '\'' +
", programId='" + mProgramId + '\'' +
", viewCount='" + mViewCount + '\'' +
'}';
}
}
Loading

0 comments on commit 36d4ba4

Please sign in to comment.