Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
SuperEasyClean
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
songjianyu
SuperEasyClean
Commits
522647a8
Commit
522647a8
authored
Jun 06, 2025
by
wanglei
Committed by
songjianyu
Jun 09, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[新增]通知逻辑优化,启动页处理通知的跳转
parent
49bc8ed4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
47 deletions
+146
-47
PopupConfigBean.kt
...main/java/com/base/appzxhy/bean/config/PopupConfigBean.kt
+1
-1
MyNotificationManager.kt
...pzxhy/business/push/notification/MyNotificationManager.kt
+30
-25
NotificationUiUtil.kt
.../appzxhy/business/push/notification/NotificationUiUtil.kt
+53
-14
SplashActivity.kt
...rc/main/java/com/base/appzxhy/ui/splash/SplashActivity.kt
+62
-7
No files found.
app/src/main/java/com/base/appzxhy/bean/config/PopupConfigBean.kt
View file @
522647a8
...
...
@@ -4,7 +4,7 @@ class PopupConfigBean(
var
popupForegroundCanPush
:
Boolean
=
true
,
//前台是否可以推送
var
popupStatus
:
Boolean
=
true
,
//推送总开关
var
popupCount
:
Int
=
2
00
,
//推送总次数
var
popupCount
:
Int
=
5
00
,
//推送总次数
var
isDifferNotificationId
:
Boolean
=
true
,
//推送使用不同的通知ID
var
popupLimitRangeTime
:
List
<
Int
>
=
listOf
(),
//推送限制时间
...
...
app/src/main/java/com/base/appzxhy/business/push/notification/MyNotificationManager.kt
View file @
522647a8
...
...
@@ -44,6 +44,25 @@ object MyNotificationManager {
if
(
BuildConfig
.
DEBUG
)
{
if
(!
testWhere
.
contains
(
bean
.
where
))
return
}
LogEx
.
logDebug
(
TAG
,
"sendNotificationIfCan where=${bean.where}"
)
if
(!
isUnLimit
)
{
//应用在前台不推
if
(
MyApplication
.
PAUSED_VALUE
==
1
&&
!
popupConfigBean
.
popupForegroundCanPush
)
{
LogEx
.
logDebug
(
TAG
,
"app Foreground"
)
return
}
//总的限制条件
if
(!
canSendNotification
(
bean
.
context
))
{
return
}
//其他条推送是否可以推送
if
(!
bean
.
canSend
.
invoke
())
{
return
}
}
if
(
bean
.
actionId
.
isEmpty
())
{
val
actionId
=
getNextActionId
()
bean
.
actionId
=
actionId
...
...
@@ -72,22 +91,8 @@ object MyNotificationManager {
if
(
bean
!=
null
)
{
LogEx
.
logDebug
(
TAG
,
"sendNotificationIfCan where=${bean.where}"
)
// EventUtils.event("Notification_Popup_Start", "where=${bean.where}")
if
(!
isUnLimit
)
{
//应用在前台不推
if
(
MyApplication
.
PAUSED_VALUE
==
1
&&
!
popupConfigBean
.
popupForegroundCanPush
)
{
LogEx
.
logDebug
(
TAG
,
"app Foreground"
)
continue
}
//总的限制条件
if
(!
canSendNotification
(
bean
.
context
))
continue
//其他条推送是否可以推送
if
(!
bean
.
canSend
.
invoke
())
continue
}
//提前准备数据
when
(
bean
.
actionId
)
{
...
...
@@ -97,7 +102,7 @@ object MyNotificationManager {
NotificationUiUtil
.
setNotification
(
bean
)
}.
await
()
LogEx
.
logDebug
(
TAG
,
"sendNotificationCan where=${bean.where}"
)
LogEx
.
logDebug
(
TAG
,
"sendNotificationCan where=${bean.where}
actionId=${bean.actionId}
"
)
//上报通知
EventUtils
.
event
(
"Notification_Popup_${bean.where}"
,
"actionId=${bean.actionId}"
)
//当天次数加一
...
...
@@ -145,8 +150,8 @@ object MyNotificationManager {
//是否开启推送
if
(!
popupConfigBean
.
popupStatus
)
{
EventUtils
.
event
(
"Notification_
Error
"
,
"status=${popupConfigBean.popupStatus}"
)
LogEx
.
logDebug
(
"canSendNotification"
,
"status
"
)
EventUtils
.
event
(
"Notification_
Limit
"
,
"status=${popupConfigBean.popupStatus}"
)
LogEx
.
logDebug
(
TAG
,
"Notification_Limit status=${popupConfigBean.popupStatus}
"
)
if
(
BuildConfig
.
DEBUG
)
{
MainScope
().
launch
(
Dispatchers
.
Main
)
{
context
.
toast
(
"配置关闭推送"
)
...
...
@@ -156,10 +161,10 @@ object MyNotificationManager {
}
//当天推送次数
val
c
ount
=
popupConfigBean
.
popupCount
if
(
dayPopupCount
>
c
ount
)
{
LogEx
.
logDebug
(
"canSendNotification"
,
"c
ount"
)
EventUtils
.
event
(
"Notification_
Error"
,
"dayPopupCount=$dayPopupCount count=$count
"
)
val
popupC
ount
=
popupConfigBean
.
popupCount
if
(
dayPopupCount
>
popupC
ount
)
{
LogEx
.
logDebug
(
TAG
,
"Notification_Limit dayPopupCount=$dayPopupCount popupCount=$popupC
ount"
)
EventUtils
.
event
(
"Notification_
Limit"
,
"dayPopupCount=$dayPopupCount popupCount=$popupCount
"
)
return
false
}
...
...
@@ -168,8 +173,8 @@ object MyNotificationManager {
val
currentHour
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
val
limitRangeTime
=
popupConfigBean
.
popupLimitRangeTime
if
(
limitRangeTime
.
contains
(
currentHour
))
{
LogEx
.
logDebug
(
"canSendNotification"
,
"
currentHour=$currentHour popupLimitRangeTime=$limitRangeTime"
)
EventUtils
.
event
(
"Notification_
Error
"
,
"currentHour=$currentHour popupLimitRangeTime=$limitRangeTime"
)
LogEx
.
logDebug
(
TAG
,
"Notification_Limit
currentHour=$currentHour popupLimitRangeTime=$limitRangeTime"
)
EventUtils
.
event
(
"Notification_
Limit
"
,
"currentHour=$currentHour popupLimitRangeTime=$limitRangeTime"
)
return
false
}
...
...
@@ -177,8 +182,8 @@ object MyNotificationManager {
val
interval
=
popupConfigBean
.
popupInterval
val
passedTime
=
System
.
currentTimeMillis
()
-
lastPopupTime
if
(
passedTime
<
interval
*
60
*
1000L
)
{
// EventUtils.event("Notification_
Error
", "interval=$interval passedTime=$passedTime")
LogEx
.
logDebug
(
"canSendNotification"
,
"
interval=$interval passedTime=$passedTime"
)
// EventUtils.event("Notification_
Limit
", "interval=$interval passedTime=$passedTime")
LogEx
.
logDebug
(
TAG
,
"Notification_Limit
interval=$interval passedTime=$passedTime"
)
return
false
}
return
true
...
...
app/src/main/java/com/base/appzxhy/business/push/notification/NotificationUiUtil.kt
View file @
522647a8
...
...
@@ -10,10 +10,12 @@ import android.os.Build
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.graphics.drawable.IconCompat
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.R
import
com.base.appzxhy.bean.FeatureBean.Companion.BATTERY_INFO
import
com.base.appzxhy.bean.FeatureBean.Companion.JUNK_CLEAN
import
com.base.appzxhy.bean.FeatureBean.Companion.LARGE_FILE_CLEAN
import
com.base.appzxhy.bean.FeatureBean.Companion.PHOTO_COMPRESSION
import
com.base.appzxhy.bean.FeatureBean.Companion.SCREENSHOT_CLEAN
import
com.base.appzxhy.bean.FeatureBean.Companion.SIMILAR_PHOTOS
import
com.base.appzxhy.bean.push.NotificationSendBean
...
...
@@ -34,73 +36,110 @@ object NotificationUiUtil {
*/
fun
setNotification
(
sendBean
:
NotificationSendBean
):
NotificationSendBean
{
val
context
=
sendBean
.
context
//弹不同的通知用不同的NotificationId
if
(
PopupConfigBean
.
popupConfigBean
.
isDifferNotificationId
)
{
sendBean
.
notificationId
=
Random
.
nextInt
(
1000
,
2000
)
}
val
intent
=
Intent
(
sendBean
.
context
,
SplashActivity
::
class
.
java
)
// val bean = sendBean.valueMap["bean"] as NotificationInfoBean
intent
.
putExtra
(
"actionId"
,
sendBean
.
actionId
)
// intent.putExtra("linkUrl", bean.linkUrl)
intent
.
putExtra
(
"notificationId"
,
sendBean
.
notificationId
)
sendBean
.
intent
=
intent
val
testNotificationId
=
if
(
BuildConfig
.
DEBUG
)
"${sendBean.notificationId}_${sendBean.actionId}_"
else
""
var
debugAction
:
(
remoteViews
:
RemoteViews
)
->
Unit
=
{
remoteViews
->
if
(
BuildConfig
.
DEBUG
)
{
remoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
sendBean
.
where
)
}
}
when
(
sendBean
.
actionId
)
{
JUNK_CLEAN
->
{
val
text
=
"Clean up the junk files on your phone now!"
val
text
=
testNotificationId
+
"Clean up the junk files on your phone now!"
sendBean
.
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
debugAction
.
invoke
(
this
)
}
sendBean
.
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_large
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_clean
)
debugAction
.
invoke
(
this
)
}
}
BATTERY_INFO
->
{
val
text
=
"Check your phone battery consumption recently!"
val
text
=
testNotificationId
+
"Check your phone battery consumption recently!"
sendBean
.
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
debugAction
.
invoke
(
this
)
}
sendBean
.
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_large
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_battery
)
debugAction
.
invoke
(
this
)
}
}
LARGE_FILE_CLEAN
->
{
val
text
=
"Clear out large files to free up your storage space!"
val
text
=
testNotificationId
+
"Clear out large files to free up your storage space!"
sendBean
.
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
debugAction
.
invoke
(
this
)
}
sendBean
.
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_large
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_large_file_cleanner
)
debugAction
.
invoke
(
this
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_files
)
}
}
SIMILAR_PHOTOS
->
{
val
text
=
"Clean Up Similar Photos – Save Space!"
val
text
=
testNotificationId
+
"Clean Up Similar Photos – Save Space!"
sendBean
.
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
debugAction
.
invoke
(
this
)
}
sendBean
.
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_large
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_screenshots
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_duplicate_photos
)
debugAction
.
invoke
(
this
)
}
}
SCREENSHOT_CLEAN
->
{
val
text
=
"Free up space by clearing screenshot clutter!"
val
text
=
testNotificationId
+
"Free up space by clearing screenshot clutter!"
sendBean
.
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
debugAction
.
invoke
(
this
)
}
sendBean
.
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_large
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_screenshot_cleaner
)
debugAction
.
invoke
(
this
)
}
}
}
if
(
PopupConfigBean
.
popupConfigBean
.
isDifferNotificationId
)
{
sendBean
.
notificationId
=
Random
.
nextInt
(
1000
,
2000
)
PHOTO_COMPRESSION
->
{
val
text
=
testNotificationId
+
"Free up your phone storage space by compressing photos."
sendBean
.
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
debugAction
.
invoke
(
this
)
}
sendBean
.
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_large
).
apply
{
setTextViewText
(
R
.
id
.
tv1
,
text
)
setImageViewResource
(
R
.
id
.
ivIcon
,
R
.
drawable
.
icon_compression
)
debugAction
.
invoke
(
this
)
}
}
else
->
{
}
}
val
intent
=
Intent
(
sendBean
.
context
,
SplashActivity
::
class
.
java
)
// val bean = sendBean.valueMap["bean"] as NotificationInfoBean
intent
.
putExtra
(
"actionId"
,
sendBean
.
actionId
)
// intent.putExtra("linkUrl", bean.linkUrl)
intent
.
putExtra
(
"notificationId"
,
sendBean
.
notificationId
)
sendBean
.
intent
=
intent
sendCustomNotification
(
sendBean
)
return
sendBean
}
...
...
app/src/main/java/com/base/appzxhy/ui/splash/SplashActivity.kt
View file @
522647a8
...
...
@@ -2,6 +2,7 @@ package com.base.appzxhy.ui.splash
import
android.Manifest
import
android.annotation.SuppressLint
import
android.app.ComponentCaller
import
android.content.Intent
import
android.graphics.Color
import
android.net.Uri
...
...
@@ -22,14 +23,24 @@ import com.base.appzxhy.MyApplication
import
com.base.appzxhy.R
import
com.base.appzxhy.SpConstObject.isGuided
import
com.base.appzxhy.base.BaseActivity
import
com.base.appzxhy.base.jumpAction
import
com.base.appzxhy.bean.FeatureBean.Companion.BATTERY_INFO
import
com.base.appzxhy.bean.FeatureBean.Companion.JUNK_CLEAN
import
com.base.appzxhy.business.ads.AdsMgr
import
com.base.appzxhy.business.ads.AdsShowCallBack
import
com.base.appzxhy.business.helper.EventUtils
import
com.base.appzxhy.business.service.StayJobService.Companion.startStayJobService
import
com.base.appzxhy.databinding.ActivitySplashBinding
import
com.base.appzxhy.ui.batteryinfo.BatteryInfoActivity
import
com.base.appzxhy.ui.clean.JunkCleanActivity
import
com.base.appzxhy.ui.dialog.StoragePermissionDialog
import
com.base.appzxhy.ui.dialog.permissionStorageJump
import
com.base.appzxhy.ui.guide.GuideCleanActivity
import
com.base.appzxhy.ui.main.MainActivity
import
com.base.appzxhy.utils.PermissionUtils.checkStorePermission
import
com.base.appzxhy.utils.PermissionUtils.requestStoragePermission
import
com.base.appzxhy.utils.UmpUtils
import
kotlinx.coroutines.MainScope
import
java.util.concurrent.atomic.AtomicBoolean
@SuppressLint
(
"CustomSplashScreen"
)
...
...
@@ -49,6 +60,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(ActivitySplashBinding
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
initUMP
()
super
.
onCreate
(
savedInstanceState
)
actionId
=
intent
?.
extras
?.
getString
(
"actionId"
)
?:
""
}
override
fun
onResumeOneShoot
()
{
...
...
@@ -150,17 +162,60 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(ActivitySplashBinding
if
(
jumped
.
get
())
return
jumped
.
set
(
true
)
if
(!
isGuided
)
{
isGuided
=
true
goToAc
(
GuideCleanActivity
::
class
.
java
)
}
else
{
goToAc
(
MainActivity
::
class
.
java
)
}
when
{
!
isGuided
->
{
isGuided
=
true
goToAc
(
GuideCleanActivity
::
class
.
java
)
finish
(
)
}
finish
()
actionId
.
isNotEmpty
()
->
{
actionIdJump
()
}
else
->
{
goToAc
(
MainActivity
::
class
.
java
)
finish
()
}
}
intent
.
extras
?.
clear
()
}
fun
actionIdJump
()
{
when
(
actionId
)
{
BATTERY_INFO
->
{
jumpAction
(
actionId
)
finish
()
}
else
->
{
if
(
checkStorePermission
())
{
jumpAction
(
actionId
)
finish
()
}
else
{
val
dialog
=
StoragePermissionDialog
(
this
)
dialog
.
action
=
{
requestStoragePermission
(
launcher
)
{
if
(
it
)
{
jumpAction
(
actionId
)
finish
()
}
else
{
goToAc
(
MainActivity
::
class
.
java
)
finish
()
}
}
}
dialog
.
showDialog
()
}
}
}
}
var
actionId
=
""
override
fun
onNewIntent
(
intent
:
Intent
?)
{
super
.
onNewIntent
(
intent
)
actionId
=
intent
?.
extras
?.
getString
(
"actionId"
)
?:
""
}
}
\ No newline at end of file
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