Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
A
appzxhy
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
appzxhy
Commits
f90d6b51
Commit
f90d6b51
authored
Jun 09, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[新增]电池触发通知
parent
0ce876e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
PopupConfigBean.kt
...main/java/com/base/appzxhy/bean/config/PopupConfigBean.kt
+3
-0
BatteryReceiver.kt
...n/java/com/base/appzxhy/ui/batteryinfo/BatteryReceiver.kt
+36
-0
RecycleBinDetailActivity.kt
...om/base/appzxhy/ui/recyclebin/RecycleBinDetailActivity.kt
+3
-0
No files found.
app/src/main/java/com/base/appzxhy/bean/config/PopupConfigBean.kt
View file @
f90d6b51
...
@@ -22,6 +22,9 @@ class PopupConfigBean(
...
@@ -22,6 +22,9 @@ class PopupConfigBean(
val
alarmS
:
Boolean
=
true
,
//是否闹钟触发推送
val
alarmS
:
Boolean
=
true
,
//是否闹钟触发推送
val
workS
:
Boolean
=
true
,
//workManager触发推送
val
workS
:
Boolean
=
true
,
//workManager触发推送
val
batteryS
:
Boolean
=
true
,
//电池触发通知开关
var
batteryInterval
:
Int
=
180
,
//电池推送间隔 秒(推送间隔一般大于总间隔才有意义)
val
notifyForegroundInterval
:
Long
=
30000L
//常驻通知栏刷新通知间隔
val
notifyForegroundInterval
:
Long
=
30000L
//常驻通知栏刷新通知间隔
)
{
)
{
companion
object
{
companion
object
{
...
...
app/src/main/java/com/base/appzxhy/ui/batteryinfo/BatteryReceiver.kt
View file @
f90d6b51
...
@@ -6,6 +6,23 @@ import android.content.Intent
...
@@ -6,6 +6,23 @@ import android.content.Intent
import
android.content.IntentFilter
import
android.content.IntentFilter
import
android.os.BatteryManager
import
android.os.BatteryManager
import
android.os.Build
import
android.os.Build
import
com.base.appzxhy.bean.FeatureBean.Companion.BATTERY_INFO
import
com.base.appzxhy.bean.config.PopupConfigBean
import
com.base.appzxhy.bean.push.NotificationSendBean
import
com.base.appzxhy.bean.push.NotificationSendBean.Companion.POPUP_WHERE_BATTERY
import
com.base.appzxhy.business.push.notification.MyNotificationManager
import
com.base.appzxhy.utils.AppPreferences
//电池上次推送时间
var
batteryLastPushTime
=
0L
get
()
{
return
AppPreferences
.
getInstance
().
getLong
(
"batteryLastPushTime"
,
field
)
}
set
(
value
)
{
field
=
value
AppPreferences
.
getInstance
().
put
(
"batteryLastPushTime"
,
value
,
true
)
}
class
BatteryReceiver
(
class
BatteryReceiver
(
private
val
block
:
(()
->
Unit
?)?
=
null
private
val
block
:
(()
->
Unit
?)?
=
null
...
@@ -71,6 +88,25 @@ class BatteryReceiver(
...
@@ -71,6 +88,25 @@ class BatteryReceiver(
private
fun
uiHandle
(
context
:
Context
)
{
private
fun
uiHandle
(
context
:
Context
)
{
val
batteryPct
=
level
*
100
/
scale
.
toFloat
()
if
(
batteryPct
.
toInt
()
>
21
&&
!
isCharging
)
return
if
(!
PopupConfigBean
.
popupConfigBean
.
batteryS
)
return
val
canSend
=
((
System
.
currentTimeMillis
()
-
batteryLastPushTime
)
/
1000
)
>
PopupConfigBean
.
popupConfigBean
.
batteryInterval
MyNotificationManager
.
submitSendBean
(
NotificationSendBean
(
context
,
where
=
POPUP_WHERE_BATTERY
,
canSend
=
{
canSend
},
sendSuccess
=
{
batteryLastPushTime
=
System
.
currentTimeMillis
()
},
).
apply
{
actionId
=
BATTERY_INFO
}
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/ui/recyclebin/RecycleBinDetailActivity.kt
View file @
f90d6b51
...
@@ -49,12 +49,14 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>(A
...
@@ -49,12 +49,14 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>(A
binding
.
ivBack
.
setOnClickListener
{
binding
.
ivBack
.
setOnClickListener
{
binding
.
v
.
visibility
=
View
.
VISIBLE
binding
.
v
.
visibility
=
View
.
VISIBLE
onBackPressedDispatcher
.
onBackPressed
()
onBackPressedDispatcher
.
onBackPressed
()
finish
()
}
}
binding
.
ivDelete
.
setOnClickListener
{
binding
.
ivDelete
.
setOnClickListener
{
lifecycleScope
.
launch
{
lifecycleScope
.
launch
{
recycleBinFile
.
deleteIfExists
()
recycleBinFile
.
deleteIfExists
()
}
}
onBackPressedDispatcher
.
onBackPressed
()
onBackPressedDispatcher
.
onBackPressed
()
finish
()
}
}
binding
.
tvRestore
.
setOnClickListener
{
binding
.
tvRestore
.
setOnClickListener
{
lifecycleScope
.
launch
{
lifecycleScope
.
launch
{
...
@@ -71,6 +73,7 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>(A
...
@@ -71,6 +73,7 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>(A
putExtra
(
"Number"
,
1
)
putExtra
(
"Number"
,
1
)
putExtra
(
"ScanType"
,
recycleBinFile
.
getType
())
putExtra
(
"ScanType"
,
recycleBinFile
.
getType
())
})
})
finish
()
}
}
})
})
...
...
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