Fix notifcation color crash, use solid toolbar color

This commit is contained in:
Bnyro 2023-06-01 12:12:08 +02:00
parent 256a0a3bdb
commit f9232c6857
3 changed files with 10 additions and 5 deletions

View file

@ -13,7 +13,6 @@ import android.os.Build
import android.os.Bundle
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import io.heckel.ntfy.R
import io.heckel.ntfy.db.*
import io.heckel.ntfy.db.Notification
@ -95,7 +94,7 @@ class NotificationService(val context: Context) {
(repository.getInsistentMaxPriorityEnabled() || subscription.insistent == Repository.INSISTENT_MAX_PRIORITY_ENABLED)
val builder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_notification)
.setColor(ContextCompat.getColor(context, Colors.notificationIcon(context)))
.setColor(Colors.notificationIcon(context))
.setContentTitle(title)
.setOnlyAlertOnce(true) // Do not vibrate or play sound if already showing (updates!)
.setAutoCancel(true) // Cancel when notification is clicked

View file

@ -9,7 +9,6 @@ import android.os.IBinder
import android.os.PowerManager
import android.os.SystemClock
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import io.heckel.ntfy.BuildConfig
import io.heckel.ntfy.R
import io.heckel.ntfy.app.Application
@ -291,7 +290,7 @@ class SubscriberService : Service() {
}
return NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_instant)
.setColor(ContextCompat.getColor(this, Colors.notificationIcon(this)))
.setColor(Colors.notificationIcon(this))
.setContentTitle(title)
.setContentText(text)
.setContentIntent(pendingIntent)

View file

@ -29,8 +29,10 @@
<item name="colorPrimaryInverse">@color/md_theme_inversePrimary</item>
<item name="switchPreferenceCompatStyle">@style/MaterialSwitch</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">?colorPrimaryInverse</item>
<item name="actionModeBackground">?backgroundColor</item>
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
<item name="actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="AppTheme" parent="BaseTheme">
@ -57,4 +59,9 @@
<style name="MaterialSwitch" parent="@style/Preference.SwitchPreferenceCompat.Material">
<item name="widgetLayout">@layout/view_preference_switch</item>
</style>
<!-- Action bar with custom background color -->
<style name="ActionBarStyle" parent="@style/Widget.Material3.ActionBar.Solid">
<item name="background">?colorPrimaryInverse</item>
</style>
</resources>