Merge pull request #10787 from JosJuice/channel-uri

Android: Add app link intent URI to channels projection
This commit is contained in:
Mai 2022-08-03 20:21:45 -04:00 committed by GitHub
commit 4617ee7d89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -87,7 +87,7 @@ public class SyncChannelJobService extends JobService
} }
else else
{ {
subscriptions = TvUtil.createUniversalSubscriptions(); subscriptions = TvUtil.createUniversalSubscriptions(context);
for (HomeScreenChannel subscription : subscriptions) for (HomeScreenChannel subscription : subscriptions)
{ {
long channelId = createChannel(subscription); long channelId = createChannel(subscription);

View File

@ -98,7 +98,8 @@ public class SyncProgramsJobService extends JobService
Channel channel = TvUtil.getChannelById(context, channelId); Channel channel = TvUtil.getChannelById(context, channelId);
for (Platform platform : Platform.values()) for (Platform platform : Platform.values())
{ {
if (channel != null && channel.getDisplayName().equals(platform.getIdString())) if (channel != null &&
channel.getAppLinkIntentUri().equals(AppLinkHelper.buildBrowseUri(platform)))
{ {
getGamesByPlatform(platform); getGamesByPlatform(platform);
syncPrograms(channelId); syncPrograms(channelId);

View File

@ -50,8 +50,9 @@ public class TvUtil
private static final String[] CHANNELS_PROJECTION = { private static final String[] CHANNELS_PROJECTION = {
TvContractCompat.Channels._ID, TvContractCompat.Channels._ID,
TvContract.Channels.COLUMN_DISPLAY_NAME, TvContractCompat.Channels.COLUMN_DISPLAY_NAME,
TvContractCompat.Channels.COLUMN_BROWSABLE TvContractCompat.Channels.COLUMN_BROWSABLE,
TvContractCompat.Channels.COLUMN_APP_LINK_INTENT_URI
}; };
private static final String LEANBACK_PACKAGE = "com.google.android.tvlauncher"; private static final String LEANBACK_PACKAGE = "com.google.android.tvlauncher";
@ -253,21 +254,19 @@ public class TvUtil
/** /**
* Generates all subscriptions for homescreen channels. * Generates all subscriptions for homescreen channels.
*/ */
public static List<HomeScreenChannel> createUniversalSubscriptions() public static List<HomeScreenChannel> createUniversalSubscriptions(Context context)
{ {
return new ArrayList<>(createPlatformSubscriptions()); return new ArrayList<>(createPlatformSubscriptions(context));
} }
private static List<HomeScreenChannel> createPlatformSubscriptions() private static List<HomeScreenChannel> createPlatformSubscriptions(Context context)
{ {
List<HomeScreenChannel> subs = new ArrayList<>(); List<HomeScreenChannel> subs = new ArrayList<>();
for (Platform platform : Platform.values()) for (Platform platform : Platform.values())
{ {
// TODO: Replace the getIdString calls with getHeaderName to get localized names.
// This would require SyncProgramsJobService to stop using the display name as a key
subs.add(new HomeScreenChannel( subs.add(new HomeScreenChannel(
platform.getIdString(), context.getString(platform.getHeaderName()),
platform.getIdString(), context.getString(platform.getHeaderName()),
AppLinkHelper.buildBrowseUri(platform))); AppLinkHelper.buildBrowseUri(platform)));
} }
return subs; return subs;