[Notification] Code Cleanup
This commit is contained in:
parent
ad51d09672
commit
7e3b4404cf
2 changed files with 3 additions and 8 deletions
|
@ -25,6 +25,7 @@ import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
|
@ -57,7 +58,6 @@ class PlayingNotificationClassic(
|
||||||
val context: Context
|
val context: Context
|
||||||
) : PlayingNotification(context) {
|
) : PlayingNotification(context) {
|
||||||
private var primaryColor: Int = 0
|
private var primaryColor: Int = 0
|
||||||
private var isInitialized = false
|
|
||||||
|
|
||||||
private fun getCombinedRemoteViews(collapsed: Boolean, song: Song): RemoteViews {
|
private fun getCombinedRemoteViews(collapsed: Boolean, song: Song): RemoteViews {
|
||||||
val remoteViews = RemoteViews(
|
val remoteViews = RemoteViews(
|
||||||
|
@ -75,7 +75,6 @@ class PlayingNotificationClassic(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
|
override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
|
||||||
isInitialized = true
|
|
||||||
val notificationLayout = getCombinedRemoteViews(true, song)
|
val notificationLayout = getCombinedRemoteViews(true, song)
|
||||||
val notificationLayoutBig = getCombinedRemoteViews(false, song)
|
val notificationLayoutBig = getCombinedRemoteViews(false, song)
|
||||||
|
|
||||||
|
@ -98,11 +97,11 @@ class PlayingNotificationClassic(
|
||||||
setContentIntent(clickIntent)
|
setContentIntent(clickIntent)
|
||||||
setDeleteIntent(deleteIntent)
|
setDeleteIntent(deleteIntent)
|
||||||
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||||
setColorized(PreferenceUtil.isColoredNotification)
|
|
||||||
priority = NotificationCompat.PRIORITY_MAX
|
priority = NotificationCompat.PRIORITY_MAX
|
||||||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
setCustomContentView(notificationLayout)
|
setCustomContentView(notificationLayout)
|
||||||
setCustomBigContentView(notificationLayoutBig)
|
setCustomBigContentView(notificationLayoutBig)
|
||||||
|
setStyle(DecoratedMediaCustomViewStyle())
|
||||||
setOngoing(true)
|
setOngoing(true)
|
||||||
val bigNotificationImageSize = context.resources
|
val bigNotificationImageSize = context.resources
|
||||||
.getDimensionPixelSize(R.dimen.notification_big_image_size)
|
.getDimensionPixelSize(R.dimen.notification_big_image_size)
|
||||||
|
@ -164,6 +163,7 @@ class PlayingNotificationClassic(
|
||||||
setNotificationContent(ColorUtil.isColorLight(bgColorFinal))
|
setNotificationContent(ColorUtil.isColorLight(bgColorFinal))
|
||||||
} else {
|
} else {
|
||||||
if (PreferenceUtil.isColoredNotification) {
|
if (PreferenceUtil.isColoredNotification) {
|
||||||
|
setColorized(true)
|
||||||
color = bgColor
|
color = bgColor
|
||||||
setNotificationContent(color.isColorLight)
|
setNotificationContent(color.isColorLight)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -114,11 +114,6 @@ class PlayingNotificationImpl24(
|
||||||
.setShowActionsInCompactView(1, 2, 3)
|
.setShowActionsInCompactView(1, 2, 3)
|
||||||
)
|
)
|
||||||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
if (Build.VERSION.SDK_INT <=
|
|
||||||
Build.VERSION_CODES.O && PreferenceUtil.isColoredNotification
|
|
||||||
) {
|
|
||||||
this.color = color
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
|
override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue