Commit 397bfd85 authored by wanglei's avatar wanglei

...

parent 209d5803
...@@ -17,11 +17,15 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_I ...@@ -17,11 +17,15 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_I
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_DOCUMENTS import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_DOCUMENTS
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_LOCK
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_TIMBER
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_count import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_count
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_end import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_end
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_interval 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_start
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_status import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_status
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_timber_interval
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
...@@ -67,7 +71,7 @@ object NotificationUiUtil { ...@@ -67,7 +71,7 @@ object NotificationUiUtil {
AppPreferences.getInstance().put("lastPopupTime", value, true) AppPreferences.getInstance().put("lastPopupTime", value, true)
} }
fun canSendNotification(): Boolean { fun canSendNotification(where: String): Boolean {
//是否开启推送 //是否开启推送
val status = AppPreferences.getInstance().getString(popup_status, "1").toInt() val status = AppPreferences.getInstance().getString(popup_status, "1").toInt()
if (status == 0) { if (status == 0) {
...@@ -91,7 +95,13 @@ object NotificationUiUtil { ...@@ -91,7 +95,13 @@ object NotificationUiUtil {
} }
//单位分钟 //单位分钟
val interval = AppPreferences.getInstance().getString(popup_interval, "1").toInt() var interval = AppPreferences.getInstance().getString(popup_interval, "1").toInt()
if (where == POPUP_WHERE_TIMBER) {
interval = AppPreferences.getInstance().getString(popup_timber_interval, "7").toInt()
}
if (where == POPUP_WHERE_LOCK) {
interval = AppPreferences.getInstance().getString(popup_lock_interval, "1").toInt()
}
if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) { if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) {
LogEx.logDebug("canSendNotification", "interval") LogEx.logDebug("canSendNotification", "interval")
return false return false
...@@ -101,8 +111,8 @@ object NotificationUiUtil { ...@@ -101,8 +111,8 @@ object NotificationUiUtil {
} }
@SuppressLint("RemoteViewLayout") @SuppressLint("RemoteViewLayout")
fun sendNotification(context: Context, actionId: String) { fun sendNotification(context: Context, actionId: String, where: String = "") {
if (!canSendNotification()) return if (!canSendNotification(where)) return
val bigRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message) val bigRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message)
val smallRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message) val smallRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message)
......
...@@ -2,6 +2,9 @@ package com.base.pdfviewerscannerwhite.fcm ...@@ -2,6 +2,9 @@ package com.base.pdfviewerscannerwhite.fcm
object PopupConstObject { object PopupConstObject {
const val POPUP_WHERE_TIMBER = "Timber"
const val POPUP_WHERE_LOCK = "Lock"
//推送总开关 0 关 1开 //推送总开关 0 关 1开
val popup_status = "popup_status" val popup_status = "popup_status"
...@@ -11,7 +14,8 @@ object PopupConstObject { ...@@ -11,7 +14,8 @@ object PopupConstObject {
val popup_start = "popup_start" val popup_start = "popup_start"
val popup_end = "popup_start" val popup_end = "popup_start"
val popup_interval = "popup_interval" val popup_interval = "popup_interval"
val popup_timber_interval = "popup_timber_interval"
val popup_lock_interval = "popup_lock_interval"
//推送样式一配置 //推送样式一配置
val popup_style1_start = "popup_style1_start" val popup_style1_start = "popup_style1_start"
......
...@@ -48,7 +48,7 @@ public class ScreenStatusReceiver extends BroadcastReceiver { ...@@ -48,7 +48,7 @@ public class ScreenStatusReceiver extends BroadcastReceiver {
int secureSetting = Integer.parseInt(AppPreferences.getInstance().getString("lockS", "1")); int secureSetting = Integer.parseInt(AppPreferences.getInstance().getString("lockS", "1"));
if (secureSetting == 1) { if (secureSetting == 1) {
String actionId = NotificationUiUtil.INSTANCE.getNextActionId(); String actionId = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(context, actionId); NotificationUiUtil.INSTANCE.sendNotification(context, actionId, PopupConstObject.POPUP_WHERE_LOCK);
} }
} }
break; break;
......
...@@ -36,8 +36,8 @@ public class TimerManager { ...@@ -36,8 +36,8 @@ public class TimerManager {
!ScreenStatusReceiver.isSecureLockActive() && !ScreenStatusReceiver.isSecureLockActive() &&
MyApplication.PAUSED_VALUE != 1) { MyApplication.PAUSED_VALUE != 1) {
Log.d("glc", "Scheduled task conditions are met"); Log.d("glc", "Scheduled task conditions are met");
String actionId= NotificationUiUtil.INSTANCE.getNextActionId(); String actionId = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(MyApplication.context, actionId); NotificationUiUtil.INSTANCE.sendNotification(MyApplication.context, actionId, PopupConstObject.POPUP_WHERE_TIMBER);
} }
} }
}; };
......
...@@ -26,7 +26,6 @@ import com.artifex.mupdfdemo.SearchTask ...@@ -26,7 +26,6 @@ import com.artifex.mupdfdemo.SearchTask
import com.artifex.mupdfdemo.SearchTaskResult import com.artifex.mupdfdemo.SearchTaskResult
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.AdmobHelper
import com.base.pdfviewerscannerwhite.ads.admob.AdmobBannerUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SAVE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SAVE_PDF
......
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