@@ -27,8 +27,8 @@ data class Notif(
27
27
val channel : NotifChannel = NotifChannel .Default ,
28
28
val id : Int ,
29
29
val smallIcon : Int = SafeR .ic_status,
30
- val title : String = META .appName ,
31
- val text : String ,
30
+ val title : String ,
31
+ val text : String? = null ,
32
32
val ongoing : Boolean ,
33
33
val autoCancel : Boolean ,
34
34
val uri : String? = null ,
@@ -45,28 +45,29 @@ data class Notif(
45
45
},
46
46
PendingIntent .FLAG_IMMUTABLE or PendingIntent .FLAG_UPDATE_CURRENT
47
47
)
48
- val deleteIntent = stopService?.let {
49
- PendingIntent .getBroadcast(
48
+ val notification = NotificationCompat .Builder (app, channel.id)
49
+ .setSmallIcon(smallIcon)
50
+ .setContentTitle(title)
51
+ .setContentText(text)
52
+ .setContentIntent(contextIntent)
53
+ .setOngoing(ongoing)
54
+ .setAutoCancel(autoCancel)
55
+ if (stopService != null ) {
56
+ val deleteIntent = PendingIntent .getBroadcast(
50
57
app,
51
58
0 ,
52
59
Intent ().apply {
53
60
action = StopServiceReceiver .STOP_ACTION
54
- putExtra(StopServiceReceiver .STOP_ACTION , it .componentName.className)
61
+ putExtra(StopServiceReceiver .STOP_ACTION , stopService .componentName.className)
55
62
setPackage(META .appId)
56
63
},
57
64
PendingIntent .FLAG_IMMUTABLE or PendingIntent .FLAG_UPDATE_CURRENT
58
65
)
66
+ notification
67
+ .setDeleteIntent(deleteIntent)
68
+ .addAction(0 , " 停止" , deleteIntent)
59
69
}
60
- val notification = NotificationCompat .Builder (app, channel.id)
61
- .setSmallIcon(smallIcon)
62
- .setContentTitle(title)
63
- .setContentText(text)
64
- .setContentIntent(contextIntent)
65
- .setDeleteIntent(deleteIntent)
66
- .setOngoing(ongoing)
67
- .setAutoCancel(autoCancel)
68
- .build()
69
- return notification
70
+ return notification.build()
70
71
}
71
72
72
73
fun notifySelf () {
@@ -91,14 +92,16 @@ data class Notif(
91
92
92
93
val abNotif = Notif (
93
94
id = 100 ,
95
+ title = " GKD" ,
94
96
text = " 无障碍正在运行" ,
95
97
ongoing = true ,
96
98
autoCancel = false ,
97
99
)
98
100
99
101
val screenshotNotif = Notif (
100
102
id = 101 ,
101
- text = " 截屏服务正在运行" ,
103
+ title = " 截屏服务正在运行" ,
104
+ text = " 保存快照时截取屏幕" ,
102
105
ongoing = true ,
103
106
autoCancel = false ,
104
107
uri = " gkd://page/1" ,
@@ -107,7 +110,8 @@ val screenshotNotif = Notif(
107
110
108
111
val floatingNotif = Notif (
109
112
id = 102 ,
110
- text = " 悬浮按钮正在显示" ,
113
+ title = " 悬浮窗服务正在运行" ,
114
+ text = " 点击按钮捕获快照" ,
111
115
ongoing = true ,
112
116
autoCancel = false ,
113
117
uri = " gkd://page/1" ,
@@ -116,7 +120,7 @@ val floatingNotif = Notif(
116
120
117
121
val httpNotif = Notif (
118
122
id = 103 ,
119
- text = " HTTP服务正在运行" ,
123
+ title = " HTTP服务正在运行" ,
120
124
ongoing = true ,
121
125
autoCancel = false ,
122
126
uri = " gkd://page/1" ,
@@ -125,15 +129,16 @@ val httpNotif = Notif(
125
129
126
130
val snapshotActionNotif = Notif (
127
131
id = 105 ,
128
- text = " 快照服务正在运行" ,
132
+ title = " 快照服务正在运行" ,
133
+ text = " 捕获快照完成后自动关闭" ,
129
134
ongoing = true ,
130
135
autoCancel = false ,
131
136
)
132
137
133
138
val snapshotNotif = Notif (
134
139
channel = NotifChannel .Snapshot ,
135
140
id = 104 ,
136
- text = " 快照已保存至记录 " ,
141
+ title = " 快照已保存 " ,
137
142
ongoing = false ,
138
143
autoCancel = true ,
139
144
uri = " gkd://page/2" ,
0 commit comments