Skip to content

[Showcase] update LeanbackShowcase sample #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MolchanovDmitry
Copy link

  • Added TOML file
  • Updated dependencies
  • Migrated ExoPlayer to Media3
  • Updated the music playback service
  • Added androidx.leanback prefixes for Leanback resources

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @MolchanovDmitry, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request updates the LeanbackShowcase sample application. The key changes include migrating ExoPlayer to Media3, updating dependencies, adding a TOML file for dependency management, updating the music playback service, and adding androidx.leanback prefixes for Leanback resources. The target SDK and compile SDK versions are also updated to 35, and the namespace is updated to androidx.leanback.leanbackshowcase.

Highlights

  • Dependency Updates: Dependencies are updated using a libs.versions.toml file and the alias syntax in the build.gradle file. This includes updates to Material Components, CardView, RecyclerView, Room, Lifecycle extensions, Dagger, Glide, Gson, and Media3 ExoPlayer.
  • ExoPlayer Migration to Media3: The ExoPlayer library is migrated to Media3. This involves changes in the ExoPlayerAdapter class, including updating imports, using MediaItem for media sources, and adapting to the new Media3 API for player control and event handling. The SimpleExoPlayer is replaced with ExoPlayer builder.
  • Leanback Resource Prefixes: Leanback resources are updated to use the androidx.leanback prefix. This change is reflected in the DetailViewExampleFragment, DetailViewExampleWithVideoBackgroundFragment, MusicConsumptionExampleFragment, VideoContentCardPresenter, and FullWidthDetailsPresenter classes.
  • MusicPlaybackService Updates: The MusicPlaybackService is updated to include PendingIntent.FLAG_IMMUTABLE when creating PendingIntent objects. Also, onUnbind is overridden to stop the service when it is unbound.
  • Target and Compile SDK Update: The targetSdkVersion and compileSdkVersion are updated to 35 in app/build.gradle.
  • Namespace Update: The namespace is updated to androidx.leanback.leanbackshowcase in app/build.gradle.
  • Activity Exported Attribute: The exported attribute is added to the DynamicVideoRowsActivity and VideoPlaybackActivity activities in AndroidManifest.xml.

Changelog

Click here to see the changelog
  • LeanbackShowcase/app/build.gradle
    • Updated plugins block to use alias syntax.
    • Updated targetSdkVersion and compileSdkVersion to 35.
    • Updated applicationId to 'androidx.leanback.leanbackshowcase'.
    • Added compileOptions for Java 17.
    • Updated dependencies to use versions defined in libs.versions.toml.
  • LeanbackShowcase/app/src/androidTest/java/androidx/leanback/leanbackshowcase/ApplicationTest.java
    • Migrated from ApplicationTestCase to AndroidJUnit4.
    • Added a test to verify the application context.
  • LeanbackShowcase/app/src/main/AndroidManifest.xml
    • Added permission android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK.
    • Added android:exported="true" to DynamicVideoRowsActivity and VideoPlaybackActivity.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/details/DetailViewExampleFragment.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/details/DetailViewExampleWithVideoBackgroundFragment.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/media/ExoPlayerAdapter.java
    • Migrated from ExoPlayer to Media3.
    • Updated imports and class usages to reflect Media3 API.
    • Replaced SimpleExoPlayer with ExoPlayer builder.
    • Updated setDataSource to use MediaItem.
    • Updated listener methods to align with Media3's Player.Listener.
    • Removed setAudioStreamType and replaced it with setAudioAttributes.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/media/MusicConsumptionExampleFragment.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/media/MusicPlaybackService.java
    • Added PendingIntent.FLAG_IMMUTABLE to PendingIntent flags.
    • Overrode onUnbind to stop the service.
    • Removed unused imports.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/media/VideoConsumptionExampleWithExoPlayerFragment.java
    • Removed setAudioStreamType call.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/room/ui/FullWidthDetailsPresenter.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/room/ui/VideoCardPresenter.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/room/viewmodel/VideosViewModel.java
    • Removed unused imports and simplified Transformations.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/rows/PublishChannelFragment.java
    • Updated resource IDs to use androidx.leanback.preference.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/rows/VideoContentCardPresenter.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/cards/presenters/SingleLineCardPresenter.java
    • Updated resource IDs to use androidx.leanback.R prefix.
  • LeanbackShowcase/build.gradle
    • Replaced buildscript block with plugins block.
    • Removed ext block.
    • Applied false to the plugins
  • LeanbackShowcase/gradle.properties
    • Added android.nonFinalResIds=false.
  • LeanbackShowcase/gradle/libs.versions.toml
    • Added TOML file to manage library versions.
  • LeanbackShowcase/gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle version to 8.11.1.
  • LeanbackShowcase/settings.gradle
    • Added pluginManagement and dependencyResolutionManagement blocks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A showcase reborn,
Media3 streams, dependencies torn,
Leanback's new prefix.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request updates the LeanbackShowcase sample, migrating ExoPlayer to Media3, updating dependencies, and adding Leanback resource prefixes. The changes generally improve the project's maintainability and modernize its dependencies. However, some areas require closer attention to ensure correctness and best practices.

Summary of Findings

  • ExoPlayerAdapter Migration: The migration from ExoPlayer to Media3 in ExoPlayerAdapter.java involves significant API changes. Ensure all event listeners and methods are correctly adapted to the new Media3 API to avoid unexpected behavior.
  • PendingIntent Flags: The addition of PendingIntent.FLAG_IMMUTABLE in MusicPlaybackService.java is crucial for security, but verify that it doesn't introduce any compatibility issues with older Android versions.
  • Resource IDs: The update of resource IDs to use androidx.leanback.R is necessary for compatibility with Leanback, but ensure that all resource references are correctly updated throughout the project.

Merge Readiness

The pull request is almost ready for merging. However, the high severity issues regarding the ExoPlayerAdapter migration must be addressed before merging. After addressing these issues, ensure thorough testing to confirm the changes' stability and compatibility. I am unable to approve this pull request, and users should have others review and approve this code before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant