Merge branch 'master' into master
This commit is contained in:
@@ -163,6 +163,12 @@ object ReadBookConfig {
|
||||
|
||||
val config get() = if (shareLayout) shareConfig else durConfig
|
||||
|
||||
var bgAlpha: Int
|
||||
get() = config.bgAlpha
|
||||
set(value) {
|
||||
config.bgAlpha = value
|
||||
}
|
||||
|
||||
var pageAnim: Int
|
||||
get() = config.curPageAnim()
|
||||
set(value) {
|
||||
@@ -419,7 +425,8 @@ object ReadBookConfig {
|
||||
var name: String = "",
|
||||
var bgStr: String = "#EEEEEE",//白天背景
|
||||
var bgStrNight: String = "#000000",//夜间背景
|
||||
var bgStrEInk: String = "#FFFFFF",
|
||||
var bgStrEInk: String = "#FFFFFF",//EInk背景
|
||||
var bgAlpha: Int = 100,//背景透明度
|
||||
var bgType: Int = 0,//白天背景类型 0:颜色, 1:assets图片, 2其它图片
|
||||
var bgTypeNight: Int = 0,//夜间背景类型
|
||||
var bgTypeEInk: Int = 0,
|
||||
|
||||
@@ -33,7 +33,6 @@ object ThemeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun resolveDrawable(context: Context, @AttrRes attr: Int): Drawable? {
|
||||
val a = context.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||
return try {
|
||||
|
||||
@@ -180,22 +180,26 @@ class HttpReadAloudService : BaseReadAloudService(),
|
||||
is SocketTimeoutException, is ConnectException -> {
|
||||
removeSpeakCache(fileName)
|
||||
downloadErrorNo++
|
||||
if (playErrorNo > 5) {
|
||||
downloadErrorNo = 0
|
||||
createSilentSound(fileName)
|
||||
if (downloadErrorNo > 5) {
|
||||
val msg = "tts超时或连接错误超过5次\n${it.localizedMessage}"
|
||||
AppLog.put(msg, it)
|
||||
toastOnUi(msg)
|
||||
pauseReadAloud(true)
|
||||
} else {
|
||||
downloadAudio()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
removeSpeakCache(fileName)
|
||||
createSilentSound(fileName)
|
||||
downloadErrorNo++
|
||||
val msg = "tts下载错误\n${it.localizedMessage}"
|
||||
AppLog.put(msg, it)
|
||||
Timber.e(it)
|
||||
if (downloadErrorNo > 5) {
|
||||
pauseReadAloud(true)
|
||||
} else {
|
||||
createSilentSound(fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,6 +1005,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
upSystemUiVisibility()
|
||||
readView.upBg()
|
||||
readView.upStyle()
|
||||
readView.upBgAlpha()
|
||||
if (it) {
|
||||
ReadBook.loadContent(resetPageOffset = false)
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.SeekBar
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.jaredrummler.android.colorpicker.ColorPickerDialog
|
||||
import io.legado.app.R
|
||||
@@ -29,6 +30,7 @@ import io.legado.app.lib.theme.getPrimaryTextColor
|
||||
import io.legado.app.lib.theme.getSecondaryTextColor
|
||||
import io.legado.app.ui.book.read.ReadBookActivity
|
||||
import io.legado.app.ui.document.HandleFileContract
|
||||
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import timber.log.Timber
|
||||
@@ -108,6 +110,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
|
||||
ivImport.setColorFilter(primaryTextColor)
|
||||
ivExport.setColorFilter(primaryTextColor)
|
||||
ivDelete.setColorFilter(primaryTextColor)
|
||||
tvBgAlpha.setTextColor(primaryTextColor)
|
||||
tvBgImage.setTextColor(primaryTextColor)
|
||||
recyclerView.adapter = adapter
|
||||
adapter.addHeaderView {
|
||||
@@ -130,6 +133,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
|
||||
private fun initData() = with(ReadBookConfig.durConfig) {
|
||||
binding.tvName.text = name.ifBlank { "文字" }
|
||||
binding.swDarkStatusIcon.isChecked = curStatusIconDark()
|
||||
binding.sbBgAlpha.progress = bgAlpha
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@@ -205,6 +209,15 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
|
||||
toastOnUi("数量已是最少,不能删除.")
|
||||
}
|
||||
}
|
||||
binding.sbBgAlpha.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
ReadBookConfig.bgAlpha = progress
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
postEvent(EventBus.UP_CONFIG, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
|
||||
@@ -185,7 +185,12 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
|
||||
fun setBg(bg: Drawable?) {
|
||||
binding.pagePanel.background = bg
|
||||
binding.vwBg.background = bg
|
||||
upBgAlpha()
|
||||
}
|
||||
|
||||
fun upBgAlpha() {
|
||||
binding.vwBg.alpha = ReadBookConfig.bgAlpha / 100f
|
||||
}
|
||||
|
||||
fun upTime() {
|
||||
|
||||
@@ -104,7 +104,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
}
|
||||
}
|
||||
|
||||
fun setRect9x() {
|
||||
private fun setRect9x() {
|
||||
tlRect.set(0f, 0f, width * 0.33f, height * 0.33f)
|
||||
tcRect.set(width * 0.33f, 0f, width * 0.66f, height * 0.33f)
|
||||
trRect.set(width * 0.36f, 0f, width.toFloat(), height * 0.33f)
|
||||
@@ -534,6 +534,12 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
nextPage.setBg(ReadBookConfig.bg)
|
||||
}
|
||||
|
||||
fun upBgAlpha() {
|
||||
curPage.upBgAlpha()
|
||||
prevPage.upBgAlpha()
|
||||
nextPage.upBgAlpha()
|
||||
}
|
||||
|
||||
fun upTime() {
|
||||
curPage.upTime()
|
||||
prevPage.upTime()
|
||||
|
||||
@@ -30,7 +30,6 @@ import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
Reference in New Issue
Block a user