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
d1841811
Commit
d1841811
authored
Dec 04, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
c357bb44
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
43 deletions
+82
-43
BatteryStatusReceiver.kt
.../com/base/locationsharewhite/fcm/BatteryStatusReceiver.kt
+20
-10
NotificationHoverUtils.kt
...com/base/locationsharewhite/fcm/NotificationHoverUtils.kt
+1
-1
NotificationUiUtil.kt
...ava/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
+13
-7
TimerManager.kt
...main/java/com/base/locationsharewhite/fcm/TimerManager.kt
+1
-1
MyApplication.kt
.../java/com/base/locationsharewhite/helper/MyApplication.kt
+4
-0
StayJobService.kt
...ava/com/base/locationsharewhite/service/StayJobService.kt
+1
-0
HowUseActivity.kt
...a/com/base/locationsharewhite/ui/howuse/HowUseActivity.kt
+3
-2
LocationCodeActivity.kt
...m/base/locationsharewhite/ui/main/LocationCodeActivity.kt
+21
-3
LocationShareActivity.kt
.../base/locationsharewhite/ui/main/LocationShareActivity.kt
+12
-18
activity_how_use.xml
app/src/main/res/layout/activity_how_use.xml
+6
-1
No files found.
app/src/main/java/com/base/locationsharewhite/fcm/BatteryStatusReceiver.kt
View file @
d1841811
...
@@ -27,6 +27,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
...
@@ -27,6 +27,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
fun
registerBatteryStatusReceiver
(
context
:
Context
)
{
fun
registerBatteryStatusReceiver
(
context
:
Context
)
{
val
intentFilter
=
IntentFilter
().
apply
{
val
intentFilter
=
IntentFilter
().
apply
{
addAction
(
Intent
.
ACTION_BATTERY_CHANGED
)
addAction
(
Intent
.
ACTION_BATTERY_CHANGED
)
addAction
(
Intent
.
ACTION_POWER_CONNECTED
)
addAction
(
Intent
.
ACTION_POWER_DISCONNECTED
)
}
}
val
applicationContext
=
context
.
applicationContext
val
applicationContext
=
context
.
applicationContext
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
...
@@ -116,22 +118,30 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
...
@@ -116,22 +118,30 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
val
action
=
intent
?.
action
val
action
=
intent
?.
action
if
(
action
==
Intent
.
ACTION_BATTERY_CHANGED
)
{
val
batteryLevel
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_LEVEL
,
-
1
)
val
batteryScale
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_SCALE
,
-
1
)
val
batteryPercentage
=
(
batteryLevel
/
batteryScale
.
toFloat
())
*
100
//避免频繁触发
when
(
action
)
{
val
changeValue
=
currentBatteryPercentage
-
batteryPercentage
Intent
.
ACTION_BATTERY_CHANGED
->
{
val
batteryLevel
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_LEVEL
,
-
1
)
val
batteryScale
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_SCALE
,
-
1
)
val
batteryPercentage
=
(
batteryLevel
/
batteryScale
.
toFloat
())
*
100
if
(
batteryPercentage
<
21
&&
changeValue
.
absoluteValue
>=
1f
)
{
//避免频繁触发
//推送次数没有达到限制并且展示的最小时间间隔大于配置时间(分钟)
val
changeValue
=
currentBatteryPercentage
-
batteryPercentage
NotificationUiUtil
.
sendNotificationIfCan
(
context
,
POPUP_WHERE_BATTERY
,
null
)
if
(
batteryPercentage
<
21
&&
changeValue
.
absoluteValue
>=
1f
)
{
//推送次数没有达到限制并且展示的最小时间间隔大于配置时间(分钟)
NotificationUiUtil
.
sendNotificationIfCan
(
context
,
POPUP_WHERE_BATTERY
,
null
)
}
currentBatteryPercentage
=
batteryPercentage
}
}
currentBatteryPercentage
=
batteryPercentage
Intent
.
ACTION_POWER_CONNECTED
->
{
NotificationUiUtil
.
sendNotificationIfCan
(
context
,
POPUP_WHERE_BATTERY
,
null
)
}
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/fcm/NotificationHoverUtils.kt
View file @
d1841811
...
@@ -21,7 +21,7 @@ object NotificationHoverUtils {
...
@@ -21,7 +21,7 @@ object NotificationHoverUtils {
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
if
(
handlerThread
==
null
)
{
if
(
handlerThread
==
null
)
{
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
handlerThread
=
HandlerThread
(
"NotificationHandlerThread"
)
...
...
app/src/main/java/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
View file @
d1841811
...
@@ -119,20 +119,26 @@ object NotificationUiUtil {
...
@@ -119,20 +119,26 @@ object NotificationUiUtil {
var
hoverActionId
=
""
var
hoverActionId
=
""
private
var
isUnLimit
:
Boolean
=
if
(
BuildConfig
.
DEBUG
)
true
else
false
@SuppressLint
(
"RemoteViewLayout"
)
@SuppressLint
(
"RemoteViewLayout"
)
fun
sendNotificationIfCan
(
context
:
Context
,
where
:
String
=
""
,
id
:
String
?
=
null
)
{
fun
sendNotificationIfCan
(
context
:
Context
,
where
:
String
=
""
,
id
:
String
?
=
null
)
{
LogEx
.
logDebug
(
TAG
,
"sendNotificationIfCan where=$where"
)
EventUtils
.
event
(
"Notification_Popup_Start"
,
"where=$where"
)
val
actionId
=
id
?:
getNextActionId
()
val
actionId
=
id
?:
getNextActionId
()
//总的限制条件
if
(!
isUnLimit
)
{
if
(!
canSendNotification
(
where
,
actionId
))
return
//总的限制条件
if
(!
canSendNotification
(
where
,
actionId
))
return
//特定类限制条件
//特定类限制条件
if
(!
canOtherSend
(
where
,
actionId
))
return
if
(!
canOtherSend
(
where
,
actionId
))
return
if
(
MyApplication
.
PAUSED_VALUE
==
1
)
{
if
(
MyApplication
.
PAUSED_VALUE
==
1
)
{
LogEx
.
logDebug
(
TAG
,
"APP Resumed"
)
LogEx
.
logDebug
(
TAG
,
"APP Resumed"
)
return
return
}
}
}
//发送通知
//发送通知
...
...
app/src/main/java/com/base/locationsharewhite/fcm/TimerManager.kt
View file @
d1841811
...
@@ -55,7 +55,7 @@ class TimerManager private constructor() {
...
@@ -55,7 +55,7 @@ class TimerManager private constructor() {
companion
object
{
companion
object
{
val
instance
:
TimerManager
by
lazy
((
LazyThreadSafetyMode
.
SYNCHRONIZED
))
{
TimerManager
()
}
private
val
instance
:
TimerManager
by
lazy
((
LazyThreadSafetyMode
.
SYNCHRONIZED
))
{
TimerManager
()
}
fun
changeTimer
()
{
fun
changeTimer
()
{
...
...
app/src/main/java/com/base/locationsharewhite/helper/MyApplication.kt
View file @
d1841811
...
@@ -16,6 +16,7 @@ import com.base.locationsharewhite.fcm.BatteryStatusReceiver
...
@@ -16,6 +16,7 @@ import com.base.locationsharewhite.fcm.BatteryStatusReceiver
import
com.base.locationsharewhite.fcm.PackageStatusReceiver
import
com.base.locationsharewhite.fcm.PackageStatusReceiver
import
com.base.locationsharewhite.fcm.PopupConstObject
import
com.base.locationsharewhite.fcm.PopupConstObject
import
com.base.locationsharewhite.fcm.ScreenStatusReceiver
import
com.base.locationsharewhite.fcm.ScreenStatusReceiver
import
com.base.locationsharewhite.fcm.TimerManager.Companion.changeTimer
import
com.base.locationsharewhite.fcm.alarm.AlarmUtils.startAlarm
import
com.base.locationsharewhite.fcm.alarm.AlarmUtils.startAlarm
import
com.base.locationsharewhite.helper.config.AppConfig
import
com.base.locationsharewhite.helper.config.AppConfig
import
com.base.locationsharewhite.service.StayJobService.Companion.startJob
import
com.base.locationsharewhite.service.StayJobService.Companion.startJob
...
@@ -210,6 +211,9 @@ class MyApplication : Application() {
...
@@ -210,6 +211,9 @@ class MyApplication : Application() {
//通知
//通知
PopupConstObject
.
popupConfigBean
=
configBean
.
popupConfigBean
PopupConstObject
.
popupConfigBean
=
configBean
.
popupConfigBean
//启动定时器
changeTimer
()
}
}
}
}
...
...
app/src/main/java/com/base/locationsharewhite/service/StayJobService.kt
View file @
d1841811
...
@@ -150,6 +150,7 @@ class StayJobService : JobService() {
...
@@ -150,6 +150,7 @@ class StayJobService : JobService() {
}
}
override
fun
onFinish
()
{
override
fun
onFinish
()
{
LogEx
.
logDebug
(
TAG
,
"Timer onFinish"
)
notifyForeground
()
notifyForeground
()
Timer
().
start
()
Timer
().
start
()
}
}
...
...
app/src/main/java/com/base/locationsharewhite/ui/howuse/HowUseActivity.kt
View file @
d1841811
...
@@ -4,6 +4,8 @@ import android.content.Intent
...
@@ -4,6 +4,8 @@ import android.content.Intent
import
android.graphics.Color
import
android.graphics.Color
import
androidx.activity.addCallback
import
androidx.activity.addCallback
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.ads.AdsMgr
import
com.base.locationsharewhite.databinding.ActivityHowUseBinding
import
com.base.locationsharewhite.databinding.ActivityHowUseBinding
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.helper.MyApplication
...
@@ -22,8 +24,7 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() {
...
@@ -22,8 +24,7 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() {
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
// val isRecreate = isLanguageRecreate(MyApplication.mainLanguage)
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_app_exit
)
// if (isRecreate) return
}
}
override
fun
initListener
()
{
override
fun
initListener
()
{
...
...
app/src/main/java/com/base/locationsharewhite/ui/main/LocationCodeActivity.kt
View file @
d1841811
...
@@ -5,6 +5,7 @@ import androidx.activity.addCallback
...
@@ -5,6 +5,7 @@ import androidx.activity.addCallback
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.ads.AdsMgr
import
com.base.locationsharewhite.ads.AdsMgr
import
com.base.locationsharewhite.ads.AdsShowCallBack
import
com.base.locationsharewhite.databinding.ActivityLocationCodeBinding
import
com.base.locationsharewhite.databinding.ActivityLocationCodeBinding
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.location.LocationLoginUtils
import
com.base.locationsharewhite.location.LocationLoginUtils
...
@@ -27,10 +28,27 @@ class LocationCodeActivity : BaseActivity<ActivityLocationCodeBinding>() {
...
@@ -27,10 +28,27 @@ class LocationCodeActivity : BaseActivity<ActivityLocationCodeBinding>() {
binding
.
tvCode
.
text
=
LocationLoginUtils
.
invitationCodeSp
binding
.
tvCode
.
text
=
LocationLoginUtils
.
invitationCodeSp
binding
.
tvCopy
.
setOnClickListener
{
binding
.
tvCopy
.
setOnClickListener
{
copyText
(
"MyLocationCode"
,
binding
.
tvCode
.
text
.
toString
())
AdsMgr
.
showInsert
(
this
,
false
,
object
:
AdsShowCallBack
()
{
toast
(
resources
.
getString
(
R
.
string
.
copy
))
override
fun
close
(
where
:
Int
)
{
copy
()
}
override
fun
failed
(
where
:
Int
)
{
copy
()
}
override
fun
googleFailed
(
where
:
Int
)
{
copy
()
}
})
}
}
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_app_exit
,)
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_app_exit
)
}
fun
copy
()
{
copyText
(
"MyLocationCode"
,
binding
.
tvCode
.
text
.
toString
())
toast
(
resources
.
getString
(
R
.
string
.
copy
),
true
)
}
}
override
fun
initListener
()
{
override
fun
initListener
()
{
...
...
app/src/main/java/com/base/locationsharewhite/ui/main/LocationShareActivity.kt
View file @
d1841811
...
@@ -107,26 +107,21 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
...
@@ -107,26 +107,21 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
toast
(
"code is empty"
,
true
)
toast
(
"code is empty"
,
true
)
return
@setOnClickListener
return
@setOnClickListener
}
}
if
(
code
.
length
>=
8
)
{
hideKeyBoard
()
hideKeyBoard
()
AdsMgr
.
showInsert
(
this
,
false
,
object
:
AdsShowCallBack
()
{
AdsMgr
.
showInsert
(
this
,
false
,
object
:
AdsShowCallBack
()
{
override
fun
close
(
where
:
Int
)
{
override
fun
close
(
where
:
Int
)
{
shareLocationCode
(
code
)
shareLocationCode
(
code
)
}
}
override
fun
failed
(
where
:
Int
)
{
shareLocationCode
(
code
)
}
override
fun
googleF
ailed
(
where
:
Int
)
{
override
fun
f
ailed
(
where
:
Int
)
{
shareLocationCode
(
code
)
shareLocationCode
(
code
)
}
}
})
override
fun
googleFailed
(
where
:
Int
)
{
shareLocationCode
(
code
)
}
}
else
{
})
toast
(
"code verification failed"
,
true
)
}
}
}
}
}
...
@@ -142,7 +137,6 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
...
@@ -142,7 +137,6 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
LocationShareUtils
.
shareMyLocationByInvitationCode
(
code
)
{
status
->
LocationShareUtils
.
shareMyLocationByInvitationCode
(
code
)
{
status
->
LogEx
.
logDebug
(
TAG
,
"status=$status"
)
LogEx
.
logDebug
(
TAG
,
"status=$status"
)
runOnUiThread
{
runOnUiThread
{
toast
(
"status=$status"
,
true
)
when
(
status
)
{
when
(
status
)
{
SHARE_STATE_FAILED
->
{
SHARE_STATE_FAILED
->
{
toast
(
"Code verification failed"
,
true
)
toast
(
"Code verification failed"
,
true
)
...
...
app/src/main/res/layout/activity_how_use.xml
View file @
d1841811
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"15dp"
android:layout_marginHorizontal=
"15dp"
android:layout_marginTop=
"
48
dp"
>
android:layout_marginTop=
"
36
dp"
>
<FrameLayout
<FrameLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -120,6 +120,11 @@
...
@@ -120,6 +120,11 @@
tools:ignore=
"ContentDescription"
/>
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</FrameLayout>
<com.base.locationsharewhite.ads.NativeParentView
android:id=
"@+id/fl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
/>
</LinearLayout>
</LinearLayout>
...
...
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