Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gedoor:master #180

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -806,15 +806,15 @@ class AnalyzeUrl(
fun setBody(value: String?) {
body = when {
value.isNullOrBlank() -> null
value.isJsonObject() -> GSON.fromJsonObject<Map<String, Any>>(value)
value.isJsonArray() -> GSON.fromJsonArray<Map<String, Any>>(value)
value.isJsonObject() -> GSON.fromJsonObject<Map<String, Any>>(value).getOrNull()
value.isJsonArray() -> GSON.fromJsonArray<Map<String, Any>>(value).getOrNull()
else -> value
}
}

fun getBody(): String? {
return body?.let {
if (it is String) it else GSON.toJson(it)
it as? String ?: GSON.toJson(it)
}
}

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/io/legado/app/service/AudioPlayService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.legado.app.constant.NotificationId
import io.legado.app.constant.Status
import io.legado.app.help.MediaHelp
import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.exoplayer.ExoPlayerHelper
import io.legado.app.help.glide.ImageLoader
import io.legado.app.model.AudioPlay
Expand Down Expand Up @@ -109,6 +110,7 @@ class AudioPlayService : BaseService(),
private var needResumeOnAudioFocusGain = false
private var position = AudioPlay.book?.durChapterPos ?: 0
private var dsJob: Job? = null
private var upNotificationJob: Coroutine<*>? = null
private var upPlayProgressJob: Job? = null
private var playSpeed: Float = 1f
private var cover: Bitmap =
Expand Down Expand Up @@ -196,6 +198,9 @@ class AudioPlayService : BaseService(),
AudioPlay.status = Status.STOP
postEvent(EventBus.AUDIO_STATE, Status.STOP)
AudioPlay.unregisterService()
upNotificationJob?.invokeOnCompletion {
notificationManager.cancel(NotificationId.AudioPlayService)
}
}

/**
Expand Down Expand Up @@ -602,7 +607,7 @@ class AudioPlayService : BaseService(),
}

private fun upAudioPlayNotification() {
execute {
upNotificationJob = execute {
try {
val notification = createNotification()
notificationManager.notify(NotificationId.AudioPlayService, notification.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import io.legado.app.constant.PreferKey
import io.legado.app.constant.Status
import io.legado.app.help.MediaHelp
import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.glide.ImageLoader
import io.legado.app.lib.permission.Permissions
import io.legado.app.lib.permission.PermissionsCompat
Expand Down Expand Up @@ -123,6 +124,7 @@ abstract class BaseReadAloudService : BaseService(),
private var needResumeOnCallStateIdle = false
private var registeredPhoneStateListener = false
private var dsJob: Job? = null
private var upNotificationJob: Coroutine<*>? = null
private var cover: Bitmap =
BitmapFactory.decodeResource(appCtx.resources, R.drawable.icon_read_book)
var pageChanged = false
Expand Down Expand Up @@ -198,6 +200,9 @@ abstract class BaseReadAloudService : BaseService(),
mediaSessionCompat.release()
ReadBook.uploadProgress()
unregisterPhoneStateListener(phoneStateListener)
upNotificationJob?.invokeOnCompletion {
notificationManager.cancel(NotificationId.ReadAloudService)
}
}

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Expand Down Expand Up @@ -504,7 +509,7 @@ abstract class BaseReadAloudService : BaseService(),
}

private fun upReadAloudNotification() {
execute {
upNotificationJob = execute {
try {
val notification = createNotification()
notificationManager.notify(NotificationId.ReadAloudService, notification.build())
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/legado/app/utils/LogUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object LogUtils {
}

val logger: Logger by lazy {
Logger.getLogger("Leagdo").apply {
Logger.getLogger("Legado").apply {
fileHandler?.let {
addHandler(it)
}
Expand Down
Loading