Update the glance support
This commit is contained in:
@ -1,19 +1,28 @@
|
||||
package com.tommasoberlose.anotherwidget.helpers
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.service.notification.StatusBarNotification
|
||||
import android.util.Log
|
||||
import com.chibatching.kotpref.Kotpref
|
||||
import com.chibatching.kotpref.blockingBulk
|
||||
import com.google.gson.Gson
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import java.lang.Exception
|
||||
|
||||
object ActiveNotificationsHelper {
|
||||
fun getLastNotification(context: Context): StatusBarNotification? {
|
||||
with(context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager) {
|
||||
activeNotifications.forEach {
|
||||
Log.d("ciao", Gson().toJson(it).toString())
|
||||
}
|
||||
fun showLastNotification(): Boolean {
|
||||
return Preferences.lastNotificationId != -1 && Preferences.lastNotificationIcon != 0 && Preferences.lastNotificationPackage.isNotBlank() && Preferences.lastNotificationTitle.isNotBlank()
|
||||
}
|
||||
|
||||
return activeNotifications.lastOrNull()
|
||||
fun clearLastNotification(context: Context) {
|
||||
Kotpref.init(context)
|
||||
Preferences.blockingBulk {
|
||||
remove(Preferences::lastNotificationId)
|
||||
remove(Preferences::lastNotificationTitle)
|
||||
remove(Preferences::lastNotificationPackage)
|
||||
remove(Preferences::lastNotificationIcon)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user