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
db732926
Commit
db732926
authored
Dec 20, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
# Conflicts: # app/src/main/res/layout/notification_common_small.xml
parents
a0f24d80
351bbf91
Pipeline
#1383
canceled with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
56 deletions
+44
-56
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
+11
-7
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 @
db732926
...
...
@@ -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 @
db732926
...
...
@@ -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 @
db732926
package
com.zxdemo.notity
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
...
...
@@ -15,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
...
...
@@ -131,8 +135,8 @@ object NotificationUtils {
fun
sendNotification
(
context
:
Context
,
action
:
String
,
value
:
String
)
{
var
actionId
=
nextNotificationId
val
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
ce_expand
)
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notif
y_stay_big
)
val
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
fication_common
)
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notif
ication_common_small
)
when
(
actionId
)
{
ID_CLEAN_JUNK
->
{
}
...
...
@@ -161,13 +165,13 @@ object NotificationUtils {
var
intent
=
Intent
(
context
,
MainActivity
::
class
.
java
)
intent
.
putExtra
(
"actionId"
,
actionId
)
val
btnPendingIntent
=
PendingIntent
.
getActivity
(
context
,
btnRequestCode
,
intent
,
flag
)
// bigRemoteViews.setOnClickPendingIntent(R.id.btn_notice
, btnPendingIntent)
// smallRemoteViews.setOnClickPendingIntent(R.id.notice
_btn, btnPendingIntent)
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 @
db732926
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 @
db732926
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