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
85a1d00d
Commit
85a1d00d
authored
Nov 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
0d63c5ec
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
64 deletions
+112
-64
NotificationUiUtil.kt
...ava/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
+6
-6
PackageStatusReceiver.kt
.../com/base/locationsharewhite/fcm/PackageStatusReceiver.kt
+1
-0
PopupConstObject.kt
.../java/com/base/locationsharewhite/fcm/PopupConstObject.kt
+4
-0
ScreenStatusReceiver.kt
...a/com/base/locationsharewhite/fcm/ScreenStatusReceiver.kt
+101
-58
No files found.
app/src/main/java/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
View file @
85a1d00d
...
@@ -102,9 +102,6 @@ object NotificationUiUtil {
...
@@ -102,9 +102,6 @@ object NotificationUiUtil {
if
(
where
==
POPUP_WHERE_TIMBER
)
{
if
(
where
==
POPUP_WHERE_TIMBER
)
{
interval
=
AppPreferences
.
getInstance
().
getString
(
popup_timer_interval
,
"7"
).
toInt
()
interval
=
AppPreferences
.
getInstance
().
getString
(
popup_timer_interval
,
"7"
).
toInt
()
}
}
if
(
where
==
POPUP_WHERE_LOCK
)
{
interval
=
AppPreferences
.
getInstance
().
getString
(
popup_lock_interval
,
"1"
).
toInt
()
}
if
(
where
==
POPUP_WHERE_FCM
)
{
if
(
where
==
POPUP_WHERE_FCM
)
{
interval
=
AppPreferences
.
getInstance
().
getString
(
popup_fcm_interval
,
"1"
).
toInt
()
interval
=
AppPreferences
.
getInstance
().
getString
(
popup_fcm_interval
,
"1"
).
toInt
()
}
}
...
@@ -168,14 +165,17 @@ object NotificationUiUtil {
...
@@ -168,14 +165,17 @@ object NotificationUiUtil {
if
(
where
==
POPUP_WHERE_PACKAGE
)
{
if
(
where
==
POPUP_WHERE_PACKAGE
)
{
canPush
=
PackageStatusReceiver
.
canPackageStatusReceiverPush
()
canPush
=
PackageStatusReceiver
.
canPackageStatusReceiverPush
()
}
}
if
(
where
==
POPUP_WHERE_LOCK
)
{
canPush
=
ScreenStatusReceiver
.
canScreenStatusReceiverPush
()
}
return
canPush
return
canPush
}
}
private
fun
saveOtherPopupData
(
where
:
String
,
actionId
:
String
)
{
private
fun
saveOtherPopupData
(
where
:
String
,
actionId
:
String
)
{
BatteryStatusReceiver
.
saveBatteryPushedData
(
actionId
,
where
)
BatteryStatusReceiver
.
saveBatteryPushedData
(
where
,
actionId
)
PackageStatusReceiver
.
savePackagePushedData
(
actionId
,
where
)
PackageStatusReceiver
.
savePackagePushedData
(
where
,
actionId
)
ScreenStatusReceiver
.
saveScreenPushedData
(
where
,
actionId
)
}
}
fun
setActionNotification
(
context
:
Context
,
actionId
:
String
)
{
fun
setActionNotification
(
context
:
Context
,
actionId
:
String
)
{
...
...
app/src/main/java/com/base/locationsharewhite/fcm/PackageStatusReceiver.kt
View file @
85a1d00d
...
@@ -88,6 +88,7 @@ class PackageStatusReceiver() : BroadcastReceiver() {
...
@@ -88,6 +88,7 @@ class PackageStatusReceiver() : BroadcastReceiver() {
}
}
}
}
}
}
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
...
...
app/src/main/java/com/base/locationsharewhite/fcm/PopupConstObject.kt
View file @
85a1d00d
...
@@ -43,6 +43,10 @@ object PopupConstObject {
...
@@ -43,6 +43,10 @@ object PopupConstObject {
const
val
popup_package_count
=
"popup_package_count"
const
val
popup_package_count
=
"popup_package_count"
const
val
popup_package_interval
=
"popup_package_interval"
const
val
popup_package_interval
=
"popup_package_interval"
//解锁可配置值
const
val
popup_screen_count
=
"popup_screen_count"
const
val
popup_screen_interval
=
"popup_screen_interval"
const
val
ACTION_STAY_HOME
=
"action_stay_home"
const
val
ACTION_STAY_HOME
=
"action_stay_home"
const
val
ACTION_STAY_MY_CODE
=
"action_stay_my_code"
const
val
ACTION_STAY_MY_CODE
=
"action_stay_my_code"
...
...
app/src/main/java/com/base/locationsharewhite/fcm/ScreenStatusReceiver.kt
View file @
85a1d00d
package
com.base.locationsharewhite.fcm
;
package
com.base.locationsharewhite.fcm
import
static
com
.
base
.
locationsharewhite
.
fcm
.
PopupConstObject
.
lockS
;
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
android.content.IntentFilter
import
android.os.Build
import
com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import
com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_LOCK
import
com.base.locationsharewhite.fcm.PopupConstObject.lockS
import
com.base.locationsharewhite.fcm.PopupConstObject.popup_screen_count
import
com.base.locationsharewhite.fcm.PopupConstObject.popup_screen_interval
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.KotlinExt.currentDate
import
java.util.Objects
import
android.content.BroadcastReceiver;
class
ScreenStatusReceiver
:
BroadcastReceiver
()
{
import
android.content.Context;
import
android.content.Intent;
import
android.content.IntentFilter;
import
android.os.Build;
import
com.base.locationsharewhite.utils.AppPreferences;
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
import
com.base.locationsharewhite.utils.LogEx;
val
action
=
intent
.
action
when
(
Objects
.
requireNonNull
<
String
?>(
action
))
{
import
java.util.Objects;
Intent
.
ACTION_SCREEN_ON
->
isDeviceInteractive
=
true
Intent
.
ACTION_SCREEN_OFF
->
{
isDeviceInteractive
=
false
isSecureLockActive
=
true
}
Intent
.
ACTION_USER_PRESENT
->
{
isSecureLockActive
=
false
if
(
isDeviceInteractive
&&
!
isSecureLockActive
)
{
val
secureSetting
=
AppPreferences
.
getInstance
().
getString
(
lockS
,
"1"
).
toInt
()
if
(
secureSetting
==
1
)
{
sendNotificationIfCan
(
context
,
PopupConstObject
.
POPUP_WHERE_LOCK
,
null
)
}
}
}
}
}
public
class
ScreenStatusReceiver
extends
BroadcastReceiver
{
private
static
boolean
isDeviceInteractive
=
true
;
companion
object
{
private
static
boolean
isSecureLockActive
=
false
;
var
isDeviceInteractive
:
Boolean
=
true
var
isSecureLockActive
:
Boolean
=
false
public
static
void
setupScreenStatusListener
(
Context
c
ontext
)
{
fun
setupScreenStatusListener
(
context
:
C
ontext
)
{
IntentFilter
intentFilter
=
new
IntentFilter
();
val
intentFilter
=
IntentFilter
()
intentFilter
.
addAction
(
Intent
.
ACTION_SCREEN_OFF
);
intentFilter
.
addAction
(
Intent
.
ACTION_SCREEN_OFF
)
intentFilter
.
addAction
(
Intent
.
ACTION_SCREEN_ON
);
intentFilter
.
addAction
(
Intent
.
ACTION_SCREEN_ON
)
intentFilter
.
addAction
(
Intent
.
ACTION_USER_PRESENT
);
intentFilter
.
addAction
(
Intent
.
ACTION_USER_PRESENT
)
final
Context
applicationContext
=
context
.
getApplicationContext
();
val
applicationContext
=
context
.
applicationContext
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
applicationContext
.
registerReceiver
(
new
ScreenStatusReceiver
(),
intentFilter
,
Context
.
RECEIVER_EXPORTED
);
applicationContext
.
registerReceiver
(
ScreenStatusReceiver
(),
intentFilter
,
Context
.
RECEIVER_EXPORTED
)
}
else
{
}
else
{
applicationContext
.
registerReceiver
(
new
ScreenStatusReceiver
(),
intentFilter
);
applicationContext
.
registerReceiver
(
ScreenStatusReceiver
(),
intentFilter
)
}
}
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
String
action
=
intent
.
getAction
();
switch
(
Objects
.
requireNonNull
(
action
))
{
case
Intent
.
ACTION_SCREEN_ON
:
setDeviceInteractive
(
true
);
break
;
case
Intent
.
ACTION_SCREEN_OFF
:
setDeviceInteractive
(
false
);
setSecureLockActive
(
true
);
break
;
case
Intent
.
ACTION_USER_PRESENT
:
setSecureLockActive
(
false
);
if
(
isDeviceInteractive
()
&&
!
isSecureLockActive
())
{
int
secureSetting
=
Integer
.
parseInt
(
AppPreferences
.
getInstance
().
getString
(
lockS
,
"1"
));
if
(
secureSetting
==
1
)
{
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
context
,
PopupConstObject
.
POPUP_WHERE_LOCK
,
null
);
}
}
}
}
break
;
/**
* 当前天推送数量
*/
private
var
todayScreenPush
=
0
get
()
{
return
AppPreferences
.
getInstance
().
getInt
(
"todayScreenPush_${currentDate()}"
,
field
)
}
}
set
(
value
)
{
field
=
value
AppPreferences
.
getInstance
().
put
(
"todayScreenPush_${currentDate()}"
,
value
,
true
)
}
}
private
void
setDeviceInteractive
(
boolean
interactive
)
{
/**
isDeviceInteractive
=
interactive
;
* 上次成功推送
*/
private
var
screenLastPushTime
=
0L
get
()
{
return
AppPreferences
.
getInstance
().
getLong
(
"screenLastPushTime"
,
field
)
}
set
(
value
)
{
field
=
value
AppPreferences
.
getInstance
().
put
(
"screenLastPushTime"
,
value
,
true
)
}
}
public
static
boolean
isDeviceInteractive
()
{
return
isDeviceInteractive
;
/**
* 解锁是否可推送
* 总的限制条件判断后才判断
*/
fun
canScreenStatusReceiverPush
():
Boolean
{
val
popupScreenCount
=
AppPreferences
.
getInstance
().
getString
(
popup_screen_count
,
"20"
).
toInt
()
val
flag1
=
todayScreenPush
<=
popupScreenCount
val
default
=
60
*
1000L
val
interval
=
AppPreferences
.
getInstance
().
getString
(
popup_screen_interval
,
default
.
toString
()).
toLong
()
val
passTime
=
System
.
currentTimeMillis
()
-
screenLastPushTime
val
flag2
=
screenLastPushTime
==
0L
||
passTime
>
interval
EventUtils
.
event
(
"Notification_Error"
,
"todayScreenPush=$todayScreenPush popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
)
return
flag1
&&
flag2
}
}
private
void
setSecureLockActive
(
boolean
active
)
{
/**
isSecureLockActive
=
active
;
* 推送成功后保存值
*/
fun
saveScreenPushedData
(
where
:
String
,
actionId
:
String
)
{
if
(
where
==
POPUP_WHERE_LOCK
)
{
todayScreenPush
+=
1
screenLastPushTime
=
System
.
currentTimeMillis
()
}
}
}
public
static
boolean
isSecureLockActive
()
{
return
isSecureLockActive
;
}
}
}
}
\ 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