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
ecb1cfcd
Commit
ecb1cfcd
authored
Nov 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
85a1d00d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
BatteryStatusReceiver.kt
.../com/base/locationsharewhite/fcm/BatteryStatusReceiver.kt
+9
-2
ScreenStatusReceiver.kt
...a/com/base/locationsharewhite/fcm/ScreenStatusReceiver.kt
+1
-1
No files found.
app/src/main/java/com/base/locationsharewhite/fcm/BatteryStatusReceiver.kt
View file @
ecb1cfcd
...
...
@@ -12,6 +12,7 @@ import com.base.locationsharewhite.fcm.PopupConstObject.popup_battery_interval
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.KotlinExt.currentDate
import
kotlin.math.absoluteValue
/**
*电量监听
...
...
@@ -99,6 +100,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
}
private
var
currentBatteryPercentage
=
0f
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
val
action
=
intent
?.
action
if
(
action
==
Intent
.
ACTION_BATTERY_CHANGED
)
{
...
...
@@ -106,11 +109,15 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
val
batteryScale
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_SCALE
,
-
1
)
val
batteryPercentage
=
(
batteryLevel
/
batteryScale
.
toFloat
())
*
100
if
(
batteryPercentage
<
21
)
{
//避免频繁触发
val
changeValue
=
currentBatteryPercentage
-
batteryPercentage
if
(
batteryPercentage
<
21
&&
changeValue
.
absoluteValue
>=
1f
)
{
//推送次数没有达到限制并且展示的最小时间间隔大于配置时间(分钟)
NotificationUiUtil
.
sendNotificationIfCan
(
context
,
where
=
POPUP_WHERE_BATTERY
)
NotificationUiUtil
.
sendNotificationIfCan
(
context
,
POPUP_WHERE_BATTERY
,
null
)
}
currentBatteryPercentage
=
batteryPercentage
}
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/ScreenStatusReceiver.kt
View file @
ecb1cfcd
...
...
@@ -31,7 +31,7 @@ class ScreenStatusReceiver : BroadcastReceiver() {
if
(
isDeviceInteractive
&&
!
isSecureLockActive
)
{
val
secureSetting
=
AppPreferences
.
getInstance
().
getString
(
lockS
,
"1"
).
toInt
()
if
(
secureSetting
==
1
)
{
sendNotificationIfCan
(
context
,
P
opupConstObject
.
P
OPUP_WHERE_LOCK
,
null
)
sendNotificationIfCan
(
context
,
POPUP_WHERE_LOCK
,
null
)
}
}
}
...
...
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