-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(capabilities): Revamp System (#86)
- Loading branch information
Showing
5 changed files
with
213 additions
and
243 deletions.
There are no files selected for viewing
This file contains 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
80 changes: 64 additions & 16 deletions
80
kotlin-audio/src/main/java/com/doublesymmetry/kotlinaudio/models/Capability.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,67 @@ | ||
package com.doublesymmetry.kotlinaudio.models | ||
|
||
enum class Capability { | ||
PLAY, | ||
PLAY_FROM_ID, | ||
PLAY_FROM_SEARCH, | ||
PAUSE, | ||
STOP, | ||
SEEK_TO, | ||
SKIP, | ||
SKIP_TO_NEXT, | ||
SKIP_TO_PREVIOUS, | ||
JUMP_FORWARD, | ||
JUMP_BACKWARD, | ||
SET_RATING, | ||
LIKE, | ||
DISLIKE, | ||
BOOKMARK | ||
/** | ||
* Defines the capabilities supported by the media session and whether they're also supported by the notification. | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showPlayPauseButton] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showStopButton] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showRewindButton] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showRewindButtonCompact] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showForwardButton] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showForwardButtonCompact] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showNextButton] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showNextButtonCompact] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showPreviousButton] | ||
* @see [com.doublesymmetry.kotlinaudio.notification.NotificationManager.showPreviousButtonCompact] | ||
*/ | ||
sealed class Capability(open val showInNotification: Boolean = true) { | ||
data class PlayPause( | ||
override val showInNotification: Boolean = true, | ||
val notificationOptions: NofiticationPlayPauseActionOptions = NofiticationPlayPauseActionOptions.DEFAULT | ||
) : Capability() | ||
|
||
object PlayFromId : Capability(showInNotification = false) | ||
|
||
object PlayFromSearch : Capability(showInNotification = false) | ||
|
||
data class Stop( | ||
override val showInNotification: Boolean = true, | ||
val notificationOptions: NofiticationIconActionOptions? = null | ||
) : Capability() | ||
|
||
object SeekTo : Capability(showInNotification = false) | ||
|
||
object Skip : Capability(showInNotification = false) | ||
|
||
data class Next( | ||
override val showInNotification: Boolean = true, | ||
val notificationOptions: NofiticationActionOptions = NofiticationActionOptions.DEFAULT | ||
) : Capability() | ||
|
||
data class Previous( | ||
override val showInNotification: Boolean = true, | ||
val notificationOptions: NofiticationActionOptions = NofiticationActionOptions.DEFAULT | ||
) : Capability() | ||
|
||
data class Forward( | ||
override val showInNotification: Boolean = true, | ||
val notificationOptions: NofiticationActionOptions = NofiticationActionOptions.DEFAULT | ||
) : Capability() | ||
|
||
data class Backward( | ||
override val showInNotification: Boolean = true, | ||
val notificationOptions: NofiticationActionOptions = NofiticationActionOptions.DEFAULT | ||
) : Capability() | ||
|
||
data class SetRating(val type: Int) : Capability(showInNotification = false) | ||
} | ||
|
||
|
||
data class CapabilitiesConfig( | ||
val capabilities: List<Capability>, | ||
val notificationOptions: NotificationOptions, | ||
) | ||
|
||
/** Custom extension to filter out only those capabilities that are supported by the notification */ | ||
fun List<Capability>.filterForNotification(): List<Capability> { | ||
return this.filter { it.showInNotification } | ||
} |
42 changes: 0 additions & 42 deletions
42
kotlin-audio/src/main/java/com/doublesymmetry/kotlinaudio/models/NotificationConfig.kt
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
kotlin-audio/src/main/java/com/doublesymmetry/kotlinaudio/models/NotificationOptions.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.doublesymmetry.kotlinaudio.models | ||
|
||
import android.app.PendingIntent | ||
import androidx.annotation.DrawableRes | ||
|
||
/** | ||
* Used to configure the player notification. | ||
* @param accentColor The accent color of the notification. | ||
* @param smallIcon The small icon of the notification which is also shown in the system status bar. | ||
* @param pendingIntent The [PendingIntent] that would be called when tapping on the notification itself. | ||
*/ | ||
data class NotificationOptions( | ||
val accentColor: Int? = null, | ||
@DrawableRes val smallIcon: Int? = null, | ||
val pendingIntent: PendingIntent? = null | ||
) | ||
|
||
/** Used to configure the properties of a standard notification button */ | ||
data class NofiticationActionOptions( | ||
@DrawableRes val icon: Int? = null, | ||
val isCompact: Boolean = false | ||
) { | ||
companion object { | ||
val DEFAULT = NofiticationActionOptions(isCompact = true) | ||
} | ||
} | ||
|
||
/** Used to configure the properties of a standard notification button */ | ||
data class NofiticationIconActionOptions( | ||
@DrawableRes val icon: Int? = null, | ||
) | ||
|
||
/** Used to configure the properties of a standard notification button */ | ||
data class NofiticationPlayPauseActionOptions( | ||
@DrawableRes val playIcon: Int? = null, | ||
@DrawableRes var pauseIcon: Int? = null, | ||
val isCompact: Boolean = false | ||
) { | ||
companion object { | ||
val DEFAULT = NofiticationPlayPauseActionOptions(isCompact = true) | ||
} | ||
} |
Oops, something went wrong.