Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

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

  • Action type: CREATE_NOTIFICATION with ActionData.CreateNotification(title, text, timeoutMs?)
  • Channel: CHANNEL_CUSTOM_NOTIFICATIONS with default priority, auto-created on init
  • Permission: Requires POST_NOTIFICATIONS (Android 13+)
  • ID generation: Uses action.hashCode() to ensure consistent notification ID for the same action configuration

UI Configuration

New configuration screen with:

  • Title and content text fields (single/multi-line)
  • Auto-dismiss checkbox with slider (5-300s, 5s increments, default 30s)
  • Real-time validation with error messages and disabled save when fields empty

Entity Persistence

  • Stores title in EXTRA_NOTIFICATION_TITLE, text in entity.data, timeout in EXTRA_NOTIFICATION_TIMEOUT
  • Bidirectional mapping in ActionDataEntityMapper
  • Validation ensures non-blank required fields on deserialization

Example Usage

ActionData.CreateNotification(
    title = "Task Complete",
    text = "Your download has finished",
    timeoutMs = 30000  // Auto-dismiss after 30s, or null for persistent
)

Follows existing patterns from ShellCommand action for configuration screen and navigation.

[!WARNING]

Original prompt

This section details on the original issue you should resolve

<filter_complete></filter_complete>

<issue_title>Action to create notification and set title and content</issue_title>
<issue_description>Developer TODO (don't remove)

  • create new branch. put issue number at start of name
  • Create a "Custom notifications" notification channel. Auto-create the channel when NotificationController is initialized. Use default priority for the channel.
  • Use existing NotificationModel class and NotificationAdapter.
  • Request POST_NOTIFICATIONS permission in ActionUtils
  • Specify a timeout that auto-dismisses the notification. Use SliderOptionText and default is 30 seconds. This is optional so also show a checkbox (CheckboxText) to enable/disable this feature.

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

This section details on the original issue you should resolve

<issue_title>Action to create notification and set title and content</issue_title>
<issue_description>Developer TODO (don't remove)

  • create new branch. put issue number at start of name
  • Create a "Custom notifications" notification channel. Auto-create the channel when NotificationController is initialized. Use default priority for the channel.
  • Use existing NotificationModel class and NotificationAdapter.
  • Request POST_NOTIFICATIONS permission in ActionUtils
  • Specify a timeout that auto-dismisses the notification. Use SliderOptionText and default is 30 seconds. This is optional so also show a checkbox (CheckboxText) to enable/disable this feature.

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)


💡 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.

Copilot AI and others added 4 commits November 2, 2025 13:50
- 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
Copilot finished work on behalf of sds100 November 2, 2025 14:02
Copilot AI requested a review from sds100 November 2, 2025 14:02
Copy link
Collaborator

@sds100 sds100 left a 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
Copy link
Collaborator

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?

Copy link
Contributor Author

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?) :
Copy link
Collaborator

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"

Copy link
Contributor Author

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>
Copilot AI requested a review from sds100 November 4, 2025 17:37
Copilot finished work on behalf of sds100 November 4, 2025 17:37
@sds100 sds100 merged commit 91a73c5 into develop Nov 9, 2025
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.

Action to create notification and set title and content

2 participants