EdricChan03 / EdricChan03/androidx-ktx-extras
[New Library] Android NotificationChannel extensions
- Dominant language
- Kotlin
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
I've noticed that the `NotificationChannel` class has some rather... interesting naming conventions for getters/setters of boolean properties:
```java
/**
* Sets whether notifications posted to this channel should display notification lights,
* on devices that support that feature.
*
* Only modifiable before the channel is submitted to
* {@link NotificationManager#createNotificationChannel(NotificationChannel)}.
*/
public void enableLights(boolean lights) {
this.mLights = lights;
}
/**
* Returns whether notifications posted to this channel trigger notification lights.
*/
public boolean shouldShowLights() {
return mLights;
}
```
As a result, no [synthetic Kotlin mutable properties](https://kotlinlang.org/docs/java-interop.html#getters-and-setters) are generated, resulting in having to use the Java getter/setter methods respectively.
## Proposed extensions
* [ ] `isBadgesShown`: delegates to [`setShowBadge` (setter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#setshowbadge)/[`canShowBadge` (getter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#canshowbadge)
* [ ] `isBubblesAllowed`: delegates to [`setAllowBubbles` (setter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#setallowbubbles)/[`canBubble` (getter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#canbubble)
* [ ] `isDndBypassable`: delegates to [`setBypassDnd` (setter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#setbypassdnd)/[`canBypassDnd` (getter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#canbypassdnd)
* [ ] `isVibrationEnabled`: delegates to [`enableVibration` (setter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#enablevibration)/[`shouldVibrate` (getter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#shouldvibrate)
* [ ] `isLightsEnabled`: delegates to [`enableLights` (setter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#enablelights)/[`shouldShowLights` (getter)](https://developer.android.com/reference/kotlin/android/app/NotificationChannel#shouldshowlights)
(API names are currently tentative, the names will change as further experimentation is done)
## Additional tasks
* [ ] Add notice that the properties can't be modified once they have been submitted (perhaps a Kotlin opt-in annotation, something like `ImmutableAfterCreation`)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.