-
Notifications
You must be signed in to change notification settings - Fork 332
Add ProgressStyle notification sample #296
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @alabiaga, 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 adds a new sample demonstrating the use of ProgressStyle
notifications to simulate a checkout order experience. It includes a new module (live-updates
) with the necessary code, resources, and configurations. The sample showcases how to track an order's progress using notifications with visual progress indicators.
Highlights
- New Module: live-updates: A new module
samples/user-interface/live-updates
is added, containing the implementation for the ProgressStyle notification sample. - LiveUpdateActivity: Introduces
LiveUpdateActivity
which uses Compose to display a UI with a button that triggers the simulated checkout process and associated notifications. - SnackbarNotificationManager: Implements
SnackbarNotificationManager
to handle the creation and display of notifications withProgressStyle
to represent different stages of the order. - Gradle Updates: Updates
app/build.gradle.kts
to include the newlive-updates
module as a dependency and upgradesgradle/libs.versions.toml
to update AGP version and add material3 dependency.
Changelog
Click here to see the changelog
- app/build.gradle.kts
- Updated
compileSdk
andtargetSdk
to 36. - Updated
minSdk
to 26. - Added implementation dependency for
:samples:user-interface:live-updates
.
- Updated
- app/src/main/java/com/example/platform/app/ApiSurface.kt
- Added
UserInterfaceLiveUpdatesApiSurface
to define the API surface for the new sample. - Added
UserInterfaceLiveUpdatesApiSurface
to theAPI_SURFACES
list.
- Added
- app/src/main/java/com/example/platform/app/SampleDemo.kt
- Imported
LiveUpdateActivity
. - Added
ActivitySampleDemo
for the live updates sample, including its name, description, documentation link, API surface, and content.
- Imported
- gradle/libs.versions.toml
- Updated
agp
version from "8.8.1" to "8.9.1". - Added
material3Android
version and dependency. - Added
compose
plugin alias.
- Updated
- gradle/wrapper/gradle-wrapper.properties
- Updated
distributionUrl
to gradle-8.11.1-bin.zip.
- Updated
- samples/user-interface/live-updates/build.gradle.kts
- Created new build.gradle.kts file for the live-updates module, including plugins, android configuration, and dependencies.
- samples/user-interface/live-updates/src/main/AndroidManifest.xml
- Created new AndroidManifest.xml file for the live-updates module, declaring the
LiveUpdateActivity
and requesting thePOST_NOTIFICATIONS
permission.
- Created new AndroidManifest.xml file for the live-updates module, declaring the
- samples/user-interface/live-updates/src/main/java/com/example/platform/ui/live_updates/LiveUpdateActivity.kt
- Created new LiveUpdateActivity.kt file, implementing the UI using Compose, requesting notification permissions, and triggering the checkout simulation.
- samples/user-interface/live-updates/src/main/java/com/example/platform/ui/live_updates/SnackbarNotificationManager.kt
- Created new SnackbarNotificationManager.kt file, handling the creation and display of notifications with ProgressStyle to simulate order tracking.
- samples/user-interface/live-updates/src/main/res/drawable/ic_launcher_background.xml
- Created new ic_launcher_background.xml file.
- samples/user-interface/live-updates/src/main/res/drawable/ic_launcher_foreground.xml
- Created new ic_launcher_foreground.xml file.
- samples/user-interface/live-updates/src/main/res/values/colors.xml
- Created new colors.xml file.
- samples/user-interface/live-updates/src/main/res/values/strings.xml
- Created new strings.xml file, defining strings for the UI and notification messages.
- samples/user-interface/live-updates/src/main/res/values/themes.xml
- Created new themes.xml file, defining the theme for the live-updates module.
- settings.gradle.kts
- Included the new module ':samples:user-interface:live-updates'.
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 progress bar's gentle climb,
A visual march through space and time,
From zero to done,
A task has begun,
Success in its linear rhyme.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new UI sample demonstrating the use of ProgressStyle
notifications for tracking an order. The code is well-structured and implements the feature as described. However, there are a few areas that could be improved for better clarity and maintainability.
Summary of Findings
- SDK Version Check for Notification Channel: The
createNotificationChannel
method should be called only when the SDK version is greater than or equal to Android O to avoid issues on older devices. - Backward Compatibility for Notifications: Consider using
NotificationCompat.Builder
instead ofNotification.Builder
for backward compatibility to ensure that the notifications are displayed correctly on older devices. - Asynchronous Task Handling: Consider using
CoroutineScope
instead ofHandler
for posting delayed notifications to provide a more Kotlin-idiomatic way of handling asynchronous tasks and avoid potential memory leaks.
Merge Readiness
The pull request is almost ready for merging. However, it's recommended to address the identified issues, especially the SDK version check for notification channel creation, before merging. I am unable to directly approve this pull request, and other reviewers should review and approve this code before merging.
notificationManager = notifManager | ||
val channel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME, IMPORTANCE_DEFAULT) | ||
appContext = context | ||
notificationManager?.createNotificationChannel(channel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minSdk = 26 | ||
targetSdk = 36 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.fillMaxSize() | ||
.padding(10.dp, 100.dp), | ||
) { | ||
Text(stringResource( R.string.live_update_summary_text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onCheckout() | ||
scope.launch { | ||
snackbarHostState.showSnackbar("Order placed") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var notificationBuilder = Notification.Builder(appContext, CHANNEL_ID) | ||
.setSmallIcon(R.drawable.ic_launcher_foreground) | ||
.setOngoing(true) | ||
.setColorized(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (state in OrderState.entries) { | ||
val notification = state.buildNotification().build() | ||
Handler(Looper.getMainLooper()).postDelayed({ | ||
notificationManager.notify(NOTIFICATION_ID, notification) | ||
}, state.delay) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the User Interface Progress Style sample that simulates a checkout order experience; tracking that order with ProgressStyle notifications.