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() {
...
@@ -55,6 +55,7 @@ class MyApplication : BaseApplication() {
FCMManager
.
initFirebase
(
this
)
FCMManager
.
initFirebase
(
this
)
FCMManager
.
subscribeToTopic
(
topic
)
FCMManager
.
subscribeToTopic
(
topic
)
LogEx
.
logDebug
(
TAG
,
"topic=${topic}"
)
LogEx
.
logDebug
(
TAG
,
"topic=${topic}"
)
InstallHelps
.
init
()
NewComUtils
.
requestCfg
{
NewComUtils
.
requestCfg
{
ScreenStatusReceiver
.
setupScreenStatusListener
(
this
)
ScreenStatusReceiver
.
setupScreenStatusListener
(
this
)
val
timerStatus
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"timerS"
,
"1"
).
toIntOrNull
()
?:
1
val
timerStatus
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"timerS"
,
"1"
).
toIntOrNull
()
?:
1
...
@@ -72,7 +73,6 @@ class MyApplication : BaseApplication() {
...
@@ -72,7 +73,6 @@ class MyApplication : BaseApplication() {
}
}
}
}
if
(
ifAgreePrivacy
)
{
if
(
ifAgreePrivacy
)
{
InstallHelps
.
init
()
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
}
}
MainScope
().
launch
(
Dispatchers
.
Main
)
{
MainScope
().
launch
(
Dispatchers
.
Main
)
{
...
...
app/src/main/java/com/base/datarecovery/ads/AdDisplayUtils.java
View file @
dcdf0978
...
@@ -93,7 +93,7 @@ public class AdDisplayUtils {
...
@@ -93,7 +93,7 @@ public class AdDisplayUtils {
}
}
adRequestFailCount
++;
adRequestFailCount
++;
saveAdRequestFailCount
();
saveAdRequestFailCount
();
Log
.
d
(
"glc"
,
"广告请求失败:"
+
adRequestFailCount
);
Log
.
d
(
"glc"
,
"广告请求失败:"
+
adRequestFailCount
);
}
}
...
@@ -106,7 +106,7 @@ public class AdDisplayUtils {
...
@@ -106,7 +106,7 @@ public class AdDisplayUtils {
saveAdClickCount
();
saveAdClickCount
();
}
}
p
rivate
String
getCurrentDate
()
{
p
ublic
String
getCurrentDate
()
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
());
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
());
Date
currentDate
=
Calendar
.
getInstance
().
getTime
();
Date
currentDate
=
Calendar
.
getInstance
().
getTime
();
return
dateFormat
.
format
(
currentDate
);
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
...
@@ -15,6 +15,7 @@ import androidx.core.graphics.drawable.IconCompat
import
com.base.datarecovery.MyApplication
import
com.base.datarecovery.MyApplication
import
com.base.datarecovery.R
import
com.base.datarecovery.R
import
com.base.datarecovery.activity.SplashActivity
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_JUNK_CLEAN_PUSH
import
com.base.datarecovery.bean.ConstObject.ID_PRIVACY_SPACE
import
com.base.datarecovery.bean.ConstObject.ID_PRIVACY_SPACE
import
com.base.datarecovery.bean.ConstObject.ID_RECOVERY_DOCUMENTS
import
com.base.datarecovery.bean.ConstObject.ID_RECOVERY_DOCUMENTS
...
@@ -101,13 +102,17 @@ object NotificationUtil {
...
@@ -101,13 +102,17 @@ object NotificationUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btn
)
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
)
val
intent
=
Intent
(
context
,
SplashActivity
::
class
.
java
)
intent
.
putExtra
(
"actionId"
,
actionId
)
intent
.
putExtra
(
"actionId"
,
actionId
)
val
btnRequestCode
=
Random
().
nextInt
(
1000
)
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
)
bigRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
fl_btn
,
btnPendingIntent
)
smallRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
tv_btn
,
btnPendingIntent
)
smallRemoteViews
.
setOnClickPendingIntent
(
R
.
id
.
tv_btn
,
btnPendingIntent
)
...
@@ -121,7 +126,12 @@ object NotificationUtil {
...
@@ -121,7 +126,12 @@ object NotificationUtil {
cancelIntent
.
setAction
(
CloseNotificationReceiver
.
Action
)
cancelIntent
.
setAction
(
CloseNotificationReceiver
.
Action
)
cancelIntent
.
putExtra
(
CloseNotificationReceiver
.
NotificationId
,
actionId
)
cancelIntent
.
putExtra
(
CloseNotificationReceiver
.
NotificationId
,
actionId
)
val
broadcastRequestCode
=
Random
().
nextInt
(
1000
)
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 {
...
@@ -133,7 +143,8 @@ object NotificationUtil {
smallRemoteViews
:
RemoteViews
smallRemoteViews
:
RemoteViews
)
{
)
{
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
//创建channel
//创建channel
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
...
@@ -163,7 +174,8 @@ object NotificationUtil {
...
@@ -163,7 +174,8 @@ object NotificationUtil {
.
setContentText
(
"notification"
)
.
setContentText
(
"notification"
)
val
requestCode
=
kotlin
.
random
.
Random
.
nextInt
(
1000
)
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
)
builder
.
setContentIntent
(
pendingIntent
)
.
setDeleteIntent
(
cancelNotificationPendingIntent
(
context
,
actionId
))
.
setDeleteIntent
(
cancelNotificationPendingIntent
(
context
,
actionId
))
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
...
@@ -186,6 +198,7 @@ object NotificationUtil {
...
@@ -186,6 +198,7 @@ object NotificationUtil {
}
else
{
}
else
{
notificationManager
.
notify
(
actionId
,
builder
.
build
())
notificationManager
.
notify
(
actionId
,
builder
.
build
())
}
}
incrementNotification
()
AppPreferences
.
getInstance
().
put
(
"last_notification_time"
,
System
.
currentTimeMillis
())
AppPreferences
.
getInstance
().
put
(
"last_notification_time"
,
System
.
currentTimeMillis
())
}
}
...
@@ -193,7 +206,20 @@ object NotificationUtil {
...
@@ -193,7 +206,20 @@ object NotificationUtil {
private
var
handlerThread
:
HandlerThread
?
=
null
private
var
handlerThread
:
HandlerThread
?
=
null
private
var
handler
:
Handler
?
=
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
)
{
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
()
val
actionId
:
Int
=
getNextNotificationId
()
EventUtils
.
event
(
"showNotification"
,
null
,
null
,
false
)
EventUtils
.
event
(
"showNotification"
,
null
,
null
,
false
)
...
@@ -201,7 +227,8 @@ object NotificationUtil {
...
@@ -201,7 +227,8 @@ object NotificationUtil {
return
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
lastTime
:
Long
=
AppPreferences
.
getInstance
().
getLong
(
"last_notification_time"
,
0
)
val
nowTime
=
System
.
currentTimeMillis
()
val
nowTime
=
System
.
currentTimeMillis
()
val
x
=
nowTime
-
lastTime
val
x
=
nowTime
-
lastTime
...
@@ -215,7 +242,8 @@ object NotificationUtil {
...
@@ -215,7 +242,8 @@ object NotificationUtil {
if
(
open
==
1
)
{
if
(
open
==
1
)
{
val
num
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"num"
,
"0"
).
toIntOrNull
()
?:
0
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
=
HandlerThread
(
"NotificationHandlerThread"
)
handlerThread
!!
.
start
()
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