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
zhouzhi
appzxhy
Commits
1691f044
Commit
1691f044
authored
Jan 07, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...更新scanqr来优化的代码
parent
49c23a61
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
467 additions
and
175 deletions
+467
-175
MyApplication.kt
app/src/main/java/com/base/appzxhy/MyApplication.kt
+31
-18
NativeParentView.kt
app/src/main/java/com/base/appzxhy/ads/NativeParentView.kt
+23
-1
AdInsertMgr.kt
app/src/main/java/com/base/appzxhy/ads/admob/AdInsertMgr.kt
+2
-0
NotificationSendBean.kt
...c/main/java/com/base/appzxhy/bean/NotificationSendBean.kt
+1
-1
FcmReceiver.kt
app/src/main/java/com/base/appzxhy/fcm/FcmReceiver.kt
+5
-0
MessagingService.kt
app/src/main/java/com/base/appzxhy/fcm/MessagingService.kt
+5
-0
AlarmReceiver.kt
...src/main/java/com/base/appzxhy/fcm/alarm/AlarmReceiver.kt
+3
-11
MyNotificationManager.kt
...om/base/appzxhy/fcm/notification/MyNotificationManager.kt
+26
-2
NotificationHoverUtils.kt
...m/base/appzxhy/fcm/notification/NotificationHoverUtils.kt
+3
-2
NotificationUiUtil.kt
...a/com/base/appzxhy/fcm/notification/NotificationUiUtil.kt
+83
-0
BatteryStatusReceiver.kt
...va/com/base/appzxhy/fcm/receiver/BatteryStatusReceiver.kt
+25
-8
FileJobReceiver.kt
...ain/java/com/base/appzxhy/fcm/receiver/FileJobReceiver.kt
+5
-1
PackageStatusReceiver.kt
...va/com/base/appzxhy/fcm/receiver/PackageStatusReceiver.kt
+12
-7
ScreenStatusReceiver.kt
...ava/com/base/appzxhy/fcm/receiver/ScreenStatusReceiver.kt
+10
-6
TimerManager.kt
app/src/main/java/com/base/appzxhy/fcm/timer/TimerManager.kt
+6
-1
StayJobService.kt
app/src/main/java/com/base/appzxhy/service/StayJobService.kt
+24
-11
StayNotification.kt
...rc/main/java/com/base/appzxhy/service/StayNotification.kt
+1
-45
IntentUtils.kt
app/src/main/java/com/base/appzxhy/utils/IntentUtils.kt
+133
-0
LanguageUtils.kt
app/src/main/java/com/base/appzxhy/utils/LanguageUtils.kt
+0
-61
PermissionUtils.kt
app/src/main/java/com/base/appzxhy/utils/PermissionUtils.kt
+21
-0
log_svg.xml
app/src/main/res/drawable/log_svg.xml
+42
-0
attrs.xml
app/src/main/res/values/attrs.xml
+6
-0
No files found.
app/src/main/java/com/base/appzxhy/MyApplication.kt
View file @
1691f044
...
@@ -14,10 +14,12 @@ import com.base.appzxhy.bean.config.AdConfigBean
...
@@ -14,10 +14,12 @@ import com.base.appzxhy.bean.config.AdConfigBean
import
com.base.appzxhy.bean.config.ConfigBean
import
com.base.appzxhy.bean.config.ConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean
import
com.base.appzxhy.fcm.FCMManager
import
com.base.appzxhy.fcm.FCMManager
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.fcm.timer.TimerManager.Companion.changeTimer
import
com.base.appzxhy.fcm.timer.TimerManager.Companion.changeTimer
import
com.base.appzxhy.fcm.receiver.BatteryStatusReceiver
import
com.base.appzxhy.fcm.receiver.BatteryStatusReceiver
import
com.base.appzxhy.fcm.receiver.PackageStatusReceiver
import
com.base.appzxhy.fcm.receiver.PackageStatusReceiver
import
com.base.appzxhy.fcm.receiver.ScreenStatusReceiver
import
com.base.appzxhy.fcm.receiver.ScreenStatusReceiver
import
com.base.appzxhy.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.InstallHelps
import
com.base.appzxhy.helper.InstallHelps
import
com.base.appzxhy.helper.NewComUtils
import
com.base.appzxhy.helper.NewComUtils
...
@@ -26,6 +28,7 @@ import com.base.appzxhy.ui.start.StartActivity
...
@@ -26,6 +28,7 @@ import com.base.appzxhy.ui.start.StartActivity
import
com.base.appzxhy.utils.ActivityManagerUtils
import
com.base.appzxhy.utils.ActivityManagerUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.LogEx
import
com.base.appzxhy.utils.LogEx
import
com.base.appzxhy.utils.SolarEngineUtils.initSolarEngine
import
com.base.appzxhy.utils.SolarEngineUtils.solarkey
import
com.base.appzxhy.utils.SolarEngineUtils.solarkey
import
com.facebook.FacebookSdk
import
com.facebook.FacebookSdk
import
com.google.android.gms.ads.identifier.AdvertisingIdClient
import
com.google.android.gms.ads.identifier.AdvertisingIdClient
...
@@ -111,6 +114,11 @@ class MyApplication : Application() {
...
@@ -111,6 +114,11 @@ class MyApplication : Application() {
}
}
private
fun
initApp
()
{
private
fun
initApp
()
{
kotlin
.
runCatching
{
startJob
()
}
//初始化广告相关业务
//初始化广告相关业务
AdsMgr
.
init
(
appContext
)
AdsMgr
.
init
(
appContext
)
...
@@ -121,7 +129,6 @@ class MyApplication : Application() {
...
@@ -121,7 +129,6 @@ class MyApplication : Application() {
FCMManager
.
initFirebase
(
this
)
FCMManager
.
initFirebase
(
this
)
FCMManager
.
subscribeToTopic
(
topic
)
FCMManager
.
subscribeToTopic
(
topic
)
initAppConfig
()
initAppConfig
()
SolarEngineManager
.
getInstance
().
preInit
(
this
,
solarkey
)
SolarEngineManager
.
getInstance
().
preInit
(
this
,
solarkey
)
...
@@ -132,13 +139,19 @@ class MyApplication : Application() {
...
@@ -132,13 +139,19 @@ class MyApplication : Application() {
PackageStatusReceiver
.
registerPackageStatusReceiver
(
this
)
PackageStatusReceiver
.
registerPackageStatusReceiver
(
this
)
BatteryStatusReceiver
.
registerBatteryStatusReceiver
(
this
)
BatteryStatusReceiver
.
registerBatteryStatusReceiver
(
this
)
//workManager
schedulePeriodicWork
(
appContext
)
startAlarm
(
appContext
,
24
)
startAlarm
(
appContext
,
24
)
startAlarm
(
appContext
,
48
)
startAlarm
(
appContext
,
48
)
startAlarm
(
appContext
,
72
)
startAlarm
(
appContext
,
72
)
kotlin
.
runCatching
{
//开启通知队列
startJob
()
MyNotificationManager
.
startNotificationQueue
()
}
appContext
.
initSolarEngine
(
true
)
}
}
private
fun
initAppConfig
()
{
private
fun
initAppConfig
()
{
...
@@ -238,26 +251,26 @@ class MyApplication : Application() {
...
@@ -238,26 +251,26 @@ class MyApplication : Application() {
private
fun
initConfig
(
config
:
String
)
{
private
fun
initConfig
(
config
:
String
)
{
// kotlin.runCatching {
// kotlin.runCatching {
val
configBean
=
Gson
().
fromJson
(
config
,
ConfigBean
::
class
.
java
)
val
configBean
=
Gson
().
fromJson
(
config
,
ConfigBean
::
class
.
java
)
val
jsonObject
=
JSONObject
()
val
jsonObject
=
JSONObject
()
jsonObject
.
put
(
"ut"
,
configBean
.
ut
)
jsonObject
.
put
(
"ut"
,
configBean
.
ut
)
EventUtils
.
event
(
"user_type"
,
ext
=
jsonObject
)
EventUtils
.
event
(
"user_type"
,
ext
=
jsonObject
)
//配置
//配置
ConfigBean
.
configBean
=
configBean
ConfigBean
.
configBean
=
configBean
//广告
//广告
AdConfigBean
.
adsConfigBean
=
configBean
.
adConfigBean
AdConfigBean
.
adsConfigBean
=
configBean
.
adConfigBean
LogEx
.
logDebug
(
"initConfig"
,
"adsConfigBean=${configBean.adConfigBean.functionInShowAd}"
)
LogEx
.
logDebug
(
"initConfig"
,
"adsConfigBean=${configBean.adConfigBean.functionInShowAd}"
)
//通知配置
//通知配置
PopupConfigBean
.
popupConfigBean
=
configBean
.
popupConfigBean
PopupConfigBean
.
popupConfigBean
=
configBean
.
popupConfigBean
LogEx
.
logDebug
(
"initConfig"
,
"popupConfigBean=${configBean.popupConfigBean.popupCount}"
)
LogEx
.
logDebug
(
"initConfig"
,
"popupConfigBean=${configBean.popupConfigBean.popupCount}"
)
//启动定时器
//启动定时器
changeTimer
()
changeTimer
()
// }
// }
}
}
...
...
app/src/main/java/com/base/appzxhy/ads/NativeParentView.kt
View file @
1691f044
...
@@ -21,6 +21,26 @@ import com.google.android.gms.ads.nativead.NativeAdView
...
@@ -21,6 +21,26 @@ import com.google.android.gms.ads.nativead.NativeAdView
@SuppressLint
(
"ViewConstructor"
)
@SuppressLint
(
"ViewConstructor"
)
class
NativeParentView
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
)
:
class
NativeParentView
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
)
:
FrameLayout
(
context
,
attrs
)
{
FrameLayout
(
context
,
attrs
)
{
private
val
TAG
=
"NativeParentView"
private
var
removeAll
=
true
init
{
// 获取XML属性
val
a
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
NativeParentView
,
0
,
0
)
// 从XML中读取属性值
// 例如,如果你的XML中有自定义属性 `app:customAttribute="value"`
removeAll
=
a
.
getBoolean
(
R
.
styleable
.
NativeParentView_removeAll
,
true
)
// 回收TypedArray
a
.
recycle
()
}
fun
setNativeAd
(
fun
setNativeAd
(
nativeAd
:
NativeAd
,
nativeAd
:
NativeAd
,
...
@@ -58,7 +78,9 @@ class NativeParentView(context: Context, attrs: AttributeSet? = null) :
...
@@ -58,7 +78,9 @@ class NativeParentView(context: Context, attrs: AttributeSet? = null) :
}
}
adView
.
setNativeAd
(
nativeAd
)
adView
.
setNativeAd
(
nativeAd
)
setBackgroundResource
(
0
)
setBackgroundResource
(
0
)
removeAllViews
()
if
(
removeAll
)
{
removeAllViews
()
}
addView
(
adView
)
addView
(
adView
)
}
}
...
...
app/src/main/java/com/base/appzxhy/ads/admob/AdInsertMgr.kt
View file @
1691f044
...
@@ -44,6 +44,8 @@ class AdInsertMgr {
...
@@ -44,6 +44,8 @@ class AdInsertMgr {
if
(
adState
.
showingAd
)
{
if
(
adState
.
showingAd
)
{
showCallBack
?.
failed
(
1
)
showCallBack
?.
failed
(
1
)
adEvent
.
adShowError
(
"showingAd"
)
adState
.
showingAd
=
false
return
return
}
}
if
(
showCallBack
!=
null
)
{
if
(
showCallBack
!=
null
)
{
...
...
app/src/main/java/com/base/appzxhy/bean/NotificationSendBean.kt
View file @
1691f044
...
@@ -20,7 +20,6 @@ class NotificationSendBean(
...
@@ -20,7 +20,6 @@ class NotificationSendBean(
companion
object
{
companion
object
{
const
val
POPUP_WHERE_TIMBER
=
"Timer"
const
val
POPUP_WHERE_LOCK
=
"Lock"
const
val
POPUP_WHERE_LOCK
=
"Lock"
const
val
POPUP_WHERE_FCM
=
"fcm"
const
val
POPUP_WHERE_FCM
=
"fcm"
const
val
POPUP_WHERE_ALARM
=
"Alarm"
const
val
POPUP_WHERE_ALARM
=
"Alarm"
...
@@ -28,6 +27,7 @@ class NotificationSendBean(
...
@@ -28,6 +27,7 @@ class NotificationSendBean(
const
val
POPUP_WHERE_PACKAGE
=
"package"
const
val
POPUP_WHERE_PACKAGE
=
"package"
const
val
POPUP_WHERE_WORK_MANAGER
=
"workManager"
const
val
POPUP_WHERE_WORK_MANAGER
=
"workManager"
const
val
POPUP_WHERE_FILE_JOB
=
"FileJob"
const
val
POPUP_WHERE_FILE_JOB
=
"FileJob"
const
val
POPUP_WHERE_TIMER
=
"Timer"
const
val
ACTION_ID_STAY_SCAN
=
"action_id_scan_1"
const
val
ACTION_ID_STAY_SCAN
=
"action_id_scan_1"
...
...
app/src/main/java/com/base/appzxhy/fcm/FcmReceiver.kt
View file @
1691f044
...
@@ -3,6 +3,9 @@ package com.base.appzxhy.fcm
...
@@ -3,6 +3,9 @@ package com.base.appzxhy.fcm
import
android.content.BroadcastReceiver
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_FCM
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.helper.EventUtils.event
import
com.base.appzxhy.helper.EventUtils.event
class
FcmReceiver
:
BroadcastReceiver
()
{
class
FcmReceiver
:
BroadcastReceiver
()
{
...
@@ -11,5 +14,7 @@ class FcmReceiver : BroadcastReceiver() {
...
@@ -11,5 +14,7 @@ class FcmReceiver : BroadcastReceiver() {
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
event
(
"FCM_Received"
,
"FcmReceiver"
,
null
)
event
(
"FCM_Received"
,
"FcmReceiver"
,
null
)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_FCM
,
canSend
=
{
true
},
sendSuccess
=
{})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
app/src/main/java/com/base/appzxhy/fcm/MessagingService.kt
View file @
1691f044
package
com.base.appzxhy.fcm
package
com.base.appzxhy.fcm
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_FCM
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.helper.EventUtils.event
import
com.base.appzxhy.helper.EventUtils.event
import
com.google.firebase.messaging.FirebaseMessagingService
import
com.google.firebase.messaging.FirebaseMessagingService
import
com.google.firebase.messaging.RemoteMessage
import
com.google.firebase.messaging.RemoteMessage
...
@@ -12,5 +15,7 @@ class MessagingService : FirebaseMessagingService() {
...
@@ -12,5 +15,7 @@ class MessagingService : FirebaseMessagingService() {
super
.
onMessageReceived
(
remoteMessage
)
super
.
onMessageReceived
(
remoteMessage
)
val
data
=
JSONObject
(
remoteMessage
.
data
.
toString
())
val
data
=
JSONObject
(
remoteMessage
.
data
.
toString
())
event
(
"FCM_Received"
,
"MessagingService"
,
data
)
event
(
"FCM_Received"
,
"MessagingService"
,
data
)
val
sendBean
=
NotificationSendBean
(
this
,
POPUP_WHERE_FCM
,
canSend
=
{
true
},
sendSuccess
=
{})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/fcm/alarm/AlarmReceiver.kt
View file @
1691f044
...
@@ -9,7 +9,6 @@ import com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_ALARM
...
@@ -9,7 +9,6 @@ import com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_ALARM
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
com.base.appzxhy.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.LogEx
import
com.base.appzxhy.utils.LogEx
...
@@ -23,16 +22,9 @@ class AlarmReceiver : BroadcastReceiver() {
...
@@ -23,16 +22,9 @@ class AlarmReceiver : BroadcastReceiver() {
@SuppressLint
(
"UnsafeProtectedBroadcastReceiver"
)
@SuppressLint
(
"UnsafeProtectedBroadcastReceiver"
)
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
LogEx
.
logDebug
(
TAG
,
"AlarmJobReceiver onReceive"
)
LogEx
.
logDebug
(
TAG
,
"AlarmJobReceiver onReceive"
)
val
lastAlarmTime
=
AppPreferences
.
getInstance
().
getLong
(
"lastAlarmTime"
,
0L
)
EventUtils
.
event
(
"alarm_push"
)
val
currentTime
=
System
.
currentTimeMillis
()
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_ALARM
,
canSend
=
{
true
},
sendSuccess
=
{})
if
(
lastAlarmTime
==
0L
||
currentTime
-
lastAlarmTime
>=
1000
*
30
*
60
)
{
MyNotificationManager
.
submitSendBean
(
sendBean
)
EventUtils
.
event
(
"alarm_push"
)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_ALARM
,
canSend
=
{
true
},
sendSuccess
=
{})
MyNotificationManager
.
submitSendBean
(
sendBean
)
AppPreferences
.
getInstance
().
put
(
"lastAlarmTime"
,
System
.
currentTimeMillis
())
}
schedulePeriodicWork
(
context
)
schedulePeriodicWork
(
context
)
return
return
}
}
...
...
app/src/main/java/com/base/appzxhy/fcm/notification/MyNotificationManager.kt
View file @
1691f044
...
@@ -3,7 +3,8 @@ package com.base.appzxhy.fcm.notification
...
@@ -3,7 +3,8 @@ package com.base.appzxhy.fcm.notification
import
android.content.Context
import
android.content.Context
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_TIMBER
import
com.base.appzxhy.bean.NotificationSendBean.Companion.ACTION_ID_SCAN
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_TIMER
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.AppPreferences
...
@@ -29,6 +30,14 @@ object MyNotificationManager {
...
@@ -29,6 +30,14 @@ object MyNotificationManager {
private
var
sendBeanBlockingQueue
=
ArrayBlockingQueue
<
NotificationSendBean
>(
10
)
private
var
sendBeanBlockingQueue
=
ArrayBlockingQueue
<
NotificationSendBean
>(
10
)
fun
submitSendBean
(
bean
:
NotificationSendBean
)
{
fun
submitSendBean
(
bean
:
NotificationSendBean
)
{
//测试哪些位置触发
if
(
BuildConfig
.
DEBUG
)
{
if
(!
testWhere
.
contains
(
bean
.
where
))
return
}
if
(
bean
.
actionId
.
isEmpty
())
{
val
actionId
=
getNextActionId
()
bean
.
actionId
=
actionId
}
try
{
try
{
sendBeanBlockingQueue
.
put
(
bean
)
sendBeanBlockingQueue
.
put
(
bean
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
...
@@ -157,6 +166,21 @@ object MyNotificationManager {
...
@@ -157,6 +166,21 @@ object MyNotificationManager {
* 值测某些类型
* 值测某些类型
*/
*/
private
var
testWhere
=
listOf
(
private
var
testWhere
=
listOf
(
POPUP_WHERE_TIMBER
POPUP_WHERE_TIMER
)
private
val
looper_actionId
=
listOf
(
ACTION_ID_SCAN
,
)
)
private
var
actionIdList
=
arrayListOf
<
String
>()
private
fun
getNextActionId
():
String
{
if
(
actionIdList
.
isEmpty
())
{
actionIdList
.
addAll
(
looper_actionId
)
}
val
next
=
actionIdList
[
0
]
actionIdList
.
removeAt
(
0
)
if
(
BuildConfig
.
DEBUG
)
{
return
ACTION_ID_SCAN
}
return
next
}
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/fcm/notification/NotificationHoverUtils.kt
View file @
1691f044
...
@@ -18,12 +18,13 @@ object NotificationHoverUtils {
...
@@ -18,12 +18,13 @@ object NotificationHoverUtils {
/**
/**
* 发送悬停通知
* 发送悬停通知
*/
*/
fun
sendHoverNotification
(
sendBean
:
NotificationSendBean
)
{
fun
sendHoverNotification
(
sendBean
:
NotificationSendBean
)
{
val
hoverStatus
=
popupConfigBean
.
popupHoverStatus
val
hoverStatus
=
popupConfigBean
.
popupHoverStatus
val
hoverCount
=
popupConfigBean
.
popupHoverCount
val
hoverCount
=
popupConfigBean
.
popupHoverCount
val
hoverDelay
=
popupConfigBean
.
popupHoverDelay
.
toLong
()
val
hoverDelay
=
popupConfigBean
.
popupHoverDelay
.
toLong
()
if
(!
hoverStatus
)
return
if
(!
hoverStatus
)
return
stopNotificationHandler
()
if
(
handlerThread
==
null
)
{
if
(
handlerThread
==
null
)
{
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
...
@@ -50,7 +51,7 @@ object NotificationHoverUtils {
...
@@ -50,7 +51,7 @@ object NotificationHoverUtils {
}
}
}
}
fun
stopNotificationHandler
()
{
private
fun
stopNotificationHandler
()
{
// 停止 HandlerThread
// 停止 HandlerThread
if
(
handler
!=
null
)
{
if
(
handler
!=
null
)
{
handler
?.
removeCallbacksAndMessages
(
null
)
handler
?.
removeCallbacksAndMessages
(
null
)
...
...
app/src/main/java/com/base/appzxhy/fcm/notification/NotificationUiUtil.kt
View file @
1691f044
package
com.base.appzxhy.fcm.notification
package
com.base.appzxhy.fcm.notification
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.content.Context
import
android.content.Intent
import
android.graphics.drawable.Icon
import
android.os.Build
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.graphics.drawable.IconCompat
import
com.base.appzxhy.R
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.ui.start.StartActivity
import
kotlin.random.Random
/**
/**
* 发送通知UI部分
* 发送通知UI部分
*/
*/
object
NotificationUiUtil
{
object
NotificationUiUtil
{
private
val
CHANNEL_ID
=
"San Qr Channel"
private
val
CHANNEL_NAME
=
"San Qr Channel NAME"
fun
setNotification
(
sendBean
:
NotificationSendBean
)
{
fun
setNotification
(
sendBean
:
NotificationSendBean
)
{
when
(
sendBean
.
actionId
)
{
}
val
intent
=
Intent
(
sendBean
.
context
,
StartActivity
::
class
.
java
)
intent
.
putExtra
(
"actionId"
,
sendBean
.
actionId
)
sendBean
.
intent
=
intent
sendCustomNotification
(
sendBean
)
}
private
fun
sendCustomNotification
(
sendBean
:
NotificationSendBean
)
{
val
notificationManager
=
sendBean
.
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
context
=
sendBean
.
context
//创建channel
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
CHANNEL_ID
,
CHANNEL_NAME
,
NotificationManager
.
IMPORTANCE_HIGH
)
channel
.
lockscreenVisibility
=
NotificationCompat
.
VISIBILITY_PUBLIC
channel
.
enableVibration
(
false
)
channel
.
vibrationPattern
=
longArrayOf
(
0
)
notificationManager
.
createNotificationChannel
(
channel
)
}
// Create the notification
val
builder
:
NotificationCompat
.
Builder
=
NotificationCompat
.
Builder
(
context
,
CHANNEL_ID
)
//设置状态栏内的小图标
val
smallIcon
=
IconCompat
.
createFromIcon
(
context
,
Icon
.
createWithResource
(
context
,
R
.
drawable
.
log_svg
)
)
smallIcon
?.
let
{
builder
.
setSmallIcon
(
smallIcon
)
}
builder
.
setContentTitle
(
sendBean
.
context
.
resources
.
getString
(
R
.
string
.
app_name
))
// .setContentText("notification")
val
requestCode
=
Random
.
nextInt
(
1000
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
requestCode
,
sendBean
.
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
builder
.
setContentIntent
(
pendingIntent
)
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
.
setAutoCancel
(
true
)
var
small
:
RemoteViews
?
=
sendBean
.
bigRemoteViews
//Android 12以下需要适配小RemoteViews
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
small
=
sendBean
.
smallRemoteViews
}
// 设置小视图
sendBean
.
smallRemoteViews
?.
let
{
builder
.
setCustomContentView
(
it
)
}
// 设置悬浮通知视图(Android 12 及以上)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
sendBean
.
smallRemoteViews
.
let
{
builder
.
setCustomHeadsUpContentView
(
it
)
}
}
// 设置大视图
sendBean
.
bigRemoteViews
?.
let
{
builder
.
setCustomBigContentView
(
it
)
}
notificationManager
.
notify
(
sendBean
.
notificationId
,
builder
.
build
())
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/fcm/receiver/BatteryStatusReceiver.kt
View file @
1691f044
...
@@ -6,8 +6,10 @@ import android.content.Intent
...
@@ -6,8 +6,10 @@ 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.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_BATTERY
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_BATTERY
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.KotlinExt.currentDate
import
com.base.appzxhy.utils.KotlinExt.currentDate
...
@@ -104,11 +106,9 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
...
@@ -104,11 +106,9 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
/**
/**
* 推送成功后保存值
* 推送成功后保存值
*/
*/
fun
saveBatteryPushedData
(
where
:
String
,
actionId
:
String
)
{
fun
saveBatteryPushedData
()
{
if
(
where
==
POPUP_WHERE_BATTERY
)
{
todayBatteryPush
+=
1
todayBatteryPush
+=
1
batteryLastPushTime
=
System
.
currentTimeMillis
()
batteryLastPushTime
=
System
.
currentTimeMillis
()
}
}
}
...
@@ -128,16 +128,33 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
...
@@ -128,16 +128,33 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
//避免频繁触发
//避免频繁触发
val
changeValue
=
currentBatteryPercentage
-
batteryPercentage
val
changeValue
=
currentBatteryPercentage
-
batteryPercentage
if
(
batteryPercentage
<
21
&&
changeValue
.
absoluteValue
>=
1f
)
{
if
(
batteryPercentage
<
popupConfigBean
.
popupBatteryValue
&&
changeValue
.
absoluteValue
>=
1f
)
{
//推送次数没有达到限制并且展示的最小时间间隔大于配置时间(分钟)
//推送次数没有达到限制并且展示的最小时间间隔大于配置时间(分钟)
// sendNotificationIfCan(context, POPUP_WHERE_BATTERY, null)
LogEx
.
logDebug
(
TAG
,
"onReceive changed"
)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_BATTERY
,
canSend
=
{
canBatteryStatusReceiverPush
()
},
sendSuccess
=
{
saveBatteryPushedData
()
})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
currentBatteryPercentage
=
batteryPercentage
currentBatteryPercentage
=
batteryPercentage
}
}
Intent
.
ACTION_POWER_CONNECTED
->
{
Intent
.
ACTION_POWER_CONNECTED
->
{
// sendNotificationIfCan(context, POPUP_WHERE_BATTERY, null)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_BATTERY
,
canSend
=
{
canBatteryStatusReceiverPush
()
},
sendSuccess
=
{
saveBatteryPushedData
()
})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
...
...
app/src/main/java/com/base/appzxhy/fcm/receiver/FileJobReceiver.kt
View file @
1691f044
...
@@ -3,13 +3,17 @@ import android.annotation.SuppressLint
...
@@ -3,13 +3,17 @@ import android.annotation.SuppressLint
import
android.content.BroadcastReceiver
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_FILE_JOB
import
com.base.appzxhy.fcm.notification.MyNotificationManager
class
FileJobReceiver
:
BroadcastReceiver
()
{
class
FileJobReceiver
:
BroadcastReceiver
()
{
@SuppressLint
(
"UnsafeProtectedBroadcastReceiver"
)
@SuppressLint
(
"UnsafeProtectedBroadcastReceiver"
)
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
// context?.startJob()
// context?.startJob()
context
?.
let
{
context
?.
let
{
// sendNotificationIfCan(context, PopupConstObject.POPUP_WHERE_FILE_JOB)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_FILE_JOB
,
canSend
=
{
true
},
sendSuccess
=
{})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/fcm/receiver/PackageStatusReceiver.kt
View file @
1691f044
...
@@ -5,8 +5,10 @@ import android.content.Context
...
@@ -5,8 +5,10 @@ import android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.IntentFilter
import
android.content.IntentFilter
import
android.os.Build
import
android.os.Build
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.POPUP_WHERE_PACKAGE
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_PACKAGE
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.KotlinExt.currentDate
import
com.base.appzxhy.utils.KotlinExt.currentDate
...
@@ -95,11 +97,9 @@ class PackageStatusReceiver() : BroadcastReceiver() {
...
@@ -95,11 +97,9 @@ class PackageStatusReceiver() : BroadcastReceiver() {
/**
/**
* 推送成功后保存值
* 推送成功后保存值
*/
*/
fun
savePackagePushedData
(
where
:
String
,
actionId
:
String
)
{
fun
savePackagePushedData
()
{
if
(
where
==
POPUP_WHERE_PACKAGE
)
{
todayPackagePush
+=
1
todayPackagePush
+=
1
packageLastPushTime
=
System
.
currentTimeMillis
()
packageLastPushTime
=
System
.
currentTimeMillis
()
}
}
}
...
@@ -110,7 +110,12 @@ class PackageStatusReceiver() : BroadcastReceiver() {
...
@@ -110,7 +110,12 @@ class PackageStatusReceiver() : BroadcastReceiver() {
LogEx
.
logDebug
(
TAG
,
"onReceive action=$action"
)
LogEx
.
logDebug
(
TAG
,
"onReceive action=$action"
)
if
(
action
==
Intent
.
ACTION_PACKAGE_ADDED
||
action
==
Intent
.
ACTION_PACKAGE_REMOVED
)
{
if
(
action
==
Intent
.
ACTION_PACKAGE_ADDED
||
action
==
Intent
.
ACTION_PACKAGE_REMOVED
)
{
// NotificationUiUtil.sendNotificationIfCan(context, POPUP_WHERE_PACKAGE)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_PACKAGE
,
canSend
=
{
canPackageStatusReceiverPush
()
},
sendSuccess
=
{
savePackagePushedData
()
})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
...
...
app/src/main/java/com/base/appzxhy/fcm/receiver/ScreenStatusReceiver.kt
View file @
1691f044
...
@@ -8,6 +8,7 @@ import android.os.Build
...
@@ -8,6 +8,7 @@ import android.os.Build
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_LOCK
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_LOCK
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.KotlinExt.currentDate
import
com.base.appzxhy.utils.KotlinExt.currentDate
...
@@ -30,7 +31,12 @@ class ScreenStatusReceiver : BroadcastReceiver() {
...
@@ -30,7 +31,12 @@ class ScreenStatusReceiver : BroadcastReceiver() {
isSecureLockActive
=
false
isSecureLockActive
=
false
if
(
isDeviceInteractive
&&
!
isSecureLockActive
)
{
if
(
isDeviceInteractive
&&
!
isSecureLockActive
)
{
if
(
popupConfigBean
.
screenS
)
{
if
(
popupConfigBean
.
screenS
)
{
// sendNotificationIfCan(context, POPUP_WHERE_LOCK, null)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_LOCK
,
canSend
=
{
canScreenStatusReceiverPush
()
},
sendSuccess
=
{
saveScreenPushedData
()
})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
}
}
...
@@ -118,11 +124,9 @@ class ScreenStatusReceiver : BroadcastReceiver() {
...
@@ -118,11 +124,9 @@ class ScreenStatusReceiver : BroadcastReceiver() {
/**
/**
* 推送成功后保存值
* 推送成功后保存值
*/
*/
fun
saveScreenPushedData
(
where
:
String
,
actionId
:
String
)
{
fun
saveScreenPushedData
()
{
if
(
where
==
POPUP_WHERE_LOCK
)
{
todayScreenPush
+=
1
todayScreenPush
+=
1
screenLastPushTime
=
System
.
currentTimeMillis
()
screenLastPushTime
=
System
.
currentTimeMillis
()
}
}
}
}
}
...
...
app/src/main/java/com/base/appzxhy/fcm/timer/TimerManager.kt
View file @
1691f044
package
com.base.appzxhy.fcm.timer
package
com.base.appzxhy.fcm.timer
import
com.base.appzxhy.MyApplication
import
com.base.appzxhy.MyApplication
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_TIMER
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.fcm.receiver.ScreenStatusReceiver
import
com.base.appzxhy.fcm.receiver.ScreenStatusReceiver
import
com.base.appzxhy.utils.LogEx.logDebug
import
com.base.appzxhy.utils.LogEx.logDebug
import
java.util.Timer
import
java.util.Timer
...
@@ -28,7 +31,9 @@ class TimerManager private constructor() {
...
@@ -28,7 +31,9 @@ class TimerManager private constructor() {
&&
MyApplication
.
PAUSED_VALUE
!=
1
&&
MyApplication
.
PAUSED_VALUE
!=
1
)
{
)
{
logDebug
(
TAG
,
"scheduleTask send"
)
logDebug
(
TAG
,
"scheduleTask send"
)
// sendNotificationIfCan(MyApplication.appContext, PopupConstObject.POPUP_WHERE_TIMBER, null)
val
sendBean
=
NotificationSendBean
(
MyApplication
.
appContext
,
POPUP_WHERE_TIMER
,
canSend
=
{
true
},
sendSuccess
=
{})
MyNotificationManager
.
submitSendBean
(
sendBean
)
}
}
}
}
}
}
...
...
app/src/main/java/com/base/appzxhy/service/StayJobService.kt
View file @
1691f044
...
@@ -13,6 +13,7 @@ import android.os.Build
...
@@ -13,6 +13,7 @@ import android.os.Build
import
android.os.CountDownTimer
import
android.os.CountDownTimer
import
androidx.work.Configuration
import
androidx.work.Configuration
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.service.StayNotification.createPermanentNotification
import
com.base.appzxhy.service.StayNotification.createPermanentNotification
import
com.base.appzxhy.utils.LogEx
import
com.base.appzxhy.utils.LogEx
...
@@ -35,14 +36,17 @@ class StayJobService : JobService() {
...
@@ -35,14 +36,17 @@ class StayJobService : JobService() {
private
var
isRunning
=
false
private
var
isRunning
=
false
private
const
val
JOB_INFO_ID
:
Int
=
101
private
const
val
JOB_INFO_ID
:
Int
=
101
private
var
startJobTime
=
0L
private
val
minimumLatency
=
if
(
BuildConfig
.
DEBUG
)
5000L
else
5000L
fun
Context
.
startJob
()
{
fun
Context
.
startJob
()
{
if
(
isRunning
)
return
if
(
isRunning
)
return
LogEx
.
logDebug
(
TAG
,
"startJob"
)
LogEx
.
logDebug
(
TAG
,
"startJob"
)
startJobTime
=
System
.
currentTimeMillis
()
val
jobScheduler
=
getSystemService
(
JOB_SCHEDULER_SERVICE
)
as
JobScheduler
val
jobScheduler
=
getSystemService
(
JOB_SCHEDULER_SERVICE
)
as
JobScheduler
val
componentName
=
ComponentName
(
this
,
StayJobService
::
class
.
java
)
val
componentName
=
ComponentName
(
this
,
StayJobService
::
class
.
java
)
val
jobInfo
=
JobInfo
.
Builder
(
JOB_INFO_ID
,
componentName
)
val
jobInfo
=
JobInfo
.
Builder
(
JOB_INFO_ID
,
componentName
)
.
setMinimumLatency
(
30000
)
.
setMinimumLatency
(
minimumLatency
)
.
build
()
.
build
()
jobScheduler
.
schedule
(
jobInfo
)
jobScheduler
.
schedule
(
jobInfo
)
}
}
...
@@ -56,17 +60,23 @@ class StayJobService : JobService() {
...
@@ -56,17 +60,23 @@ class StayJobService : JobService() {
}
}
private
fun
startForeground
()
{
private
fun
startForeground
()
{
val
notification
=
createPermanentNotification
(
applicationContext
)
try
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
val
notification
=
createPermanentNotification
(
applicationContext
)
startForeground
(
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
NOTIFICATION_STAY_ID
,
startForeground
(
notification
,
NOTIFICATION_STAY_ID
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_LOCATION
notification
,
)
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
}
else
{
)
startForeground
(
NOTIFICATION_STAY_ID
,
notification
)
}
else
{
startForeground
(
NOTIFICATION_STAY_ID
,
notification
)
}
isRunning
=
true
EventUtils
.
event
(
"startForeground"
)
LogEx
.
logDebug
(
TAG
,
"startForeground"
)
}
catch
(
e
:
Exception
)
{
EventUtils
.
event
(
"start_foreground_service_error"
)
}
}
isRunning
=
true
}
}
private
fun
notifyForeground
()
{
private
fun
notifyForeground
()
{
...
@@ -87,6 +97,9 @@ class StayJobService : JobService() {
...
@@ -87,6 +97,9 @@ class StayJobService : JobService() {
override
fun
onCreate
()
{
override
fun
onCreate
()
{
LogEx
.
logDebug
(
TAG
,
"onCreate isRunning=$isRunning"
)
LogEx
.
logDebug
(
TAG
,
"onCreate isRunning=$isRunning"
)
if
(!
isRunning
)
{
if
(!
isRunning
)
{
val
startTime
=
System
.
currentTimeMillis
()
-
startJobTime
LogEx
.
logDebug
(
TAG
,
"onCreate startTime=$startTime"
)
EventUtils
.
event
(
"StayJobService_onCreate"
,
"startTime=$startTime"
)
isRunning
=
true
isRunning
=
true
startForeground
()
startForeground
()
Timer
().
start
()
Timer
().
start
()
...
...
app/src/main/java/com/base/appzxhy/service/StayNotification.kt
View file @
1691f044
...
@@ -33,54 +33,10 @@ object StayNotification {
...
@@ -33,54 +33,10 @@ object StayNotification {
// )
// )
// contentView.setOnClickPendingIntent(R.id.fl_1, pendingIntent1)
// contentView.setOnClickPendingIntent(R.id.fl_1, pendingIntent1)
// expendView.setOnClickPendingIntent(R.id.fl_1, pendingIntent1)
// expendView.setOnClickPendingIntent(R.id.fl_1, pendingIntent1)
//
// val requestCode2 = Random.nextInt(1800)
// val intent2 = Intent(context, MyStartActivity::class.java).apply {
// putExtra("actionId", ConstObject.NOTIFICATION_ACTION_DOCUMENT)
// }
// val pendingIntent2 =
// PendingIntent.getActivity(
// context,
// requestCode2,
// intent2,
// PendingIntent.FLAG_IMMUTABLE
// )
// contentView.setOnClickPendingIntent(R.id.ll_2, pendingIntent2)
// expendView.setOnClickPendingIntent(R.id.ll_2, pendingIntent2)
//
// val requestCode3 = Random.nextInt(1800)
// val intent3 = Intent(context, MyStartActivity::class.java).apply {
// putExtra("actionId", ConstObject.NOTIFICATION_ACTION_BOOKMARK)
// }
// val pendingIntent3 =
// PendingIntent.getActivity(
// context,
// requestCode3,
// intent3,
// PendingIntent.FLAG_IMMUTABLE
// )
// contentView.setOnClickPendingIntent(R.id.ll_3, pendingIntent3)
// expendView.setOnClickPendingIntent(R.id.ll_3, pendingIntent3)
//
//
// val requestCode4 = Random.nextInt(1800)
// val intent4 = Intent(context, MyStartActivity::class.java).apply {
// putExtra("actionId", ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF)
// }
// val pendingIntent4 =
// PendingIntent.getActivity(
// context,
// requestCode4,
// intent4,
// PendingIntent.FLAG_IMMUTABLE
// )
// contentView.setOnClickPendingIntent(R.id.ll_4, pendingIntent4)
// expendView.setOnClickPendingIntent(R.id.ll_4, pendingIntent4)
}
}
fun
notifyStayNotification
(
context
:
Context
,
desc
:
String
)
{
fun
notifyStayNotification
(
context
:
Context
)
{
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
...
...
app/src/main/java/com/base/appzxhy/utils/IntentUtils.kt
View file @
1691f044
package
com.base.appzxhy.utils
package
com.base.appzxhy.utils
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
android.os.Build
import
android.os.Build
import
android.provider.CalendarContract
import
android.provider.ContactsContract
import
android.provider.Settings
import
android.provider.Settings
import
androidx.core.content.FileProvider
import
java.io.File
import
java.util.GregorianCalendar
import
java.util.TimeZone
object
IntentUtils
{
object
IntentUtils
{
...
@@ -27,4 +35,129 @@ object IntentUtils {
...
@@ -27,4 +35,129 @@ object IntentUtils {
}
}
return
intent
return
intent
}
}
fun
intentShareImage
(
context
:
Context
,
imagePath
:
String
):
Intent
{
kotlin
.
runCatching
{
// 获取图片文件的URI
val
imageUri
:
Uri
=
FileProvider
.
getUriForFile
(
context
,
context
.
packageName
+
".provider"
,
File
(
imagePath
))
val
shareIntent
=
Intent
()
shareIntent
.
action
=
Intent
.
ACTION_SEND
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
imageUri
)
shareIntent
.
type
=
"image/jpeg"
return
shareIntent
}
return
Intent
()
}
fun
intentShareText
(
text
:
String
):
Intent
{
val
sendIntent
=
Intent
()
sendIntent
.
action
=
Intent
.
ACTION_SEND
sendIntent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
text
)
// 添加要分享的文本
sendIntent
.
type
=
"text/plain"
// 设置数据类型为纯文本
// 启动Intent
val
shareIntent
=
Intent
.
createChooser
(
sendIntent
,
null
)
return
shareIntent
}
fun
intentSafPickImage
():
Intent
{
val
intent
=
Intent
(
Intent
.
ACTION_OPEN_DOCUMENT
)
intent
.
addCategory
(
Intent
.
CATEGORY_OPENABLE
)
intent
.
setType
(
"image/*"
)
return
intent
}
fun
intentWifiSettings
():
Intent
{
val
intent
=
Intent
()
intent
.
setAction
(
Settings
.
ACTION_WIFI_SETTINGS
)
return
intent
}
// fun intentSendEmail(emailUIBean: EmailUIBean): Intent {
// val emailIntent = Intent(Intent.ACTION_SEND)
// emailIntent.setType("text/plain")
// emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(emailUIBean.address)) // 替换为收件人邮箱
// emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailUIBean.subject) // 替换为邮件主题
// emailIntent.putExtra(Intent.EXTRA_TEXT, emailUIBean.message) // 替换为邮件内容
// return Intent.createChooser(emailIntent, "Select your mail client")
// }
fun
intentViewHttp
(
url
:
String
):
Intent
{
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
intent
.
setData
(
Uri
.
parse
(
url
))
return
intent
}
// fun intentAddCalendar(eventUIBean: EventUIBean): Intent {
// val intent = Intent(Intent.ACTION_INSERT)
// intent.setData(CalendarContract.Events.CONTENT_URI)
// // 设置事件标题
// intent.putExtra(CalendarContract.Events.TITLE, eventUIBean.summary)
//
// val startCalendar = GregorianCalendar()
// startCalendar.timeInMillis = eventUIBean.startTime
// startCalendar.setTimeZone(TimeZone.getTimeZone("UTC")) // 设置时区为UTC
// intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startCalendar.timeInMillis)
//
// val endCalendar = GregorianCalendar()
// endCalendar.timeInMillis = eventUIBean.endTime
// endCalendar.setTimeZone(TimeZone.getTimeZone("UTC")) // 设置时区为UTC
// intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endCalendar.timeInMillis)
//
// intent.putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY)
// intent.putExtra(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().id)
// // 设置事件描述(可选)
// intent.putExtra(CalendarContract.Events.DESCRIPTION, eventUIBean.description)
// // 设置事件地点
// intent.putExtra(CalendarContract.Events.EVENT_LOCATION, eventUIBean.location)
// return intent
// }
fun
intentPickContacts
():
Intent
{
val
intent
=
Intent
(
Intent
.
ACTION_PICK
)
intent
.
setType
(
ContactsContract
.
Contacts
.
CONTENT_TYPE
)
val
chooser
=
Intent
.
createChooser
(
intent
,
null
)
return
chooser
}
fun
intentCallPhone
(
tel
:
String
):
Intent
{
val
callIntent
=
Intent
(
Intent
.
ACTION_CALL
,
Uri
.
parse
(
"tel:$tel"
))
val
shareIntent
=
Intent
.
createChooser
(
callIntent
,
null
)
return
shareIntent
}
// fun intentWriteContract(bean: ContractUIBean): Intent {
// val intent = Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI)
// intent.putExtra(ContactsContract.Intents.Insert.NAME, bean.n)
// intent.putExtra(ContactsContract.Intents.Insert.PHONE, bean.tel)
// intent.putExtra(ContactsContract.Intents.Insert.EMAIL, bean.email)
// //竞品拿个公司地址,受不了
// intent.putExtra(ContactsContract.Intents.Insert.COMPANY, bean.adr)
//// val values = ContentValues().apply {
//// put(
//// ContactsContract.CommonDataKinds.StructuredPostal.TYPE,
//// ContactsContract.CommonDataKinds.StructuredPostal.TYPE_OTHER
//// )
//// put(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS, bean.adr)
//// }
//// val dataArrayList = ArrayList<ContentValues>()
//// dataArrayList.add(values)
////
//// intent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA,dataArrayList)
//
// val shareIntent = Intent.createChooser(intent, null)
// return shareIntent
// }
// @SuppressLint("IntentReset")
// fun intentSendSms(bean: MessageUIBean): Intent {
// val smsIntent = Intent(Intent.ACTION_VIEW)
// smsIntent.setType("vnd.android-dir/mms-sms")
// smsIntent.setData(Uri.parse("smsto:" + bean.smsto))
// smsIntent.putExtra("sms_body", bean.msg)
// val chooserIntent = Intent.createChooser(smsIntent, null)
// return chooserIntent
// }
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/utils/LanguageUtils.kt
deleted
100644 → 0
View file @
49c23a61
package
com.base.appzxhy.utils
import
android.content.Context
import
android.os.LocaleList
import
java.util.Locale
object
LanguageUtils
{
fun
getSystemLanguage
():
String
{
return
Locale
.
getDefault
().
language
}
val
supportLanguage
=
listOf
(
Locale
.
ENGLISH
.
language
,
Locale
.
PRC
.
language
,
Locale
(
"pt"
,
"BR"
).
language
,
Locale
(
"es"
).
language
,
Locale
.
FRENCH
.
language
,
Locale
(
"de"
).
language
,
Locale
(
"th"
,
"TH"
).
language
,
Locale
(
"in"
,
"ID"
).
language
,
Locale
(
"ms"
,
"MY"
).
language
,
Locale
(
"vi"
,
"VN"
).
language
,
Locale
(
"ja"
,
"JP"
).
language
,
Locale
(
"it"
,
"IT"
).
language
,
Locale
(
"ko"
,
"KR"
).
language
,
Locale
(
"nl"
,
"NL"
).
language
,
Locale
(
"zh"
,
"TW"
).
language
,
Locale
(
"tr"
,
"TR"
).
language
)
fun
getSystemLanguageDefault
():
String
{
var
systemLanguage
=
getSystemLanguage
()
if
(!
supportLanguage
.
contains
(
systemLanguage
))
{
systemLanguage
=
Locale
.
ENGLISH
.
language
}
return
systemLanguage
}
fun
isSupportSystemLanguage
():
Boolean
{
return
supportLanguage
.
contains
(
getSystemLanguage
())
}
fun
changeAppLanguage
(
context
:
Context
,
languageCountry
:
String
)
{
val
config
=
context
.
resources
.
configuration
val
lc
=
languageCountry
.
split
(
"_"
)
val
locale
=
if
(
lc
.
size
==
2
)
{
Locale
(
lc
[
0
],
lc
[
1
])
}
else
{
Locale
(
lc
[
0
])
}
//Android 7.0以上的方法
config
.
setLocale
(
locale
)
config
.
setLocales
(
LocaleList
(
locale
))
context
.
createConfigurationContext
(
config
)
context
.
resources
.
updateConfiguration
(
config
,
context
.
resources
.
displayMetrics
)
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/utils/PermissionUtils.kt
View file @
1691f044
...
@@ -15,6 +15,27 @@ import com.base.appzxhy.utils.IntentUtils.intentAppDetailsSettings
...
@@ -15,6 +15,27 @@ import com.base.appzxhy.utils.IntentUtils.intentAppDetailsSettings
object
PermissionUtils
{
object
PermissionUtils
{
//region 打电话
fun
Context
.
checkCallPhonePermission
():
Boolean
{
return
PackageManager
.
PERMISSION_GRANTED
==
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
CALL_PHONE
)
}
//endregion
//region联系人
fun
Context
.
checkContactsReadPermission
():
Boolean
{
return
PackageManager
.
PERMISSION_GRANTED
==
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
READ_CONTACTS
)
}
fun
Context
.
checkContactsWritePermission
():
Boolean
{
return
PackageManager
.
PERMISSION_GRANTED
==
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
WRITE_CONTACTS
)
}
//endregion
//region 相机
fun
Context
.
checkCameraPermission
():
Boolean
{
return
PackageManager
.
PERMISSION_GRANTED
==
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
CAMERA
)
}
//endregion
//region 通知
//region 通知
fun
Context
.
areNotificationsEnabled
():
Boolean
{
fun
Context
.
areNotificationsEnabled
():
Boolean
{
...
...
app/src/main/res/drawable/log_svg.xml
0 → 100644
View file @
1691f044
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:aapt=
"http://schemas.android.com/aapt"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24"
android:viewportHeight=
"24"
>
<group>
<clip-path
android:pathData=
"M0,0h24v24h-24z"
/>
<!-- <path-->
<!-- android:pathData="M0,0h24v24h-24z"-->
<!-- android:fillColor="#ffffff"/>-->
<!-- <path-->
<!-- android:pathData="M12,24C18.627,24 24,18.627 24,12C24,5.373 18.627,0 12,0C5.373,0 0,5.373 0,12C0,18.627 5.373,24 12,24Z"-->
<!-- android:fillColor="#ABABAB"/>-->
<path
android:pathData=
"M10.98,18.118H6.392C6.257,18.118 6.127,18.064 6.032,17.968C5.936,17.873 5.882,17.743 5.882,17.608V13.02C5.882,12.738 6.111,12.51 6.392,12.51H10.98C11.262,12.51 11.49,12.738 11.49,13.02V17.608C11.49,17.889 11.262,18.118 10.98,18.118ZM10.471,13.53H6.902V17.098H10.471V13.53ZM10.98,11.49H6.392C6.111,11.49 5.882,11.262 5.882,10.981V6.392C5.882,6.111 6.111,5.883 6.392,5.883H10.98C11.262,5.883 11.49,6.111 11.49,6.392V10.981C11.49,11.262 11.262,11.49 10.98,11.49ZM10.471,6.902H6.902V10.471H10.471V6.902ZM17.608,18.118H13.02C12.738,18.118 12.51,17.889 12.51,17.608V13.02C12.51,12.738 12.738,12.51 13.02,12.51H17.608C17.889,12.51 18.118,12.738 18.118,13.02V17.608C18.118,17.889 17.889,18.118 17.608,18.118ZM17.098,13.53H13.53V17.098H17.098V13.53ZM7.921,16.078H9.451V14.549H7.921V16.078ZM7.921,9.451H9.451V7.922H7.921V9.451ZM16.588,11.49H18.118V9.961H16.588V11.49ZM16.588,7.412H15.568V5.882H18.118V8.431H16.588V7.412L16.588,7.412ZM12.51,7.412H14.039V5.882H12.51V7.412ZM14.549,16.078H16.078V14.549H14.549V16.078ZM12.51,11.49H14.039V9.961H12.51V11.49ZM14.039,9.961H15.568V7.412H14.039V9.961Z"
android:fillColor=
"#ffffff"
/>
<path
android:pathData=
"M4.605,4C4.271,4 4,4.271 4,4.605V6.508C4,6.747 4.194,6.941 4.432,6.941C4.671,6.941 4.865,6.747 4.865,6.508V4.865H6.508C6.747,4.865 6.941,4.671 6.941,4.432C6.941,4.194 6.747,4 6.508,4H4.605ZM19.395,4C19.729,4 20,4.271 20,4.605V6.508C20,6.747 19.806,6.941 19.568,6.941C19.329,6.941 19.135,6.747 19.135,6.508V4.865H17.492C17.253,4.865 17.059,4.671 17.059,4.432C17.059,4.194 17.253,4 17.492,4H19.395ZM4,19.395C4,19.729 4.271,20 4.605,20H6.508C6.747,20 6.941,19.806 6.941,19.568C6.941,19.329 6.747,19.135 6.508,19.135H4.865V17.492C4.865,17.253 4.671,17.059 4.432,17.059C4.194,17.059 4,17.253 4,17.492V19.395ZM19.395,20C19.729,20 20,19.729 20,19.395V17.751C20,17.513 19.806,17.319 19.568,17.319C19.329,17.319 19.135,17.513 19.135,17.751V19.135H17.751C17.513,19.135 17.319,19.329 17.319,19.568C17.319,19.806 17.513,20 17.751,20H19.395Z"
android:fillColor=
"#ffffff"
android:fillType=
"evenOdd"
/>
<path
android:pathData=
"M4,14.353H20V11.529H4V14.353Z"
>
<aapt:attr
name=
"android:fillColor"
>
<gradient
android:startX=
"12"
android:startY=
"14.353"
android:endX=
"12"
android:endY=
"11.529"
android:type=
"linear"
>
<item
android:offset=
"0"
android:color=
"#00E6E7E7"
/>
<item
android:offset=
"1"
android:color=
"#7FE6E7E7"
/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData=
"M4,11.529V10.588H20V11.529H4Z"
android:fillColor=
"#E6E7E7"
android:fillType=
"evenOdd"
/>
</group>
</vector>
app/src/main/res/values/attrs.xml
0 → 100644
View file @
1691f044
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable
name=
"NativeParentView"
>
<attr
name=
"removeAll"
format=
"boolean"
/>
</declare-styleable>
</resources>
\ No newline at end of file
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