mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
Merge branch 'gedoor:master' into master
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="io.legado.app">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
|
||||
**2022/05/13**
|
||||
|
||||
* 书源编辑添加cookieJar选项
|
||||
* 源编辑添加cookieJar选项
|
||||
* 源编辑菜单里添加清除cookie,如果之前能用的书源不能用了,可以关闭cookieJar后点下菜单里的清除cookie后再试
|
||||
* 书源支持文件类型 by Xwite
|
||||
|
||||
**2022/05/11**
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ object BookType {
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@IntDef(default, audio, image)
|
||||
@IntDef(default, audio, image, file)
|
||||
annotation class Type
|
||||
}
|
||||
@@ -56,8 +56,8 @@ object CookieStore : CookieManager {
|
||||
|
||||
override fun removeCookie(url: String) {
|
||||
val domain = NetworkUtils.getSubDomain(url)
|
||||
CacheManager.deleteMemory("${domain}_cookie")
|
||||
appDb.cookieDao.delete(domain)
|
||||
CacheManager.deleteMemory("${domain}_cookie")
|
||||
}
|
||||
|
||||
override fun cookieToMap(cookie: String): MutableMap<String, String> {
|
||||
|
||||
@@ -18,6 +18,7 @@ import io.legado.app.databinding.ActivityBookSourceEditBinding
|
||||
import io.legado.app.help.config.LocalConfig
|
||||
import io.legado.app.lib.dialogs.SelectItem
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.lib.theme.accentColor
|
||||
import io.legado.app.lib.theme.backgroundColor
|
||||
import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity
|
||||
@@ -47,7 +48,7 @@ class BookSourceEditActivity :
|
||||
private val qrCodeResult = registerForActivityResult(QrCodeResult()) {
|
||||
it ?: return@registerForActivityResult
|
||||
viewModel.importSource(it) { source ->
|
||||
upRecyclerView(source)
|
||||
upSourceView(source)
|
||||
}
|
||||
}
|
||||
private val selectDoc = registerForActivityResult(HandleFileContract()) {
|
||||
@@ -68,7 +69,7 @@ class BookSourceEditActivity :
|
||||
softKeyboardTool.attachToWindow(window)
|
||||
initView()
|
||||
viewModel.initData(intent) {
|
||||
upRecyclerView()
|
||||
upSourceView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,9 +110,10 @@ class BookSourceEditActivity :
|
||||
}
|
||||
}
|
||||
}
|
||||
R.id.menu_clear_cookie -> viewModel.clearCookie(getSource().bookSourceUrl)
|
||||
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete
|
||||
R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource()))
|
||||
R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) }
|
||||
R.id.menu_paste_source -> viewModel.pasteSource { upSourceView(it) }
|
||||
R.id.menu_qr_code_camera -> qrCodeResult.launch()
|
||||
R.id.menu_share_str -> share(GSON.toJson(getSource()))
|
||||
R.id.menu_share_qr -> shareWithQr(
|
||||
@@ -139,6 +141,7 @@ class BookSourceEditActivity :
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.tabLayout.setBackgroundColor(backgroundColor)
|
||||
binding.tabLayout.setSelectedTabIndicatorColor(accentColor)
|
||||
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabReselected(tab: TabLayout.Tab?) {
|
||||
|
||||
@@ -186,7 +189,7 @@ class BookSourceEditActivity :
|
||||
binding.recyclerView.scrollToPosition(0)
|
||||
}
|
||||
|
||||
private fun upRecyclerView(source: BookSource? = viewModel.bookSource) {
|
||||
private fun upSourceView(source: BookSource? = viewModel.bookSource) {
|
||||
source?.let {
|
||||
binding.cbIsEnable.isChecked = it.enabled
|
||||
binding.cbIsEnableFind.isChecked = it.enabledExplore
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.RuleComplete
|
||||
import io.legado.app.help.http.CookieStore
|
||||
import io.legado.app.help.http.newCallStrResponse
|
||||
import io.legado.app.help.http.okHttpClient
|
||||
import io.legado.app.utils.*
|
||||
@@ -95,6 +96,12 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
|
||||
}
|
||||
}
|
||||
|
||||
fun clearCookie(url: String) {
|
||||
execute {
|
||||
CookieStore.removeCookie(url)
|
||||
}
|
||||
}
|
||||
|
||||
fun ruleComplete(rule: String?, preRule: String? = null, type: Int = 1): String? {
|
||||
if (autoComplete) {
|
||||
return RuleComplete.autoComplete(rule, preRule, type)
|
||||
|
||||
@@ -48,7 +48,7 @@ class RssSourceEditActivity :
|
||||
private val qrCodeResult = registerForActivityResult(QrCodeResult()) {
|
||||
it?.let {
|
||||
viewModel.importSource(it) { source: RssSource ->
|
||||
upRecyclerView(source)
|
||||
upSourceView(source)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class RssSourceEditActivity :
|
||||
softKeyboardTool.attachToWindow(window)
|
||||
initView()
|
||||
viewModel.initData(intent) {
|
||||
upRecyclerView()
|
||||
upSourceView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,10 +130,11 @@ class RssSourceEditActivity :
|
||||
}
|
||||
}
|
||||
}
|
||||
R.id.menu_clear_cookie -> viewModel.clearCookie(getRssSource().sourceUrl)
|
||||
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete
|
||||
R.id.menu_copy_source -> sendToClip(GSON.toJson(getRssSource()))
|
||||
R.id.menu_qr_code_camera -> qrCodeResult.launch()
|
||||
R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) }
|
||||
R.id.menu_paste_source -> viewModel.pasteSource { upSourceView(it) }
|
||||
R.id.menu_share_str -> share(GSON.toJson(getRssSource()))
|
||||
R.id.menu_share_qr -> shareWithQr(
|
||||
GSON.toJson(getRssSource()),
|
||||
@@ -150,10 +151,11 @@ class RssSourceEditActivity :
|
||||
binding.recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
private fun upRecyclerView(source: RssSource? = viewModel.rssSource) {
|
||||
private fun upSourceView(source: RssSource? = viewModel.rssSource) {
|
||||
source?.let {
|
||||
binding.cbIsEnable.isChecked = source.enabled
|
||||
binding.cbSingleUrl.isChecked = source.singleUrl
|
||||
binding.cbIsEnableCookie.isChecked = source.enabledCookieJar == true
|
||||
binding.cbEnableJs.isChecked = source.enableJs
|
||||
binding.cbEnableBaseUrl.isChecked = source.loadWithBaseUrl
|
||||
}
|
||||
@@ -191,6 +193,7 @@ class RssSourceEditActivity :
|
||||
val source = viewModel.rssSource
|
||||
source.enabled = binding.cbIsEnable.isChecked
|
||||
source.singleUrl = binding.cbSingleUrl.isChecked
|
||||
source.enabledCookieJar = binding.cbIsEnableCookie.isChecked
|
||||
source.enableJs = binding.cbEnableJs.isChecked
|
||||
source.loadWithBaseUrl = binding.cbEnableBaseUrl.isChecked
|
||||
sourceEntities.forEach {
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.legado.app.base.BaseViewModel
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.RssSource
|
||||
import io.legado.app.help.RuleComplete
|
||||
import io.legado.app.help.http.CookieStore
|
||||
import io.legado.app.utils.getClipText
|
||||
import io.legado.app.utils.msg
|
||||
import io.legado.app.utils.printOnDebug
|
||||
@@ -77,6 +78,12 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
|
||||
}
|
||||
}
|
||||
|
||||
fun clearCookie(url: String) {
|
||||
execute {
|
||||
CookieStore.removeCookie(url)
|
||||
}
|
||||
}
|
||||
|
||||
fun ruleComplete(rule: String?, preRule: String? = null, type: Int = 1): String? {
|
||||
if (autoComplete) {
|
||||
return RuleComplete.autoComplete(rule, preRule, type)
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.widget.FrameLayout.LayoutParams
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import io.legado.app.R
|
||||
import io.legado.app.lib.theme.accentColor
|
||||
import io.legado.app.utils.ColorUtils
|
||||
import io.legado.app.utils.getCompatColor
|
||||
import io.legado.app.utils.invisible
|
||||
import io.legado.app.utils.visible
|
||||
@@ -87,8 +88,6 @@ class BadgeView @JvmOverloads constructor(
|
||||
setLayoutParams(layoutParams)
|
||||
}
|
||||
|
||||
// set default font
|
||||
setTextColor(Color.WHITE)
|
||||
//setTypeface(Typeface.DEFAULT_BOLD);
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 11f)
|
||||
setPadding(dip2Px(5f), dip2Px(1f), dip2Px(5f), dip2Px(1f))
|
||||
@@ -106,6 +105,10 @@ class BadgeView @JvmOverloads constructor(
|
||||
minHeight = dip2Px(16f)
|
||||
}
|
||||
|
||||
override fun setBackgroundColor(color: Int) {
|
||||
setBackground(radius, color)
|
||||
}
|
||||
|
||||
fun setBackground(dipRadius: Float, badgeColor: Int) {
|
||||
val radius = dip2Px(dipRadius).toFloat()
|
||||
val radiusArray =
|
||||
@@ -118,10 +121,13 @@ class BadgeView @JvmOverloads constructor(
|
||||
val bgDrawable = ShapeDrawable(roundRect)
|
||||
bgDrawable.paint.color = badgeColor
|
||||
background = bgDrawable
|
||||
}
|
||||
|
||||
fun setBackground(badgeColor: Int) {
|
||||
setBackground(radius, badgeColor)
|
||||
setTextColor(
|
||||
if (ColorUtils.isColorLight(badgeColor)) {
|
||||
Color.BLACK
|
||||
} else {
|
||||
Color.WHITE
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,9 +148,9 @@ class BadgeView @JvmOverloads constructor(
|
||||
|
||||
fun setHighlight(highlight: Boolean) {
|
||||
if (highlight) {
|
||||
setBackground(context.accentColor)
|
||||
setBackgroundColor(context.accentColor)
|
||||
} else {
|
||||
setBackground(context.getCompatColor(R.color.darker_gray))
|
||||
setBackgroundColor(context.getCompatColor(R.color.darker_gray))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,13 @@
|
||||
android:text="@string/single_url"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeCheckBox
|
||||
android:id="@+id/cb_is_enable_cookie"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/auto_save_cookie" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
android:title="@string/login"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_clear_cookie"
|
||||
android:title="@string/cookie"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_auto_complete"
|
||||
android:title="@string/auto_complete"
|
||||
|
||||
@@ -980,5 +980,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
@@ -983,5 +983,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
@@ -983,5 +983,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
@@ -980,5 +980,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
@@ -982,5 +982,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
@@ -982,5 +982,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
@@ -983,5 +983,6 @@
|
||||
<string name="import_txt_toc_rule">导入txt目录规则</string>
|
||||
<string name="auto_save_cookie">CookieJar</string>
|
||||
<string name="click_read_button_load">点击阅读加载目录</string>
|
||||
<string name="cookie">清除cookie</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user