-
-
Notifications
You must be signed in to change notification settings - Fork 214
Add CREATE_NOTIFICATION action for persistent custom notifications #1877
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
Conversation
- Added CREATE_NOTIFICATION to ActionId enum - Added CreateNotification data class to ActionData with title, text, and optional timeout - Added CHANNEL_CUSTOM_NOTIFICATIONS channel in NotificationController - Added POST_NOTIFICATIONS permission requirement in ActionUtils - Implemented notification creation in PerformActionsUseCase - Added entity mapping in ActionDataEntityMapper - Added string resources for the action - Added notification extras constants in ActionEntity Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
- Created ConfigCreateNotificationViewModel for managing notification state - Created CreateNotificationActionScreen with title, text, and timeout inputs - Added navigation support via NavDestination.ConfigCreateNotification - Integrated configuration screen into BaseMainNavHost - Added string resources for configuration UI labels - Marked CreateNotification action as editable - Configured timeout slider with 5-300 second range Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
- Improved notification ID generation to avoid collisions using timestamp + hash - Added validation feedback with error messages and disabled Done button - Extracted magic numbers to constants (MIN/MAX/STEP timeout values) - Added supportingText for empty field errors in UI Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
- Added validation for entity.data to ensure text is not blank - Fixed notification ID generation to avoid integer overflow - Use Long arithmetic and convert to absolute value to ensure positive IDs Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
sds100
left a comment
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.
| } | ||
|
|
||
| is ActionData.CreateNotification -> { | ||
| // Generate a unique notification ID using absolute value to avoid negative IDs |
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.
can you use a notification ID that is unique to the action. Use the hashcode of the ActionData.CreateNotification instance?
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.
Changed to use action.hashCode() for the notification ID. This ensures the same action configuration will always generate the same notification ID. Commit: c8dcc53
| } | ||
|
|
||
| @Serializable | ||
| data class ConfigCreateNotification(val actionJson: String?) : |
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.
Just call this screen "ConfigNotificationActionScreen"
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.
Renamed ConfigCreateNotification to ConfigNotificationAction to follow the naming convention. Commit: c8dcc53
- Use action.hashCode() for notification ID as requested - Rename ConfigCreateNotification to ConfigNotificationAction Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
Implements action to create custom notifications with configurable title, content, and optional auto-dismiss timeout. Unlike existing toasts, these notifications persist and are dismissible by the user.
Core Implementation
CREATE_NOTIFICATIONwithActionData.CreateNotification(title, text, timeoutMs?)CHANNEL_CUSTOM_NOTIFICATIONSwith default priority, auto-created on initPOST_NOTIFICATIONS(Android 13+)action.hashCode()to ensure consistent notification ID for the same action configurationUI Configuration
New configuration screen with:
Entity Persistence
EXTRA_NOTIFICATION_TITLE, text in entity.data, timeout inEXTRA_NOTIFICATION_TIMEOUTActionDataEntityMapperExample Usage
Follows existing patterns from
ShellCommandaction for configuration screen and navigation.Original prompt
<issue_description>Developer TODO (don't remove)
I'd like to have an action to create a notification and specify a title and content please. The current toasts are nice but are ephemeral.</issue_description>
Comments on the Issue (you are @copilot in this section)
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.