Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
4e5caaf804
Merge e95db8ea1d into 9247d56cbd 2024-05-28 13:57:27 +08:00
2 changed files with 11 additions and 20 deletions

View File

@ -1,7 +1,6 @@
package io.legado.app.base package io.legado.app.base
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.IBinder import android.os.IBinder
import androidx.annotation.CallSuper import androidx.annotation.CallSuper
import androidx.lifecycle.LifecycleService import androidx.lifecycle.LifecycleService
@ -84,11 +83,9 @@ abstract class BaseService : LifecycleService() {
} }
} }
.request() .request()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { PermissionsCompat.Builder()
PermissionsCompat.Builder() .addPermissions(Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
.addPermissions(Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) .rationale(R.string.ignore_battery_permission_rationale)
.rationale(R.string.ignore_battery_permission_rationale) .request()
.request()
}
} }
} }

View File

@ -27,7 +27,6 @@ import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.ContentProcessor import io.legado.app.help.book.ContentProcessor
import io.legado.app.help.book.getExportFileName import io.legado.app.help.book.getExportFileName
import io.legado.app.help.book.isLocal import io.legado.app.help.book.isLocal
import io.legado.app.help.book.isLocalModified
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.model.localBook.LocalBook import io.legado.app.model.localBook.LocalBook
import io.legado.app.ui.book.cache.CacheActivity import io.legado.app.ui.book.cache.CacheActivity
@ -58,7 +57,6 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.ensureActive import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.flow.collectIndexed import kotlinx.coroutines.flow.collectIndexed
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import me.ag2s.epublib.domain.Author import me.ag2s.epublib.domain.Author
import me.ag2s.epublib.domain.Date import me.ag2s.epublib.domain.Date
@ -123,10 +121,7 @@ class ExportBookService : BaseService() {
toastOnUi(it.localizedMessage) toastOnUi(it.localizedMessage)
} }
IntentAction.stop -> { IntentAction.stop -> stopSelf()
notificationManager.cancel(NotificationId.ExportBook)
stopSelf()
}
} }
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }
@ -135,9 +130,6 @@ class ExportBookService : BaseService() {
super.onDestroy() super.onDestroy()
exportProgress.clear() exportProgress.clear()
exportMsg.clear() exportMsg.clear()
waitExportBooks.keys.forEach {
postEvent(EventBus.EXPORT_BOOK, it)
}
} }
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
@ -176,7 +168,7 @@ class ExportBookService : BaseService() {
return return
} }
exportJob = lifecycleScope.launch(IO) { exportJob = lifecycleScope.launch(IO) {
while (isActive) { while (true) {
val (bookUrl, exportConfig) = waitExportBooks.entries.firstOrNull() ?: let { val (bookUrl, exportConfig) = waitExportBooks.entries.firstOrNull() ?: let {
notificationContentText = "导出完成" notificationContentText = "导出完成"
upExportNotification(true) upExportNotification(true)
@ -208,7 +200,6 @@ class ExportBookService : BaseService() {
} }
exportMsg[book.bookUrl] = getString(R.string.export_success) exportMsg[book.bookUrl] = getString(R.string.export_success)
} catch (e: Throwable) { } catch (e: Throwable) {
ensureActive()
exportMsg[bookUrl] = e.localizedMessage ?: "ERROR" exportMsg[bookUrl] = e.localizedMessage ?: "ERROR"
AppLog.put("导出书籍<${book?.name ?: bookUrl}>出错", e) AppLog.put("导出书籍<${book?.name ?: bookUrl}>出错", e)
} finally { } finally {
@ -220,7 +211,10 @@ class ExportBookService : BaseService() {
} }
private fun refreshChapterList(book: Book) { private fun refreshChapterList(book: Book) {
if (!book.isLocal || !book.isLocalModified()) { if (!book.isLocal) {
return
}
if (LocalBook.getLastModified(book).getOrDefault(0L) < book.latestChapterTime) {
return return
} }
kotlin.runCatching { kotlin.runCatching {