Skip to content

Commit 0ff5c7e

Browse files
committed
优化通知条的提示
1 parent 25db88e commit 0ff5c7e

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

app/src/main/java/me/teble/xposed/autodaily/dex/struct/StringDataItem.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class StringDataItem {
2727
fun parser(src: ByteArray?, index: Int): StringDataItem {
2828
val item = StringDataItem()
2929
val idx = intArrayOf(index)
30-
// System.out.println(bytesToHexString(copyByte(src, index[0], 4)));
3130
item.size = ByteUtils.readUleb128(src, idx)
3231
item.dataBytes = ByteUtils.readByteString(src, idx)
3332
item.data = String(item.dataBytes)

app/src/main/java/me/teble/xposed/autodaily/hook/CoreServiceHook.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class CoreServiceHook : BaseHook() {
143143
runtimeTasks.remove(it)
144144
}
145145
}
146-
XANotification.setContent("签到执行完毕", false)
146+
XANotification.setContent("签到执行完毕", onGoing = false, isTask = true)
147147
withContext(Dispatchers.IO) {
148148
delay(5000)
149149
}

app/src/main/java/me/teble/xposed/autodaily/hook/SplashActivityHook.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SplashActivityHook : BaseHook() {
7070
}
7171
}
7272

73-
lateinit var appUpdateDialog: AlertDialog
73+
private lateinit var appUpdateDialog: AlertDialog
7474

7575
suspend fun Activity.openAppUpdateDialog() {
7676
withContext(Dispatchers.IO) {
@@ -116,7 +116,7 @@ suspend fun Activity.openAppUpdateDialog() {
116116
}
117117
}
118118

119-
lateinit var configUpdateDialog: AlertDialog
119+
private lateinit var configUpdateDialog: AlertDialog
120120

121121
suspend fun Activity.openConfigUpdateLog() {
122122
withContext(Dispatchers.IO) {

app/src/main/java/me/teble/xposed/autodaily/hook/notification/XANotification.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import me.teble.xposed.autodaily.ui.ConfUnit
1717

1818
object XANotification {
1919

20-
private const val NOTIFICATION_ID = 1101
20+
private const val NOTIFICATION_ID = 0
2121
private const val CHANNEL_ID = "me.teble.xposed.autodaily.XA_FOREST_NOTIFY_CHANNEL"
22+
private var atomicId = 1
2223

2324
private val notificationManager by lazy {
2425
hostContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@@ -35,10 +36,9 @@ object XANotification {
3536

3637
initNotification(hostContext)
3738
isStart = true
38-
notificationManager.notify(NOTIFICATION_ID, mNotification)
3939
}
4040

41-
fun setContent(content: String, onGoing: Boolean = true, bigText: Boolean = false) {
41+
fun setContent(content: String, onGoing: Boolean = true, bigText: Boolean = false, isTask: Boolean = true) {
4242
if (!enabled) return
4343
if (!isStart) start()
4444

@@ -53,7 +53,7 @@ object XANotification {
5353
}
5454
setOngoing(onGoing)
5555
}.build()
56-
notificationManager.notify(NOTIFICATION_ID, mNotification)
56+
notificationManager.notify(if (isTask) atomicId++ else NOTIFICATION_ID, mNotification)
5757
}
5858

5959
fun stop() {
@@ -63,6 +63,12 @@ object XANotification {
6363
isStart = false
6464
}
6565

66+
fun cancelAll() {
67+
if (!isStart) return
68+
notificationManager.cancelAll()
69+
isStart = false
70+
}
71+
6672
private fun initNotification(context: Context) {
6773
if (XANotification::mNotification.isInitialized) return
6874

app/src/main/java/me/teble/xposed/autodaily/task/filter/GroupTaskFilterChain.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GroupTaskFilterChain(
5757
continue
5858
}
5959
try {
60-
// 进行异常计数,超过一定次数,当天不再执行该任务
60+
XANotification.setContent("正在执行任务${task.id}")
6161
TaskUtil.execute(reqType, task, relayTaskMap, env.toMutableMap())
6262
} catch (e: SocketTimeoutException) {
6363
LogUtil.e(e, "执行任务${task.id}异常: ")

0 commit comments

Comments
 (0)