From e3f75f60d307788b2af717446599bbed143d4115 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Jan 2022 09:30:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=83=8C=E6=99=AF=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E5=BA=A6=E8=B0=83=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadBookConfig.kt | 9 +++++- .../io/legado/app/lib/theme/ThemeUtils.kt | 1 - .../app/ui/book/read/ReadBookActivity.kt | 1 + .../ui/book/read/config/BgTextConfigDialog.kt | 13 +++++++++ .../legado/app/ui/book/read/page/PageView.kt | 7 ++++- .../legado/app/ui/book/read/page/ReadView.kt | 8 +++++- .../main/res/layout/dialog_read_bg_text.xml | 28 +++++++++++++++---- app/src/main/res/layout/view_book_page.xml | 7 ++++- app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 3 ++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 3 +- 15 files changed, 74 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 0e0664565..bfd935ef0 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -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, diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt index 267c5cc67..198c3ad89 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt @@ -33,7 +33,6 @@ object ThemeUtils { } } - @JvmOverloads fun resolveDrawable(context: Context, @AttrRes attr: Int): Drawable? { val a = context.theme.obtainStyledAttributes(intArrayOf(attr)) return try { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 28ba6e57f..136aa71f5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -1005,6 +1005,7 @@ class ReadBookActivity : BaseReadBookActivity(), upSystemUiVisibility() readView.upBg() readView.upStyle() + readView.upBgAlpha() if (it) { ReadBook.loadContent(resetPageOffset = false) } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 438839367..fdc01bd8a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -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") diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index f838c3166..8708e1175 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -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() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt index 1cb59cb1a..baa394207 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt @@ -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() diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 73faa0c78..e2c2a2ee2 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -12,8 +12,8 @@ + android:gravity="center_vertical" + android:padding="6dp"> + app:tint="@color/secondaryText" /> + android:text="@string/dark_status_icon" + tools:ignore="TouchTargetSizeCheck" /> + + + + + + 展开文本选择菜单 书籍保存位置 从其它应用打开的书籍保存位置 + 背景透明度 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index ed121ea77..42a11b401 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -916,5 +916,6 @@ 展开文本选择菜单 书籍保存位置 从其它应用打开的书籍保存位置 + 背景透明度 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 60ec51145..79f653394 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -418,6 +418,7 @@ 目录列表规则(capítuloLista) 章节名称规则(capítuloNome) 章节URL规则(capítuloUrl) + 卷标识(isVolume) VIP标识(éVip) 更新时间(capítuloInfo) 正文规则(conteúdo) @@ -426,6 +427,7 @@ 资源正则(fonteRegex) 替换规则(substRegex) 图片样式(imagemFormato) + 购买操作(payAction) 图标(fonteÍcone) 列表规则(regrasArtigos) @@ -914,5 +916,6 @@ 展开文本选择菜单 书籍保存位置 从其它应用打开的书籍保存位置 + 背景透明度 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 4ea4750da..b3759c663 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -913,5 +913,6 @@ 展开文本选择菜单 书籍保存位置 从其它应用打开的书籍保存位置 + 背景透明度 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 2c163ac5d..5f4e69d82 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -915,5 +915,6 @@ 搜尋結果 書籍儲存位置 從其它應用程式打開的書籍儲存位置 + 背景透明度 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index bd023a0a0..5df8c8f4a 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -915,5 +915,6 @@ 展开文本选择菜单 书籍保存位置 从其它应用打开的书籍保存位置 + 背景透明度 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d88a10077..624fdf9ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -418,7 +418,7 @@ 目录列表规则(chapterList) 章节名称规则(ChapterName) 章节URL规则(chapterUrl) - Volume标识(isVolume) + 卷标识(isVolume) VIP标识(isVip) 更新时间(ChapterInfo) 正文规则(content) @@ -916,5 +916,6 @@ 展开文本选择菜单 书籍保存位置 从其它应用打开的书籍保存位置 + 背景透明度