Update the glance support

This commit is contained in:
Tommaso Berlose
2020-10-14 00:45:29 +02:00
parent 9f4cdc950b
commit c4a16224f0
62 changed files with 472 additions and 112 deletions

View File

@ -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)
}
}
}