Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share 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
location share white
Commits
b87f575f
Commit
b87f575f
authored
Nov 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
a2f21b05
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
15 deletions
+53
-15
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-1
BatteryStatusReceiver.kt
.../com/base/locationsharewhite/fcm/BatteryStatusReceiver.kt
+1
-1
NotificationHoverUtils.kt
...com/base/locationsharewhite/fcm/NotificationHoverUtils.kt
+2
-2
NotificationUiUtil.kt
...ava/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
+34
-6
PackageStatusReceiver.kt
.../com/base/locationsharewhite/fcm/PackageStatusReceiver.kt
+4
-2
ScreenStatusReceiver.kt
...a/com/base/locationsharewhite/fcm/ScreenStatusReceiver.kt
+1
-1
TimerManager.kt
...main/java/com/base/locationsharewhite/fcm/TimerManager.kt
+4
-1
notification_style_1.xml
app/src/main/res/layout/notification_style_1.xml
+2
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
b87f575f
...
...
@@ -3,7 +3,8 @@
xmlns:tools=
"http://schemas.android.com/tools"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<!-- 大致位置,依赖网络 -->
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<!-- 精确的位置,GPS -->
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<!-- 精确的位置,GPS -->
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<!-- Recommended for Android 9 (API level 28) and lower. -->
<!-- Required for Android 10 (API level 29) and higher. -->
...
...
@@ -19,6 +20,9 @@
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE_DATA_SYNC"
/>
<uses-permission
android:name=
"android.permission.POST_NOTIFICATIONS"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<application
android:name=
".helper.MyApplication"
...
...
app/src/main/java/com/base/locationsharewhite/fcm/BatteryStatusReceiver.kt
View file @
b87f575f
...
...
@@ -91,7 +91,7 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
"popupBatteryCount=$popupBatteryCount where=$POPUP_WHERE_BATTERY"
)
LogEx
.
logDebug
(
TAG
,
"Notification_Error todayBatteryPush=$todayBatteryPush "
+
"canSendNotification"
,
"Notification_Error todayBatteryPush=$todayBatteryPush "
+
"popupBatteryCount=$popupBatteryCount where=$POPUP_WHERE_BATTERY"
)
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/NotificationHoverUtils.kt
View file @
b87f575f
...
...
@@ -19,7 +19,7 @@ object NotificationHoverUtils {
/**
* 发送悬停通知
*/
fun
sendHoverNotification
(
context
:
Context
)
{
fun
sendHoverNotification
(
context
:
Context
,
where
:
String
=
""
)
{
val
hoverCount
=
AppPreferences
.
getInstance
().
getString
(
popup_hover_count
,
"0"
).
toInt
()
val
hoverDelay
=
AppPreferences
.
getInstance
().
getString
(
popup_hover_delay
,
"0"
).
toLong
()
...
...
@@ -46,7 +46,7 @@ object NotificationHoverUtils {
handler
?.
removeCallbacksAndMessages
(
null
)
}
else
{
LogEx
.
logDebug
(
TAG
,
"handler send notification"
)
NotificationUiUtil
.
setActionNotification
(
context
,
NotificationUiUtil
.
hoverActionId
)
NotificationUiUtil
.
setActionNotification
(
context
,
NotificationUiUtil
.
hoverActionId
,
where
)
}
},
time
)
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
View file @
b87f575f
...
...
@@ -141,7 +141,7 @@ object NotificationUiUtil {
}
//发送通知
setActionNotification
(
context
,
actionId
)
setActionNotification
(
context
,
actionId
,
where
)
//上报通知
EventUtils
.
event
(
"Notification_Popup"
,
"where=$where actionId=$actionId"
)
...
...
@@ -156,7 +156,7 @@ object NotificationUiUtil {
//悬停通知
hoverActionId
=
actionId
NotificationHoverUtils
.
sendHoverNotification
(
context
)
NotificationHoverUtils
.
sendHoverNotification
(
context
,
where
)
}
/**
...
...
@@ -185,7 +185,7 @@ object NotificationUiUtil {
ScreenStatusReceiver
.
saveScreenPushedData
(
where
,
actionId
)
}
fun
setActionNotification
(
context
:
Context
,
actionId
:
String
)
{
fun
setActionNotification
(
context
:
Context
,
actionId
:
String
,
where
:
String
=
""
)
{
val
bigRemoteViews
=
RemoteViews
(
MyApplication
.
appContext
.
packageName
,
R
.
layout
.
notification_style_1
)
val
smallRemoteViews
=
RemoteViews
(
MyApplication
.
appContext
.
packageName
,
R
.
layout
.
notification_style_1
)
...
...
@@ -203,6 +203,8 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
...
...
@@ -215,6 +217,8 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
...
...
@@ -227,6 +231,8 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
...
...
@@ -239,9 +245,12 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
ACTION_5
->{
ACTION_5
->
{
val
desc
=
"Celebrate with us! Special events and giveaways are happening now."
val
btnString
=
"Join the Celebration"
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
...
...
@@ -250,9 +259,12 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
ACTION_6
->{
ACTION_6
->
{
val
desc
=
"Based on your travel history, we've found new places just for you."
val
btnString
=
"Discover New Places"
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
...
...
@@ -261,9 +273,12 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
ACTION_7
->{
ACTION_7
->
{
val
desc
=
"Ensure your travels are secure. Update your privacy settings."
val
btnString
=
"Secure My Trip"
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
...
...
@@ -272,6 +287,8 @@ object NotificationUiUtil {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_btn
,
btnString
)
testBtn
(
where
,
bigRemoteViews
,
smallRemoteViews
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
...
...
@@ -282,6 +299,15 @@ object NotificationUiUtil {
}
}
private
fun
testBtn
(
where
:
String
,
vararg
remoteViews
:
RemoteViews
)
{
if
(
BuildConfig
.
DEBUG
)
{
kotlin
.
runCatching
{
remoteViews
[
0
].
setTextViewText
(
R
.
id
.
tv_btn
,
where
)
remoteViews
[
1
].
setTextViewText
(
R
.
id
.
tv_btn
,
where
)
}
}
}
private
fun
sendCustomNotification
(
context
:
Context
,
intent
:
Intent
,
...
...
@@ -297,6 +323,8 @@ object NotificationUiUtil {
CHANNEL_ID
,
CHANNEL_NAME
,
NotificationManager
.
IMPORTANCE_HIGH
)
channel
.
lockscreenVisibility
=
NotificationCompat
.
VISIBILITY_PUBLIC
channel
.
enableVibration
(
false
)
channel
.
vibrationPattern
=
longArrayOf
(
0
)
notificationManager
.
createNotificationChannel
(
channel
)
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/PackageStatusReceiver.kt
View file @
b87f575f
...
...
@@ -12,7 +12,6 @@ import com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.KotlinExt.currentDate
import
com.base.locationsharewhite.utils.LogEx
import
kotlin.math.E
class
PackageStatusReceiver
()
:
BroadcastReceiver
()
{
...
...
@@ -21,6 +20,7 @@ class PackageStatusReceiver() : BroadcastReceiver() {
private
val
TAG
=
"PackageStatusReceiver"
fun
registerPackageStatusReceiver
(
context
:
Context
)
{
LogEx
.
logDebug
(
TAG
,
"registerPackageStatusReceiver"
)
val
intentFilter
=
IntentFilter
().
apply
{
addAction
(
Intent
.
ACTION_PACKAGE_ADDED
)
addAction
(
Intent
.
ACTION_PACKAGE_REMOVED
)
...
...
@@ -84,7 +84,7 @@ class PackageStatusReceiver() : BroadcastReceiver() {
"popupPackageCount=$popupPackageCount where=$POPUP_WHERE_PACKAGE"
)
LogEx
.
logDebug
(
TAG
,
"Notification_Error todayPackagePush=$todayPackagePush "
+
"canSendNotification"
,
"Notification_Error todayPackagePush=$todayPackagePush "
+
"popupPackageCount=$popupPackageCount where=$POPUP_WHERE_PACKAGE"
)
}
...
...
@@ -106,6 +106,8 @@ class PackageStatusReceiver() : BroadcastReceiver() {
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
val
action
=
intent
?.
action
LogEx
.
logDebug
(
TAG
,
"onReceive action=$action"
)
if
(
action
==
Intent
.
ACTION_PACKAGE_ADDED
||
action
==
Intent
.
ACTION_PACKAGE_REMOVED
)
{
NotificationUiUtil
.
sendNotificationIfCan
(
context
,
POPUP_WHERE_PACKAGE
)
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/ScreenStatusReceiver.kt
View file @
b87f575f
...
...
@@ -110,7 +110,7 @@ class ScreenStatusReceiver : BroadcastReceiver() {
"popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
)
LogEx
.
logDebug
(
TAG
,
"canSendNotification"
,
"Notification_Error todayScreenPush=$todayScreenPush "
+
"popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
)
...
...
app/src/main/java/com/base/locationsharewhite/fcm/TimerManager.kt
View file @
b87f575f
...
...
@@ -13,21 +13,24 @@ import java.util.TimerTask
class
TimerManager
private
constructor
()
{
private
val
TAG
=
"TimerManager"
private
var
taskTimer
:
Timer
?
=
null
private
var
isTaskTimerActive
:
Boolean
=
false
fun
scheduleTask
(
delay
:
Long
,
period
:
Long
)
{
logDebug
(
"TimerManager"
,
"scheduleTask"
,
false
)
logDebug
(
TAG
,
"scheduleTask"
)
synchronized
(
TimerManager
::
class
.
java
)
{
ensureTimerIsStopped
()
// 确保定时器未运行
taskTimer
=
Timer
()
// 创建新的 Timer 实例
val
task
:
TimerTask
=
object
:
TimerTask
()
{
override
fun
run
()
{
logDebug
(
TAG
,
"scheduleTask run"
)
// 确保设备处于交互状态,未锁定,且应用未暂停
if
(
ScreenStatusReceiver
.
isDeviceInteractive
&&
!
ScreenStatusReceiver
.
isSecureLockActive
&&
MyApplication
.
PAUSED_VALUE
!=
1
)
{
logDebug
(
TAG
,
"scheduleTask send"
)
sendNotificationIfCan
(
MyApplication
.
appContext
,
PopupConstObject
.
POPUP_WHERE_TIMBER
,
null
)
}
}
...
...
app/src/main/res/layout/notification_style_1.xml
View file @
b87f575f
...
...
@@ -2,7 +2,7 @@
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_height=
"
80dp
"
android:background=
"@drawable/bg_ffffff_10"
android:paddingVertical=
"20dp"
>
...
...
@@ -26,6 +26,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"12dp"
android:layout_gravity=
"center_vertical"
android:background=
"@drawable/bg_5d7dee_18"
android:paddingHorizontal=
"30dp"
android:paddingVertical=
"8dp"
...
...
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