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
3f40efe6
Commit
3f40efe6
authored
Nov 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
a2d9f548
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
365 additions
and
104 deletions
+365
-104
FcmReceiver.java
...ain/java/com/base/locationsharewhite/fcm/FcmReceiver.java
+0
-1
MessagingService.java
...ava/com/base/locationsharewhite/fcm/MessagingService.java
+0
-1
NotificationHoverUtils.kt
...com/base/locationsharewhite/fcm/NotificationHoverUtils.kt
+5
-7
NotificationUiUtil.kt
...ava/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
+70
-70
PopupConstObject.kt
.../java/com/base/locationsharewhite/fcm/PopupConstObject.kt
+9
-1
AlarmJobReceiver.kt
...com/base/locationsharewhite/fcm/alarm/AlarmJobReceiver.kt
+5
-5
AlarmUtils.kt
.../java/com/base/locationsharewhite/fcm/alarm/AlarmUtils.kt
+5
-4
ConstConfig.kt
.../com/base/locationsharewhite/helper/config/ConstConfig.kt
+0
-1
StayJobService.kt
...ava/com/base/locationsharewhite/service/StayJobService.kt
+127
-0
StayNotification.kt
...a/com/base/locationsharewhite/service/StayNotification.kt
+132
-0
SplashActivity.kt
...a/com/base/locationsharewhite/ui/splash/SplashActivity.kt
+12
-14
No files found.
app/src/main/java/com/base/locationsharewhite/fcm/FcmReceiver.java
View file @
3f40efe6
...
@@ -6,7 +6,6 @@ import android.content.Intent;
...
@@ -6,7 +6,6 @@ import android.content.Intent;
import
com.base.locationsharewhite.helper.EventUtils
;
import
com.base.locationsharewhite.helper.EventUtils
;
import
com.base.locationsharewhite.utils.LogEx
;
import
com.base.locationsharewhite.utils.LogEx
;
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject
;
public
class
FcmReceiver
extends
BroadcastReceiver
{
public
class
FcmReceiver
extends
BroadcastReceiver
{
...
...
app/src/main/java/com/base/locationsharewhite/fcm/MessagingService.java
View file @
3f40efe6
...
@@ -6,7 +6,6 @@ import androidx.annotation.NonNull;
...
@@ -6,7 +6,6 @@ import androidx.annotation.NonNull;
import
com.base.locationsharewhite.helper.EventUtils
;
import
com.base.locationsharewhite.helper.EventUtils
;
import
com.base.locationsharewhite.utils.LogEx
;
import
com.base.locationsharewhite.utils.LogEx
;
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.RemoteMessage
;
import
com.google.firebase.messaging.RemoteMessage
;
...
...
app/src/main/java/com/base/locationsharewhite/fcm/NotificationHoverUtils.kt
View file @
3f40efe6
package
com.base.locationsharewhite.fcm
package
com.base.locationsharewhite.fcm
import
android.content.Context
import
android.content.Context
import
android.os.Handler
import
android.os.Handler
import
android.os.HandlerThread
import
android.os.HandlerThread
import
com.base.locationsharewhite.fcm.PopupConstObject.popup_hover_count
import
com.base.locationsharewhite.fcm.PopupConstObject.popup_hover_delay
import
com.base.locationsharewhite.fcm.PopupConstObject.popup_hover_status
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.LogEx
import
com.base.locationsharewhite.utils.LogEx
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.popup_hover_count
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.popup_hover_delay
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.popup_hover_status
object
NotificationHoverUtils
{
object
NotificationHoverUtils
{
...
@@ -15,7 +16,6 @@ object NotificationHoverUtils {
...
@@ -15,7 +16,6 @@ object NotificationHoverUtils {
private
var
handlerThread
:
HandlerThread
?
=
null
private
var
handlerThread
:
HandlerThread
?
=
null
private
var
handler
:
Handler
?
=
null
private
var
handler
:
Handler
?
=
null
/**
/**
* 发送悬停通知
* 发送悬停通知
*/
*/
...
@@ -44,9 +44,7 @@ object NotificationHoverUtils {
...
@@ -44,9 +44,7 @@ object NotificationHoverUtils {
LogEx
.
logDebug
(
TAG
,
"handler ${MyApplication.PAUSED_VALUE}"
)
LogEx
.
logDebug
(
TAG
,
"handler ${MyApplication.PAUSED_VALUE}"
)
if
(
MyApplication
.
PAUSED_VALUE
==
1
)
{
if
(
MyApplication
.
PAUSED_VALUE
==
1
)
{
handler
?.
removeCallbacksAndMessages
(
null
)
handler
?.
removeCallbacksAndMessages
(
null
)
return
@Runnable
}
else
{
}
if
(
MyApplication
.
PAUSED_VALUE
!=
1
)
{
LogEx
.
logDebug
(
TAG
,
"handler send notification"
)
LogEx
.
logDebug
(
TAG
,
"handler send notification"
)
NotificationUiUtil
.
setActionNotification
(
context
,
NotificationUiUtil
.
hoverActionId
)
NotificationUiUtil
.
setActionNotification
(
context
,
NotificationUiUtil
.
hoverActionId
)
}
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/NotificationUiUtil.kt
View file @
3f40efe6
...
@@ -42,9 +42,9 @@ import kotlin.random.Random
...
@@ -42,9 +42,9 @@ import kotlin.random.Random
object
NotificationUiUtil
{
object
NotificationUiUtil
{
private
val
TAG
=
"NotificationUiUtil"
private
val
TAG
=
"NotificationUiUtil"
const
val
CHANNEL_ID
=
"browser
_notification_id"
// 通知渠道ID
private
val
CHANNEL_ID
=
"location
_notification_id"
// 通知渠道ID
const
val
CHANNEL_NAME
=
"browser
_fcm_channel"
// 通知渠道名称
private
val
CHANNEL_NAME
=
"location
_fcm_channel"
// 通知渠道名称
var
NOTIFICATION_ID
=
8999
private
var
NOTIFICATION_ID
=
8999
private
fun
currentDate
():
String
{
private
fun
currentDate
():
String
{
val
dateFormat
=
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
())
val
dateFormat
=
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
())
...
@@ -155,85 +155,85 @@ object NotificationUiUtil {
...
@@ -155,85 +155,85 @@ object NotificationUiUtil {
//
//
when
(
actionId
)
{
when
(
actionId
)
{
else
->
{
else
->
{
EventUtils
.
event
(
"Notification_Error"
,
"unKnow actionId actionId=$actionId"
)
EventUtils
.
event
(
"Notification_Error"
,
"unKnow actionId actionId=$actionId"
)
}
}
}
}
}
}
private
fun
sendCustomNotification
(
private
fun
sendCustomNotification
(
context
:
Context
,
context
:
Context
,
intent
:
Intent
,
intent
:
Intent
,
bigRemoteViews
:
RemoteViews
,
bigRemoteViews
:
RemoteViews
,
smallRemoteViews
:
RemoteViews
,
smallRemoteViews
:
RemoteViews
,
)
{
)
{
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
//创建channel
//创建channel
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
val
channel
=
NotificationChannel
(
CHANNEL_ID
,
CHANNEL_NAME
,
NotificationManager
.
IMPORTANCE_HIGH
CHANNEL_ID
,
CHANNEL_NAME
,
NotificationManager
.
IMPORTANCE_HIGH
)
)
channel
.
lockscreenVisibility
=
NotificationCompat
.
VISIBILITY_PUBLIC
channel
.
lockscreenVisibility
=
NotificationCompat
.
VISIBILITY_PUBLIC
notificationManager
.
createNotificationChannel
(
channel
)
notificationManager
.
createNotificationChannel
(
channel
)
}
}
// Create the notification
// Create the notification
val
builder
:
NotificationCompat
.
Builder
=
NotificationCompat
.
Builder
(
context
,
CHANNEL_ID
)
val
builder
:
NotificationCompat
.
Builder
=
NotificationCompat
.
Builder
(
context
,
CHANNEL_ID
)
//设置状态栏内的小图标
//设置状态栏内的小图标
val
smallIcon
=
IconCompat
.
createFromIcon
(
val
smallIcon
=
IconCompat
.
createFromIcon
(
context
,
Icon
.
createWithResource
(
context
,
Icon
.
createWithResource
(
context
,
R
.
mipmap
.
logo
context
,
R
.
mipmap
.
logo
)
)
)
)
smallIcon
?.
let
{
smallIcon
?.
let
{
builder
.
setSmallIcon
(
smallIcon
)
builder
.
setSmallIcon
(
smallIcon
)
}
}
builder
.
setContentTitle
(
context
.
resources
.
getString
(
R
.
string
.
app_name
))
builder
.
setContentTitle
(
context
.
resources
.
getString
(
R
.
string
.
app_name
))
.
setContentText
(
"notification"
)
.
setContentText
(
"notification"
)
val
requestCode
=
Random
.
nextInt
(
1000
)
val
requestCode
=
Random
.
nextInt
(
1000
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
requestCode
,
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
requestCode
,
intent
,
PendingIntent
.
FLAG_IMMUTABLE
)
builder
.
setContentIntent
(
pendingIntent
)
builder
.
setContentIntent
(
pendingIntent
)
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
.
setAutoCancel
(
true
)
.
setAutoCancel
(
true
)
var
small
:
RemoteViews
?
=
bigRemoteViews
var
small
:
RemoteViews
?
=
bigRemoteViews
//Android 12以下需要适配小RemoteViews
//Android 12以下需要适配小RemoteViews
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
small
=
smallRemoteViews
small
=
smallRemoteViews
}
}
// 设置小视图
// 设置小视图
builder
.
setCustomContentView
(
smallRemoteViews
)
builder
.
setCustomContentView
(
smallRemoteViews
)
// 设置悬浮通知视图(Android 12 及以上)
// 设置悬浮通知视图(Android 12 及以上)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
builder
.
setCustomHeadsUpContentView
(
bigRemoteViews
)
builder
.
setCustomHeadsUpContentView
(
bigRemoteViews
)
}
}
// 设置大视图
// 设置大视图
builder
.
setCustomBigContentView
(
bigRemoteViews
)
builder
.
setCustomBigContentView
(
bigRemoteViews
)
notificationManager
.
notify
(
NOTIFICATION_ID
,
builder
.
build
())
notificationManager
.
notify
(
NOTIFICATION_ID
,
builder
.
build
())
}
}
val
looper_actionId
=
listOf
(
val
looper_actionId
=
listOf
(
ACTION_APP_PROCESS
,
ACTION_APP_PROCESS
,
)
)
var
actionIdList
=
arrayListOf
<
String
>()
var
actionIdList
=
arrayListOf
<
String
>()
fun
getNextActionId
():
String
{
fun
getNextActionId
():
String
{
if
(
actionIdList
.
isEmpty
())
{
if
(
actionIdList
.
isEmpty
())
{
actionIdList
.
addAll
(
looper_actionId
)
actionIdList
.
addAll
(
looper_actionId
)
}
}
val
next
=
actionIdList
[
0
]
val
next
=
actionIdList
[
0
]
actionIdList
.
removeAt
(
0
)
actionIdList
.
removeAt
(
0
)
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
// return NOTIFICATION_ACTION_WEATHER
// return NOTIFICATION_ACTION_WEATHER
}
return
next
}
}
return
next
}
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/fcm/PopupConstObject.kt
View file @
3f40efe6
...
@@ -10,7 +10,6 @@ object PopupConstObject {
...
@@ -10,7 +10,6 @@ object PopupConstObject {
const
val
POPUP_WHERE_ALARM
=
"Alarm"
const
val
POPUP_WHERE_ALARM
=
"Alarm"
const
val
POPUP_WHERE_WORK_MANAGER
=
"workmanager"
const
val
POPUP_WHERE_WORK_MANAGER
=
"workmanager"
const
val
POPUP_WHERE_MEDIA_CHANGE
=
"media_change"
const
val
POPUP_WHERE_HOVER_HANDLE
=
"hover_handle"
//悬停调用
const
val
POPUP_WHERE_HOVER_HANDLE
=
"hover_handle"
//悬停调用
//推送总开关 0 关 1开
//推送总开关 0 关 1开
...
@@ -44,4 +43,13 @@ object PopupConstObject {
...
@@ -44,4 +43,13 @@ object PopupConstObject {
AppPreferences
.
getInstance
().
put
(
"topic_number"
,
value
,
true
)
AppPreferences
.
getInstance
().
put
(
"topic_number"
,
value
,
true
)
}
}
const
val
ACTION_STAY_HOME
=
"action_stay_home"
const
val
ACTION_STAY_MY_CODE
=
"action_stay_my_code"
const
val
ACTION_STAY_SHARE
=
"action_stay_share"
const
val
ACTION_STAY_SETTING
=
"action_stay_setting"
const
val
ACTION_SHARE_LOCATION
=
"action_share_location"
const
val
ACTION_ENABLE_LOCATION
=
"action_enable_location"
const
val
ACTION_COPY_CODE
=
"action_copy_code"
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/fcm/alarm/AlarmJobReceiver.kt
View file @
3f40efe6
...
@@ -4,12 +4,12 @@ import android.annotation.SuppressLint
...
@@ -4,12 +4,12 @@ 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.locationsharewhite.BuildConfig
import
com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import
com.base.locationsharewhite.fcm.PopupConstObject
import
com.base.locationsharewhite.fcm.PopupConstObject
import
com.base.pdfreaderallpdfreader.BuildConfig
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.pdfreaderallpdfreader.fcm.NotificationUiUtil.sendNotificationIfCan
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.pdfreaderallpdfreader.helper.EventUtils
import
com.base.locationsharewhite.utils.LogEx
import
com.base.pdfreaderallpdfreader.utils.AppPreferences
import
com.base.pdfreaderallpdfreader.utils.LogEx
class
AlarmJobReceiver
:
BroadcastReceiver
()
{
class
AlarmJobReceiver
:
BroadcastReceiver
()
{
...
...
app/src/main/java/com/base/locationsharewhite/fcm/alarm/AlarmUtils.kt
View file @
3f40efe6
package
com.base.
pdfreaderallpdfreader
.fcm.alarm
package
com.base.
locationsharewhite
.fcm.alarm
import
android.app.AlarmManager
import
android.app.AlarmManager
import
android.app.PendingIntent
import
android.app.PendingIntent
import
android.app.job.JobService
import
android.app.job.JobService
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
com.base.pdfreaderallpdfreader.BuildConfig
import
com.base.locationsharewhite.BuildConfig
import
com.base.pdfreaderallpdfreader.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
com.base.locationsharewhite.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
com.base.pdfreaderallpdfreader.service.StayJobService.Companion.startJob
import
com.base.locationsharewhite.service.StayJobService.Companion.startJob
import
com.base.pdfreaderallpdfreader.fcm.alarm.AlarmJobReceiver
import
java.util.Calendar
import
java.util.Calendar
object
AlarmUtils
{
object
AlarmUtils
{
...
...
app/src/main/java/com/base/locationsharewhite/helper/config/ConstConfig.kt
View file @
3f40efe6
...
@@ -27,5 +27,4 @@ object ConstConfig {
...
@@ -27,5 +27,4 @@ object ConstConfig {
const
val
openAdmobId
=
"/6499/example/app-open"
const
val
openAdmobId
=
"/6499/example/app-open"
const
val
bannerAdmobId
=
"ca-app-pub-3940256099942544/9214581111"
const
val
bannerAdmobId
=
"ca-app-pub-3940256099942544/9214581111"
const
val
ACTION_APP_PROCESS
=
""
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/service/StayJobService.kt
0 → 100644
View file @
3f40efe6
package
com.base.locationsharewhite.service
import
android.app.Notification
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.app.job.JobInfo
import
android.app.job.JobParameters
import
android.app.job.JobScheduler
import
android.app.job.JobService
import
android.content.ComponentName
import
android.content.Context
import
android.content.Intent
import
android.content.pm.ServiceInfo
import
android.graphics.BitmapFactory
import
android.graphics.drawable.Icon
import
android.os.Build
import
android.os.CountDownTimer
import
android.provider.MediaStore
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.graphics.drawable.IconCompat
import
androidx.work.Configuration
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.service.StayNotification.createPermanentNotification
import
com.base.locationsharewhite.utils.LogEx
import
kotlin.random.Random
/**
* 常驻通知栏
*/
class
StayJobService
:
JobService
()
{
init
{
val
builder
=
Configuration
.
Builder
()
builder
.
setJobSchedulerJobIdRange
(
0
,
1000
)
}
private
val
TAG
=
"StayJobService"
companion
object
{
private
val
NOTIFICATION_PERMANENT_ID
=
186
var
isRunning
=
false
private
const
val
JOB_INFO_ID
:
Int
=
101
private
const
val
JOB_PERIODIC
:
Long
=
5
*
1000L
fun
Context
.
startJob
()
{
if
(
isRunning
)
return
val
jobScheduler
=
getSystemService
(
JOB_SCHEDULER_SERVICE
)
as
JobScheduler
val
componentName
=
ComponentName
(
this
,
StayJobService
::
class
.
java
)
val
jobInfo
=
JobInfo
.
Builder
(
JOB_INFO_ID
,
componentName
)
.
setMinimumLatency
(
30000
)
.
build
()
jobScheduler
.
schedule
(
jobInfo
)
}
}
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
return
super
.
onStartCommand
(
intent
,
flags
,
startId
)
}
private
fun
startForeground
()
{
val
notification
=
createPermanentNotification
(
applicationContext
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
startForeground
(
NOTIFICATION_PERMANENT_ID
,
notification
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
}
else
{
startForeground
(
NOTIFICATION_PERMANENT_ID
,
notification
)
}
isRunning
=
true
}
private
fun
notifyForeground
()
{
val
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
notificationManager
.
notify
(
NOTIFICATION_PERMANENT_ID
,
createPermanentNotification
(
applicationContext
)
)
}
override
fun
onDestroy
()
{
isRunning
=
false
super
.
onDestroy
()
}
override
fun
onCreate
()
{
LogEx
.
logDebug
(
TAG
,
"onCreate isRunning=$isRunning"
)
if
(!
isRunning
)
{
isRunning
=
true
startForeground
()
Timer
().
start
()
}
super
.
onCreate
()
}
override
fun
onStartJob
(
params
:
JobParameters
?):
Boolean
{
return
true
}
override
fun
onStopJob
(
params
:
JobParameters
?):
Boolean
{
return
false
}
private
inner
class
Timer
()
:
CountDownTimer
(
30000
,
1000
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
}
override
fun
onFinish
()
{
notifyForeground
()
Timer
().
start
()
}
}
}
app/src/main/java/com/base/locationsharewhite/service/StayNotification.kt
0 → 100644
View file @
3f40efe6
package
com.base.locationsharewhite.service
import
android.app.Notification
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.content.Context
import
android.content.Intent
import
android.graphics.BitmapFactory
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.locationsharewhite.R
import
com.base.locationsharewhite.ui.main.MainActivity
object
StayNotification
{
private
fun
customRemoteViews
(
contentView
:
RemoteViews
,
expendView
:
RemoteViews
)
{
// val requestCode1 = Random.nextInt(1800)
// val intent1 = Intent(context, MyStartActivity::class.java).apply {
// putExtra("actionId", ConstObject.NOTIFICATION_ACTION_LOG)
// }
// val pendingIntent1 =
// PendingIntent.getActivity(
// context,
// requestCode1,
// intent1,
// PendingIntent.FLAG_IMMUTABLE
// )
// contentView.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
createPermanentNotification
(
context
:
Context
):
Notification
{
val
channelName
=
"Permanent Foreground Service Channel"
val
channelId
=
"permanent_channel"
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
val
expendView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
customRemoteViews
(
contentView
,
expendView
)
val
builder
=
NotificationCompat
.
Builder
(
context
,
channelId
)
val
smallIcon
=
IconCompat
.
createFromIcon
(
context
,
Icon
.
createWithResource
(
context
,
R
.
mipmap
.
logo
)
)
smallIcon
?.
let
{
builder
.
setSmallIcon
(
smallIcon
)
//设置状态栏内的小图标
}
val
nfIntent
=
Intent
(
context
,
MainActivity
::
class
.
java
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
0
,
nfIntent
,
PendingIntent
.
FLAG_IMMUTABLE
)
builder
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
context
.
resources
,
R
.
mipmap
.
logo
)
)
builder
.
setContentTitle
(
context
.
resources
.
getString
(
R
.
string
.
app_name
))
builder
.
setContentIntent
(
pendingIntent
)
//设置PendingIntent
builder
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PRIVATE
)
//设置通知公开可见
builder
.
setAutoCancel
(
false
)
builder
.
setOngoing
(
true
)
builder
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
//优先级为:重要通知
builder
.
setWhen
(
System
.
currentTimeMillis
())
builder
.
setCustomContentView
(
contentView
)
builder
.
setCustomBigContentView
(
expendView
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
channelId
,
channelName
,
NotificationManager
.
IMPORTANCE_LOW
)
channel
.
lockscreenVisibility
=
1
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
notificationManager
.
createNotificationChannel
(
channel
)
builder
.
setChannelId
(
channelId
)
}
return
builder
.
build
()
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ui/splash/SplashActivity.kt
View file @
3f40efe6
...
@@ -11,9 +11,8 @@ import com.base.locationsharewhite.bean.ConstObject.ifAgreePrivacy
...
@@ -11,9 +11,8 @@ import com.base.locationsharewhite.bean.ConstObject.ifAgreePrivacy
import
com.base.locationsharewhite.bean.ConstObject.isFirstLauncher
import
com.base.locationsharewhite.bean.ConstObject.isFirstLauncher
import
com.base.locationsharewhite.databinding.ActivitySplashBinding
import
com.base.locationsharewhite.databinding.ActivitySplashBinding
import
com.base.locationsharewhite.fcm.NotificationHoverUtils
import
com.base.locationsharewhite.fcm.NotificationHoverUtils
import
com.base.locationsharewhite.fcm.PopupConstObject
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.config.ConstConfig
import
com.base.locationsharewhite.service.StayNotificationService.Companion.startStayNotification
import
com.base.locationsharewhite.ui.howuse.HowUseActivity
import
com.base.locationsharewhite.ui.howuse.HowUseActivity
import
com.base.locationsharewhite.ui.main.LocationCodeActivity
import
com.base.locationsharewhite.ui.main.LocationCodeActivity
import
com.base.locationsharewhite.ui.main.LocationShareActivity
import
com.base.locationsharewhite.ui.main.LocationShareActivity
...
@@ -40,16 +39,15 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
...
@@ -40,16 +39,15 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
override
val
binding
:
ActivitySplashBinding
by
lazy
{
override
val
binding
:
ActivitySplashBinding
by
lazy
{
ActivitySplashBinding
.
inflate
(
layoutInflater
)
ActivitySplashBinding
.
inflate
(
layoutInflater
)
}
}
private
var
actionId
:
Int
?
=
null
private
var
actionId
:
String
?
=
null
override
fun
initView
()
{
override
fun
initView
()
{
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
splashPresenter
=
SplashPresenter
(
this
)
splashPresenter
=
SplashPresenter
(
this
)
startStayNotification
()
actionId
=
intent
.
extras
?.
getString
(
"actionId"
)
actionId
=
intent
.
extras
?.
getInt
(
"actionId"
)
LogEx
.
logDebug
(
TAG
,
"actionId=$actionId"
)
LogEx
.
logDebug
(
TAG
,
"actionId=$actionId"
)
if
(
actionId
!=
null
)
{
if
(
actionId
!=
null
)
{
NotificationHoverUtils
.
stopNotificationHandler
()
NotificationHoverUtils
.
stopNotificationHandler
()
...
@@ -122,45 +120,45 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
...
@@ -122,45 +120,45 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
}
}
private
fun
handleActionIdJump
()
{
private
fun
handleActionIdJump
()
{
actionId
=
intent
.
extras
?.
get
Int
(
"actionId"
)
actionId
=
intent
.
extras
?.
get
String
(
"actionId"
)
LogEx
.
logDebug
(
TAG
,
"handleActionIdJump actionId=$actionId"
)
LogEx
.
logDebug
(
TAG
,
"handleActionIdJump actionId=$actionId"
)
when
(
actionId
)
{
when
(
actionId
)
{
ConstConfig
.
ACTION_STAY_HOME
->
{
PopupConstObject
.
ACTION_STAY_HOME
->
{
startActivity
(
Intent
(
this
,
MainActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
MainActivity
::
class
.
java
).
apply
{
putExtra
(
"actionId"
,
actionId
)
putExtra
(
"actionId"
,
actionId
)
})
})
}
}
ConstConfig
.
ACTION_STAY_MY_CODE
->
{
PopupConstObject
.
ACTION_STAY_MY_CODE
->
{
startActivity
(
Intent
(
this
,
LocationCodeActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
LocationCodeActivity
::
class
.
java
).
apply
{
// putExtra("actionId", actionId)
// putExtra("actionId", actionId)
})
})
}
}
ConstConfig
.
ACTION_STAY_SHARE
->
{
PopupConstObject
.
ACTION_STAY_SHARE
->
{
startActivity
(
Intent
(
this
,
LocationShareActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
LocationShareActivity
::
class
.
java
).
apply
{
// putExtra("actionId", actionId)
// putExtra("actionId", actionId)
})
})
}
}
ConstConfig
.
ACTION_STAY_SETTING
->
{
PopupConstObject
.
ACTION_STAY_SETTING
->
{
startActivity
(
Intent
(
this
,
SettingActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
SettingActivity
::
class
.
java
).
apply
{
// putExtra("actionId", actionId)
// putExtra("actionId", actionId)
})
})
}
}
ConstConfig
.
ACTION_SHARE_LOCATION
->
{
PopupConstObject
.
ACTION_SHARE_LOCATION
->
{
startActivity
(
Intent
(
this
,
LocationShareActivity
::
class
.
java
).
apply
{})
startActivity
(
Intent
(
this
,
LocationShareActivity
::
class
.
java
).
apply
{})
}
}
ConstConfig
.
ACTION_ENABLE_LOCATION
->
{
PopupConstObject
.
ACTION_ENABLE_LOCATION
->
{
startActivity
(
Intent
(
this
,
MainActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
MainActivity
::
class
.
java
).
apply
{
putExtra
(
"actionId"
,
actionId
)
putExtra
(
"actionId"
,
actionId
)
})
})
}
}
ConstConfig
.
ACTION_COPY_CODE
->
{
PopupConstObject
.
ACTION_COPY_CODE
->
{
startActivity
(
Intent
(
this
,
LocationCodeActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
LocationCodeActivity
::
class
.
java
).
apply
{
putExtra
(
"actionId"
,
actionId
)
putExtra
(
"actionId"
,
actionId
)
})
})
...
...
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