https://github.com/androidbroadcast/android-notification-dsl
https://github.com/androidbroadcast/android-notification-dsl
android dsl kotlin notifications
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/androidbroadcast/android-notification-dsl
- Owner: androidbroadcast
- Archived: true
- Created: 2019-11-17T08:00:24.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2022-01-18T16:21:36.000Z (over 4 years ago)
- Last Synced: 2025-05-05T03:19:06.865Z (about 1 year ago)
- Topics: android, dsl, kotlin, notifications
- Language: Kotlin
- Homepage:
- Size: 896 KB
- Stars: 162
- Watchers: 9
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android Notification DSL (In Development)
Kotlin DSL for creating Android Notification using [NotificationCompat](https://developer.android.com/reference/androidx/core/app/NotificationCompat).
```gradle
// Core functionality
implementation 'com.github.kirich1409:android-notification-dsl-core:0.2.1'
// Extentions to simoplify work
implementation 'com.github.kirich1409:android-notification-dsl-extensions:0.2.1'
// Media Notification DSL
implementation 'com.github.kirich1409:android-notification-dsl-media:0.2.1'
```
## Sample
### Simple Notification
:
```kotlin
notification(context, CHANNEL_ID, smallIcon = R.drawable.notification_icon) {
contentTitle(textTitle)
contentText(textContent)
priority(NotificationCompat.PRIORITY_DEFAULT)
}
```
### Grouped Notification
Create grouped notifications
```kotlin
notificationsGroup(context, groupKey = GROUP_KEY, channelId = CHANNEL) {
summary(SUMMARY_NOTIFICATION_ID, smallIcon = R.drawable.ic_android_white_24dp) {
contentTitle(R.string.notification_summary_title)
contentText(R.string.notification_summary_text)
}
notifications {
notification(NOTIFICATION_1_ID, smallIcon = R.drawable.ic_android_white_24dp) {
contentTitle(R.string.notification_1_title)
}
notification(NOTIFICATION_2_ID, smallIcon = R.drawable.ic_android_white_24dp) {
contentTitle(R.string.notification_2_title)
}
}
}
```
### Notification Channels DSL
Creating Android Notification Channels and Groups
```kotlin
createChannelsAndGroups(context) {
channel(CHANNEL_1_ID, CHANNEL_1_NAME)
group(CHANNEL_GROUP_1_ID, CHANNEL_GROUP_1_NAME) {
// Empty group
}
group(CHANNEL_GROUP_2_ID, CHANNEL_GROUP_2_NAME) {
channel(CHANNEL_2_ID, CHANNEL_2_NAME)
}
}
```