Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser 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
Browser White
Commits
eea87918
Commit
eea87918
authored
Sep 05, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
6764a076
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
78 deletions
+7
-78
MessagingService.java
...main/java/com/base/browserwhite/fcm/MessagingService.java
+4
-5
NotificationPushUtil.kt
...in/java/com/base/browserwhite/fcm/NotificationPushUtil.kt
+0
-72
RecoveryTimerManager.java
.../java/com/base/browserwhite/fcm/RecoveryTimerManager.java
+3
-1
No files found.
app/src/main/java/com/base/browserwhite/fcm/MessagingService.java
View file @
eea87918
package
com
.
base
.
browserwhite
.
fcm
;
import
static
com
.
base
.
browserwhite
.
fcm
.
NotificationPushUtil
.
PUSH_WHERE_FCM
;
import
android.annotation.SuppressLint
;
import
androidx.annotation.NonNull
;
import
com.base.browserwhite.MyApplication
;
import
com.base.browserwhite.help.EventUtils
;
import
com.base.browserwhite.utils.AppPreferences
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
...
...
@@ -19,10 +22,6 @@ public class MessagingService extends FirebaseMessagingService {
@Override
public
void
onMessageReceived
(
@NonNull
RemoteMessage
remoteMessage
)
{
super
.
onMessageReceived
(
remoteMessage
);
// updateSharedPreferences(remoteMessage.getData());
// manageTimerBasedOnMessage(remoteMessage.getData());
// AdDisplayUtils.getInstance().saveSp();
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
null
,
null
,
false
);
sendLocalNotification
();
}
...
...
@@ -57,7 +56,7 @@ public class MessagingService extends FirebaseMessagingService {
// Consider implementing this method if local notifications are needed
private
void
sendLocalNotification
()
{
// NotificationUtil.INSTANCE.sendNotification(MyApplication.context, "MessagingService"
);
NotificationPushUtil
.
INSTANCE
.
sendNotificationWhere
(
MyApplication
.
context
,
null
,
PUSH_WHERE_FCM
);
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/fcm/NotificationPushUtil.kt
View file @
eea87918
...
...
@@ -58,9 +58,6 @@ object NotificationPushUtil {
EventUtils
.
event
(
"showNotification"
,
where
,
null
,
false
)
// AppPreferences.getInstance().putInt("notificationCount_${getCurrentDate()}", todayShowCount + 1)
beginPushTimber
(
this
)
beginNewsPushTimber
(
this
)
}
/**
...
...
@@ -113,75 +110,6 @@ object NotificationPushUtil {
}
private
fun
beginPushTimber
(
context
:
Context
)
{
val
open
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"open"
,
"0"
).
toIntOrNull
()
?:
0
if
(
open
==
1
)
{
val
num
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"num"
,
"0"
).
toIntOrNull
()
?:
0
val
delay
:
Long
=
AppPreferences
.
getInstance
().
getString
(
"delay"
,
"0"
).
toLongOrNull
()
?:
0L
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
handlerThread
?.
start
()
// 创建 Handler
handler
=
Handler
(
handlerThread
!!
.
looper
)
for
(
i
in
1
..
num
)
{
val
time
=
i
*
delay
handler
?.
postDelayed
(
Runnable
{
if
(
MyApplication
.
PAUSED_VALUE
!=
1
&&
ScreenStatusReceiver
.
isDeviceInteractive
()
&&
!
ScreenStatusReceiver
.
isSecureLockActive
()
)
{
context
.
sendNotificationWhere
(
null
,
PUSH_WHERE_TIMBER
)
}
if
(
MyApplication
.
PAUSED_VALUE
==
1
)
{
if
(
handler
!=
null
)
{
handler
?.
removeCallbacksAndMessages
(
null
)
}
return
@Runnable
}
},
time
)
}
}
}
private
var
newsHandlerThread
:
HandlerThread
?
=
null
private
var
newsHandler
:
Handler
?
=
null
private
var
newsRunnable
:
Runnable
?
=
null
private
fun
beginNewsPushTimber
(
context
:
Context
)
{
if
(
newsHandler
!=
null
||
newsHandlerThread
!=
null
||
newsRunnable
!=
null
)
return
newsHandlerThread
=
HandlerThread
(
"NotificationHandlerThreadNews"
)
newsHandlerThread
?.
start
()
newsHandler
=
Handler
(
newsHandlerThread
!!
.
looper
)
newsRunnable
=
Runnable
{
LogEx
.
logDebug
(
TAG
,
"beginNewsPushTimber"
)
context
.
sendNotificationWhere
(
ID_NEWS
,
PUSH_WHERE_TIMBER
)
newsRunnable
?.
let
{
newsHandler
?.
postDelayed
(
it
,
30
*
60
*
1000
)
}
}
// newsRunnable?.let { newsHandler?.postDelayed(it, 5 * 60 * 1000) }
newsRunnable
?.
let
{
newsHandler
?.
post
(
it
)
}
}
fun
stopNotificationHandlerNews
()
{
// 停止 HandlerThread
if
(
newsHandler
!=
null
)
{
newsHandler
?.
removeCallbacksAndMessages
(
null
)
}
if
(
newsHandlerThread
!=
null
)
{
newsHandlerThread
?.
quit
()
newsHandlerThread
=
null
}
newsHandler
=
null
}
//天气
private
fun
canPushWeather
(
where
:
String
):
Boolean
{
val
lastPushTime
=
AppPreferences
.
getInstance
().
getLong
(
"last_notification_time"
,
0
)
...
...
app/src/main/java/com/base/browserwhite/fcm/RecoveryTimerManager.java
View file @
eea87918
package
com
.
base
.
browserwhite
.
fcm
;
import
static
com
.
base
.
browserwhite
.
fcm
.
NotificationPushUtil
.
PUSH_WHERE_TIMBER
;
import
android.util.Log
;
import
com.base.browserwhite.MyApplication
;
...
...
@@ -35,7 +37,7 @@ public class RecoveryTimerManager {
if
(
ScreenStatusReceiver
.
isDeviceInteractive
()
&&
!
ScreenStatusReceiver
.
isSecureLockActive
()
&&
MyApplication
.
PAUSED_VALUE
!=
1
)
{
Log
.
d
(
"glc"
,
"Scheduled task conditions are met"
);
// NotificationUtil.INSTANCE.sendNotification(MyApplication.context, "scheduleTask"
);
NotificationPushUtil
.
INSTANCE
.
sendNotificationWhere
(
MyApplication
.
context
,
null
,
PUSH_WHERE_TIMBER
);
}
}
};
...
...
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