Commit 77f295db authored by wanglei's avatar wanglei

...

parent a68b65da
...@@ -118,12 +118,22 @@ object NotificationUtils { ...@@ -118,12 +118,22 @@ object NotificationUtils {
} }
private var lastNotificationTime = 0L
fun sendNotification(context: Context, where: String) { fun sendNotification(context: Context, where: String) {
if (isDeviceLocked || isAppInForeground || !isScreenOn) { if (isDeviceLocked || isAppInForeground || !isScreenOn) {
return return
} }
val actionId = nextNotificationId val actionId = nextNotificationId
val intervalTime = System.currentTimeMillis() - lastNotificationTime
val spInterval = SpUtils.getInstance().getInt("NotificationInterval", 1)
val oneMinute = 1 * 60 * 1000L
Log.e("sendNotification", "where=$where actionId=$actionId intervalTime=$intervalTime spInterval=$spInterval")
if (lastNotificationTime != 0L && intervalTime < spInterval * oneMinute) {
return
}
val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_common) val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_common)
val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_common_small) val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_common_small)
var intentAction = "" var intentAction = ""
...@@ -138,9 +148,11 @@ object NotificationUtils { ...@@ -138,9 +148,11 @@ object NotificationUtils {
intentAction = Global.FUNCTION_CLEAN intentAction = Global.FUNCTION_CLEAN
} }
FUNCTION_APP_MANAGER -> { FUNCTION_APP_MANAGER -> {
} }
FUNCTION_BATTERY -> { FUNCTION_BATTERY -> {
} }
...@@ -148,15 +160,19 @@ object NotificationUtils { ...@@ -148,15 +160,19 @@ object NotificationUtils {
FUNCTION_LARGE_FILE -> { FUNCTION_LARGE_FILE -> {
} }
FUNCTION_WHATS_APP-> {
FUNCTION_WHATS_APP -> {
} }
FUNCTION_APP_PROCESS -> { FUNCTION_APP_PROCESS -> {
} }
FUNCTION_SIMILAR_PHOTOS -> { FUNCTION_SIMILAR_PHOTOS -> {
} }
FUNCTION_SCREENSHOT -> { FUNCTION_SCREENSHOT -> {
} }
...@@ -183,6 +199,7 @@ object NotificationUtils { ...@@ -183,6 +199,7 @@ object NotificationUtils {
bigRemoteViews, bigRemoteViews,
smallRemoteViews, smallRemoteViews,
) )
lastNotificationTime = System.currentTimeMillis()
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment