mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user