Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
D
Data Recovery White
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
Data Recovery White
Commits
dcdf0978
Commit
dcdf0978
authored
Jul 16, 2024
by
leichao.gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加推送限制
parent
d80c22fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
10 deletions
+38
-10
MyApplication.kt
app/src/main/java/com/base/datarecovery/MyApplication.kt
+1
-1
AdDisplayUtils.java
...c/main/java/com/base/datarecovery/ads/AdDisplayUtils.java
+2
-2
NotificationUtil.kt
...c/main/java/com/base/datarecovery/fcm/NotificationUtil.kt
+35
-7
No files found.
app/src/main/java/com/base/datarecovery/MyApplication.kt
View file @
dcdf0978
...
...
@@ -55,6 +55,7 @@ class MyApplication : BaseApplication() {
FCMManager
.
initFirebase
(
this
)
FCMManager
.
subscribeToTopic
(
topic
)
LogEx
.
logDebug
(
TAG
,
"topic=${topic}"
)
InstallHelps
.
init
()
NewComUtils
.
requestCfg
{
ScreenStatusReceiver
.
setupScreenStatusListener
(
this
)
val
timerStatus
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"timerS"
,
"1"
).
toIntOrNull
()
?:
1
...
...
@@ -72,7 +73,6 @@ class MyApplication : BaseApplication() {
}
}
if
(
ifAgreePrivacy
)
{
InstallHelps
.
init
()
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
}
MainScope
().
launch
(
Dispatchers
.
Main
)
{
...
...
app/src/main/java/com/base/datarecovery/ads/AdDisplayUtils.java
View file @
dcdf0978
...
...
@@ -93,7 +93,7 @@ public class AdDisplayUtils {
}
adRequestFailCount
++;
saveAdRequestFailCount
();
Log
.
d
(
"glc"
,
"广告请求失败:"
+
adRequestFailCount
);
Log
.
d
(
"glc"
,
"广告请求失败:"
+
adRequestFailCount
);
}
...
...
@@ -106,7 +106,7 @@ public class AdDisplayUtils {
saveAdClickCount
();
}
p
rivate
String
getCurrentDate
()
{
p
ublic
String
getCurrentDate
()
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
());
Date
currentDate
=
Calendar
.
getInstance
().
getTime
();
return
dateFormat
.
format
(
currentDate
);
...
...
app/src/main/java/com/base/datarecovery/fcm/NotificationUtil.kt
View file @
dcdf0978
...
...
@@ -15,6 +15,7 @@ import androidx.core.graphics.drawable.IconCompat
import
com.base.datarecovery.MyApplication
import
com.base.datarecovery.R
import
com.base.datarecovery.activity.SplashActivity
import
com.base.datarecovery.ads.AdDisplayUtils
import
com.base.datarecovery.bean.ConstObject.ID_JUNK_CLEAN_PUSH
import
com.base.datarecovery.bean.ConstObject.ID_PRIVACY_SPACE
import
com.base.datarecovery.bean.ConstObject.ID_RECOVERY_DOCUMENTS
...
...
@@ -101,13 +102,17 @@ object NotificationUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btn
)
//取消按钮
bigRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
fl_cancel
,
cancelNotificationPendingIntent
(
context
,
actionId
))
bigRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
fl_cancel
,
cancelNotificationPendingIntent
(
context
,
actionId
)
)
//跳转
val
intent
=
Intent
(
context
,
SplashActivity
::
class
.
java
)
intent
.
putExtra
(
"actionId"
,
actionId
)
val
btnRequestCode
=
Random
().
nextInt
(
1000
)
val
btnPendingIntent
=
PendingIntent
.
getActivity
(
context
,
btnRequestCode
,
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
val
btnPendingIntent
=
PendingIntent
.
getActivity
(
context
,
btnRequestCode
,
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
bigRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
fl_btn
,
btnPendingIntent
)
smallRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
tv_btn
,
btnPendingIntent
)
...
...
@@ -121,7 +126,12 @@ object NotificationUtil {
cancelIntent
.
setAction
(
CloseNotificationReceiver
.
Action
)
cancelIntent
.
putExtra
(
CloseNotificationReceiver
.
NotificationId
,
actionId
)
val
broadcastRequestCode
=
Random
().
nextInt
(
1000
)
return
PendingIntent
.
getBroadcast
(
context
,
broadcastRequestCode
,
cancelIntent
,
PendingIntent
.
FLAG_IMMUTABLE
)
return
PendingIntent
.
getBroadcast
(
context
,
broadcastRequestCode
,
cancelIntent
,
PendingIntent
.
FLAG_IMMUTABLE
)
}
...
...
@@ -133,7 +143,8 @@ object NotificationUtil {
smallRemoteViews
:
RemoteViews
)
{
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
//创建channel
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
...
...
@@ -163,7 +174,8 @@ object NotificationUtil {
.
setContentText
(
"notification"
)
val
requestCode
=
kotlin
.
random
.
Random
.
nextInt
(
1000
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
requestCode
,
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
requestCode
,
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
builder
.
setContentIntent
(
pendingIntent
)
.
setDeleteIntent
(
cancelNotificationPendingIntent
(
context
,
actionId
))
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
...
...
@@ -186,6 +198,7 @@ object NotificationUtil {
}
else
{
notificationManager
.
notify
(
actionId
,
builder
.
build
())
}
incrementNotification
()
AppPreferences
.
getInstance
().
put
(
"last_notification_time"
,
System
.
currentTimeMillis
())
}
...
...
@@ -193,7 +206,20 @@ object NotificationUtil {
private
var
handlerThread
:
HandlerThread
?
=
null
private
var
handler
:
Handler
?
=
null
private
fun
incrementNotification
()
{
val
key
=
"showNotificationCount_"
+
AdDisplayUtils
.
getInstance
().
getCurrentDate
()
var
s
=
AppPreferences
.
getInstance
().
getInt
(
key
,
0
)
s
++
AppPreferences
.
getInstance
().
put
(
key
,
s
)
}
fun
sendNotification
(
context
:
Context
)
{
val
currentNum
=
AppPreferences
.
getInstance
().
getInt
(
"showNotificationCount_"
+
AdDisplayUtils
.
getInstance
().
getCurrentDate
(),
0
)
val
maxNum
=
AppPreferences
.
getInstance
().
getInt
(
"maxShowNotificationCount"
,
100
)
if
(
currentNum
>=
maxNum
)
{
return
}
val
actionId
:
Int
=
getNextNotificationId
()
EventUtils
.
event
(
"showNotification"
,
null
,
null
,
false
)
...
...
@@ -201,7 +227,8 @@ object NotificationUtil {
return
}
val
interval
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"notificationInterval"
,
"60"
).
toIntOrNull
()
?:
60
val
interval
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"notificationInterval"
,
"60"
).
toIntOrNull
()
?:
60
val
lastTime
:
Long
=
AppPreferences
.
getInstance
().
getLong
(
"last_notification_time"
,
0
)
val
nowTime
=
System
.
currentTimeMillis
()
val
x
=
nowTime
-
lastTime
...
...
@@ -215,7 +242,8 @@ object NotificationUtil {
if
(
open
==
1
)
{
val
num
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"num"
,
"0"
).
toIntOrNull
()
?:
0
val
delay
:
Long
=
AppPreferences
.
getInstance
().
getString
(
"delay"
,
"0"
).
toLongOrNull
()
?:
0L
val
delay
:
Long
=
AppPreferences
.
getInstance
().
getString
(
"delay"
,
"0"
).
toLongOrNull
()
?:
0L
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
handlerThread
!!
.
start
()
...
...
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