Commit 5b896ade authored by wanglei's avatar wanglei

...开锁屏通知

parent 3de00392
......@@ -7,6 +7,7 @@ import android.os.Bundle
import com.base.datarecovery.activity.SplashActivity
import com.base.datarecovery.ads.AdmobOpenUtils
import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
import com.base.datarecovery.fcm.ActionBroadcast
import com.base.datarecovery.fcm.FCMManager
import com.base.datarecovery.fcm.RecoveryTimerManager
import com.base.datarecovery.help.BaseApplication
......@@ -32,18 +33,19 @@ class MyApplication : BaseApplication() {
fun initApp() {
FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(packageName+"_push")
FCMManager.subscribeToTopic(packageName + "_push")
NewComUtils.requestCfg {
val timerStatus: Int = AppPreferences.getInstance().getString("timerS", "1").toIntOrNull()?:1
ActionBroadcast.initBroadcast(this)
val timerStatus: Int = AppPreferences.getInstance().getString("timerS", "1").toIntOrNull() ?: 1
if (timerStatus == 0) {
RecoveryTimerManager.getInstance().stopTaskTimer()
} else {
val timerDelay: Int = AppPreferences.getInstance().getString("timerDelay", "1").toIntOrNull()?:1
val timerInterval: Int = AppPreferences.getInstance().getString("timerInterval", "7").toIntOrNull()?:7
val timerDelay: Int = AppPreferences.getInstance().getString("timerDelay", "1").toIntOrNull() ?: 1
val timerInterval: Int = AppPreferences.getInstance().getString("timerInterval", "7").toIntOrNull() ?: 7
if (!RecoveryTimerManager.getInstance().isTaskTimerActive) {
RecoveryTimerManager.getInstance().scheduleTask(
(timerDelay * 60*1000).toLong(),
(timerInterval * 60*1000).toLong()
(timerDelay * 60 * 1000).toLong(),
(timerInterval * 60 * 1000).toLong()
)
}
}
......
package com.base.datarecovery.fcm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import com.base.datarecovery.help.BaseApplication;
import com.base.datarecovery.utils.AppPreferences;
public class ActionBroadcast extends BroadcastReceiver {
public static boolean mIsScreenOn = true;
public static boolean isLock = false;
public static void initBroadcast(Context context) {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_USER_PRESENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(new ActionBroadcast(), filter, Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(new ActionBroadcast(), filter);
}
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch (action) {
case Intent.ACTION_SCREEN_ON:
mIsScreenOn = true;
break;
case Intent.ACTION_SCREEN_OFF:
mIsScreenOn = false;
isLock = true;
break;
case Intent.ACTION_USER_PRESENT:
isLock = false;
if (mIsScreenOn && !isLock) {
int locks = AppPreferences.getInstance().getInt("lockS", 1);
if (locks == 1) {
NotificationUtil.INSTANCE.sendNotification(BaseApplication.context);
}
}
break;
}
}
}
......@@ -228,7 +228,7 @@ object NotificationUtil {
handler?.removeCallbacksAndMessages(null)
return@Runnable
}
if (MyApplication.PAUSED_VALUE !== 1) {
if (MyApplication.PAUSED_VALUE !== 1 && ActionBroadcast.mIsScreenOn && !ActionBroadcast.isLock) {
sendNotification(context, actionId)
}
}, time)
......
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