Commit 8ec129b3 authored by wanglei's avatar wanglei

...

parent ac5769c2
...@@ -17,7 +17,6 @@ import androidx.core.graphics.drawable.IconCompat ...@@ -17,7 +17,6 @@ import androidx.core.graphics.drawable.IconCompat
import com.base.filerecoveryrecyclebin.MyApplication import com.base.filerecoveryrecyclebin.MyApplication
import com.base.filerecoveryrecyclebin.R import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.activity.SplashActivity import com.base.filerecoveryrecyclebin.activity.SplashActivity
import com.base.filerecoveryrecyclebin.bean.ConstObject.BATTERY_INFO
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_MANAGER import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_MANAGER
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_PROCESS import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_PROCESS
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_BATTERY_INFO import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_BATTERY_INFO
...@@ -40,6 +39,9 @@ import com.base.filerecoveryrecyclebin.utils.PhotoRecoveryStringManager ...@@ -40,6 +39,9 @@ import com.base.filerecoveryrecyclebin.utils.PhotoRecoveryStringManager
import com.base.filerecoveryrecyclebin.utils.ScreenshotCleanupStringManager import com.base.filerecoveryrecyclebin.utils.ScreenshotCleanupStringManager
import com.base.filerecoveryrecyclebin.utils.VideoRecoveryStringManager import com.base.filerecoveryrecyclebin.utils.VideoRecoveryStringManager
import com.base.filerecoveryrecyclebin.utils.WhatsappCleanerStringManager import com.base.filerecoveryrecyclebin.utils.WhatsappCleanerStringManager
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
import java.util.Random import java.util.Random
/** /**
...@@ -220,6 +222,12 @@ object NotificationUtil { ...@@ -220,6 +222,12 @@ object NotificationUtil {
private var handlerThread: HandlerThread? = null private var handlerThread: HandlerThread? = null
private var handler: Handler? = null private var handler: Handler? = null
private fun getCurrentDate(): String {
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val currentDate = Calendar.getInstance().time
return dateFormat.format(currentDate)
}
fun sendNotification(context: Context, where: String = "") { fun sendNotification(context: Context, where: String = "") {
val actionId: Int = getNextNotificationId() val actionId: Int = getNextNotificationId()
EventUtils.event("showNotification", where, null, false) EventUtils.event("showNotification", where, null, false)
...@@ -227,6 +235,11 @@ object NotificationUtil { ...@@ -227,6 +235,11 @@ object NotificationUtil {
if (MyApplication.PAUSED_VALUE == 1) { if (MyApplication.PAUSED_VALUE == 1) {
return return
} }
val maxShowNotificationCount = AppPreferences.getInstance().getString("maxShowNotificationCount", "0").toInt()
var todayShowCount = AppPreferences.getInstance().getInt("notificationCount_${getCurrentDate()}", 0)
if (todayShowCount >= maxShowNotificationCount) {
return
}
val interval: Int = AppPreferences.getInstance().getString("notificationInterval", "60").toIntOrNull() ?: 60 val interval: Int = AppPreferences.getInstance().getString("notificationInterval", "60").toIntOrNull() ?: 60
val lastTime: Long = AppPreferences.getInstance().getLong("last_notification_time", 0) val lastTime: Long = AppPreferences.getInstance().getLong("last_notification_time", 0)
...@@ -238,6 +251,8 @@ object NotificationUtil { ...@@ -238,6 +251,8 @@ object NotificationUtil {
sendNotification(context, actionId) sendNotification(context, actionId)
AppPreferences.getInstance().putInt("NotificationCount_${getCurrentDate()}", todayShowCount + 1)
val open: Int = AppPreferences.getInstance().getString("open", "0").toIntOrNull() ?: 0 val open: Int = AppPreferences.getInstance().getString("open", "0").toIntOrNull() ?: 0
if (open == 1) { if (open == 1) {
......
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