This commit is contained in:
kunfei
2023-07-29 23:03:05 +08:00
parent 0f0b7b89a2
commit d43d61647a
2 changed files with 12 additions and 15 deletions

View File

@@ -49,9 +49,10 @@ object AppConst {
const val notificationIdRead = -1122391
const val notificationIdAudio = -1122392
const val notificationIdCache = -1122393
const val notificationIdWeb = -1122394
const val notificationIdDownload = -1122395
const val notificationIdCheckSource = -1122395
const val notificationIdExport = -1122394
const val notificationIdWeb = -1122395
const val notificationIdDownload = -1122396
const val notificationIdCheckSource = -1122397
const val imagePathKey = "imagePath"

View File

@@ -1,5 +1,6 @@
package io.legado.app.service
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
@@ -122,33 +123,28 @@ class ExportBookService : BaseService() {
exportMsg.clear()
}
@SuppressLint("MissingPermission")
override fun upNotification() {
val notification = NotificationCompat.Builder(this, AppConst.channelIdDownload)
.setSmallIcon(R.drawable.ic_export)
.setContentTitle(getString(R.string.export_book))
.setContentIntent(activityPendingIntent<CacheActivity>("cacheActivity"))
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentText(notificationContent)
if (exportJob?.isActive == true) {
notification.setOngoing(true)
notification.addAction(
R.drawable.ic_stop_black_24dp,
getString(R.string.cancel),
servicePendingIntent<ExportBookService>(IntentAction.stop)
)
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
stopForeground(STOP_FOREGROUND_DETACH)
} else {
@Suppress("DEPRECATION")
stopForeground(false)
}
notification.setOngoing(false)
notification.setDeleteIntent(
notification.addAction(
R.drawable.ic_stop_black_24dp,
getString(R.string.close),
servicePendingIntent<ExportBookService>(IntentAction.stop)
)
}
notification.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
notification.setContentText(notificationContent)
startForeground(AppConst.notificationIdCache, notification.build())
startForeground(AppConst.notificationIdExport, notification.build())
}
private fun export() {