Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
package com.google.samples.quickstart.engagesdksamples.watch.data.converters

import android.net.Uri
import com.google.android.engage.common.datamodel.DisplayTimeWindow
import com.google.android.engage.common.datamodel.Image
import com.google.android.engage.common.datamodel.ImageTheme
import com.google.android.engage.common.datamodel.PlatformSpecificUri
import com.google.android.engage.video.datamodel.MovieEntity
import com.google.android.engage.video.datamodel.RatingSystem
import com.google.samples.quickstart.engagesdksamples.watch.data.model.MovieItem

const val PACKAGE_NAME: String = "com.google.samples.quickstart.engagesdksamples.watch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package com.google.samples.quickstart.engagesdksamples.watch.publish

import android.content.Context
import android.net.Uri
import com.google.android.engage.common.datamodel.AccountProfile
import com.google.android.engage.common.datamodel.ContinuationCluster
import com.google.android.engage.common.datamodel.FeaturedCluster
import com.google.android.engage.common.datamodel.Image
Expand All @@ -31,7 +32,6 @@ import com.google.samples.quickstart.engagesdksamples.watch.data.converters.PACK
import com.google.samples.quickstart.engagesdksamples.watch.data.room.WatchDatabase
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob

/**
* Class in charge of constructing the publishing requests and sending them to their respective
* publishers
Expand All @@ -40,6 +40,10 @@ class ClusterRequestFactory(context: Context) {

private val db = WatchDatabase.getDatabase(context, CoroutineScope(SupervisorJob()))
private val movieDao = db.movieDao()
private val accountProfile = AccountProfile.Builder()
.setAccountId("account_id")
.setProfileId("profile_id")
.build()
private val recommendationClusterTitle =
context.resources.getString(R.string.recommendation_cluster_title)
private val signInCardAction = context.resources.getString(R.string.sign_in_card_action_text)
Expand All @@ -55,7 +59,6 @@ class ClusterRequestFactory(context: Context) {
.setActionText(signInCardAction)
.setActionUri(Uri.parse("https://xyz.com/signin"))
.build()

/**
* [constructFeaturedClusterRequest] returns a [PublishFeaturedClusterRequest] to be used by the
* [EngageServiceWorker] to publish Featured clusters
Expand All @@ -72,7 +75,6 @@ class ClusterRequestFactory(context: Context) {
.setFeaturedCluster(featuredCluster.build())
.build()
}

/**
* [constructRecommendationClustersRequest] returns a [PublishRecommendationClustersRequest] to be
* used by the [EngageServiceWorker] to publish Recommendations clusters
Expand All @@ -89,7 +91,6 @@ class ClusterRequestFactory(context: Context) {
.addRecommendationCluster(recommendationCluster.setTitle(recommendationClusterTitle).build())
.build()
}

/**
* [constructContinuationClusterRequest] returns a [PublishContinuationClusterRequest] to be used
* by the [EngageServiceWorker] to publish Continuations clusters
Expand All @@ -102,11 +103,12 @@ class ClusterRequestFactory(context: Context) {
for (item in continuationList) {
continuationCluster.addEntity(ItemToEntityConverter.convertMovie(item))
}
continuationCluster.setUserConsentToSyncAcrossDevices(true)
continuationCluster.setAccountProfile(accountProfile)
return PublishContinuationClusterRequest.Builder()
.setContinuationCluster(continuationCluster.build())
.build()
}

/**
* [constructUserAccountManagementClusterRequest] returns a [PublishUserAccountManagementRequest]
* to be used by the [EngageServiceWorker] to publish User Account Management clusters
Expand All @@ -115,4 +117,4 @@ class ClusterRequestFactory(context: Context) {
*/
fun constructUserAccountManagementClusterRequest(): PublishUserAccountManagementRequest =
PublishUserAccountManagementRequest.Builder().setSignInCardEntity(signInCard).build()
}
}