Skip to content

Conversation

@alabiaga
Copy link
Member

Add message/toggle to allow user to enable live update permission in settings

…n settings

Change-Id: I822f4d1d8ad1b347ed53420fe3c8404958261d49
Change-Id: Iaf5acbaffa2d098f1833a99a35e9052cb5f5b769
@gemini-code-assist
Copy link
Contributor

Summary of Changes

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!

This pull request implements a feature that allows users to manage "Live Updates" notification permissions more easily. It introduces a new UI component in the LiveUpdateSample that detects if these specific notifications are disabled and provides a button to navigate the user directly to the relevant system settings page to enable them. This enhances the user experience by making permission management more intuitive and accessible for critical live update features.

Highlights

  • Live Update Permission Toggle: A new UI element has been introduced to allow users to enable or disable "Live Updates" notification permissions directly from the app's settings.
  • Direct Settings Navigation: The application now provides a direct link to the specific app notification promotion settings within the Android system settings, improving user accessibility.
  • Permission Status Check: A new utility function isPostPromotionsEnabled() has been added to SnackbarNotificationManager to programmatically check the status of live update notification permissions.
  • AndroidManifest Update: The AndroidManifest.xml file has been updated to include an intent filter, enabling the application to launch the specific notification promotion settings screen.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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
Contributor

@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

This pull request successfully adds a user-facing message and a toggle to enable live update permissions, guiding them to the system settings. The implementation is solid, including updates to the AndroidManifest and the creation of a new Composable to handle the permission check. I've included a few suggestions to enhance the code, focusing on improving user navigation behavior and adhering to common Kotlin and Compose coding conventions.

Comment on lines 123 to 127
val isPostPromotionsEnabled = remember { mutableStateOf(SnackbarNotificationManager.isPostPromotionsEnabled()) }
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
isPostPromotionsEnabled.value = SnackbarNotificationManager.isPostPromotionsEnabled()
}
if (!isPostPromotionsEnabled.value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and to follow idiomatic Compose conventions, you can use a property delegate (by) for your MutableState. This will allow you to access and modify the value directly without needing to use .value.

To use this, you may need to add import androidx.compose.runtime.getValue and import androidx.compose.runtime.setValue.

Suggested change
val isPostPromotionsEnabled = remember { mutableStateOf(SnackbarNotificationManager.isPostPromotionsEnabled()) }
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
isPostPromotionsEnabled.value = SnackbarNotificationManager.isPostPromotionsEnabled()
}
if (!isPostPromotionsEnabled.value) {
var isPostPromotionsEnabled by remember { mutableStateOf(SnackbarNotificationManager.isPostPromotionsEnabled()) }
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
isPostPromotionsEnabled = SnackbarNotificationManager.isPostPromotionsEnabled()
}
if (!isPostPromotionsEnabled) {

Button(
onClick = {
val intent = Intent(Settings.ACTION_APP_NOTIFICATION_PROMOTION_SETTINGS).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using Intent.FLAG_ACTIVITY_NEW_TASK is not ideal here. Since LocalContext.current within a Composable hosted by an Activity will typically be that Activity's context, starting the settings activity in a new task can disrupt the user's navigation flow. When they press the back button from the settings screen, they might not return to your app as expected. It's better to launch the settings activity in the same task by removing this flag.

Comment on lines 263 to 265
fun isPostPromotionsEnabled(): Boolean {
return notificationManager.canPostPromotedNotifications()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The code inside this function is not correctly indented. Following standard Kotlin formatting guidelines improves code readability and maintainability.

Suggested change
fun isPostPromotionsEnabled(): Boolean {
return notificationManager.canPostPromotedNotifications()
}
fun isPostPromotionsEnabled(): Boolean {
return notificationManager.canPostPromotedNotifications()
}

Change-Id: I2db246e697aa54aebba466ae96cb1b5321b7ec72
@alabiaga alabiaga merged commit 44b83d9 into android:main Oct 17, 2025
3 checks passed
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.

2 participants