|
|
@ -5,10 +5,13 @@ import android.content.res.ColorStateList |
|
|
|
import android.graphics.drawable.GradientDrawable |
|
|
|
import android.graphics.drawable.GradientDrawable |
|
|
|
import android.util.AttributeSet |
|
|
|
import android.util.AttributeSet |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.LayoutInflater |
|
|
|
|
|
|
|
import android.view.View.OnClickListener |
|
|
|
|
|
|
|
import android.view.View.OnLongClickListener |
|
|
|
import android.view.WindowManager |
|
|
|
import android.view.WindowManager |
|
|
|
import android.view.animation.Animation |
|
|
|
import android.view.animation.Animation |
|
|
|
import android.widget.FrameLayout |
|
|
|
import android.widget.FrameLayout |
|
|
|
import android.widget.SeekBar |
|
|
|
import android.widget.SeekBar |
|
|
|
|
|
|
|
import androidx.appcompat.widget.PopupMenu |
|
|
|
import androidx.core.view.isGone |
|
|
|
import androidx.core.view.isGone |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import io.legado.app.R |
|
|
|
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.web.WebViewActivity |
|
|
|
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener |
|
|
|
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener |
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
|
|
|
|
|
import splitties.views.onClick |
|
|
|
import splitties.views.onLongClick |
|
|
|
import splitties.views.onLongClick |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -44,7 +48,23 @@ class ReadMenu @JvmOverloads constructor( |
|
|
|
.setPressedColor(ColorUtils.darkenColor(bgColor)) |
|
|
|
.setPressedColor(ColorUtils.darkenColor(bgColor)) |
|
|
|
.create() |
|
|
|
.create() |
|
|
|
private var onMenuOutEnd: (() -> Unit)? = null |
|
|
|
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 { |
|
|
|
init { |
|
|
|
initView() |
|
|
|
initView() |
|
|
@ -138,10 +158,7 @@ class ReadMenu @JvmOverloads constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun bindEvent() = binding.run { |
|
|
|
private fun bindEvent() = binding.run { |
|
|
|
tvChapterName.setOnClickListener { |
|
|
|
val chapterViewClickListener = OnClickListener { |
|
|
|
callBack.openSourceEditActivity() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tvChapterUrl.setOnClickListener { |
|
|
|
|
|
|
|
if (AppConfig.readUrlInBrowser) { |
|
|
|
if (AppConfig.readUrlInBrowser) { |
|
|
|
context.openUrl(tvChapterUrl.text.toString().substringBefore(",{")) |
|
|
|
context.openUrl(tvChapterUrl.text.toString().substringBefore(",{")) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -153,7 +170,7 @@ class ReadMenu @JvmOverloads constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
tvChapterUrl.onLongClick { |
|
|
|
val chapterViewLongClickListener = OnLongClickListener { |
|
|
|
context.alert(R.string.Open_fan) { |
|
|
|
context.alert(R.string.Open_fan) { |
|
|
|
setMessage(R.string.use_browser_open) |
|
|
|
setMessage(R.string.use_browser_open) |
|
|
|
okButton { |
|
|
|
okButton { |
|
|
@ -163,14 +180,24 @@ class ReadMenu @JvmOverloads constructor( |
|
|
|
AppConfig.readUrlInBrowser = false |
|
|
|
AppConfig.readUrlInBrowser = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tvChapterName.setOnClickListener(chapterViewClickListener) |
|
|
|
|
|
|
|
tvChapterName.setOnLongClickListener(chapterViewLongClickListener) |
|
|
|
|
|
|
|
tvChapterUrl.setOnClickListener(chapterViewClickListener) |
|
|
|
|
|
|
|
tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener) |
|
|
|
//登录 |
|
|
|
//登录 |
|
|
|
tvLogin.setOnClickListener { |
|
|
|
tvLogin.setOnClickListener { |
|
|
|
callBack.showLogin() |
|
|
|
callBack.showLogin() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//购买 |
|
|
|
tvPay.setOnClickListener { |
|
|
|
tvPay.setOnClickListener { |
|
|
|
callBack.payAction() |
|
|
|
callBack.payAction() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//书源操作 |
|
|
|
|
|
|
|
tvSourceAction.onClick { |
|
|
|
|
|
|
|
sourceMenu.show() |
|
|
|
|
|
|
|
} |
|
|
|
//亮度跟随 |
|
|
|
//亮度跟随 |
|
|
|
ivBrightnessAuto.setOnClickListener { |
|
|
|
ivBrightnessAuto.setOnClickListener { |
|
|
|
context.putPrefBoolean("brightnessAuto", !brightnessAuto()) |
|
|
|
context.putPrefBoolean("brightnessAuto", !brightnessAuto()) |
|
|
@ -365,6 +392,7 @@ class ReadMenu @JvmOverloads constructor( |
|
|
|
fun showReadMenuHelp() |
|
|
|
fun showReadMenuHelp() |
|
|
|
fun showLogin() |
|
|
|
fun showLogin() |
|
|
|
fun payAction() |
|
|
|
fun payAction() |
|
|
|
|
|
|
|
fun disableSource() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|