Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
swiftcleanerphonehelper
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
swiftcleanerphonehelper
Commits
351bbf91
Commit
351bbf91
authored
Dec 20, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
0a5b0386
Pipeline
#1382
canceled with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
52 deletions
+39
-52
Global.java
.../main/java/com/swiftcleaner/chovey/model/bean/Global.java
+15
-0
ZxApplication.kt
app/src/main/java/com/zxdemo/ZxApplication.kt
+2
-9
NotificationUtils.kt
app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
+6
-3
UnlockReceiver.kt
app/src/main/java/com/zxdemo/receiver/UnlockReceiver.kt
+8
-36
InstallRefeerUtils.kt
app/src/main/java/com/zxdemo/utils/InstallRefeerUtils.kt
+8
-4
No files found.
app/src/main/java/com/swiftcleaner/chovey/model/bean/Global.java
View file @
351bbf91
...
...
@@ -5,4 +5,19 @@ public class Global {
public
static
String
FUNCTION_APP_MANAGER
=
"function_app_manager"
;
public
static
String
FUNCTION_BATTERY
=
"function_battery"
;
public
static
String
FUNCTION_LARGE_FILE
=
"function_large_file"
;
//配置
public
static
String
NotificationStayStatus
=
"NotificationStayStatus"
;
//int
public
static
String
NotificationStayCount
=
"NotificationStayCount"
;
//int
public
static
String
NotificationStayDelay
=
"NotificationStayDelay"
;
//int
public
static
String
timerStatus
=
"timerStatus"
;
//int
public
static
String
timerDelay
=
"timerDelay"
;
//int
public
static
String
timerInterval
=
"timerInterval"
;
//int
public
static
String
lockNotificationStatus
=
"lockNotificationStatus"
;
}
app/src/main/java/com/zxdemo/ZxApplication.kt
View file @
351bbf91
...
...
@@ -62,23 +62,16 @@ class ZxApplication : Application() {
UnlockReceiver
.
mIsScreenOn
}
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
fun
sendBroadCast
()
{
//注册广播
AppInstallReceiver
.
registerReceiver
(
context
)
UnlockReceiver
().
initBroadcast
(
context
)
val
filter
=
IntentFilter
(
Intent
.
ACTION_BATTERY_CHANGED
)
if
(
context
!=
null
)
{
runCatching
{
context
.
registerReceiver
(
BatteryStatusReceiver
(),
filter
)
}
var
minute
=
SpUtils
.
getInstance
().
getInt
(
"MINUTE"
,
-
1
)
if
(
minute
<
0
)
{
minute
=
LocalTime
.
now
().
minute
}
else
{
SpUtils
.
getInstance
().
putInt
(
"MINUTE"
,
minute
)
}
FcmUtils
().
initFirebase
(
context
)
FcmUtils
().
subscribeToTopic
(
"${packname}_push
_$minute
"
)
FcmUtils
().
subscribeToTopic
(
"${packname}_push"
)
// var config = SolarEngineConfig.Builder().build()
// SolarEngineManager.getInstance()
...
...
app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
View file @
351bbf91
...
...
@@ -16,6 +16,9 @@ import androidx.core.app.NotificationCompat
import
androidx.core.app.NotificationManagerCompat
import
androidx.core.content.ContextCompat
import
com.swiftcleaner.chovey.R
import
com.swiftcleaner.chovey.model.bean.Global.NotificationStayCount
import
com.swiftcleaner.chovey.model.bean.Global.NotificationStayDelay
import
com.swiftcleaner.chovey.model.bean.Global.NotificationStayStatus
import
com.swiftcleaner.chovey.view.MainActivity
import
com.zxdemo.ZxApplication.Companion.isAppInForeground
import
com.zxdemo.ZxApplication.Companion.isDeviceLocked
...
...
@@ -165,10 +168,10 @@ object NotificationUtils {
bigRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
fl_btn
,
btnPendingIntent
)
smallRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
tv_btn
,
btnPendingIntent
)
val
open
=
SpUtils
.
getInstance
().
getInt
(
"NotificationStayStatus"
,
0
)
val
open
=
SpUtils
.
getInstance
().
getInt
(
NotificationStayStatus
,
0
)
if
(
open
==
1
)
{
val
num
=
SpUtils
.
getInstance
().
getInt
(
"NotificationStayCount"
,
5
)
val
delay
=
SpUtils
.
getInstance
().
getInt
(
"NotificationStayDelay"
,
4000
).
toLong
()
val
num
=
SpUtils
.
getInstance
().
getInt
(
NotificationStayCount
,
5
)
val
delay
=
SpUtils
.
getInstance
().
getInt
(
NotificationStayDelay
,
4000
).
toLong
()
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
handlerThread
!!
.
start
()
// 创建 Handler
...
...
app/src/main/java/com/zxdemo/receiver/UnlockReceiver.kt
View file @
351bbf91
package
com.zxdemo.receiver
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
...
...
@@ -6,6 +7,7 @@ import android.content.IntentFilter
import
android.os.Build
import
android.util.Log
import
androidx.annotation.RequiresApi
import
com.swiftcleaner.chovey.model.bean.Global.lockNotificationStatus
import
com.zxdemo.ZxApplication
import
com.zxdemo.notity.NotificationUtils
import
com.zxdemo.utils.SpUtils
...
...
@@ -52,44 +54,14 @@ class UnlockReceiver : BroadcastReceiver() {
Intent
.
ACTION_USER_PRESENT
->
{
isLock
=
false
// 执行解锁后的操作,比如启动服务、发送通知等
var
lockNotificationInterval
=
SpUtils
.
getInstance
().
getInt
(
"lockNotificationInterval"
)
val
lastTime
=
SpUtils
.
getInstance
()
.
getString
(
"NOTICE_UNLOCK_TIME"
,
""
)
var
current
=
LocalDateTime
.
now
()
val
lockNotificationStatus
=
SpUtils
.
getInstance
().
getInt
(
lockNotificationStatus
,
0
)
var
parsedDateTime
:
LocalDateTime
=
current
if
(
lastTime
!=
""
)
{
parsedDateTime
=
LocalDateTime
.
parse
(
lastTime
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
)
)
}
val
minutesBetween
=
ChronoUnit
.
MINUTES
.
between
(
parsedDateTime
,
current
)
Log
.
d
(
"TAG"
,
"onReceive:: $minutesBetween"
)
var
lockNotificationStatus
=
SpUtils
.
getInstance
().
getInt
(
"lockNotificationStatus"
,
0
)
var
lockNotificationCount
=
SpUtils
.
getInstance
().
getInt
(
"lockNotificationCount"
,
45
)
var
count
=
SpUtils
.
getInstance
().
getInt
(
"NOTICE_UNLOCK_COUNT"
,
0
)
//获取当前时间和上一次推送的时间
if
(
lockNotificationStatus
==
1
&&
mIsScreenOn
&&
!
isLock
&&
(
minutesBetween
.
toInt
()
==
0
||
minutesBetween
>
lockNotificationInterval
))
{
if
(
lockNotificationCount
==
0
||
count
<
lockNotificationCount
)
{
Log
.
d
(
"TAG"
,
"onReceive: 解锁推送"
)
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
"showNotification"
,
"receive_unlock"
)
SpUtils
.
getInstance
().
putString
(
"NOTICE_UNLOCK_COUNT"
,
current
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
))
)
}
if
(
lockNotificationStatus
==
1
&&
mIsScreenOn
&&
!
isLock
)
{
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
"showNotification"
,
"receive_unlock"
)
}
}
...
...
app/src/main/java/com/zxdemo/utils/InstallRefeerUtils.kt
View file @
351bbf91
package
com.zxdemo.utils
import
android.text.TextUtils
import
android.util.Log
import
com.android.installreferrer.api.InstallReferrerClient
import
com.android.installreferrer.api.InstallReferrerStateListener
import
com.swiftcleaner.chovey.model.bean.Global.timerDelay
import
com.swiftcleaner.chovey.model.bean.Global.timerInterval
import
com.swiftcleaner.chovey.model.bean.Global.timerStatus
import
com.zxdemo.ZxApplication
import
com.zxdemo.http.ZxHttp
import
org.json.JSONObject
...
...
@@ -120,16 +124,16 @@ object InstallRefeerUtils {
fun
getHttpConfig
()
{
ZxHttp
.
getHttpConfig
{
var
timerStatus
=
SpUtils
.
getInstance
().
getInt
(
"timerStatus"
,
0
)
var
timerStatus
=
SpUtils
.
getInstance
().
getInt
(
timerStatus
,
0
)
Log
.
d
(
"TAG"
,
"timerStatus: $timerStatus"
)
if
(
timerStatus
==
1
)
{
//打开定时器
var
timerDelay
=
SpUtils
.
getInstance
().
getInt
(
"timerDelay"
,
3
)
SpUtils
.
getInstance
().
getInt
(
timerDelay
,
3
)
var
timerInterval
=
SpUtils
.
getInstance
().
getInt
(
"timerInterval"
,
7
)
SpUtils
.
getInstance
().
getInt
(
timerInterval
,
7
)
GlobalTimer
.
scheduleTask
(
timerDelay
*
1000L
,
timerDelay
*
1000L
,
timerInterval
*
1000L
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment