From 758d8c06c098b4d8543925dfc53b1159947ff4c7 Mon Sep 17 00:00:00 2001 From: neihobatho <76517199+neihobatho@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:25:37 +0800 Subject: [PATCH 01/40] Update arrays.xml --- app/src/main/res/values-zh-rTW/arrays.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml index ff880fda3..d88800ca3 100644 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -6,8 +6,8 @@ - 标签 - 文件夹 + 標籤 + 文件夾 From f3a3e7a9a5be828a6c6b45843a4debacb9ed4bc4 Mon Sep 17 00:00:00 2001 From: neihobatho <76517199+neihobatho@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:37:19 +0800 Subject: [PATCH 02/40] Update strings.xml --- app/src/main/res/values-zh-rTW/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index e55d5cd04..cb5621f19 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -345,7 +345,7 @@ 顯示所有發現 關閉則只顯示勾選源的發現 更新目錄 - Txt目錄正則 + TXT目錄正則 設定編碼 倒序-順序 排序 @@ -843,8 +843,8 @@ 分組樣式 匯出檔案名 重設 - url为空 + url為空 字典 - 未知错误 + 未知錯誤 From 37fb6e6dc5ebd48e884b99950096424129bfc065 Mon Sep 17 00:00:00 2001 From: neihobatho <76517199+neihobatho@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:38:41 +0800 Subject: [PATCH 03/40] Update arrays.xml --- app/src/main/res/values-zh-rHK/arrays.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-zh-rHK/arrays.xml b/app/src/main/res/values-zh-rHK/arrays.xml index 6a0784ea8..a16e661f9 100644 --- a/app/src/main/res/values-zh-rHK/arrays.xml +++ b/app/src/main/res/values-zh-rHK/arrays.xml @@ -7,8 +7,8 @@ - 标签 - 文件夹 + 標籤 + 文件夾 @@ -76,4 +76,4 @@ 替換規則 - \ No newline at end of file + From 248adf8c7e90eabdffb745c2b292fc7654243dbb Mon Sep 17 00:00:00 2001 From: neihobatho <76517199+neihobatho@users.noreply.github.com> Date: Tue, 3 Aug 2021 12:00:19 +0800 Subject: [PATCH 04/40] Update strings.xml --- app/src/main/res/values-zh-rHK/strings.xml | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index b7c405f4f..04159bbe9 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -343,7 +343,7 @@ 顯示所有發現 關閉則只顯示勾選源的發現 更新目錄 - Txt目錄正則 + TXT目錄正則 設置編碼 倒序-順序 排序 @@ -405,7 +405,7 @@ 書籍 URL 正則 (bookUrlPattern) 預處理規則 (bookInfoInit) 目錄 URL 規則 (tocUrl) - 允许修改书名作者(canReName) + 允許修改書名作者 (canReName) 目錄下一頁規則 (nextTocUrl) 目錄列表規則 (chapterList) 章節名稱規則 (ChapterName) @@ -414,7 +414,7 @@ 更新時間 (ChapterInfo) 正文規則 (content) 正文下一頁 URL 規則 (nextContentUrl) - WebViewJs(webJs) + WebViewJs (webJs) 資源正則 (sourceRegex) 圖標 (sourceIcon) 列表規則 (ruleArticles) @@ -672,10 +672,10 @@ 開發人員 聯繫我們 開源許可 - 關注公衆號 + 關注公眾號 WeChat 你的支持是我更新的動力 - 公众号[开源阅读] + 公眾號[开源阅读] 正在自動換源 點擊加入 @@ -716,46 +716,46 @@ 該書已在下載列表 點擊打開 關注[legado-top]點擊廣告支持我 - 微信赞赏码 + 微信讚賞碼 支付寶 支付寶紅包搜索碼 537954522 點擊複製 支付寶紅包二維碼 支付寶收款二維碼 QQ收款二維碼 - gedoor,Invinciblelee等,详情请在github中查看 + gedoor,Invinciblelee等,詳情請在github中查看 清除已下載書籍和字體緩存 默認封面 恢復忽略列表 恢復時忽略一些內容不恢復,方便不同手機配置不同 閱讀界面設置 - 图片样式(imageStyle) - 替换规则(replaceRegex) + 圖片樣式 (imageStyle) + 替換規則 (replaceRegex) 分組名稱 備註內容 - 默认启用替换净化 - 新加入书架的书是否启用替换净化 - 选择恢复文件 + 默認啟用替換淨化 + 新加入書架的書是否啟用替換淨化 + 選擇恢復文件 白天背景不能太暗 - 白天底栏不能太暗 - 夜间背景不能太亮 - 夜间底栏不能太亮 - 强调色不能和背景颜色相似 - 强调色不能和文字颜色相似 + 白天底欄不能太暗 + 夜間背景不能太亮 + 夜間底欄不能太亮 + 強調色不能和背景顏色相似 + 強調色不能和文字顏色相似 格式不對 錯誤 顯示亮度調節控制項 語言 匯入訂閱源 - 您嘅支援是我更新嘅動力 - 公众号[开源阅读软件] + 您嘅支援喺我更新嘅動力 + 公眾號[开源阅读软件] 閲讀記錄 閱讀時間記錄 本地TTS 線程數 總閲讀時間 全部唔要 - 删除所有 + 刪除所有 導入 導出 儲存主題配置 @@ -789,7 +789,7 @@ 無操作 正文標題 顯示/隱藏 - 页眉页脚 + 頁眉頁脚 規則訂閱 添加大佬們提供的規則匯入地址 添加後點擊可匯入規則 拉取雲端進度 @@ -836,14 +836,14 @@ 狀態欄顯示時隱藏 自訂源分組 輸入自訂源分組名稱 - 反转目录 - 显示发现 - 样式 - 分组样式 - 导出文件名 + 反轉目錄 + 顯示發現 + 樣式 + 分組樣式 + 導出文件名 重置 - url为空 + url為空 字典 - 未知错误 + 未知錯誤 From 6674284ed42d169c759b7ca7b26a3fad6fdfede0 Mon Sep 17 00:00:00 2001 From: neihobatho <76517199+neihobatho@users.noreply.github.com> Date: Tue, 3 Aug 2021 14:05:31 +0800 Subject: [PATCH 05/40] Update strings.xml --- app/src/main/res/values-zh-rHK/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 04159bbe9..5d4812042 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -789,7 +789,7 @@ 無操作 正文標題 顯示/隱藏 - 頁眉頁脚 + 頁眉頁腳 規則訂閱 添加大佬們提供的規則匯入地址 添加後點擊可匯入規則 拉取雲端進度 From 583f276cc006b0210a12f58b47590b8e533dc52c Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 3 Aug 2021 16:27:12 +0800 Subject: [PATCH 06/40] =?UTF-8?q?=E5=B0=81=E9=9D=A2=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E4=B8=BB=E9=A2=98=E9=87=8C=E9=9D=A2,?= =?UTF-8?q?=E7=99=BD=E5=A4=A9=E5=92=8C=E5=A4=9C=E9=97=B4=E5=8F=AF=E5=88=86?= =?UTF-8?q?=E5=88=AB=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 822f304e9..d78ac0baf 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,7 +2,6 @@ * 关注公众号 **[开源阅读]** 菜单•软件下载 提前享受新版本。 * 关注合作公众号 **[小说拾遗]** 获取好看的小说。 -* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 ## **必读** @@ -13,7 +12,7 @@ * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! **2021/08/02** - +* 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法 1. 换源界面功能添加:置顶,置底,删除 by h11128 2. Cronet:优化 by ag2s20150909 3. 优化自动翻页 by jiuZhouWorlds From ced88a5570fea606aba0a2ee14607a8ae7d8d994 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 3 Aug 2021 16:27:54 +0800 Subject: [PATCH 07/40] edit updateLog.md --- app/src/main/assets/updateLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index d78ac0baf..25069b073 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -12,7 +12,9 @@ * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! **2021/08/02** + * 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法 + 1. 换源界面功能添加:置顶,置底,删除 by h11128 2. Cronet:优化 by ag2s20150909 3. 优化自动翻页 by jiuZhouWorlds From 127239f182b9181bb0e5760d3ae1ede3fcb6c7d6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 3 Aug 2021 16:33:39 +0800 Subject: [PATCH 08/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ThemeConfig.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index e7a88d40f..bdbe9eb8d 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -11,6 +11,7 @@ import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.constant.Theme import io.legado.app.lib.theme.ThemeStore +import io.legado.app.ui.widget.image.CoverImageView import io.legado.app.utils.* import splitties.init.appCtx import java.io.File @@ -28,6 +29,7 @@ object ThemeConfig { ReadBookConfig.upBg() applyTheme(context) initNightMode() + CoverImageView.upDefaultCover() postEvent(EventBus.RECREATE, "") } From ea4602b8577d95fafd458587b3b0f88904955cbd Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 08:15:19 +0800 Subject: [PATCH 09/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/config/BgTextConfigDialog.kt | 6 +++--- app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) 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 5175f6610..b70f72854 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 @@ -47,12 +47,12 @@ class BgTextConfigDialog : BaseDialogFragment() { private var secondaryTextColor = 0 private val importFormNet = "网络导入" private val selectBgImage = registerForActivityResult(ActivityResultContracts.GetContent()) { + it ?: return@registerForActivityResult setBgFromUri(it) } private val selectExportDir = registerForActivityResult(FilePicker()) { - it?.let { - exportConfig(it) - } + it ?: return@registerForActivityResult + exportConfig(it) } private val selectImportDoc = registerForActivityResult(FilePicker()) { it ?: return@registerForActivityResult diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index b5f4c0eaa..b78d15239 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -12,7 +12,6 @@ import io.legado.app.help.DefaultData import io.legado.app.help.LocalConfig import io.legado.app.model.webBook.WebBook import io.legado.app.service.help.CacheBook -import io.legado.app.utils.FileUtils import io.legado.app.utils.postEvent import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.delay @@ -143,7 +142,6 @@ class MainViewModel(application: Application) : BaseViewModel(application) { fun postLoad() { execute { - FileUtils.deleteFile(FileUtils.getPath(context.cacheDir, "Fonts")) if (appDb.httpTTSDao.count == 0) { DefaultData.httpTTS.let { appDb.httpTTSDao.insert(*it.toTypedArray()) From e734ef77762a0487316360426475d27609051c78 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 15:30:02 +0800 Subject: [PATCH 10/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 902af3cd7..58ce975d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -198,7 +198,7 @@ dependencies { implementation('org.nanohttpd:nanohttpd-apache-fileupload:2.3.1') //二维码 - implementation('com.github.jenly1314:zxing-lite:2.1.0') + implementation('com.github.jenly1314:zxing-lite:2.1.1') //颜色选择 implementation('com.jaredrummler:colorpicker:1.1.0') From 765608a8450721dc66cf076a9032be5e5822bc2d Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 16:10:37 +0800 Subject: [PATCH 11/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt | 2 +- app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt b/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt index dcabe5b8c..5bf92439c 100644 --- a/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt @@ -20,7 +20,7 @@ class QrCodeActivity : BaseActivity(), OnScanResul override val binding by viewBinding(ActivityQrcodeCaptureBinding::inflate) private val selectQrImage = registerForActivityResult(ActivityResultContracts.GetContent()) { - it.readBytes(this)?.let { bytes -> + it?.readBytes(this)?.let { bytes -> val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size) onScanResultCallback(QRCodeUtils.parseCodeResult(bitmap)) } diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index 1728f7320..a8ebdd2a3 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -43,6 +43,7 @@ class ReadRssActivity : VMBaseActivity private var customWebViewCallback: WebChromeClient.CustomViewCallback? = null private var webPic: String? = null private val saveImage = registerForActivityResult(FilePicker()) { + it ?: return@registerForActivityResult ACache.get(this).put(imagePathKey, it.toString()) viewModel.saveImage(webPic, it.toString()) } From 8907cec1d353761503e1f9e50149f105a35d5e28 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 4 Aug 2021 17:07:01 +0800 Subject: [PATCH 12/40] build.gradle: Add dependency renderscript-intrinsics-replacement-toolkit Signed-off-by: 1552980358 <1552980358@qq.com> --- app/build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 902af3cd7..76266295b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,8 +98,8 @@ android { // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled true // Sets Java compatibility to Java 11 - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility "1.8" + targetCompatibility "1.8" } kotlinOptions { @@ -213,6 +213,9 @@ dependencies { implementation("io.noties.markwon:ext-tables:$markwonVersion") implementation("io.noties.markwon:html:$markwonVersion") + // 谷歌RenderScript库 + implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3') + //转换繁体 implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.1') From ccb31350559de1e4b1c45ec4556a054881e80bb9 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 4 Aug 2021 17:07:44 +0800 Subject: [PATCH 13/40] ThemeConfig.kt: Set getBgImage return type as Bitmap? Signed-off-by: 1552980358 <1552980358@qq.com> --- app/src/main/java/io/legado/app/help/ThemeConfig.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index bdbe9eb8d..39d33e02b 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -1,9 +1,9 @@ package io.legado.app.help import android.content.Context +import android.graphics.Bitmap +import android.graphics.BitmapFactory import android.graphics.Color -import android.graphics.drawable.BitmapDrawable -import android.graphics.drawable.Drawable import androidx.annotation.Keep import androidx.appcompat.app.AppCompatDelegate import io.legado.app.R @@ -43,14 +43,14 @@ object ThemeConfig { AppCompatDelegate.setDefaultNightMode(targetMode) } - fun getBgImage(context: Context): Drawable? { + fun getBgImage(context: Context): Bitmap? { val bgPath = when (Theme.getTheme()) { Theme.Light -> context.getPrefString(PreferKey.bgImage) Theme.Dark -> context.getPrefString(PreferKey.bgImageN) else -> null } if (bgPath.isNullOrBlank()) return null - return BitmapDrawable.createFromPath(bgPath) + return BitmapFactory.decodeFile(bgPath) } fun upConfig() { From bf1b5bb813de17fb98f9a96c626efe9165fda63c Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 4 Aug 2021 17:08:02 +0800 Subject: [PATCH 14/40] PreferKey.kt: Update key bgImageBlurring Signed-off-by: 1552980358 <1552980358@qq.com> --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index b92ad091c..59c10f8e8 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -91,6 +91,7 @@ object PreferKey { const val cBackground = "colorBackground" const val cBBackground = "colorBottomBackground" const val bgImage = "backgroundImage" + const val bgImageBlurring = "backgroundImageBlurring" const val cNPrimary = "colorPrimaryNight" const val cNAccent = "colorAccentNight" From c02331e9be37b72d6045ed16530cd57cf155ddb5 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 4 Aug 2021 17:08:28 +0800 Subject: [PATCH 15/40] Update ImageBlurringDialogFragment Signed-off-by: 1552980358 <1552980358@qq.com> --- .../ui/config/ImageBlurringDialogFragment.kt | 53 +++++++++++++++++++ .../layout/fragment_image_blurring_dialog.xml | 28 ++++++++++ 2 files changed, 81 insertions(+) create mode 100644 app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt create mode 100644 app/src/main/res/layout/fragment_image_blurring_dialog.xml diff --git a/app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt b/app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt new file mode 100644 index 000000000..06065dd69 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt @@ -0,0 +1,53 @@ +package io.legado.app.ui.config + +import android.app.Dialog +import android.content.SharedPreferences +import android.os.Bundle +import android.widget.SeekBar +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.DialogFragment +import androidx.fragment.app.FragmentManager +import androidx.preference.PreferenceManager +import io.legado.app.R +import io.legado.app.databinding.FragmentImageBlurringDialogBinding + +class ImageBlurringDialogFragment(private val prefName: String, private val block: () -> Unit): DialogFragment() { + + companion object { + private const val DEFAULT_VALUE = 0 + private const val TAG = "ImageBlurringDialogFragment" + } + + private val requireContext get() = requireContext() + private var _fragmentImageBlurringDialogBinding: FragmentImageBlurringDialogBinding? = null + private val fragmentImageBlurringDialog get() = _fragmentImageBlurringDialogBinding!! + private lateinit var sharedPreference: SharedPreferences + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + _fragmentImageBlurringDialogBinding = FragmentImageBlurringDialogBinding.inflate(layoutInflater) + sharedPreference = PreferenceManager.getDefaultSharedPreferences(requireContext) + sharedPreference.getInt(prefName, DEFAULT_VALUE).apply { + fragmentImageBlurringDialog.seekBar.progress = this + fragmentImageBlurringDialog.textViewValue.text = this.toString() + } + fragmentImageBlurringDialog.seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { + override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { + fragmentImageBlurringDialog.textViewValue.text = progress.toString() + } + override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit + override fun onStopTrackingTouch(seekBar: SeekBar?) = Unit + }) + return AlertDialog.Builder(requireContext) + .setTitle(R.string.background_image_blurring_radius) + .setView(fragmentImageBlurringDialog.root) + .setPositiveButton(R.string.dialog_confirm) { _, _ -> + sharedPreference.edit().putInt(prefName, fragmentImageBlurringDialog.seekBar.progress).commit() + block() + } + .setNegativeButton(R.string.dialog_cancel) { _, _ -> } + .create() + } + + fun show(fragmentManager: FragmentManager) = show(fragmentManager, TAG) + +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_image_blurring_dialog.xml b/app/src/main/res/layout/fragment_image_blurring_dialog.xml new file mode 100644 index 000000000..907aff57c --- /dev/null +++ b/app/src/main/res/layout/fragment_image_blurring_dialog.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file From 13ccb69a9fbdee3fbcfbcfe22f382dba1f891d68 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 4 Aug 2021 17:09:17 +0800 Subject: [PATCH 16/40] Update and implement setting blurring of background image for day mode Signed-off-by: 1552980358 <1552980358@qq.com> --- .../java/io/legado/app/base/BaseActivity.kt | 18 +++++++++++++++--- .../app/ui/config/ThemeConfigFragment.kt | 3 +++ app/src/main/res/values-zh/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_config_theme.xml | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 6406c18bf..433ce1ba5 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -2,6 +2,8 @@ package io.legado.app.base import android.content.Context import android.content.res.Configuration +import android.graphics.Bitmap +import android.graphics.drawable.BitmapDrawable import android.os.Build import android.os.Bundle import android.util.AttributeSet @@ -10,11 +12,14 @@ import android.view.MenuItem import android.view.View import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity +import androidx.preference.PreferenceManager import androidx.viewbinding.ViewBinding +import com.google.android.renderscript.Toolkit import io.legado.app.App import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey +import io.legado.app.constant.PreferKey.bgImageBlurring import io.legado.app.constant.Theme import io.legado.app.help.AppConfig import io.legado.app.help.ThemeConfig @@ -174,9 +179,7 @@ abstract class BaseActivity( } if (imageBg) { try { - ThemeConfig.getBgImage(this)?.let { - window.decorView.background = it - } + window.decorView.background = BitmapDrawable(resources, getBackgroundImage(ThemeConfig.getBgImage(this) ?: return)) } catch (e: OutOfMemoryError) { toastOnUi(e.localizedMessage) } catch (e: Exception) { @@ -185,6 +188,15 @@ abstract class BaseActivity( } } + private fun getBackgroundImage(bitmap: Bitmap): Bitmap { + PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply { + if (this != 0) { + return Toolkit.blur(bitmap, this) + } + } + return bitmap + } + private fun setupSystemBar() { if (fullScreen && !isInMultiWindow) { ATH.fullScreen(this) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index da4d47c6f..2f8976d08 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -183,6 +183,9 @@ class ThemeConfigFragment : BasePreferenceFragment(), } } } + PreferKey.bgImageBlurring -> { + ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager) + } PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) { selectImage.launch(requestCodeCover) } else { diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 910663504..e1d905ecc 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -807,6 +807,9 @@ 预先下载%s章正文 是否启用 背景图片 + 背景图片虚化 + 虚化半径 + 0为停用,启用范围1~25\n半径数值越大,虚化效果越高 导出文件夹 导出编码 导出到WebDav diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 92954b0a0..f36ab7c67 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -807,6 +807,9 @@ Download %s chapters in advance Is enabled Background image + Background image blurring + Blurring radius + Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring Copy book URL Copy chapters URL Export folder diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 8fb8143be..50ffb4172 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -86,6 +86,10 @@ android:key="backgroundImage" android:title="@string/background_image" /> + + Date: Wed, 4 Aug 2021 17:14:23 +0800 Subject: [PATCH 17/40] build.gradle: Revert target JavaVersion back to VERSION_11 Signed-off-by: 1552980358 <1552980358@qq.com> --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 76266295b..ca80a26a8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,8 +98,8 @@ android { // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled true // Sets Java compatibility to Java 11 - sourceCompatibility "1.8" - targetCompatibility "1.8" + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { From 9a751d1fbbc67558ca6e68b99787fa6754cdbcf0 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 4 Aug 2021 17:51:59 +0800 Subject: [PATCH 18/40] Add support customize background image blurring Signed-off-by: 1552980358 <1552980358@qq.com> --- .../main/java/io/legado/app/base/BaseActivity.kt | 14 +++++++++++--- .../main/java/io/legado/app/constant/PreferKey.kt | 1 + .../io/legado/app/ui/config/ThemeConfigFragment.kt | 5 ++--- app/src/main/res/xml/pref_config_theme.xml | 4 ++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 433ce1ba5..306e61943 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -20,6 +20,7 @@ import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey.bgImageBlurring +import io.legado.app.constant.PreferKey.bgImageNBlurring import io.legado.app.constant.Theme import io.legado.app.help.AppConfig import io.legado.app.help.ThemeConfig @@ -189,9 +190,16 @@ abstract class BaseActivity( } private fun getBackgroundImage(bitmap: Bitmap): Bitmap { - PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply { - if (this != 0) { - return Toolkit.blur(bitmap, this) + when (Theme.getTheme()) { + Theme.Light -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply { + if (this != 0) { + return Toolkit.blur(bitmap, this) + } + } + Theme.Dark -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageNBlurring, 0).apply { + if (this != 0) { + return Toolkit.blur(bitmap, this) + } } } return bitmap diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 59c10f8e8..d2224a584 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -98,5 +98,6 @@ object PreferKey { const val cNBackground = "colorBackgroundNight" const val cNBBackground = "colorBottomBackgroundNight" const val bgImageN = "backgroundImageNight" + const val bgImageNBlurring = "backgroundImageNightBlurring" } diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 2f8976d08..8f6163216 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -183,9 +183,8 @@ class ThemeConfigFragment : BasePreferenceFragment(), } } } - PreferKey.bgImageBlurring -> { - ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager) - } + PreferKey.bgImageBlurring -> ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager) + PreferKey.bgImageNBlurring -> ImageBlurringDialogFragment(PreferKey.bgImageNBlurring) { upTheme(true) }.show(parentFragmentManager) PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) { selectImage.launch(requestCodeCover) } else { diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 50ffb4172..564cb9811 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -153,6 +153,10 @@ android:key="backgroundImageNight" android:title="@string/background_image" /> + + Date: Wed, 4 Aug 2021 18:03:17 +0800 Subject: [PATCH 19/40] Update strings.xml for zh-rHK and zh-rTW Signed-off-by: 1552980358 <1552980358@qq.com> --- app/src/main/res/values-zh-rHK/strings.xml | 3 +++ app/src/main/res/values-zh-rTW/strings.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 5d4812042..7ab4f87ea 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -804,6 +804,9 @@ 預先下載%s章正文 係咪啟用 背景圖片 + 背景圖片虛化 + 虛化半徑 + 0為停用,啓用範圍1~25\n半徑數值越大,虛化效果越高 導出資料夾 導出編碼 導出到WebDav diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index cb5621f19..609cf8f27 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -807,6 +807,9 @@ 預先下載%s章正文 是否啟用 背景圖片 + 背景圖片虛化 + 虛化半徑 + 0為停用,啓用範圍1~25\n半徑數值越大,虛化效果越高 匯出資料夾 匯出編碼 匯出到WebDav From b80376617c74f8ccd10cfff5cf9742f2d66d674c Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 20:20:33 +0800 Subject: [PATCH 20/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/layout-land/activity_book_info.xml | 1 + .../main/res/layout/activity_book_info.xml | 7 ++-- .../res/layout/activity_book_info_edit.xml | 8 +++-- .../main/res/layout/activity_chapter_list.xml | 4 ++- .../main/res/layout/activity_import_book.xml | 3 +- app/src/main/res/layout/activity_main.xml | 4 ++- .../main/res/layout/activity_replace_edit.xml | 21 ++++++++---- .../main/res/layout/activity_replace_rule.xml | 3 +- .../main/res/layout/activity_rss_artivles.xml | 4 ++- .../res/layout/activity_rss_source_edit.xml | 12 ++++--- .../res/layout/activity_search_content.xml | 3 +- app/src/main/res/layout/dialog_bookmark.xml | 6 ++-- .../res/layout/dialog_bookshelf_config.xml | 34 +++++++++++++------ .../res/layout/dialog_download_choice.xml | 14 +++++--- app/src/main/res/layout/dialog_edit_text.xml | 30 ++++++++-------- .../main/res/layout/dialog_recycler_view.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 | 1 + 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 | 1 + 23 files changed, 114 insertions(+), 54 deletions(-) diff --git a/app/src/main/res/layout-land/activity_book_info.xml b/app/src/main/res/layout-land/activity_book_info.xml index 05a4b316a..036cdd05e 100644 --- a/app/src/main/res/layout-land/activity_book_info.xml +++ b/app/src/main/res/layout-land/activity_book_info.xml @@ -362,6 +362,7 @@ android:layout_marginTop="8dp" android:clickable="true" android:focusable="true" + android:minHeight="48dp" android:paddingLeft="8dp" android:paddingBottom="8dp" android:text="@string/book_intro" diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index e2d35458f..c34395d21 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -333,16 +333,17 @@ diff --git a/app/src/main/res/layout/activity_book_info_edit.xml b/app/src/main/res/layout/activity_book_info_edit.xml index 0301bcfb6..07e177b7b 100644 --- a/app/src/main/res/layout/activity_book_info_edit.xml +++ b/app/src/main/res/layout/activity_book_info_edit.xml @@ -52,6 +52,7 @@ android:id="@+id/tie_book_name" android:layout_width="match_parent" android:layout_height="wrap_content" + android:minHeight="48dp" android:singleLine="true" /> @@ -65,6 +66,7 @@ android:id="@+id/tie_book_author" android:layout_width="match_parent" android:layout_height="wrap_content" + android:minHeight="48dp" android:singleLine="true" /> @@ -81,7 +83,8 @@ + android:layout_height="wrap_content" + android:minHeight="48dp" /> + android:layout_height="wrap_content" + android:minHeight="48dp" /> diff --git a/app/src/main/res/layout/activity_chapter_list.xml b/app/src/main/res/layout/activity_chapter_list.xml index c78973583..9bceaa108 100644 --- a/app/src/main/res/layout/activity_chapter_list.xml +++ b/app/src/main/res/layout/activity_chapter_list.xml @@ -1,6 +1,7 @@ @@ -15,6 +16,7 @@ + android:layout_height="match_parent" + tools:ignore="SpeakableTextPresentCheck" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index 73635c2f4..7e3ee8997 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -69,7 +69,8 @@ + android:layout_height="match_parent" + tools:ignore="SpeakableTextPresentCheck" /> @@ -9,7 +10,8 @@ android:id="@+id/view_pager_main" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_weight="1" /> + android:layout_weight="1" + tools:ignore="SpeakableTextPresentCheck" /> + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> + android:text="@string/use_regex" + tools:ignore="TouchTargetSizeCheck" /> @@ -94,7 +99,8 @@ + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> diff --git a/app/src/main/res/layout/activity_replace_rule.xml b/app/src/main/res/layout/activity_replace_rule.xml index b244fc3d9..eeb2a26f9 100644 --- a/app/src/main/res/layout/activity_replace_rule.xml +++ b/app/src/main/res/layout/activity_replace_rule.xml @@ -23,7 +23,8 @@ + android:layout_height="match_parent" + tools:ignore="SpeakableTextPresentCheck" /> diff --git a/app/src/main/res/layout/activity_rss_artivles.xml b/app/src/main/res/layout/activity_rss_artivles.xml index 50e503a9e..27a0dff9d 100644 --- a/app/src/main/res/layout/activity_rss_artivles.xml +++ b/app/src/main/res/layout/activity_rss_artivles.xml @@ -1,5 +1,6 @@ + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_rss_source_edit.xml b/app/src/main/res/layout/activity_rss_source_edit.xml index f576312db..aab498529 100644 --- a/app/src/main/res/layout/activity_rss_source_edit.xml +++ b/app/src/main/res/layout/activity_rss_source_edit.xml @@ -34,14 +34,16 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" - android:text="@string/is_enable" /> + android:text="@string/is_enable" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/single_url" + tools:ignore="TouchTargetSizeCheck" /> @@ -64,14 +66,16 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" - android:text="@string/enable_js" /> + android:text="@string/enable_js" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/load_with_base_url" + tools:ignore="TouchTargetSizeCheck" /> diff --git a/app/src/main/res/layout/activity_search_content.xml b/app/src/main/res/layout/activity_search_content.xml index e9bde053b..9a4a5da87 100644 --- a/app/src/main/res/layout/activity_search_content.xml +++ b/app/src/main/res/layout/activity_search_content.xml @@ -25,7 +25,8 @@ android:layout_height="0dp" android:overScrollMode="never" app:layout_constraintBottom_toTopOf="@+id/ll_search_base_info" - app:layout_constraintTop_toBottomOf="@id/refresh_progress_bar" /> + app:layout_constraintTop_toBottomOf="@id/refresh_progress_bar" + tools:ignore="SpeakableTextPresentCheck" /> + android:hint="@string/content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> @@ -56,7 +57,8 @@ android:id="@+id/edit_content" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/note_content" /> + android:hint="@string/note_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> diff --git a/app/src/main/res/layout/dialog_bookshelf_config.xml b/app/src/main/res/layout/dialog_bookshelf_config.xml index cbf550197..bb385cf3a 100644 --- a/app/src/main/res/layout/dialog_bookshelf_config.xml +++ b/app/src/main/res/layout/dialog_bookshelf_config.xml @@ -1,5 +1,6 @@ + app:theme="@style/Spinner" + tools:ignore="TouchTargetSizeCheck" /> @@ -51,27 +53,32 @@ + android:text="@string/layout_list" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/layout_grid3" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/layout_grid4" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/layout_grid5" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/layout_grid6" + tools:ignore="TouchTargetSizeCheck" /> @@ -84,8 +91,9 @@ android:padding="6dp" android:text="@string/show_unread" app:layout_constraintLeft_toRightOf="@+id/ll_layout" + app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintRight_toRightOf="parent" /> + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/bookshelf_px_0" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/bookshelf_px_1" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/bookshelf_px_2" + tools:ignore="TouchTargetSizeCheck" /> + android:text="@string/bookshelf_px_3" + tools:ignore="TouchTargetSizeCheck" /> diff --git a/app/src/main/res/layout/dialog_download_choice.xml b/app/src/main/res/layout/dialog_download_choice.xml index 4548ac329..8e60ea030 100644 --- a/app/src/main/res/layout/dialog_download_choice.xml +++ b/app/src/main/res/layout/dialog_download_choice.xml @@ -4,10 +4,10 @@ android:id="@+id/ll_content" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="16dp" android:background="@color/background" android:gravity="center" - android:orientation="horizontal"> + android:orientation="horizontal" + android:padding="16dp"> + android:textSize="14sp" + tools:ignore="TouchTargetSizeCheck" /> + android:textSize="14sp" + tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" /> - + + android:id="@+id/edit_view" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="48dp" + android:layout_marginStart="20dp" + android:layout_marginLeft="20dp" + android:layout_marginEnd="20dp" + android:layout_marginRight="20dp" + tools:ignore="SpeakableTextPresentCheck" /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_recycler_view.xml b/app/src/main/res/layout/dialog_recycler_view.xml index 7f577dde3..82feaf44e 100644 --- a/app/src/main/res/layout/dialog_recycler_view.xml +++ b/app/src/main/res/layout/dialog_recycler_view.xml @@ -23,7 +23,8 @@ android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:scrollbars="none" /> + android:scrollbars="none" + tools:ignore="SpeakableTextPresentCheck" /> + + URL nula 字典 未知错误 + end diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 42cb3aa38..cc05056fd 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -847,4 +847,5 @@ url为空 字典 未知错误 + end diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index b3f2e2eb1..c804508f7 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -847,4 +847,5 @@ Nenhuma url Dicionários 未知错误 + end diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 5d4812042..491800154 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -845,5 +845,6 @@ url為空 字典 未知錯誤 + end diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index cb5621f19..e2e486326 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -846,5 +846,6 @@ url為空 字典 未知錯誤 + end diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 910663504..a6fc6c733 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -847,5 +847,6 @@ 字典 未知错误 自动备份失败 + 结束 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 92954b0a0..5cb9d844d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -849,5 +849,6 @@ 字典 未知错误 Autobackup failed + end From 154c8695c28a1c01925e2abab31e4da25fd4f3cf Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 20:35:23 +0800 Subject: [PATCH 21/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_book_info_edit.xml | 8 ++------ app/src/main/res/layout/dialog_edit_text.xml | 1 - app/src/main/res/layout/dialog_toc_regex_edit.xml | 7 +++++-- app/src/main/res/layout/dialog_wait.xml | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/layout/activity_book_info_edit.xml b/app/src/main/res/layout/activity_book_info_edit.xml index 07e177b7b..0301bcfb6 100644 --- a/app/src/main/res/layout/activity_book_info_edit.xml +++ b/app/src/main/res/layout/activity_book_info_edit.xml @@ -52,7 +52,6 @@ android:id="@+id/tie_book_name" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="48dp" android:singleLine="true" /> @@ -66,7 +65,6 @@ android:id="@+id/tie_book_author" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="48dp" android:singleLine="true" /> @@ -83,8 +81,7 @@ + android:layout_height="wrap_content" /> + android:layout_height="wrap_content" /> diff --git a/app/src/main/res/layout/dialog_edit_text.xml b/app/src/main/res/layout/dialog_edit_text.xml index 711072f3e..f5a9e8c39 100644 --- a/app/src/main/res/layout/dialog_edit_text.xml +++ b/app/src/main/res/layout/dialog_edit_text.xml @@ -11,7 +11,6 @@ android:id="@+id/edit_view" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="48dp" android:layout_marginStart="20dp" android:layout_marginLeft="20dp" android:layout_marginEnd="20dp" diff --git a/app/src/main/res/layout/dialog_toc_regex_edit.xml b/app/src/main/res/layout/dialog_toc_regex_edit.xml index 07c0816a4..71ea57fb7 100644 --- a/app/src/main/res/layout/dialog_toc_regex_edit.xml +++ b/app/src/main/res/layout/dialog_toc_regex_edit.xml @@ -1,5 +1,6 @@ + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> @@ -27,7 +29,8 @@ + android:layout_height="wrap_content" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> diff --git a/app/src/main/res/layout/dialog_wait.xml b/app/src/main/res/layout/dialog_wait.xml index ccd7d4ccc..bc490a506 100644 --- a/app/src/main/res/layout/dialog_wait.xml +++ b/app/src/main/res/layout/dialog_wait.xml @@ -20,6 +20,6 @@ android:layout_height="wrap_content" android:padding="6dp" android:gravity="center" - android:text="执行中......" + android:text="@string/loading" android:textColor="@color/primaryText" /> \ No newline at end of file From 6df0ab1eae12bfdc67fadd6caa26180d8ffbb71e Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 21:25:36 +0800 Subject: [PATCH 22/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/association/ImportBookSourceDialog.kt | 1 + .../ui/association/ImportRssSourceDialog.kt | 1 + .../legado/app/ui/book/cache/CacheActivity.kt | 2 ++ .../app/ui/book/local/ImportBookActivity.kt | 1 + .../app/ui/book/read/ReadBookBaseActivity.kt | 1 + .../ui/book/read/config/BgTextConfigDialog.kt | 1 + .../ui/book/read/config/SpeakEngineDialog.kt | 1 + .../app/ui/book/read/config/TocRegexDialog.kt | 4 ++-- .../book/source/manage/BookSourceActivity.kt | 2 ++ .../ui/book/source/manage/GroupManageDialog.kt | 5 +++-- .../app/ui/config/OtherConfigFragment.kt | 6 ++++-- .../app/ui/config/ThemeConfigFragment.kt | 4 +++- .../ui/main/bookshelf/BaseBookshelfFragment.kt | 4 +++- .../legado/app/ui/replace/GroupManageDialog.kt | 10 ++++------ .../app/ui/replace/ReplaceRuleActivity.kt | 1 + .../ui/rss/source/manage/GroupManageDialog.kt | 18 +++++++----------- .../ui/rss/source/manage/RssSourceActivity.kt | 1 + app/src/main/res/layout/dialog_edit_text.xml | 3 ++- 18 files changed, 40 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt index 7775cbc0b..cee6ca70f 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt @@ -176,6 +176,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList appDb.bookSourceDao.allGroup.forEach { group -> groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) } + editView.setHint(R.string.group_name) editView.setFilterValues(groups.toList()) editView.dropDownHeight = 180.dp } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt index b139beb90..41d3e9567 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt @@ -172,6 +172,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe appDb.rssSourceDao.allGroup.forEach { group -> groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) } + editView.setHint(R.string.group_name) editView.setFilterValues(groups.toList()) editView.dropDownHeight = 180.dp } diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt index 55b482f72..9c03a0851 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt @@ -298,6 +298,7 @@ class CacheActivity : VMBaseActivity() private fun alertExportFileName() { alert(R.string.export_file_name) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { + editView.hint = "file name js" editView.setText(AppConfig.bookExportFileName) } customView { alertBinding.root } @@ -317,6 +318,7 @@ class CacheActivity : VMBaseActivity() private fun showCharsetConfig() { alert(R.string.set_charset) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { + editView.hint = "charset name" editView.setFilterValues(charsets) editView.setText(AppConfig.exportCharset) } diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index d9c5998ac..0601cacd0 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -280,6 +280,7 @@ class ImportBookActivity : VMBaseActivity diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt index d9a5acbfe..679886807 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt @@ -65,7 +65,9 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> + \ No newline at end of file From b66264b21ef35be73d5c09646389bb1ca7f0fcd5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 21:53:29 +0800 Subject: [PATCH 23/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/association/ImportBookSourceDialog.kt | 2 +- .../ui/association/ImportRssSourceDialog.kt | 2 +- .../legado/app/ui/book/cache/CacheActivity.kt | 4 +-- .../io/legado/app/ui/book/group/GroupEdit.kt | 2 +- .../app/ui/book/group/GroupManageDialog.kt | 2 +- .../app/ui/book/group/GroupSelectDialog.kt | 4 +-- .../app/ui/book/local/ImportBookActivity.kt | 2 +- .../app/ui/book/read/ReadBookBaseActivity.kt | 2 +- .../ui/book/read/config/BgTextConfigDialog.kt | 2 +- .../ui/book/read/config/SpeakEngineDialog.kt | 2 +- .../app/ui/book/read/config/TocRegexDialog.kt | 2 +- .../book/source/manage/BookSourceActivity.kt | 8 +++--- .../book/source/manage/GroupManageDialog.kt | 9 +++--- .../app/ui/config/OtherConfigFragment.kt | 2 +- .../app/ui/config/ThemeConfigFragment.kt | 2 +- .../main/bookshelf/BaseBookshelfFragment.kt | 4 +-- .../app/ui/replace/GroupManageDialog.kt | 4 +-- .../app/ui/replace/ReplaceRuleActivity.kt | 2 +- .../ui/rss/source/manage/GroupManageDialog.kt | 4 +-- .../ui/rss/source/manage/RssSourceActivity.kt | 2 +- app/src/main/res/layout/dialog_edit_text.xml | 28 +++++++++++-------- 21 files changed, 48 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt index cee6ca70f..e3a096677 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt @@ -176,7 +176,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList appDb.bookSourceDao.allGroup.forEach { group -> groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) } - editView.setHint(R.string.group_name) + textInputLayout.setHint(R.string.group_name) editView.setFilterValues(groups.toList()) editView.dropDownHeight = 180.dp } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt index 41d3e9567..f2a8188dd 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt @@ -172,7 +172,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe appDb.rssSourceDao.allGroup.forEach { group -> groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) } - editView.setHint(R.string.group_name) + textInputLayout.setHint(R.string.group_name) editView.setFilterValues(groups.toList()) editView.dropDownHeight = 180.dp } diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt index 9c03a0851..9fed01921 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt @@ -298,7 +298,7 @@ class CacheActivity : VMBaseActivity() private fun alertExportFileName() { alert(R.string.export_file_name) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.hint = "file name js" + textInputLayout.hint = "file name js" editView.setText(AppConfig.bookExportFileName) } customView { alertBinding.root } @@ -318,7 +318,7 @@ class CacheActivity : VMBaseActivity() private fun showCharsetConfig() { alert(R.string.set_charset) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.hint = "charset name" + textInputLayout.hint = "charset name" editView.setFilterValues(charsets) editView.setText(AppConfig.exportCharset) } diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupEdit.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupEdit.kt index c2a3610cf..79d66bd42 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupEdit.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupEdit.kt @@ -15,7 +15,7 @@ object GroupEdit { fun show(context: Context, layoutInflater: LayoutInflater, bookGroup: BookGroup) = context.run { alert(title = getString(R.string.group_edit)) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.setHint(R.string.group_name) + textInputLayout.setHint(R.string.group_name) editView.setText(bookGroup.groupName) } if (bookGroup.groupId >= 0) { diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index ca6271a15..89dfd8495 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -103,7 +103,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener private fun addGroup() { alert(title = getString(R.string.add_group)) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.setHint(R.string.group_name) + textInputLayout.setHint(R.string.group_name) } customView { alertBinding.root } yesButton { diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index d202701ab..8a7fff0a5 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -125,7 +125,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener private fun addGroup() { alert(title = getString(R.string.add_group)) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.setHint(R.string.group_name) + textInputLayout.setHint(R.string.group_name) } customView { alertBinding.root } yesButton { @@ -143,7 +143,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener private fun editGroup(bookGroup: BookGroup) { alert(title = getString(R.string.group_edit)) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.setHint(R.string.group_name) + textInputLayout.setHint(R.string.group_name) editView.setText(bookGroup.groupName) } customView { alertBinding.root } diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index 0601cacd0..bea70bba4 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -280,7 +280,7 @@ class ImportBookActivity : VMBaseActivity - - + android:layout_height="wrap_content"> - \ No newline at end of file + + + + + \ No newline at end of file From 4de996711fb1d440cacb0508f486985b274f56a9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 22:14:44 +0800 Subject: [PATCH 24/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseActivity.kt | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 306e61943..1d8b1f7cf 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -12,7 +12,6 @@ import android.view.MenuItem import android.view.View import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity -import androidx.preference.PreferenceManager import androidx.viewbinding.ViewBinding import com.google.android.renderscript.Toolkit import io.legado.app.App @@ -180,7 +179,9 @@ abstract class BaseActivity( } if (imageBg) { try { - window.decorView.background = BitmapDrawable(resources, getBackgroundImage(ThemeConfig.getBgImage(this) ?: return)) + getBackgroundImage()?.let { + window.decorView.background = BitmapDrawable(resources, it) + } } catch (e: OutOfMemoryError) { toastOnUi(e.localizedMessage) } catch (e: Exception) { @@ -189,20 +190,14 @@ abstract class BaseActivity( } } - private fun getBackgroundImage(bitmap: Bitmap): Bitmap { - when (Theme.getTheme()) { - Theme.Light -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageBlurring, 0).apply { - if (this != 0) { - return Toolkit.blur(bitmap, this) - } - } - Theme.Dark -> PreferenceManager.getDefaultSharedPreferences(this).getInt(bgImageNBlurring, 0).apply { - if (this != 0) { - return Toolkit.blur(bitmap, this) - } - } + private fun getBackgroundImage(): Bitmap? { + val bgImage = ThemeConfig.getBgImage(this) ?: return null + val blur = if (AppConfig.isNightTheme) { + getPrefInt(bgImageBlurring, 0) + } else { + getPrefInt(bgImageNBlurring, 0) } - return bitmap + return Toolkit.blur(bgImage, blur) } private fun setupSystemBar() { From 0994e59d4c8ce33462a7d6b4b67bb9aceb0c15e1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 23:30:10 +0800 Subject: [PATCH 25/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseActivity.kt | 16 +---------- .../java/io/legado/app/help/ThemeConfig.kt | 26 ++++++++++++------ .../ui/book/changecover/ChangeCoverDialog.kt | 5 ++-- .../book/changesource/ChangeSourceDialog.kt | 2 +- .../app/ui/book/group/GroupManageDialog.kt | 4 +-- .../app/ui/book/group/GroupSelectDialog.kt | 4 +-- .../book/read/config/PaddingConfigDialog.kt | 4 +-- .../book/read/config/ReadAloudConfigDialog.kt | 4 +-- .../ui/book/read/config/SpeakEngineDialog.kt | 2 +- .../app/ui/book/read/config/TocRegexDialog.kt | 2 +- .../source/edit/BookSourceEditActivity.kt | 2 +- .../book/source/manage/GroupManageDialog.kt | 4 +-- .../legado/app/ui/config/ThemeListDialog.kt | 2 +- .../app/ui/document/FilePickerDialog.kt | 2 +- .../app/ui/replace/GroupManageDialog.kt | 2 +- .../ui/replace/edit/ReplaceEditActivity.kt | 4 +-- .../rss/source/edit/RssSourceEditActivity.kt | 2 +- .../ui/rss/source/manage/GroupManageDialog.kt | 2 +- .../legado/app/ui/widget/dialog/TextDialog.kt | 4 +-- .../app/ui/widget/dialog/TextListDialog.kt | 4 +-- .../app/ui/widget/font/FontSelectDialog.kt | 2 +- .../app/ui/widget/prefs/IconListPreference.kt | 4 +-- .../io/legado/app/utils/ActivityExtensions.kt | 27 ++++++++++--------- .../{MiscExtensions.kt => JsonExtensions.kt} | 0 24 files changed, 63 insertions(+), 67 deletions(-) rename app/src/main/java/io/legado/app/utils/{MiscExtensions.kt => JsonExtensions.kt} (100%) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 1d8b1f7cf..8f4105882 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -2,7 +2,6 @@ package io.legado.app.base import android.content.Context import android.content.res.Configuration -import android.graphics.Bitmap import android.graphics.drawable.BitmapDrawable import android.os.Build import android.os.Bundle @@ -13,13 +12,10 @@ import android.view.View import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity import androidx.viewbinding.ViewBinding -import com.google.android.renderscript.Toolkit import io.legado.app.App import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey -import io.legado.app.constant.PreferKey.bgImageBlurring -import io.legado.app.constant.PreferKey.bgImageNBlurring import io.legado.app.constant.Theme import io.legado.app.help.AppConfig import io.legado.app.help.ThemeConfig @@ -179,7 +175,7 @@ abstract class BaseActivity( } if (imageBg) { try { - getBackgroundImage()?.let { + ThemeConfig.getBgImage(this, windowSize)?.let { window.decorView.background = BitmapDrawable(resources, it) } } catch (e: OutOfMemoryError) { @@ -190,16 +186,6 @@ abstract class BaseActivity( } } - private fun getBackgroundImage(): Bitmap? { - val bgImage = ThemeConfig.getBgImage(this) ?: return null - val blur = if (AppConfig.isNightTheme) { - getPrefInt(bgImageBlurring, 0) - } else { - getPrefInt(bgImageNBlurring, 0) - } - return Toolkit.blur(bgImage, blur) - } - private fun setupSystemBar() { if (fullScreen && !isInMultiWindow) { ATH.fullScreen(this) diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index 39d33e02b..506082c9d 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -2,10 +2,11 @@ package io.legado.app.help import android.content.Context import android.graphics.Bitmap -import android.graphics.BitmapFactory import android.graphics.Color +import android.util.DisplayMetrics import androidx.annotation.Keep import androidx.appcompat.app.AppCompatDelegate +import com.google.android.renderscript.Toolkit import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -43,14 +44,23 @@ object ThemeConfig { AppCompatDelegate.setDefaultNightMode(targetMode) } - fun getBgImage(context: Context): Bitmap? { - val bgPath = when (Theme.getTheme()) { - Theme.Light -> context.getPrefString(PreferKey.bgImage) - Theme.Dark -> context.getPrefString(PreferKey.bgImageN) + fun getBgImage(context: Context, metrics: DisplayMetrics): Bitmap? { + val bgCfg = when (Theme.getTheme()) { + Theme.Light -> Pair( + context.getPrefString(PreferKey.bgImage), + context.getPrefInt(PreferKey.bgImageBlurring, 0) + ) + Theme.Dark -> Pair( + context.getPrefString(PreferKey.bgImageN), + context.getPrefInt(PreferKey.bgImageNBlurring, 0) + ) else -> null - } - if (bgPath.isNullOrBlank()) return null - return BitmapFactory.decodeFile(bgPath) + } ?: return null + if (bgCfg.first.isNullOrBlank()) return null + val bgImage = BitmapUtils + .decodeBitmap(bgCfg.first!!, metrics.widthPixels, metrics.heightPixels) + ?: return null + return Toolkit.blur(bgImage, bgCfg.second) } fun upConfig() { diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 5558da7fc..2d3084173 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -14,9 +14,8 @@ import io.legado.app.base.BaseDialogFragment import io.legado.app.databinding.DialogChangeCoverBinding import io.legado.app.lib.theme.primaryColor import io.legado.app.utils.applyTint -import io.legado.app.utils.getSize - import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize class ChangeCoverDialog : BaseDialogFragment(), @@ -45,7 +44,7 @@ class ChangeCoverDialog : BaseDialogFragment(), override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index acd00f18d..b5e3873b6 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -53,7 +53,7 @@ class ChangeSourceDialog : BaseDialogFragment(), override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index 89dfd8495..b3e7dfc66 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -28,10 +28,10 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint -import io.legado.app.utils.getSize import io.legado.app.utils.requestInputMethod import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.visible +import io.legado.app.utils.windowSize import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch @@ -43,7 +43,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index 8a7fff0a5..6beb2e626 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -29,9 +29,9 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint -import io.legado.app.utils.getSize import io.legado.app.utils.requestInputMethod import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch @@ -61,7 +61,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index e44eeb8b2..d07fb7618 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -11,9 +11,9 @@ import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.EventBus import io.legado.app.databinding.DialogReadPaddingBinding import io.legado.app.help.ReadBookConfig -import io.legado.app.utils.getSize import io.legado.app.utils.postEvent import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize class PaddingConfigDialog : BaseDialogFragment() { @@ -21,7 +21,7 @@ class PaddingConfigDialog : BaseDialogFragment() { override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) val attr = it.attributes diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt index 38bf88920..d161a4ede 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt @@ -19,8 +19,8 @@ import io.legado.app.lib.theme.backgroundColor import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud import io.legado.app.utils.getPrefLong -import io.legado.app.utils.getSize import io.legado.app.utils.postEvent +import io.legado.app.utils.windowSize import splitties.init.appCtx class ReadAloudConfigDialog : DialogFragment() { @@ -28,7 +28,7 @@ class ReadAloudConfigDialog : DialogFragment() { override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.let { it.setBackgroundDrawableResource(R.color.transparent) it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt index 6ecc7356b..97e3a2bf6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt @@ -54,7 +54,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index 6e278246f..56aa2eb69 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -45,7 +45,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.8).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 0ab548be7..74c2aaf8f 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -444,7 +444,7 @@ class BookSourceEditActivity : val rect = Rect() // 获取当前页面窗口的显示范围 window.decorView.getWindowVisibleDisplayFrame(rect) - val screenHeight = this@BookSourceEditActivity.getSize().heightPixels + val screenHeight = this@BookSourceEditActivity.windowSize.heightPixels val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 val preShowing = mIsSoftKeyBoardShowing if (abs(keyboardHeight) > screenHeight / 5) { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt index 92ffb0c9a..9d608d7b7 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt @@ -24,10 +24,10 @@ import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint -import io.legado.app.utils.getSize import io.legado.app.utils.requestInputMethod import io.legado.app.utils.splitNotBlank import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch @@ -39,7 +39,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt index be118d3de..b4275a7ae 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt @@ -26,7 +26,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/document/FilePickerDialog.kt b/app/src/main/java/io/legado/app/ui/document/FilePickerDialog.kt index af573efb0..06964a969 100644 --- a/app/src/main/java/io/legado/app/ui/document/FilePickerDialog.kt +++ b/app/src/main/java/io/legado/app/ui/document/FilePickerDialog.kt @@ -76,7 +76,7 @@ class FilePickerDialog : DialogFragment(), override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.8).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt index 814f7493e..9572b2582 100644 --- a/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt @@ -36,7 +36,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt b/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt index 8fd22551a..922875250 100644 --- a/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt @@ -19,9 +19,9 @@ import io.legado.app.databinding.ActivityReplaceEditBinding import io.legado.app.lib.dialogs.selector import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.ui.widget.dialog.TextDialog -import io.legado.app.utils.getSize import io.legado.app.utils.toastOnUi import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize import kotlin.math.abs /** @@ -166,7 +166,7 @@ class ReplaceEditActivity : val rect = Rect() // 获取当前页面窗口的显示范围 window.decorView.getWindowVisibleDisplayFrame(rect) - val screenHeight = this.getSize().heightPixels + val screenHeight = this.windowSize.heightPixels val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 val preShowing = mIsSoftKeyBoardShowing if (abs(keyboardHeight) > screenHeight / 5) { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index cd941c206..f5eac52f4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -256,7 +256,7 @@ class RssSourceEditActivity : val rect = Rect() // 获取当前页面窗口的显示范围 window.decorView.getWindowVisibleDisplayFrame(rect) - val screenHeight = this@RssSourceEditActivity.getSize().heightPixels + val screenHeight = this@RssSourceEditActivity.windowSize.heightPixels val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 val preShowing = mIsSoftKeyBoardShowing if (abs(keyboardHeight) > screenHeight / 5) { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt index f058c5577..7696f4b58 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt @@ -37,7 +37,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt index 8c1df6110..75d02b6b5 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt @@ -8,8 +8,8 @@ import androidx.fragment.app.FragmentManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.databinding.DialogTextViewBinding -import io.legado.app.utils.getSize import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize import io.noties.markwon.Markwon import io.noties.markwon.ext.tables.TablePlugin import io.noties.markwon.html.HtmlPlugin @@ -49,7 +49,7 @@ class TextDialog : BaseDialogFragment() { override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt index cc79dc726..6dd173274 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt @@ -13,8 +13,8 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.RecyclerAdapter import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.ItemLogBinding -import io.legado.app.utils.getSize import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize class TextListDialog : BaseDialogFragment() { @@ -35,7 +35,7 @@ class TextListDialog : BaseDialogFragment() { override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 22f205101..3b25ba29d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -65,7 +65,7 @@ class FontSelectDialog : BaseDialogFragment(), override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt()) } diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index 12b33a2c7..bf469748c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -21,8 +21,8 @@ import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.ItemIconPreferenceBinding import io.legado.app.lib.theme.primaryColor import io.legado.app.utils.getCompatDrawable -import io.legado.app.utils.getSize import io.legado.app.utils.viewbindingdelegate.viewBinding +import io.legado.app.utils.windowSize class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference(context, attrs) { @@ -131,7 +131,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference override fun onStart() { super.onStart() - val dm = requireActivity().getSize() + val dm = requireActivity().windowSize dialog?.window?.setLayout( (dm.widthPixels * 0.8).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT diff --git a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt index 72840c097..842a95bbe 100644 --- a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt @@ -6,20 +6,21 @@ import android.util.DisplayMetrics import android.view.WindowInsets import android.view.WindowMetrics -fun Activity.getSize(): DisplayMetrics { - val displayMetrics = DisplayMetrics() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - val windowMetrics: WindowMetrics = windowManager.currentWindowMetrics - val insets = windowMetrics.windowInsets - .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()) - displayMetrics.widthPixels = windowMetrics.bounds.width() - insets.left - insets.right - displayMetrics.heightPixels = windowMetrics.bounds.height() - insets.top - insets.bottom - } else { - @Suppress("DEPRECATION") - windowManager.defaultDisplay.getMetrics(displayMetrics) +val Activity.windowSize: DisplayMetrics + get() { + val displayMetrics = DisplayMetrics() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + val windowMetrics: WindowMetrics = windowManager.currentWindowMetrics + val insets = windowMetrics.windowInsets + .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()) + displayMetrics.widthPixels = windowMetrics.bounds.width() - insets.left - insets.right + displayMetrics.heightPixels = windowMetrics.bounds.height() - insets.top - insets.bottom + } else { + @Suppress("DEPRECATION") + windowManager.defaultDisplay.getMetrics(displayMetrics) + } + return displayMetrics } - return displayMetrics -} /** * 该方法需要在View完全被绘制出来之后调用,否则判断不了 diff --git a/app/src/main/java/io/legado/app/utils/MiscExtensions.kt b/app/src/main/java/io/legado/app/utils/JsonExtensions.kt similarity index 100% rename from app/src/main/java/io/legado/app/utils/MiscExtensions.kt rename to app/src/main/java/io/legado/app/utils/JsonExtensions.kt From bb8ff27b07b1019539bc587f6d4e33ea71a19557 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 4 Aug 2021 23:41:18 +0800 Subject: [PATCH 26/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 3 --- app/src/main/java/io/legado/app/help/ThemeConfig.kt | 3 +-- app/src/main/java/io/legado/app/utils/BitmapUtils.kt | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e49b041a2..58ce975d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -213,9 +213,6 @@ dependencies { implementation("io.noties.markwon:ext-tables:$markwonVersion") implementation("io.noties.markwon:html:$markwonVersion") - // 谷歌RenderScript库 - implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3') - //转换繁体 implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.1') diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index 506082c9d..1da67c7cb 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -6,7 +6,6 @@ import android.graphics.Color import android.util.DisplayMetrics import androidx.annotation.Keep import androidx.appcompat.app.AppCompatDelegate -import com.google.android.renderscript.Toolkit import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -60,7 +59,7 @@ object ThemeConfig { val bgImage = BitmapUtils .decodeBitmap(bgCfg.first!!, metrics.widthPixels, metrics.heightPixels) ?: return null - return Toolkit.blur(bgImage, bgCfg.second) + return BitmapUtils.stackBlur(bgImage, bgCfg.second.toFloat()) } fun upConfig() { diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index 2e7ae06ba..c200980c2 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -249,7 +249,7 @@ object BitmapUtils { /** * 高斯模糊 */ - fun stackBlur(srcBitmap: Bitmap?): Bitmap? { + fun stackBlur(srcBitmap: Bitmap?, radius: Float = 8f): Bitmap? { if (srcBitmap == null) return null val rs = RenderScript.create(appCtx) val blurredBitmap = srcBitmap.copy(Config.ARGB_8888, true) @@ -268,7 +268,7 @@ object BitmapUtils { script.setInput(input) //设置模糊半径 - script.setRadius(8f) + script.setRadius(radius) //启动 ScriptIntrinsicBlur script.forEach(output) From 1f3e13b169ef312764e913462a8a792a61aeff1c Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 08:05:09 +0800 Subject: [PATCH 27/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ThemeConfig.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index 1da67c7cb..8918a3596 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -59,6 +59,9 @@ object ThemeConfig { val bgImage = BitmapUtils .decodeBitmap(bgCfg.first!!, metrics.widthPixels, metrics.heightPixels) ?: return null + if (bgCfg.second == 0) { + return bgImage + } return BitmapUtils.stackBlur(bgImage, bgCfg.second.toFloat()) } From dd15cab020c7e9f56d55bb6eab0cbc031c08adb5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 09:34:32 +0800 Subject: [PATCH 28/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/config/ImageBlurringDialogFragment.kt | 53 ------------------- .../app/ui/config/ThemeConfigFragment.kt | 46 ++++++++++++++-- ...g_dialog.xml => dialog_image_blurring.xml} | 26 ++++----- 3 files changed, 55 insertions(+), 70 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt rename app/src/main/res/layout/{fragment_image_blurring_dialog.xml => dialog_image_blurring.xml} (67%) diff --git a/app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt b/app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt deleted file mode 100644 index 06065dd69..000000000 --- a/app/src/main/java/io/legado/app/ui/config/ImageBlurringDialogFragment.kt +++ /dev/null @@ -1,53 +0,0 @@ -package io.legado.app.ui.config - -import android.app.Dialog -import android.content.SharedPreferences -import android.os.Bundle -import android.widget.SeekBar -import androidx.appcompat.app.AlertDialog -import androidx.fragment.app.DialogFragment -import androidx.fragment.app.FragmentManager -import androidx.preference.PreferenceManager -import io.legado.app.R -import io.legado.app.databinding.FragmentImageBlurringDialogBinding - -class ImageBlurringDialogFragment(private val prefName: String, private val block: () -> Unit): DialogFragment() { - - companion object { - private const val DEFAULT_VALUE = 0 - private const val TAG = "ImageBlurringDialogFragment" - } - - private val requireContext get() = requireContext() - private var _fragmentImageBlurringDialogBinding: FragmentImageBlurringDialogBinding? = null - private val fragmentImageBlurringDialog get() = _fragmentImageBlurringDialogBinding!! - private lateinit var sharedPreference: SharedPreferences - - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - _fragmentImageBlurringDialogBinding = FragmentImageBlurringDialogBinding.inflate(layoutInflater) - sharedPreference = PreferenceManager.getDefaultSharedPreferences(requireContext) - sharedPreference.getInt(prefName, DEFAULT_VALUE).apply { - fragmentImageBlurringDialog.seekBar.progress = this - fragmentImageBlurringDialog.textViewValue.text = this.toString() - } - fragmentImageBlurringDialog.seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { - override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { - fragmentImageBlurringDialog.textViewValue.text = progress.toString() - } - override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit - override fun onStopTrackingTouch(seekBar: SeekBar?) = Unit - }) - return AlertDialog.Builder(requireContext) - .setTitle(R.string.background_image_blurring_radius) - .setView(fragmentImageBlurringDialog.root) - .setPositiveButton(R.string.dialog_confirm) { _, _ -> - sharedPreference.edit().putInt(prefName, fragmentImageBlurringDialog.seekBar.progress).commit() - block() - } - .setNegativeButton(R.string.dialog_cancel) { _, _ -> } - .create() - } - - fun show(fragmentManager: FragmentManager) = show(fragmentManager, TAG) - -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 44c7f0b28..510819f23 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -9,6 +9,7 @@ import android.view.Menu import android.view.MenuInflater import android.view.MenuItem import android.view.View +import android.widget.SeekBar import androidx.documentfile.provider.DocumentFile import androidx.preference.Preference import io.legado.app.R @@ -17,6 +18,7 @@ import io.legado.app.constant.AppConst import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.databinding.DialogEditTextBinding +import io.legado.app.databinding.DialogImageBlurringBinding import io.legado.app.help.AppConfig import io.legado.app.help.LauncherIconHelp import io.legado.app.help.ThemeConfig @@ -28,6 +30,7 @@ import io.legado.app.lib.theme.ATH import io.legado.app.ui.widget.image.CoverImageView import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.ui.widget.prefs.ColorPreference +import io.legado.app.ui.widget.seekbar.SeekBarChangeListener import io.legado.app.utils.* import java.io.File @@ -134,7 +137,10 @@ class ThemeConfigFragment : BasePreferenceFragment(), PreferKey.cNBBackground -> { upTheme(true) } - PreferKey.defaultCover, PreferKey.defaultCoverDark -> { + PreferKey.bgImage, + PreferKey.bgImageN, + PreferKey.defaultCover, + PreferKey.defaultCoverDark -> { upPreferenceSummary(key, getPrefString(key)) } } @@ -183,8 +189,12 @@ class ThemeConfigFragment : BasePreferenceFragment(), } } } - PreferKey.bgImageBlurring -> ImageBlurringDialogFragment(PreferKey.bgImageBlurring) { upTheme(false) }.show(parentFragmentManager) - PreferKey.bgImageNBlurring -> ImageBlurringDialogFragment(PreferKey.bgImageNBlurring) { upTheme(true) }.show(parentFragmentManager) + PreferKey.bgImageBlurring -> alertImageBlurring(PreferKey.bgImageBlurring) { + upTheme(false) + } + PreferKey.bgImageNBlurring -> alertImageBlurring(PreferKey.bgImageNBlurring) { + upTheme(true) + } PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) { selectImage.launch(requestCodeCover) } else { @@ -235,6 +245,34 @@ class ThemeConfigFragment : BasePreferenceFragment(), }.show() } + private fun alertImageBlurring(preferKey: String, success: () -> Unit) { + alert(R.string.background_image_blurring) { + val alertBinding = DialogImageBlurringBinding.inflate(layoutInflater).apply { + getPrefInt(preferKey, 0).let { + seekBar.progress = it + textViewValue.text = it.toString() + } + seekBar.setOnSeekBarChangeListener(object : SeekBarChangeListener { + override fun onProgressChanged( + seekBar: SeekBar, + progress: Int, + fromUser: Boolean + ) { + textViewValue.text = progress.toString() + } + }) + } + customView { alertBinding.root } + okButton { + alertBinding.seekBar.progress.let { + putPrefInt(preferKey, it) + success.invoke() + } + } + noButton() + }.show() + } + private fun upTheme(isNightTheme: Boolean) { if (AppConfig.isNightTheme == isNightTheme) { listView.post { @@ -276,7 +314,6 @@ class ThemeConfigFragment : BasePreferenceFragment(), }.getOrNull()?.let { byteArray -> file.writeBytes(byteArray) putPrefString(preferenceKey, file.absolutePath) - upPreferenceSummary(preferenceKey, file.absolutePath) success() } ?: toastOnUi("获取文件出错") } @@ -295,7 +332,6 @@ class ThemeConfigFragment : BasePreferenceFragment(), file = FileUtils.createFileIfNotExist(file, preferenceKey, imgFile.name) file.writeBytes(imgFile.readBytes()) putPrefString(preferenceKey, file.absolutePath) - upPreferenceSummary(preferenceKey, file.absolutePath) success() } } diff --git a/app/src/main/res/layout/fragment_image_blurring_dialog.xml b/app/src/main/res/layout/dialog_image_blurring.xml similarity index 67% rename from app/src/main/res/layout/fragment_image_blurring_dialog.xml rename to app/src/main/res/layout/dialog_image_blurring.xml index 907aff57c..b9d20e55e 100644 --- a/app/src/main/res/layout/fragment_image_blurring_dialog.xml +++ b/app/src/main/res/layout/dialog_image_blurring.xml @@ -1,28 +1,30 @@ - - - + android:textColor="@color/primaryText" + android:textSize="17sp" /> + + \ No newline at end of file From 9b100ba6a485bd77abef7f9bc83c6ab957cd6d43 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 10:20:42 +0800 Subject: [PATCH 29/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/ThemeConfigFragment.kt | 66 ++++++++++--------- app/src/main/res/xml/pref_config_theme.xml | 36 ++++------ 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 510819f23..2367cc2cb 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -164,37 +164,9 @@ class ThemeConfigFragment : BasePreferenceFragment(), recreateActivities() } "themeList" -> ThemeListDialog().show(childFragmentManager, "themeList") - "saveDayTheme", "saveNightTheme" -> saveThemeAlert(key) - PreferKey.bgImage -> if (getPrefString(PreferKey.bgImage).isNullOrEmpty()) { - selectImage.launch(requestCodeBgLight) - } else { - selector(items = arrayListOf("删除图片", "选择图片")) { _, i -> - if (i == 0) { - removePref(PreferKey.bgImage) - upTheme(false) - } else { - selectImage.launch(requestCodeBgLight) - } - } - } - PreferKey.bgImageN -> if (getPrefString(PreferKey.bgImageN).isNullOrEmpty()) { - selectImage.launch(requestCodeBgDark) - } else { - selector(items = arrayListOf("删除图片", "选择图片")) { _, i -> - if (i == 0) { - removePref(PreferKey.bgImageN) - upTheme(true) - } else { - selectImage.launch(requestCodeBgDark) - } - } - } - PreferKey.bgImageBlurring -> alertImageBlurring(PreferKey.bgImageBlurring) { - upTheme(false) - } - PreferKey.bgImageNBlurring -> alertImageBlurring(PreferKey.bgImageNBlurring) { - upTheme(true) - } + "saveDayTheme", "saveNightTheme" -> alertSaveTheme(key) + PreferKey.bgImage -> selectBgAction(false) + PreferKey.bgImageN -> selectBgAction(true) PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) { selectImage.launch(requestCodeCover) } else { @@ -223,7 +195,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), } @SuppressLint("InflateParams") - private fun saveThemeAlert(key: String) { + private fun alertSaveTheme(key: String) { alert(R.string.theme_name) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { textInputLayout.hint = "name" @@ -245,6 +217,36 @@ class ThemeConfigFragment : BasePreferenceFragment(), }.show() } + private fun selectBgAction(isNight: Boolean) { + val bgKey = if (isNight) PreferKey.bgImageN else PreferKey.bgImage + val blurringKey = if (isNight) PreferKey.bgImageNBlurring else PreferKey.bgImageBlurring + val actions = arrayListOf( + getString(R.string.background_image_blurring), + getString(R.string.select_image) + ) + if (!getPrefString(bgKey).isNullOrEmpty()) { + actions.add(getString(R.string.delete)) + } + selector(items = actions) { _, i -> + when (i) { + 0 -> alertImageBlurring(blurringKey) { + upTheme(isNight) + } + 1 -> { + if (isNight) { + selectImage.launch(requestCodeBgDark) + } else { + selectImage.launch(requestCodeBgLight) + } + } + 2 -> { + removePref(bgKey) + upTheme(isNight) + } + } + } + } + private fun alertImageBlurring(preferKey: String, success: () -> Unit) { alert(R.string.background_image_blurring) { val alertBinding = DialogImageBlurringBinding.inflate(layoutInflater).apply { diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 564cb9811..a30c3c603 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -82,14 +82,6 @@ app:cpv_dialogType="preset" app:iconSpaceReserved="false" /> - - - - + + + android:title="@string/default_cover" /> - - - - + + + android:title="@string/default_cover" /> From 967ae46c78c311b51fcf00d8e7f17d372fcef7de Mon Sep 17 00:00:00 2001 From: NineWorlds <1365887550@qq.com> Date: Thu, 5 Aug 2021 14:46:08 +0800 Subject: [PATCH 30/40] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=BF=BB=E9=A1=B5?= =?UTF-8?q?=E6=97=B6=E5=B1=8F=E5=B9=95=E5=B8=B8=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 3 +++ 1 file changed, 3 insertions(+) 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 65bbfc910..25b65117f 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 @@ -686,6 +686,8 @@ class ReadBookActivity : ReadBookBaseActivity(), binding.readView.upContent(1) autoPagePlus() binding.readMenu.setAutoPage(true) + screenTimeOut=-1L + screenOffTimerStart() } } @@ -694,6 +696,7 @@ class ReadBookActivity : ReadBookBaseActivity(), mHandler.removeCallbacks(autoPageRunnable) binding.readView.upContent() binding.readMenu.setAutoPage(false) + upScreenTimeOut() } private fun autoPagePlus() { From 29475f2cee75adb0dd8c32d15afdcda1cbf81ede Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 15:55:30 +0800 Subject: [PATCH 31/40] =?UTF-8?q?=E6=8D=A2=E6=BA=90=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=8E=E6=9B=B4=E6=96=B0=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E6=BA=90=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/EventBus.kt | 1 + .../legado/app/ui/book/audio/AudioPlayViewModel.kt | 3 +++ .../app/ui/book/changesource/ChangeSourceAdapter.kt | 5 +++++ .../app/ui/book/changesource/ChangeSourceDialog.kt | 12 +++++++++++- .../io/legado/app/ui/book/info/BookInfoViewModel.kt | 3 +++ .../io/legado/app/ui/book/read/ReadBookViewModel.kt | 3 +++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/constant/EventBus.kt b/app/src/main/java/io/legado/app/constant/EventBus.kt index 04f165a60..1cb16afd5 100644 --- a/app/src/main/java/io/legado/app/constant/EventBus.kt +++ b/app/src/main/java/io/legado/app/constant/EventBus.kt @@ -24,4 +24,5 @@ object EventBus { const val CHECK_SOURCE = "checkSource" const val CHECK_SOURCE_DONE = "checkSourceDone" const val TIP_COLOR = "tipColor" + const val SOURCE_CHANGED = "sourceChanged" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt index 8770dd494..6877bd036 100644 --- a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt @@ -4,12 +4,14 @@ import android.app.Application import android.content.Intent import io.legado.app.R import io.legado.app.base.BaseViewModel +import io.legado.app.constant.EventBus import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp import io.legado.app.model.webBook.WebBook import io.legado.app.service.help.AudioPlay +import io.legado.app.utils.postEvent import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers @@ -98,6 +100,7 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) } else { loadChapterList(book1) { upChangeDurChapterIndex(book1, oldTocSize, it) } } + postEvent(EventBus.SOURCE_CHANGED, book1.bookUrl) } } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index d34f7a441..35eea0a90 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -62,6 +62,11 @@ class ChangeSourceAdapter( when (it) { "name" -> tvOrigin.text = item.originName "latest" -> tvLast.text = item.getDisplayLastChapterTitle() + "upCurSource" -> if (callBack.bookUrl == item.bookUrl) { + ivChecked.visible() + } else { + ivChecked.invisible() + } } } } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index b5e3873b6..392349057 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.AppPattern +import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.appDb import io.legado.app.data.entities.Book @@ -218,12 +219,12 @@ class ChangeSourceDialog : BaseDialogFragment(), } override fun deleteSource(searchBook: SearchBook) { + viewModel.del(searchBook) if (bookUrl == searchBook.bookUrl) { viewModel.firstSourceOrNull(searchBook)?.let { changeSource(it) } } - viewModel.del(searchBook) } private fun changeSource(searchBook: SearchBook) { @@ -259,6 +260,15 @@ class ChangeSourceDialog : BaseDialogFragment(), } } + override fun observeLiveBus() { + observeEvent(EventBus.SOURCE_CHANGED) { + val payload = Bundle().apply { + putString("upCurSource", bookUrl) + } + adapter.notifyItemRangeChanged(0, adapter.itemCount, payload) + } + } + interface CallBack { val oldBook: Book? fun changeTo(book: Book) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index ddb0f9b0d..eef30dc4e 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -5,6 +5,7 @@ import android.content.Intent import androidx.lifecycle.MutableLiveData import io.legado.app.R import io.legado.app.base.BaseViewModel +import io.legado.app.constant.EventBus import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -13,6 +14,7 @@ import io.legado.app.help.BookHelp import io.legado.app.model.localBook.LocalBook import io.legado.app.model.webBook.WebBook import io.legado.app.service.help.ReadBook +import io.legado.app.utils.postEvent import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers.IO @@ -167,6 +169,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { upChangeDurChapterIndex(newBook, oldTocSize, it) } } + postEvent(EventBus.SOURCE_CHANGED, newBook.bookUrl) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 968ffbd80..ebaa2f4bf 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -5,6 +5,7 @@ import android.content.Intent import androidx.lifecycle.viewModelScope import io.legado.app.R import io.legado.app.base.BaseViewModel +import io.legado.app.constant.EventBus import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -20,6 +21,7 @@ import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud import io.legado.app.service.help.ReadBook import io.legado.app.utils.msg +import io.legado.app.utils.postEvent import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main @@ -207,6 +209,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { upChangeDurChapterIndex(newBook, oldTocSize, it) } } + postEvent(EventBus.SOURCE_CHANGED, newBook.bookUrl) } } From 3465a79349f72237113dde6190ed37ec18f90216 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 18:33:46 +0800 Subject: [PATCH 32/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/AudioPlayService.kt | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 4c9d247ce..3611280ce 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -161,17 +161,22 @@ class AudioPlayService : BaseService(), } private fun resume() { - pause = false - if (!mediaPlayer.isPlaying) { - mediaPlayer.start() - mediaPlayer.seekTo(position) + try { + pause = false + if (!mediaPlayer.isPlaying) { + mediaPlayer.start() + mediaPlayer.seekTo(position) + } + handler.removeCallbacks(mpRunnable) + handler.postDelayed(mpRunnable, 1000) + upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) + AudioPlay.status = Status.PLAY + postEvent(EventBus.AUDIO_STATE, Status.PLAY) + upNotification() + } catch (e: Exception) { + e.printStackTrace() + stopSelf() } - handler.removeCallbacks(mpRunnable) - handler.postDelayed(mpRunnable, 1000) - upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) - AudioPlay.status = Status.PLAY - postEvent(EventBus.AUDIO_STATE, Status.PLAY) - upNotification() } private fun adjustProgress(position: Int) { From 24f8996969f5ccf926658375604b3d80561a6924 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 20:10:46 +0800 Subject: [PATCH 33/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt | 1 + .../main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt | 1 + .../main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 1 + 3 files changed, 3 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt index 6877bd036..086443409 100644 --- a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayViewModel.kt @@ -100,6 +100,7 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) } else { loadChapterList(book1) { upChangeDurChapterIndex(book1, oldTocSize, it) } } + }.onFinally { postEvent(EventBus.SOURCE_CHANGED, book1.bookUrl) } } diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index eef30dc4e..f7ba8ff00 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -169,6 +169,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { upChangeDurChapterIndex(newBook, oldTocSize, it) } } + }.onFinally { postEvent(EventBus.SOURCE_CHANGED, newBook.bookUrl) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index ebaa2f4bf..9395b8f1c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -209,6 +209,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { upChangeDurChapterIndex(newBook, oldTocSize, it) } } + }.onFinally { postEvent(EventBus.SOURCE_CHANGED, newBook.bookUrl) } } From 8ffb5cada08b14a3304987bf375d64a922cdf526 Mon Sep 17 00:00:00 2001 From: Eternal Times <1749119916@qq.com> Date: Thu, 5 Aug 2021 20:57:05 +0800 Subject: [PATCH 34/40] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/epub/chapter.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/assets/epub/chapter.html b/app/src/main/assets/epub/chapter.html index 6067f6649..39b505fad 100644 --- a/app/src/main/assets/epub/chapter.html +++ b/app/src/main/assets/epub/chapter.html @@ -10,6 +10,8 @@ +
+

{title}

{content} From e0a05181031a19c77b1da11a37a92412aa18c85e Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 5 Aug 2021 21:13:50 +0800 Subject: [PATCH 35/40] =?UTF-8?q?=E4=B9=A6=E7=B1=8D=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=8F=9C=E5=8D=95=E6=B7=BB=E5=8A=A0=E7=BD=AE?= =?UTF-8?q?=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/dao/BookDao.kt | 3 +++ .../io/legado/app/ui/book/info/BookInfoActivity.kt | 10 ++++++++++ .../io/legado/app/ui/book/info/BookInfoViewModel.kt | 10 ++++++++++ .../io/legado/app/ui/book/read/ReadBookActivity.kt | 11 +++++------ app/src/main/res/menu/book_info.xml | 5 +++++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index bfc933f64..42ceea9a4 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -62,6 +62,9 @@ interface BookDao { @get:Query("SELECT COUNT(*) FROM books") val allBookCount: Int + @get:Query("select min(`order`) from books") + val minOrder: Int + @get:Query("select max(`order`) from books") val maxOrder: Int diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index cfdf84d02..b084d24b2 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -15,6 +15,7 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.request.RequestOptions.bitmapTransform import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.AppConst import io.legado.app.constant.BookType import io.legado.app.constant.Theme import io.legado.app.data.appDb @@ -36,6 +37,7 @@ import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.search.SearchActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.toc.TocActivityResult +import io.legado.app.ui.login.SourceLoginActivity import io.legado.app.ui.widget.image.CoverImageView import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -151,6 +153,14 @@ class BookInfoActivity : viewModel.loadBookInfo(it, false) } } + R.id.menu_login -> viewModel.bookSource?.let { + startActivity { + putExtra("sourceUrl", it.bookSourceUrl) + putExtra("loginUrl", it.loginUrl) + putExtra("userAgent", it.getHeaderMap()[AppConst.UA_NAME]) + } + } + R.id.menu_top -> viewModel.topBook() R.id.menu_copy_book_url -> viewModel.bookData.value?.bookUrl?.let { sendToClip(it) } ?: toastOnUi(R.string.no_book) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index f7ba8ff00..1a4e7e481 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -196,6 +196,16 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { } } + fun topBook() { + execute { + bookData.value?.let { book -> + val minOrder = appDb.bookDao.minOrder + book.order = minOrder - 1 + appDb.bookDao.update(book) + } + } + } + fun saveBook(success: (() -> Unit)? = null) { execute { bookData.value?.let { book -> 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 25b65117f..0e0152540 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 @@ -686,7 +686,7 @@ class ReadBookActivity : ReadBookBaseActivity(), binding.readView.upContent(1) autoPagePlus() binding.readMenu.setAutoPage(true) - screenTimeOut=-1L + screenTimeOut = -1L screenOffTimerStart() } } @@ -703,8 +703,8 @@ class ReadBookActivity : ReadBookBaseActivity(), var delayMillis = ReadBookConfig.autoReadSpeed * 1000L / binding.readView.height var scrollOffset = 1 if (delayMillis < 20) { - var delayInt=delayMillis.toInt() - if(delayInt==0)delayInt =1 + var delayInt = delayMillis.toInt() + if (delayInt == 0) delayInt = 1 scrollOffset = 20 / delayInt delayMillis = 20 } @@ -973,9 +973,8 @@ class ReadBookActivity : ReadBookBaseActivity(), } private fun upScreenTimeOut() { - getPrefString(PreferKey.keepLight)?.let { - screenTimeOut = it.toLong() * 1000 - } + val keepLightPrefer = getPrefString(PreferKey.keepLight)?.toInt() ?: 0 + screenTimeOut = keepLightPrefer * 1000L screenOffTimerStart() } diff --git a/app/src/main/res/menu/book_info.xml b/app/src/main/res/menu/book_info.xml index 0d8c97281..370597f5c 100644 --- a/app/src/main/res/menu/book_info.xml +++ b/app/src/main/res/menu/book_info.xml @@ -24,6 +24,11 @@ android:title="@string/login" app:showAsAction="never" /> + + Date: Thu, 5 Aug 2021 21:18:43 +0800 Subject: [PATCH 36/40] edit updateLog.md --- app/src/main/assets/updateLog.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 25069b073..fd0be8fc2 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -10,10 +10,15 @@ * 阅读只是一个转码工具,不提供内容,第一次安装app,需要自己手动导入书源,可以从公众号 **[开源阅读]**、QQ群、酷安评论里获取由书友制作分享的书源。 * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则出现问题, 出现简体变化问题检查一下简繁转换是否关闭。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! +* 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法 -**2021/08/02** +**2021/08/06** -* 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法 +1. 背景图片添加模糊设置 +2. 书籍信息界面添加置顶操作 +3. 自动翻页时屏幕常亮 + +**2021/08/02** 1. 换源界面功能添加:置顶,置底,删除 by h11128 2. Cronet:优化 by ag2s20150909 From 3cd000eebca215d695307719b3ae6bd9d168e1e6 Mon Sep 17 00:00:00 2001 From: HalfLife <6436073+o0HalfLife0o@users.noreply.github.com> Date: Thu, 5 Aug 2021 22:16:18 +0800 Subject: [PATCH 37/40] Update legado.yml --- .github/workflows/legado.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/legado.yml b/.github/workflows/legado.yml index 3702e0f5c..74e30a461 100644 --- a/.github/workflows/legado.yml +++ b/.github/workflows/legado.yml @@ -55,26 +55,30 @@ jobs: echo "开始进行release构建" chmod +x gradlew ./gradlew assembleAppRelease --build-cache --parallel + echo "开始进行cronet构建" + ./gradlew assembleCronetRelease --build-cache --parallel + - name: Organize the files + run: | + mkdir -p ${{ github.workspace }}/apk/ + cp -rf ${{ github.workspace }}/app/build/outputs/apk/*/*/*.apk ${{ github.workspace }}/apk/ - name: Upload App To Artifact if: ${{ env.UPLOAD_ARTIFACT != 'false' }} uses: actions/upload-artifact@v2 with: name: legado apk - path: ${{ github.workspace }}/app/build/outputs/apk/app/release/*.apk + path: ${{ github.workspace }}/apk/*.apk - name: Upload App To Lanzou if: ${{ env.ylogin }} run: | - path="$GITHUB_WORKSPACE/app/build/outputs/apk/app/release" + path="$GITHUB_WORKSPACE/apk" files=$(ls $path) for f in $files do if [[ $f == *"apk" ]]; then file=$f echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 文件:$file" - break + python3 $GITHUB_WORKSPACE/.github/scripts/lzy_web.py "$path/$file" "$LANZOU_FOLDER_ID" fi done - - python3 $GITHUB_WORKSPACE/.github/scripts/lzy_web.py "$path/$file" "$LANZOU_FOLDER_ID" echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: https://kunfei.lanzoux.com/b0f810h4b" From 101432d24a1c1bc9b61fc86429fd7d68a050b830 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 6 Aug 2021 12:28:28 +0800 Subject: [PATCH 38/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 4 ---- app/src/main/java/io/legado/app/base/BaseActivity.kt | 8 -------- .../app/ui/book/changesource/ChangeSourceDialog.kt | 10 ++++++---- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 1 + .../java/io/legado/app/ui/book/read/page/PageView.kt | 3 +-- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 24bfe161d..58d6094da 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -86,8 +86,4 @@ class App : MultiDexApplication() { } } - companion object { - var navigationBarHeight = 0 - } - } diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 8f4105882..deb4a5f62 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -12,7 +12,6 @@ import android.view.View import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity import androidx.viewbinding.ViewBinding -import io.legado.app.App import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey @@ -100,13 +99,6 @@ abstract class BaseActivity( observeLiveBus() } - override fun onWindowFocusChanged(hasFocus: Boolean) { - super.onWindowFocusChanged(hasFocus) - if (hasFocus) { - App.navigationBarHeight = navigationBarHeight - } - } - override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration?) { super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig) findViewById(R.id.title_bar) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 392349057..c79096391 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.* import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.Toolbar +import androidx.core.os.bundleOf import androidx.fragment.app.FragmentManager import androidx.fragment.app.viewModels import androidx.recyclerview.widget.LinearLayoutManager @@ -262,10 +263,11 @@ class ChangeSourceDialog : BaseDialogFragment(), override fun observeLiveBus() { observeEvent(EventBus.SOURCE_CHANGED) { - val payload = Bundle().apply { - putString("upCurSource", bookUrl) - } - adapter.notifyItemRangeChanged(0, adapter.itemCount, payload) + adapter.notifyItemRangeChanged( + 0, + adapter.itemCount, + bundleOf(Pair("upCurSource", bookUrl)) + ) } } 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 0e0152540..d5e0705db 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 @@ -150,6 +150,7 @@ class ReadBookActivity : ReadBookBaseActivity(), override fun onWindowFocusChanged(hasFocus: Boolean) { super.onWindowFocusChanged(hasFocus) + binding.readView.upStyle() upSystemUiVisibility() } 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 cc4399d85..0d9c0c146 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 @@ -7,7 +7,6 @@ import android.view.LayoutInflater import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible -import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.constant.AppConst.timeFormat @@ -85,7 +84,7 @@ class PageView(context: Context) : FrameLayout(context) { vwTopDivider.visible(it.showHeaderLine) vwBottomDivider.visible(it.showFooterLine) pageNvBar.layoutParams = pageNvBar.layoutParams.apply { - height = if (it.hideNavigationBar) 0 else App.navigationBarHeight + height = if (it.hideNavigationBar) 0 else activity?.navigationBarHeight ?: 0 } } contentTextView.upVisibleRect() From 8add075fc4e10cc4db96995134f75ef8a2e46511 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 6 Aug 2021 15:50:42 +0800 Subject: [PATCH 39/40] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/provider/ChapterProvider.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index 9f3b17088..74d4734b9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -343,8 +343,10 @@ object ChapterProvider { } x = x1 } - val words1 = words.copyOfRange(bodyIndent.length, words.size) - addCharsToLineMiddle(textLine, words1, textPaint, desiredWidth, x, srcList) + if (words.size > bodyIndent.length) { + val words1 = words.copyOfRange(bodyIndent.length, words.size) + addCharsToLineMiddle(textLine, words1, textPaint, desiredWidth, x, srcList) + } } /** From d7b53cfca40eb2444a4cb29c1c2bf19ebfae277a Mon Sep 17 00:00:00 2001 From: HalfLife <6436073+o0HalfLife0o@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:45:42 +0800 Subject: [PATCH 40/40] Update legado.yml --- .github/workflows/legado.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/legado.yml b/.github/workflows/legado.yml index 74e30a461..b0f3b982e 100644 --- a/.github/workflows/legado.yml +++ b/.github/workflows/legado.yml @@ -50,6 +50,9 @@ jobs: echo "设置apk共存" sed "s/'.release'/'.releaseA'/" $GITHUB_WORKSPACE/app/build.gradle -i sed 's/.release/.releaseA/' $GITHUB_WORKSPACE/app/google-services.json -i + echo "统一版本号" + version=$(date -d "8 hour" -u +3.%y.%m%d%H%M) + sed "/def version/c def version = \"$version\"" $GITHUB_WORKSPACE/app/build.gradle -i - name: Build With Gradle run: | echo "开始进行release构建"