Merge branch 'gedoor:master' into master

pull/1516/head
Xwite 3 years ago committed by GitHub
commit a69e9f5f9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt
  2. 3
      app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt
  3. 3
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  4. 5
      app/src/main/java/io/legado/app/ui/about/AppLogDialog.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt
  6. 17
      app/src/main/java/io/legado/app/utils/NetworkUtils.kt

@ -261,8 +261,11 @@ object WebBook {
Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
return bookChapter.url
}
//章节名为卷名时 且 章节url没获取到,返回空白
if(bookChapter.isVolume && bookChapter.url == bookChapter.title) return ""
if(bookChapter.isVolume && bookChapter.url == bookChapter.title) {
//不返回空值,是为了过书源检测
Debug.log(bookSource.bookSourceUrl, "⇒一级目录正文,使用章节标题:${bookChapter.title}")
return bookChapter.title
}
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
BookContent.analyzeContent(
scope = scope,

@ -4,7 +4,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.view.KeyEvent
import io.legado.app.constant.AppLog
import io.legado.app.constant.EventBus
import io.legado.app.data.appDb
import io.legado.app.help.AppConfig
@ -42,7 +41,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
val keycode: Int = keyEvent.keyCode
val action: Int = keyEvent.action
if (action == KeyEvent.ACTION_DOWN) {
AppLog.put("mediaButton $action")
when (keycode) {
KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
if (context.getPrefBoolean("mediaButtonPerNext", false)) {
@ -88,7 +86,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
LifecycleHelp.isExistActivity(AudioPlayActivity::class.java) ->
postEvent(EventBus.MEDIA_BUTTON, true)
else -> if (AppConfig.mediaButtonOnExit || LifecycleHelp.activitySize() > 0 || !isMediaKey) {
AppLog.put("readAloud start Service")
if (ReadBook.book != null) {
ReadBook.readAloud()
} else {

@ -279,18 +279,15 @@ abstract class BaseReadAloudService : BaseService(),
override fun onAudioFocusChange(focusChange: Int) {
when (focusChange) {
AudioManager.AUDIOFOCUS_GAIN -> {
AppLog.put("重新获得焦点, 恢复播放")
audioFocusLossTransient = false
if (!pause) resumeReadAloud()
}
AudioManager.AUDIOFOCUS_LOSS -> {
AppLog.put("永久丢失焦点")
if (audioFocusLossTransient) {
pauseReadAloud(true)
}
}
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
AppLog.put("暂时丢失焦点, 暂停播放")
audioFocusLossTransient = true
if (!pause) pauseReadAloud(false)
}

@ -50,7 +50,10 @@ class AppLogDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_clear -> AppLog.clear()
R.id.menu_clear -> {
AppLog.clear()
adapter.clearItems()
}
}
return true
}

@ -332,7 +332,7 @@ object ChapterProvider {
}
lineIndex == layout.lineCount - 1 -> {
//最后一行
textLine.text = "$words\n"
textLine.text = if(isVolumeTitle) "" else "$words\n"
isLastLine = true
//标题居中
val startX = if (isTitle && ReadBookConfig.titleMode == 1 || isVolumeTitle)
@ -349,7 +349,7 @@ object ChapterProvider {
}
else -> {
//中间行
textLine.text = words
textLine.text = if(isVolumeTitle) "" else words
addCharsToLineMiddle(
absStartX,
textLine,

@ -140,11 +140,16 @@ object NetworkUtils {
}
fun getBaseUrl(url: String?): String? {
if (url == null || !url.startsWith("http")) return null
val index = url.indexOf("/", 9)
return if (index == -1) {
url
} else url.substring(0, index)
url ?: return null
if (url.startsWith("http://", true)
|| url.startsWith("https://", true)
) {
val index = url.indexOf("/", 9)
return if (index == -1) {
url
} else url.substring(0, index)
}
return null
}
/**
@ -163,7 +168,7 @@ object NetworkUtils {
if (isIPAddress(host)) return baseUrl
//PublicSuffixDatabase处理域名
PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) ?: baseUrl
}.getOrDefault(url)
}.getOrDefault(baseUrl)
}
/**

Loading…
Cancel
Save