目录规则添加是否购买

pull/1319/head
gedoor 3 years ago
parent cd4bbb8eba
commit 03b4ef64f5
  1. 14
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt
  3. 2
      app/src/main/res/values/non_translat.xml

@ -5,6 +5,7 @@ import androidx.room.Entity
import androidx.room.ForeignKey import androidx.room.ForeignKey
import androidx.room.Ignore import androidx.room.Ignore
import androidx.room.Index import androidx.room.Index
import io.legado.app.R
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.analyzeRule.RuleDataInterface import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
@ -13,6 +14,7 @@ import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.fromJsonObject import io.legado.app.utils.fromJsonObject
import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import splitties.init.appCtx
@Parcelize @Parcelize
@Entity( @Entity(
@ -69,11 +71,21 @@ data class BookChapter(
return false return false
} }
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 { fun getAbsoluteURL(): String {
val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) val urlMatcher = AnalyzeUrl.paramPattern.matcher(url)
val urlBefore = if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url val urlBefore = if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url
val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl, urlBefore) val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl, urlBefore)
return if(urlBefore.length == url.length) urlAbsoluteBefore else urlAbsoluteBefore + ',' + url.substring(urlMatcher.end()) 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)) fun getFileName(): String = String.format("%05d-%s.nb", index, MD5Utils.md5Encode16(title))

@ -36,7 +36,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
} else { } else {
tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText)) tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText))
} }
tvChapterName.text = item.title tvChapterName.text = item.getDisplayTitle()
if (!item.tag.isNullOrEmpty()) { if (!item.tag.isNullOrEmpty()) {
tvTag.text = item.tag tvTag.text = item.tag
tvTag.visible() tvTag.visible()

@ -4,5 +4,7 @@
<string name="http_ip">http://%1$s:%2$d</string> <string name="http_ip">http://%1$s:%2$d</string>
<string name="git_hub">GitHub</string> <string name="git_hub">GitHub</string>
<string name="diy_edit_source_group_title">【%s】</string> <string name="diy_edit_source_group_title">【%s】</string>
<string name="vip_title">🔒%s</string>
<string name="payed_title">🔓%s</string>
</resources> </resources>
Loading…
Cancel
Save