mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
修复在刘海屏手机中显示顶部栏时候列表上下滚动 (#4691)
* 修复在刘海屏手机中显示顶部栏时候列表上下滚动 * 修复解密失败一直显示加载框问题 * 修复有些源图片解密失败
This commit is contained in:
@@ -27,7 +27,7 @@ object OkHttpModelLoader : ModelLoader<GlideUrl?, InputStream?> {
|
||||
}
|
||||
return ModelLoader.LoadData(
|
||||
modelWithHeader,
|
||||
OkHttpStreamFetcher(modelWithHeader, options)
|
||||
OkHttpStreamFetcher(model,modelWithHeader, options)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.legado.app.help.glide
|
||||
|
||||
import android.net.Uri
|
||||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.HttpException
|
||||
@@ -28,6 +29,7 @@ import java.io.InputStream
|
||||
|
||||
|
||||
class OkHttpStreamFetcher(
|
||||
private val oldUrl: GlideUrl,
|
||||
private val url: GlideUrl,
|
||||
private val options: Options,
|
||||
) :
|
||||
@@ -99,25 +101,24 @@ class OkHttpStreamFetcher(
|
||||
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
responseBody = response.body
|
||||
val manga = options.get(OkHttpModelLoader.mangaOption) == true
|
||||
val decodeResult = if (manga) {
|
||||
ImageUtils.decode(
|
||||
url.toStringUrl(),
|
||||
responseBody!!.byteStream().readBytes(),
|
||||
isCover = false,
|
||||
source,
|
||||
ReadMange.book
|
||||
).let {
|
||||
ByteArrayInputStream(it)
|
||||
}
|
||||
} else {
|
||||
ImageUtils.decode(
|
||||
url.toStringUrl(), responseBody!!.byteStream(),
|
||||
isCover = true, source
|
||||
)
|
||||
}
|
||||
if (response.isSuccessful) {
|
||||
|
||||
val manga = options.get(OkHttpModelLoader.mangaOption) == true
|
||||
val decodeResult = if (manga) {
|
||||
ImageUtils.decode(
|
||||
Uri.decode(oldUrl.toStringUrl()),
|
||||
responseBody!!.byteStream().readBytes(),
|
||||
isCover = false,
|
||||
source,
|
||||
ReadMange.book
|
||||
)?.let {
|
||||
ByteArrayInputStream(it)
|
||||
}
|
||||
} else {
|
||||
ImageUtils.decode(
|
||||
url.toStringUrl(), responseBody!!.byteStream(),
|
||||
isCover = true, source
|
||||
)
|
||||
}
|
||||
if (decodeResult == null) {
|
||||
callback?.onLoadFailed(NoStackTraceException("封面二次解密失败"))
|
||||
} else {
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package io.legado.app.ui.book.manga
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
@@ -31,10 +29,8 @@ import io.legado.app.databinding.ActivityMangeBinding
|
||||
import io.legado.app.databinding.ViewLoadMoreBinding
|
||||
import io.legado.app.help.book.isImage
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.help.storage.Backup
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.lib.theme.ThemeStore
|
||||
import io.legado.app.model.ReadMange
|
||||
import io.legado.app.model.ReadMange.mFirstLoading
|
||||
import io.legado.app.model.recyclerView.MangeContent
|
||||
@@ -47,25 +43,21 @@ import io.legado.app.ui.book.read.MangaMenu
|
||||
import io.legado.app.ui.book.read.ReadBookActivity.Companion.RESULT_DELETED
|
||||
import io.legado.app.ui.book.toc.TocActivityResult
|
||||
import io.legado.app.ui.widget.recycler.LoadMoreView
|
||||
import io.legado.app.utils.ColorUtils
|
||||
import io.legado.app.utils.NetworkUtils
|
||||
import io.legado.app.utils.StartActivityContract
|
||||
import io.legado.app.utils.getCompatColor
|
||||
import io.legado.app.utils.gone
|
||||
import io.legado.app.utils.immersionFullScreen
|
||||
import io.legado.app.utils.printOnDebug
|
||||
import io.legado.app.utils.setLightStatusBar
|
||||
import io.legado.app.utils.setNavigationBarColorAuto
|
||||
import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import io.legado.app.utils.visible
|
||||
import splitties.dimensions.dp
|
||||
|
||||
class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>(),
|
||||
ReadMange.Callback, ChangeBookSourceDialog.CallBack, MangaMenu.CallBack {
|
||||
|
||||
private val menuLayoutIsVisible get() = binding.mangaMenu.isVisible
|
||||
|
||||
private val mLayoutManager by lazy {
|
||||
LinearLayoutManager(this@ReadMangaActivity)
|
||||
}
|
||||
@@ -98,6 +90,10 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
||||
}
|
||||
}
|
||||
|
||||
private val windowInsetsControllerCompat by lazy {
|
||||
WindowInsetsControllerCompat(window, binding.root)
|
||||
}
|
||||
|
||||
//打开目录返回选择章节返回结果
|
||||
private val tocActivity =
|
||||
registerForActivityResult(TocActivityResult()) {
|
||||
@@ -117,7 +113,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
||||
override val viewModel by viewModels<MangaViewModel>()
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
immersionFullScreen(WindowInsetsControllerCompat(window, binding.root))
|
||||
immersionFullScreen(windowInsetsControllerCompat)
|
||||
ReadMange.register(this)
|
||||
binding.mRecyclerMange.run {
|
||||
adapter = mAdapter
|
||||
@@ -182,6 +178,11 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
||||
}
|
||||
}
|
||||
loadMoreView.gone()
|
||||
binding.mangaMenu.setTitleBarPadding(
|
||||
ViewCompat.getRootWindowInsets(findViewById(android.R.id.content))?.getInsets(
|
||||
WindowInsetsCompat.Type.statusBars()
|
||||
)?.top ?: dp(25)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
@@ -257,7 +258,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
||||
networkChangedListener.register()
|
||||
networkChangedListener.onNetworkChanged = {
|
||||
// 当网络是可用状态且无需初始化时同步进度(初始化中已有同步进度逻辑)
|
||||
if (AppConfig.syncBookProgressPlus && NetworkUtils.isAvailable()&&!justInitData) {
|
||||
if (AppConfig.syncBookProgressPlus && NetworkUtils.isAvailable() && !justInitData) {
|
||||
ReadMange.syncProgress({ progress -> sureNewProgress(progress) })
|
||||
}
|
||||
}
|
||||
@@ -369,19 +370,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
||||
return super.onCompatOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun upNavigationBarColor() {
|
||||
when {
|
||||
binding.mangaMenu.isVisible -> super.upNavigationBarColor()
|
||||
!AppConfig.immNavigationBar -> super.upNavigationBarColor()
|
||||
else -> setNavigationBarColorAuto(ReadBookConfig.bgMeanColor)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
private fun upNavigationBar(value: Boolean) {
|
||||
binding.mangaMenu.isVisible = value
|
||||
}
|
||||
|
||||
override fun openBookInfoActivity() {
|
||||
ReadMange.book?.let {
|
||||
bookInfoActivity.launch {
|
||||
@@ -392,74 +380,8 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
||||
}
|
||||
|
||||
override fun upSystemUiVisibility(value: Boolean) {
|
||||
upSystemUiVisibility(isInMultiWindow, !menuLayoutIsVisible, false)
|
||||
upNavigationBarColor()
|
||||
upNavigationBar(value)
|
||||
if (!value) {
|
||||
immersionFullScreen(WindowInsetsControllerCompat(window, binding.root))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态栏,导航栏
|
||||
*/
|
||||
fun upSystemUiVisibility(
|
||||
isInMultiWindow: Boolean,
|
||||
toolBarHide: Boolean = true,
|
||||
useBgMeanColor: Boolean = false,
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.insetsController?.run {
|
||||
if (toolBarHide && ReadBookConfig.hideNavigationBar) {
|
||||
hide(WindowInsets.Type.navigationBars())
|
||||
} else {
|
||||
show(WindowInsets.Type.navigationBars())
|
||||
}
|
||||
if (toolBarHide && ReadBookConfig.hideStatusBar) {
|
||||
hide(WindowInsets.Type.statusBars())
|
||||
} else {
|
||||
show(WindowInsets.Type.statusBars())
|
||||
}
|
||||
}
|
||||
}
|
||||
upSystemUiVisibilityO(isInMultiWindow, toolBarHide)
|
||||
if (toolBarHide) {
|
||||
setLightStatusBar(ReadBookConfig.durConfig.curStatusIconDark())
|
||||
} else {
|
||||
val statusBarColor =
|
||||
if (AppConfig.readBarStyleFollowPage
|
||||
&& ReadBookConfig.durConfig.curBgType() == 0
|
||||
|| useBgMeanColor
|
||||
) {
|
||||
ReadBookConfig.bgMeanColor
|
||||
} else {
|
||||
ThemeStore.statusBarColor(this, AppConfig.isTransparentStatusBar)
|
||||
}
|
||||
setLightStatusBar(ColorUtils.isColorLight(statusBarColor))
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun upSystemUiVisibilityO(
|
||||
isInMultiWindow: Boolean,
|
||||
toolBarHide: Boolean = true,
|
||||
) {
|
||||
var flag = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
or View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
||||
if (!isInMultiWindow) {
|
||||
flag = flag or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
}
|
||||
if (ReadBookConfig.hideNavigationBar) {
|
||||
flag = flag or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
if (toolBarHide) {
|
||||
flag = flag or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
}
|
||||
}
|
||||
if (ReadBookConfig.hideStatusBar && toolBarHide) {
|
||||
flag = flag or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
}
|
||||
window.decorView.systemUiVisibility = flag
|
||||
binding.mangaMenu.isVisible = value
|
||||
immersionFullScreen(WindowInsetsControllerCompat(window, binding.root))
|
||||
}
|
||||
|
||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||
|
||||
@@ -36,6 +36,9 @@ import io.legado.app.utils.modifyBegin
|
||||
import io.legado.app.utils.openUrl
|
||||
import io.legado.app.utils.startActivity
|
||||
import io.legado.app.utils.visible
|
||||
import splitties.views.bottomPadding
|
||||
import splitties.views.leftPadding
|
||||
import splitties.views.rightPadding
|
||||
|
||||
class MangaMenu @JvmOverloads constructor(
|
||||
context: Context,
|
||||
@@ -81,7 +84,7 @@ class MangaMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation) {
|
||||
binding.titleBar.invisible()
|
||||
binding.flTitleBar.invisible()
|
||||
isMenuOutAnimating = false
|
||||
canShowMenu = false
|
||||
callBack.upSystemUiVisibility(false)
|
||||
@@ -108,7 +111,7 @@ class MangaMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
initView()
|
||||
initView(true)
|
||||
bindEvent()
|
||||
}
|
||||
|
||||
@@ -117,6 +120,7 @@ class MangaMenu @JvmOverloads constructor(
|
||||
if (immersiveMenu) {
|
||||
val lightTextColor = ColorUtils.withAlpha(ColorUtils.lightenColor(textColor), 0.75f)
|
||||
titleBar.setTextColor(textColor)
|
||||
flTitleBar.setBackgroundColor(bgColor)
|
||||
titleBar.setBackgroundColor(bgColor)
|
||||
titleBar.setColorFilter(textColor)
|
||||
tvChapterName.setTextColor(lightTextColor)
|
||||
@@ -125,6 +129,7 @@ class MangaMenu @JvmOverloads constructor(
|
||||
val bgColor = context.primaryColor
|
||||
val textColor = context.primaryTextColor
|
||||
titleBar.setTextColor(textColor)
|
||||
flTitleBar.setBackgroundColor(bgColor)
|
||||
titleBar.setBackgroundColor(bgColor)
|
||||
titleBar.setColorFilter(textColor)
|
||||
tvChapterName.setTextColor(textColor)
|
||||
@@ -173,7 +178,7 @@ class MangaMenu @JvmOverloads constructor(
|
||||
}
|
||||
if (this.isVisible) {
|
||||
if (anim) {
|
||||
binding.titleBar.startAnimation(menuTopOut)
|
||||
binding.flTitleBar.startAnimation(menuTopOut)
|
||||
} else {
|
||||
menuOutListener.onAnimationStart(menuBottomOut)
|
||||
menuOutListener.onAnimationEnd(menuBottomOut)
|
||||
@@ -183,9 +188,9 @@ class MangaMenu @JvmOverloads constructor(
|
||||
|
||||
fun runMenuIn(anim: Boolean = !AppConfig.isEInkMode) {
|
||||
this.visible()
|
||||
binding.titleBar.visible()
|
||||
binding.flTitleBar.visible()
|
||||
if (anim) {
|
||||
binding.titleBar.startAnimation(menuTopIn)
|
||||
binding.flTitleBar.startAnimation(menuTopIn)
|
||||
} else {
|
||||
menuInListener.onAnimationStart(menuBottomIn)
|
||||
menuInListener.onAnimationEnd(menuBottomIn)
|
||||
@@ -228,9 +233,15 @@ class MangaMenu @JvmOverloads constructor(
|
||||
tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener)
|
||||
}
|
||||
|
||||
fun setTitleBarPadding(top: Int) {
|
||||
binding.flTitleBar.run {
|
||||
setPadding(leftPadding, this.paddingTop.plus(top), rightPadding, bottomPadding)
|
||||
}
|
||||
}
|
||||
|
||||
interface CallBack {
|
||||
fun openBookInfoActivity()
|
||||
fun upSystemUiVisibility(value:Boolean)
|
||||
fun upSystemUiVisibility(value: Boolean)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,59 +15,68 @@
|
||||
tools:layout_editor_absoluteX="0dp"
|
||||
tools:layout_editor_absoluteY="0dp" />
|
||||
|
||||
<io.legado.app.ui.widget.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="?attr/actionBarStyle"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_bar_addition"
|
||||
<io.legado.app.ui.widget.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="?attr/actionBarStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_chapter_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:singleLine="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/tv_source_action"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_bar_addition"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_chapter_url"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:singleLine="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/tv_source_action"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_chapter_name" />
|
||||
<TextView
|
||||
android:id="@+id/tv_chapter_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:singleLine="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/tv_source_action"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<io.legado.app.ui.widget.text.AccentBgTextView
|
||||
android:id="@+id/tv_source_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="1dp"
|
||||
android:gravity="center"
|
||||
android:maxWidth="120dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:text="@string/book_source"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_chapter_url"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:radius="2dp" />
|
||||
<TextView
|
||||
android:id="@+id/tv_chapter_url"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:singleLine="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/tv_source_action"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_chapter_name"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<io.legado.app.ui.widget.text.AccentBgTextView
|
||||
android:id="@+id/tv_source_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="1dp"
|
||||
android:gravity="center"
|
||||
android:maxWidth="120dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:text="@string/book_source"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_chapter_url"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:radius="2dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</io.legado.app.ui.widget.TitleBar>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</io.legado.app.ui.widget.TitleBar>
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user