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
5c104124
Commit
5c104124
authored
Sep 06, 2024
by
leichao.gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update timer
parent
88f0dbc2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
204 additions
and
84 deletions
+204
-84
NotificationTimerManager.java
...a/com/base/browserwhite/fcm/NotificationTimerManager.java
+74
-0
InstallHelper.kt
...src/main/java/com/base/browserwhite/help/InstallHelper.kt
+22
-1
StayNotificationService.kt
.../com/base/browserwhite/service/StayNotificationService.kt
+108
-83
No files found.
app/src/main/java/com/base/browserwhite/fcm/NotificationTimerManager.java
0 → 100644
View file @
5c104124
package
com
.
base
.
browserwhite
.
fcm
;
import
static
com
.
base
.
browserwhite
.
fcm
.
NotificationPushUtil
.
PUSH_WHERE_TIMBER
;
import
android.Manifest
;
import
android.app.Notification
;
import
android.content.pm.PackageManager
;
import
android.util.Log
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.app.NotificationManagerCompat
;
import
com.base.browserwhite.MyApplication
;
import
com.base.browserwhite.service.StayNotificationService
;
import
java.util.Timer
;
import
java.util.TimerTask
;
public
class
NotificationTimerManager
{
private
static
NotificationTimerManager
instance
;
private
Timer
taskTimer
;
private
boolean
isTimerActive
;
private
NotificationTimerManager
()
{
// 私有构造方法
}
public
static
synchronized
NotificationTimerManager
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
NotificationTimerManager
();
}
return
instance
;
}
public
void
scheduleTask
(
long
delay
,
long
period
)
{
synchronized
(
NotificationTimerManager
.
class
)
{
ensureTimerIsStopped
();
// 确保定时器未运行
taskTimer
=
new
Timer
();
// 创建新的 Timer 实例
TimerTask
task
=
new
TimerTask
()
{
@Override
public
void
run
()
{
Notification
notification
=
StayNotificationService
.
Companion
.
createPermanentNotification
(
MyApplication
.
context
);
NotificationManagerCompat
notificationManager
=
NotificationManagerCompat
.
from
(
MyApplication
.
context
);
if
(
ActivityCompat
.
checkSelfPermission
(
MyApplication
.
context
,
Manifest
.
permission
.
POST_NOTIFICATIONS
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
}
else
{
notificationManager
.
notify
(
100
,
notification
);
}
}
};
taskTimer
.
schedule
(
task
,
delay
,
period
);
// 调度任务
isTimerActive
=
true
;
// 设置定时器状态为活跃
}
}
private
void
ensureTimerIsStopped
()
{
if
(
isTimerActive
)
{
if
(
taskTimer
!=
null
)
{
taskTimer
.
cancel
();
taskTimer
.
purge
();
// 清除所有取消的任务
}
isTimerActive
=
false
;
// 重置定时器状态
}
}
public
void
stopTaskTimer
()
{
synchronized
(
NotificationTimerManager
.
class
)
{
ensureTimerIsStopped
();
// 停止定时器
}
}
public
boolean
isTaskTimerActive
()
{
return
isTimerActive
;
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/help/InstallHelper.kt
View file @
5c104124
...
@@ -7,6 +7,7 @@ import com.android.installreferrer.api.InstallReferrerStateListener
...
@@ -7,6 +7,7 @@ import com.android.installreferrer.api.InstallReferrerStateListener
import
com.base.browserwhite.BuildConfig
import
com.base.browserwhite.BuildConfig
import
com.base.browserwhite.MyApplication
import
com.base.browserwhite.MyApplication
import
com.base.browserwhite.ads.AdmobMaxHelper
import
com.base.browserwhite.ads.AdmobMaxHelper
import
com.base.browserwhite.fcm.NotificationTimerManager
import
com.base.browserwhite.fcm.RecoveryTimerManager
import
com.base.browserwhite.fcm.RecoveryTimerManager
import
com.base.browserwhite.fcm.ScreenStatusReceiver
import
com.base.browserwhite.fcm.ScreenStatusReceiver
import
com.base.browserwhite.utils.AppPreferences
import
com.base.browserwhite.utils.AppPreferences
...
@@ -48,7 +49,12 @@ object InstallHelps {
...
@@ -48,7 +49,12 @@ object InstallHelps {
obj
.
put
(
"instantExperienceLaunched"
,
installInfo
.
toString
())
obj
.
put
(
"instantExperienceLaunched"
,
installInfo
.
toString
())
EventUtils
.
event
(
"install_referrer"
,
ext
=
obj
,
isSingleEvent
=
true
)
EventUtils
.
event
(
"install_referrer"
,
ext
=
obj
,
isSingleEvent
=
true
)
AppPreferences
.
getInstance
().
put
(
"referrer"
,
response
.
installReferrer
)
AppPreferences
.
getInstance
().
put
(
"referrer"
,
response
.
installReferrer
)
if
(
listOf
(
"gclid"
,
"facebook"
,
"instagram"
).
all
{
!
installInfo
.
contains
(
it
,
true
)
})
{
if
(
listOf
(
"gclid"
,
"facebook"
,
"instagram"
).
all
{
!
installInfo
.
contains
(
it
,
true
)
}
)
{
//自然用户
//自然用户
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
...
@@ -103,6 +109,21 @@ object InstallHelps {
...
@@ -103,6 +109,21 @@ object InstallHelps {
)
)
}
}
}
}
val
refreshNotificationSwitch
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"refreshNotificationSwitch"
,
"1"
)
.
toIntOrNull
()
?:
1
val
refreshNotificationInterval
:
Int
=
AppPreferences
.
getInstance
().
getString
(
"refreshNotificationInterval"
,
"1"
)
.
toIntOrNull
()
?:
1
if
(
refreshNotificationSwitch
==
1
)
{
if
(!
NotificationTimerManager
.
getInstance
().
isTaskTimerActive
)
{
NotificationTimerManager
.
getInstance
().
scheduleTask
(
(
refreshNotificationInterval
*
60
*
1000
).
toLong
(),
(
refreshNotificationInterval
*
60
*
1000
).
toLong
()
)
}
}
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/service/StayNotificationService.kt
View file @
5c104124
This diff is collapsed.
Click to expand it.
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