优化
This commit is contained in:
@@ -49,9 +49,10 @@ object AppConst {
|
|||||||
const val notificationIdRead = -1122391
|
const val notificationIdRead = -1122391
|
||||||
const val notificationIdAudio = -1122392
|
const val notificationIdAudio = -1122392
|
||||||
const val notificationIdCache = -1122393
|
const val notificationIdCache = -1122393
|
||||||
const val notificationIdWeb = -1122394
|
const val notificationIdExport = -1122394
|
||||||
const val notificationIdDownload = -1122395
|
const val notificationIdWeb = -1122395
|
||||||
const val notificationIdCheckSource = -1122395
|
const val notificationIdDownload = -1122396
|
||||||
|
const val notificationIdCheckSource = -1122397
|
||||||
|
|
||||||
const val imagePathKey = "imagePath"
|
const val imagePathKey = "imagePath"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.legado.app.service
|
package io.legado.app.service
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
@@ -122,33 +123,28 @@ class ExportBookService : BaseService() {
|
|||||||
exportMsg.clear()
|
exportMsg.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingPermission")
|
||||||
override fun upNotification() {
|
override fun upNotification() {
|
||||||
val notification = NotificationCompat.Builder(this, AppConst.channelIdDownload)
|
val notification = NotificationCompat.Builder(this, AppConst.channelIdDownload)
|
||||||
.setSmallIcon(R.drawable.ic_export)
|
.setSmallIcon(R.drawable.ic_export)
|
||||||
.setContentTitle(getString(R.string.export_book))
|
.setContentTitle(getString(R.string.export_book))
|
||||||
.setContentIntent(activityPendingIntent<CacheActivity>("cacheActivity"))
|
.setContentIntent(activityPendingIntent<CacheActivity>("cacheActivity"))
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
.setContentText(notificationContent)
|
||||||
if (exportJob?.isActive == true) {
|
if (exportJob?.isActive == true) {
|
||||||
notification.setOngoing(true)
|
|
||||||
notification.addAction(
|
notification.addAction(
|
||||||
R.drawable.ic_stop_black_24dp,
|
R.drawable.ic_stop_black_24dp,
|
||||||
getString(R.string.cancel),
|
getString(R.string.cancel),
|
||||||
servicePendingIntent<ExportBookService>(IntentAction.stop)
|
servicePendingIntent<ExportBookService>(IntentAction.stop)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
notification.addAction(
|
||||||
stopForeground(STOP_FOREGROUND_DETACH)
|
R.drawable.ic_stop_black_24dp,
|
||||||
} else {
|
getString(R.string.close),
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
stopForeground(false)
|
|
||||||
}
|
|
||||||
notification.setOngoing(false)
|
|
||||||
notification.setDeleteIntent(
|
|
||||||
servicePendingIntent<ExportBookService>(IntentAction.stop)
|
servicePendingIntent<ExportBookService>(IntentAction.stop)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
notification.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
startForeground(AppConst.notificationIdExport, notification.build())
|
||||||
notification.setContentText(notificationContent)
|
|
||||||
startForeground(AppConst.notificationIdCache, notification.build())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun export() {
|
private fun export() {
|
||||||
|
|||||||
Reference in New Issue
Block a user