From db97240467fbc8f11bf23c7c9949efcad4842cfc Mon Sep 17 00:00:00 2001 From: AndyBernie Date: Tue, 18 Aug 2020 21:27:54 +0800 Subject: [PATCH 1/8] update --- .../java/io/legado/app/ui/book/read/page/ContentTextView.kt | 2 +- .../legado/app/ui/book/read/page/provider/ImageProvider.kt | 6 +++--- .../main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 0c5c63aa8..bc7e8c5b6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -163,7 +163,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at ReadBook.book!!, textPage.chapterIndex, textChar.charData, - textChar.charData, + null, true )?.let { canvas.drawBitmap(it, null, rectF, null) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt index 0084bfc5f..b6109e9d3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt @@ -31,7 +31,7 @@ object ImageProvider { indexCache[src] = bitmap } - fun getImage(book: Book, chapterIndex: Int, src: String, baseUrl: String, onUi: Boolean = false): Bitmap? { + fun getImage(book: Book, chapterIndex: Int, src: String, referrer: String?, onUi: Boolean = false): Bitmap? { getCache(chapterIndex, src)?.let { return it } @@ -48,8 +48,8 @@ object ImageProvider { out.flush() out.close() } - } else if (!onUi) { - HttpHelper.getBytes(src, baseUrl)?.let { + } else if (!onUi && referrer != null) { + HttpHelper.getBytes(src, referrer)?.let { FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it) } } diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt index c00064222..69c062295 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt @@ -56,7 +56,7 @@ class PhotoDialog : BaseDialogFragment() { val src = it.getString("src") ReadBook.book?.let { book -> src?.let { - ImageProvider.getImage(book, chapterIndex, src, src)?.let { bitmap -> + ImageProvider.getImage(book, chapterIndex, src, null)?.let { bitmap -> photo_view.setImageBitmap(bitmap) } } From e1711cae2761e8bbd138e3dca89ca86ca7afc792 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 15:49:54 +0800 Subject: [PATCH 2/8] =?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/help/ReadBook.kt | 18 +++++++++++------- .../app/ui/book/read/ReadBookActivity.kt | 6 +++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 7878cb1c2..afb7702a8 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -7,6 +7,7 @@ import io.legado.app.R import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.data.entities.BookSource import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.IntentDataHelp @@ -35,6 +36,7 @@ object ReadBook { var prevTextChapter: TextChapter? = null var curTextChapter: TextChapter? = null var nextTextChapter: TextChapter? = null + var bookSource: BookSource? = null var webBook: WebBook? = null var msg: String? = null private val loadingChapters = arrayListOf() @@ -54,14 +56,16 @@ object ReadBook { } fun upWebBook(book: Book) { - webBook = if (book.origin == BookType.local) { - null + if (book.origin == BookType.local) { + bookSource = null + webBook = null } else { - val bookSource = App.db.bookSourceDao().getBookSource(book.origin) - if (bookSource != null) { - WebBook(bookSource) - } else { - null + App.db.bookSourceDao().getBookSource(book.origin)?.let { + bookSource = it + webBook = WebBook(it) + } ?: let { + bookSource = null + webBook = null } } } 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 512d22a6f..42f4a45df 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 @@ -632,7 +632,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo * 替换 */ override fun openReplaceRule() { - startActivityForResult(requestCodeReplace) + startActivityForResult( + requestCodeReplace, + Pair("bookName", ReadBook.book?.name), + Pair("bookSource", ReadBook.bookSource?.bookSourceUrl) + ) } /** From 94a0701bcdc6c82270cff8ab200046c245318f43 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 15:51:17 +0800 Subject: [PATCH 3/8] =?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/ui/book/read/ReadBookActivity.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 42f4a45df..512d22a6f 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 @@ -632,11 +632,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo * 替换 */ override fun openReplaceRule() { - startActivityForResult( - requestCodeReplace, - Pair("bookName", ReadBook.book?.name), - Pair("bookSource", ReadBook.bookSource?.bookSourceUrl) - ) + startActivityForResult(requestCodeReplace) } /** From 900aef347f96fee8b7982e8478a101fb86f4f08c Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 17:05:36 +0800 Subject: [PATCH 4/8] =?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/replacerule/edit/ReplaceEditDialog.kt | 6 ++++-- .../ui/replacerule/edit/ReplaceEditViewModel.kt | 16 ++++++++++------ build.gradle | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index 60235a279..6b207cd0b 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -35,15 +35,17 @@ class ReplaceEditDialog : BaseDialogFragment(), fragmentManager: FragmentManager, id: Long = -1, pattern: String? = null, - isRegex: Boolean = false + isRegex: Boolean = false, + scope: String? = null ) { val dialog = ReplaceEditDialog() val bundle = Bundle() bundle.putLong("id", id) bundle.putString("pattern", pattern) bundle.putBoolean("isRegex", isRegex) + bundle.putString("scope", scope) dialog.arguments = bundle - dialog.show(fragmentManager, "editReplace") + dialog.show(fragmentManager, this::class.simpleName) } } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt index e4a0d443c..1308b64ec 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt @@ -20,12 +20,16 @@ class ReplaceEditViewModel(application: Application) : BaseViewModel(application replaceRuleData.postValue(it) } } else { - bundle.getString("pattern")?.let { pattern -> - val isRegex = bundle.getBoolean("isRegex") - replaceRuleData.postValue( - ReplaceRule(name = pattern, pattern = pattern, isRegex = isRegex) - ) - } + val pattern = bundle.getString("pattern") ?: "" + val isRegex = bundle.getBoolean("isRegex") + val scope = bundle.getString("scope") + val rule = ReplaceRule( + name = pattern, + pattern = pattern, + isRegex = isRegex, + scope = scope + ) + replaceRuleData.postValue(rule) } } } diff --git a/build.gradle b/build.gradle index 13629c5e0..f2d22610f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.0' repositories { google() jcenter() From 3f622f522c23287680c73dc127befcf1262f9491 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 17:33:26 +0800 Subject: [PATCH 5/8] =?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/ReadBookActivity.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 512d22a6f..c89d6ac5d 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 @@ -470,7 +470,18 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override fun onMenuItemSelected(itemId: Int): Boolean { when (itemId) { R.id.menu_replace -> { - ReplaceEditDialog.show(supportFragmentManager, pattern = selectedText) + val scopes = arrayListOf() + ReadBook.book?.name?.let { + scopes.add(it) + } + ReadBook.bookSource?.bookSourceUrl?.let { + scopes.add(it) + } + ReplaceEditDialog.show( + supportFragmentManager, + pattern = selectedText, + scope = scopes.joinToString { ";" } + ) return true } } From 36e1ba9f25b2490eca16496d3c56b5cdd5fe2530 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 17:50:02 +0800 Subject: [PATCH 6/8] =?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/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values-zh/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index aacb27576..f9d881de9 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -319,7 +319,7 @@ 書籍信息編輯 默認打開書架 自動跳轉最近閲讀 - 替換範圍,選填書名或者源名 + 替換範圍,選填書名或者書源url 分組 內容緩存路徑 清理緩存 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 208ea687f..6aaf6b82f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -320,7 +320,7 @@ 書籍訊息編輯 預設打開書架 自動跳轉最近閱讀 - 取代範圍,選填書名或者源名 + 取代範圍,選填書名或者書源url 分組 內容快取路徑 清理快取 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index a0a3eb278..27aa2a8f8 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -321,7 +321,7 @@ 书籍信息编辑 默认打开书架 自动跳转最近阅读 - 替换范围,选填书名或者源名 + 替换范围,选填书名或者书源url 分组 内容缓存路径 清理缓存 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5bf2741dd..2b1b21058 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -321,7 +321,7 @@ Edit book infomation Use Bookshelf as start page Auto jump to Recent list - Replacement object. Book name or source name is available + Replacement object. Book name or source url is available Groups Cache path Clear cache From d1bfb849a5b5406a4e15c62fa40f28672c2f8ff3 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 18:15:24 +0800 Subject: [PATCH 7/8] =?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/read/ReadBookActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c89d6ac5d..7ad4008ac 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 @@ -480,7 +480,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo ReplaceEditDialog.show( supportFragmentManager, pattern = selectedText, - scope = scopes.joinToString { ";" } + scope = scopes.joinToString(";") ) return true } From c5eeb2536f9f39900fa45807746daefd61116ab6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 18:16:35 +0800 Subject: [PATCH 8/8] =?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/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 2ba3ec7a5..e0f13a0c8 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 关注合作公众号 **[小说拾遗]()** 获取好看的小说。 - 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2020/08/19** +* 选择文本替换时带入书名和书源 + **2020/08/16** * 添加亮度调节控件显示开关 * 添加应用内语言切换