mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
Merge branch 'gedoor:master' into master
This commit is contained in:
commit
a69e9f5f9e
@ -261,8 +261,11 @@ object WebBook {
|
|||||||
Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
|
Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
|
||||||
return bookChapter.url
|
return bookChapter.url
|
||||||
}
|
}
|
||||||
//章节名为卷名时 且 章节url没获取到,返回空白
|
if(bookChapter.isVolume && bookChapter.url == bookChapter.title) {
|
||||||
if(bookChapter.isVolume && bookChapter.url == bookChapter.title) return ""
|
//不返回空值,是为了过书源检测
|
||||||
|
Debug.log(bookSource.bookSourceUrl, "⇒一级目录正文,使用章节标题:${bookChapter.title}")
|
||||||
|
return bookChapter.title
|
||||||
|
}
|
||||||
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
|
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
|
||||||
BookContent.analyzeContent(
|
BookContent.analyzeContent(
|
||||||
scope = scope,
|
scope = scope,
|
||||||
|
@ -4,7 +4,6 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import io.legado.app.constant.AppLog
|
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.help.AppConfig
|
import io.legado.app.help.AppConfig
|
||||||
@ -42,7 +41,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
|
|||||||
val keycode: Int = keyEvent.keyCode
|
val keycode: Int = keyEvent.keyCode
|
||||||
val action: Int = keyEvent.action
|
val action: Int = keyEvent.action
|
||||||
if (action == KeyEvent.ACTION_DOWN) {
|
if (action == KeyEvent.ACTION_DOWN) {
|
||||||
AppLog.put("mediaButton $action")
|
|
||||||
when (keycode) {
|
when (keycode) {
|
||||||
KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
|
KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
|
||||||
if (context.getPrefBoolean("mediaButtonPerNext", false)) {
|
if (context.getPrefBoolean("mediaButtonPerNext", false)) {
|
||||||
@ -88,7 +86,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
|
|||||||
LifecycleHelp.isExistActivity(AudioPlayActivity::class.java) ->
|
LifecycleHelp.isExistActivity(AudioPlayActivity::class.java) ->
|
||||||
postEvent(EventBus.MEDIA_BUTTON, true)
|
postEvent(EventBus.MEDIA_BUTTON, true)
|
||||||
else -> if (AppConfig.mediaButtonOnExit || LifecycleHelp.activitySize() > 0 || !isMediaKey) {
|
else -> if (AppConfig.mediaButtonOnExit || LifecycleHelp.activitySize() > 0 || !isMediaKey) {
|
||||||
AppLog.put("readAloud start Service")
|
|
||||||
if (ReadBook.book != null) {
|
if (ReadBook.book != null) {
|
||||||
ReadBook.readAloud()
|
ReadBook.readAloud()
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,18 +279,15 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
override fun onAudioFocusChange(focusChange: Int) {
|
override fun onAudioFocusChange(focusChange: Int) {
|
||||||
when (focusChange) {
|
when (focusChange) {
|
||||||
AudioManager.AUDIOFOCUS_GAIN -> {
|
AudioManager.AUDIOFOCUS_GAIN -> {
|
||||||
AppLog.put("重新获得焦点, 恢复播放")
|
|
||||||
audioFocusLossTransient = false
|
audioFocusLossTransient = false
|
||||||
if (!pause) resumeReadAloud()
|
if (!pause) resumeReadAloud()
|
||||||
}
|
}
|
||||||
AudioManager.AUDIOFOCUS_LOSS -> {
|
AudioManager.AUDIOFOCUS_LOSS -> {
|
||||||
AppLog.put("永久丢失焦点")
|
|
||||||
if (audioFocusLossTransient) {
|
if (audioFocusLossTransient) {
|
||||||
pauseReadAloud(true)
|
pauseReadAloud(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
|
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
|
||||||
AppLog.put("暂时丢失焦点, 暂停播放")
|
|
||||||
audioFocusLossTransient = true
|
audioFocusLossTransient = true
|
||||||
if (!pause) pauseReadAloud(false)
|
if (!pause) pauseReadAloud(false)
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,10 @@ class AppLogDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
|||||||
|
|
||||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||||
when (item?.itemId) {
|
when (item?.itemId) {
|
||||||
R.id.menu_clear -> AppLog.clear()
|
R.id.menu_clear -> {
|
||||||
|
AppLog.clear()
|
||||||
|
adapter.clearItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ object ChapterProvider {
|
|||||||
}
|
}
|
||||||
lineIndex == layout.lineCount - 1 -> {
|
lineIndex == layout.lineCount - 1 -> {
|
||||||
//最后一行
|
//最后一行
|
||||||
textLine.text = "$words\n"
|
textLine.text = if(isVolumeTitle) "" else "$words\n"
|
||||||
isLastLine = true
|
isLastLine = true
|
||||||
//标题居中
|
//标题居中
|
||||||
val startX = if (isTitle && ReadBookConfig.titleMode == 1 || isVolumeTitle)
|
val startX = if (isTitle && ReadBookConfig.titleMode == 1 || isVolumeTitle)
|
||||||
@ -349,7 +349,7 @@ object ChapterProvider {
|
|||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
//中间行
|
//中间行
|
||||||
textLine.text = words
|
textLine.text = if(isVolumeTitle) "" else words
|
||||||
addCharsToLineMiddle(
|
addCharsToLineMiddle(
|
||||||
absStartX,
|
absStartX,
|
||||||
textLine,
|
textLine,
|
||||||
|
@ -140,11 +140,16 @@ object NetworkUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBaseUrl(url: String?): String? {
|
fun getBaseUrl(url: String?): String? {
|
||||||
if (url == null || !url.startsWith("http")) return null
|
url ?: return null
|
||||||
val index = url.indexOf("/", 9)
|
if (url.startsWith("http://", true)
|
||||||
return if (index == -1) {
|
|| url.startsWith("https://", true)
|
||||||
url
|
) {
|
||||||
} else url.substring(0, index)
|
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
|
if (isIPAddress(host)) return baseUrl
|
||||||
//PublicSuffixDatabase处理域名
|
//PublicSuffixDatabase处理域名
|
||||||
PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) ?: baseUrl
|
PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) ?: baseUrl
|
||||||
}.getOrDefault(url)
|
}.getOrDefault(baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user