From 03b4ef64f5e6af6d1f224e2af9594063bf98e12a Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 13 Sep 2021 22:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=A7=84=E5=88=99=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=98=AF=E5=90=A6=E8=B4=AD=E4=B9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/data/entities/BookChapter.kt | 20 +++++++++++++++---- .../app/ui/book/toc/ChapterListAdapter.kt | 2 +- app/src/main/res/values/non_translat.xml | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt index 76a9da66e..ba0380472 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt @@ -5,6 +5,7 @@ import androidx.room.Entity import androidx.room.ForeignKey import androidx.room.Ignore import androidx.room.Index +import io.legado.app.R import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.RuleDataInterface import io.legado.app.utils.GSON @@ -13,6 +14,7 @@ import io.legado.app.utils.NetworkUtils import io.legado.app.utils.fromJsonObject import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.Parcelize +import splitties.init.appCtx @Parcelize @Entity( @@ -69,11 +71,21 @@ data class BookChapter( return false } - fun getAbsoluteURL():String{ + fun getDisplayTitle(): String { + return when { + !isVip -> title + isPay -> appCtx.getString(R.string.payed_title, title) + else -> appCtx.getString(R.string.vip_title, title) + } + } + + fun getAbsoluteURL(): String { val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) - val urlBefore = if(urlMatcher.find())url.substring(0,urlMatcher.start()) else url - val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl,urlBefore) - return if(urlBefore.length == url.length) urlAbsoluteBefore else urlAbsoluteBefore + ',' + url.substring(urlMatcher.end()) + val urlBefore = if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url + val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl, urlBefore) + return if (urlBefore.length == url.length) urlAbsoluteBefore else urlAbsoluteBefore + ',' + url.substring( + urlMatcher.end() + ) } fun getFileName(): String = String.format("%05d-%s.nb", index, MD5Utils.md5Encode16(title)) diff --git a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt index 15eebaeb6..aec125643 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt @@ -36,7 +36,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) : } else { tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText)) } - tvChapterName.text = item.title + tvChapterName.text = item.getDisplayTitle() if (!item.tag.isNullOrEmpty()) { tvTag.text = item.tag tvTag.visible() diff --git a/app/src/main/res/values/non_translat.xml b/app/src/main/res/values/non_translat.xml index defba67b0..7d066484b 100644 --- a/app/src/main/res/values/non_translat.xml +++ b/app/src/main/res/values/non_translat.xml @@ -4,5 +4,7 @@ http://%1$s:%2$d GitHub 【%s】 + 🔒%s + 🔓%s \ No newline at end of file