Add CREATE_NOTIFICATION action for persistent custom notifications#1877
Merged
Add CREATE_NOTIFICATION action for persistent custom notifications#1877
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>
Copilot
AI
changed the title
[WIP] Add action to create notifications with title and content
Add CREATE_NOTIFICATION action for persistent custom notifications
Nov 2, 2025
sds100
requested changes
Nov 4, 2025
| } | ||
|
|
||
| is ActionData.CreateNotification -> { | ||
| // Generate a unique notification ID using absolute value to avoid negative IDs |
Collaborator
There was a problem hiding this comment.
can you use a notification ID that is unique to the action. Use the hashcode of the ActionData.CreateNotification instance?
Contributor
Author
There was a problem hiding this comment.
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?) : |
Collaborator
There was a problem hiding this comment.
Just call this screen "ConfigNotificationActionScreen"
Contributor
Author
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.