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 3a1214088..eb7818ddc 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
@@ -195,8 +195,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
for (i in 0 until menu.size) {
val item = menu[i]
when (item.groupId) {
- R.id.menu_group_on_line,
- R.id.menu_group_on_line_ns -> item.isVisible = onLine
+ R.id.menu_group_on_line -> item.isVisible == onLine
R.id.menu_group_local -> item.isVisible = !onLine
R.id.menu_group_text -> item.isVisible = book.isLocalTxt()
else -> when (item.itemId) {
@@ -758,6 +757,13 @@ class ReadBookActivity : ReadBookBaseActivity(),
}
}
+ /**
+ * 禁用书源
+ */
+ override fun disableSource() {
+ viewModel.disableSource()
+ }
+
/**
* 显示阅读样式配置
*/
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 94cd908d9..00bb8baa3 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
@@ -335,6 +335,15 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
}
+ fun disableSource() {
+ execute {
+ BookRead.bookSource?.let {
+ it.enabled = false
+ appDb.bookSourceDao.update(it)
+ }
+ }
+ }
+
override fun onCleared() {
super.onCleared()
if (BaseReadAloudService.pause) {
diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
index d59d913cb..089040264 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
@@ -5,10 +5,13 @@ import android.content.res.ColorStateList
import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet
import android.view.LayoutInflater
+import android.view.View.OnClickListener
+import android.view.View.OnLongClickListener
import android.view.WindowManager
import android.view.animation.Animation
import android.widget.FrameLayout
import android.widget.SeekBar
+import androidx.appcompat.widget.PopupMenu
import androidx.core.view.isGone
import androidx.core.view.isVisible
import io.legado.app.R
@@ -21,6 +24,7 @@ import io.legado.app.model.BookRead
import io.legado.app.ui.web.WebViewActivity
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
import io.legado.app.utils.*
+import splitties.views.onClick
import splitties.views.onLongClick
/**
@@ -44,7 +48,23 @@ class ReadMenu @JvmOverloads constructor(
.setPressedColor(ColorUtils.darkenColor(bgColor))
.create()
private var onMenuOutEnd: (() -> Unit)? = null
- val showBrightnessView get() = context.getPrefBoolean(PreferKey.showBrightnessView, true)
+ private val showBrightnessView
+ get() = context.getPrefBoolean(
+ PreferKey.showBrightnessView,
+ true
+ )
+ private val sourceMenu by lazy {
+ PopupMenu(context, binding.tvSourceAction).apply {
+ inflate(R.menu.book_read_source)
+ setOnMenuItemClickListener {
+ when (it.itemId) {
+ R.id.menu_edit_source -> callBack.openSourceEditActivity()
+ R.id.menu_disable_source -> callBack.disableSource()
+ }
+ true
+ }
+ }
+ }
init {
initView()
@@ -138,10 +158,7 @@ class ReadMenu @JvmOverloads constructor(
}
private fun bindEvent() = binding.run {
- tvChapterName.setOnClickListener {
- callBack.openSourceEditActivity()
- }
- tvChapterUrl.setOnClickListener {
+ val chapterViewClickListener = OnClickListener {
if (AppConfig.readUrlInBrowser) {
context.openUrl(tvChapterUrl.text.toString().substringBefore(",{"))
} else {
@@ -153,7 +170,7 @@ class ReadMenu @JvmOverloads constructor(
}
}
}
- tvChapterUrl.onLongClick {
+ val chapterViewLongClickListener = OnLongClickListener {
context.alert(R.string.Open_fan) {
setMessage(R.string.use_browser_open)
okButton {
@@ -163,14 +180,24 @@ class ReadMenu @JvmOverloads constructor(
AppConfig.readUrlInBrowser = false
}
}
+ true
}
+ tvChapterName.setOnClickListener(chapterViewClickListener)
+ tvChapterName.setOnLongClickListener(chapterViewLongClickListener)
+ tvChapterUrl.setOnClickListener(chapterViewClickListener)
+ tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener)
//登录
tvLogin.setOnClickListener {
callBack.showLogin()
}
+ //购买
tvPay.setOnClickListener {
callBack.payAction()
}
+ //书源操作
+ tvSourceAction.onClick {
+ sourceMenu.show()
+ }
//亮度跟随
ivBrightnessAuto.setOnClickListener {
context.putPrefBoolean("brightnessAuto", !brightnessAuto())
@@ -365,6 +392,7 @@ class ReadMenu @JvmOverloads constructor(
fun showReadMenuHelp()
fun showLogin()
fun payAction()
+ fun disableSource()
}
}
diff --git a/app/src/main/res/layout/view_read_menu.xml b/app/src/main/res/layout/view_read_menu.xml
index e41cd22fd..cd6e2211e 100644
--- a/app/src/main/res/layout/view_read_menu.xml
+++ b/app/src/main/res/layout/view_read_menu.xml
@@ -32,7 +32,6 @@
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
- android:textSize="12sp"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tv_login"
@@ -45,7 +44,6 @@
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
- android:textSize="12sp"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tv_login"
@@ -55,29 +53,46 @@
android:id="@+id/tv_login"
android:layout_width="wrap_content"
android:layout_height="0dp"
+ android:layout_margin="1dp"
android:gravity="center"
+ android:maxWidth="80dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="@string/login"
- android:layout_margin="1dp"
- app:radius="1dp"
app:layout_constraintBottom_toBottomOf="@+id/tv_chapter_url"
app:layout_constraintRight_toLeftOf="@+id/tv_pay"
- app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toTopOf="parent"
+ app:radius="1dp" />
+
+
+ app:layout_constraintTop_toTopOf="parent"
+ app:radius="1dp" />
diff --git a/app/src/main/res/menu/book_read.xml b/app/src/main/res/menu/book_read.xml
index bb713e388..bb39a0fec 100644
--- a/app/src/main/res/menu/book_read.xml
+++ b/app/src/main/res/menu/book_read.xml
@@ -49,15 +49,6 @@
android:title="@string/bookmark_add"
app:showAsAction="never" />
-
-
-
-
-
-
-
+
+
+
+
+
+