Commit 535a918c authored by wanglei's avatar wanglei

...

parent 55d5928a
......@@ -27,7 +27,7 @@ import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_interval
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_lock_interval
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_start
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_status
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_timber_interval
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_timer_interval
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
......@@ -74,7 +74,7 @@ object NotificationUiUtil {
AppPreferences.getInstance().put("lastPopupTime", value, true)
}
fun canSendNotification(where: String): Boolean {
fun canSendNotification(where: String, actionId: String): Boolean {
//是否开启推送
val status = AppPreferences.getInstance().getString(popup_status, "1").toInt()
if (status == 0) {
......@@ -86,7 +86,7 @@ object NotificationUiUtil {
val count = AppPreferences.getInstance().getString(popup_count, "20").toInt()
if (dayPopupCount > count) {
LogEx.logDebug("canSendNotification", "count")
EventUtils.event("Notification_Error", "dayPopupCount=$dayPopupCount count=$count")
EventUtils.event("Notification_Error", "dayPopupCount=$dayPopupCount count=$count where=$where actionId=$actionId")
return false
}
//判断是否在时间区域
......@@ -95,15 +95,15 @@ object NotificationUiUtil {
val calendar = Calendar.getInstance()
val currentHour = calendar.get(Calendar.HOUR_OF_DAY)
if (currentHour !in start until end) {
LogEx.logDebug("canSendNotification", "start end currentHour=$currentHour start=$start end=$end")
EventUtils.event("Notification_Error", "start=$start end=$end currentHour=$currentHour")
LogEx.logDebug("canSendNotification", "start-end currentHour=$currentHour start=$start end=$end")
EventUtils.event("Notification_Error", "start=$start end=$end currentHour=$currentHour where=$where actionId=$actionId")
return false
}
//单位分钟
var interval = AppPreferences.getInstance().getString(popup_interval, "1").toInt()
if (where == POPUP_WHERE_TIMBER) {
interval = AppPreferences.getInstance().getString(popup_timber_interval, "7").toInt()
interval = AppPreferences.getInstance().getString(popup_timer_interval, "7").toInt()
}
if (where == POPUP_WHERE_LOCK) {
interval = AppPreferences.getInstance().getString(popup_lock_interval, "1").toInt()
......@@ -112,7 +112,7 @@ object NotificationUiUtil {
interval = AppPreferences.getInstance().getString(popup_fcm_interval, "1").toInt()
}
if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) {
EventUtils.event("Notification_Error", "where=$where interval=$interval")
EventUtils.event("Notification_Error", "where=$where actionId=$actionId interval=$interval")
LogEx.logDebug("canSendNotification", "interval")
return false
}
......@@ -122,7 +122,7 @@ object NotificationUiUtil {
@SuppressLint("RemoteViewLayout")
fun sendNotification(context: Context, actionId: String, where: String = "") {
if (!canSendNotification(where)) return
if (!canSendNotification(where, actionId)) return
val bigRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message)
val smallRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message)
......
......@@ -4,9 +4,10 @@ import com.base.pdfviewerscannerwhite.utils.AppPreferences
object PopupConstObject {
const val POPUP_WHERE_TIMBER = "Timber"
const val POPUP_WHERE_TIMBER = "Timer"
const val POPUP_WHERE_LOCK = "Lock"
const val POPUP_WHERE_FCM = "fcm"
const val POPUP_WHERE_MEDIA_CHANGE = "media_change"
//推送总开关 0 关 1开
val popup_status = "popup_status"
......@@ -17,7 +18,7 @@ object PopupConstObject {
val popup_start = "popup_start"
val popup_end = "popup_end"
val popup_interval = "popup_interval"
val popup_timber_interval = "popup_timber_interval"
val popup_timer_interval = "popup_timber_interval"
val popup_lock_interval = "popup_lock_interval"
val popup_fcm_interval = "popup_fcm_interval"
......
......@@ -8,6 +8,7 @@ import android.net.Uri
import android.provider.MediaStore
import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.fcm.NotificationUiUtil
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject
import com.base.pdfviewerscannerwhite.utils.LogEx
/**
......@@ -22,7 +23,11 @@ class MediaContentObserver(val context: Context) : ContentObserver(null) {
super.onChange(selfChange, uri)
LogEx.logDebug(TAG, "uri=${uri.toString()}")
if (uri.toString().contains("images")) {
NotificationUiUtil.sendNotification(context, ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF)
NotificationUiUtil.sendNotification(
context,
ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF,
PopupConstObject.POPUP_WHERE_MEDIA_CHANGE
)
}
// uri?.let { queryNewMediaFiles(it) }
}
......
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