Edit BooK info fragment

This commit is contained in:
HapeLee committed 2025-06-01 23:23:14 +08:00
1 parent 459aba41e2
commit e847187c32
2 files changed
+149 -162

No files matched your search

@@ -2,6 +2,8 @@ package io.legado.app.ui.book.info
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.RenderEffect
import android.graphics.Shader
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@@ -36,10 +38,10 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.LocalConfig import io.legado.app.help.config.LocalConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.selector import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.accentColor //import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.backgroundColor //import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.bottomBackground //import io.legado.app.lib.theme.bottomBackground
import io.legado.app.lib.theme.getPrimaryTextColor //import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.model.BookCover import io.legado.app.model.BookCover
import io.legado.app.model.remote.RemoteBookWebDav import io.legado.app.model.remote.RemoteBookWebDav
import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.about.AppLogDialog
@@ -156,16 +158,17 @@ class BookInfoActivity :
@SuppressLint("PrivateResource") @SuppressLint("PrivateResource")
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.titleBar.setBackgroundResource(R.color.transparent) binding.titleBar.setBackgroundResource(R.color.transparent)
binding.refreshLayout?.setColorSchemeColors(accentColor) // binding.refreshLayout?.setColorSchemeColors(accentColor)
binding.arcView.setBgColor(backgroundColor) // binding.llInfo.setBackgroundColor(backgroundColor)
binding.llInfo.setBackgroundColor(backgroundColor) // binding.flAction.setBackgroundColor(bottomBackground)
binding.flAction.setBackgroundColor(bottomBackground)
binding.flAction.applyNavigationBarPadding() binding.flAction.applyNavigationBarPadding()
binding.tvShelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground))) binding.btnShelf?.text = getString(R.string.remove_from_bookshelf)
binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading)) binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
binding.tvIntro.revealOnFocusHint = false binding.tvIntro.revealOnFocusHint = false
} }
viewModel.bookData.observe(this) { showBook(it) } viewModel.bookData.observe(this) { showBook(it) }
viewModel.chapterListData.observe(this) { upLoading(false, it) } viewModel.chapterListData.observe(this) { upLoading(false, it) }
viewModel.waitDialogData.observe(this) { upWaitDialogStatus(it) } viewModel.waitDialogData.observe(this) { upWaitDialogStatus(it) }
@@ -369,8 +372,18 @@ class BookInfoActivity :
private fun showCover(book: Book) { private fun showCover(book: Book) {
binding.ivCover.load(book.getDisplayCover(), book.name, book.author, false, book.origin) { binding.ivCover.load(book.getDisplayCover(), book.name, book.author, false, book.origin) {
if (!AppConfig.isEInkMode) { if (!AppConfig.isEInkMode) {
BookCover.loadBlur(this, book.getDisplayCover(), false, book.origin) //高版本使用RenderEffect
BookCover.load(this, book.getDisplayCover(), false, book.origin)
.into(binding.bgBook) .into(binding.bgBook)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
BookCover.load(this, book.getDisplayCover(), false, book.origin)
.into(binding.bgBook)
val blurEffect = RenderEffect.createBlurEffect(60f, 60f, Shader.TileMode.CLAMP)
binding.bgBook.setRenderEffect(blurEffect)
}else{
BookCover.loadBlur(this, book.getDisplayCover(), false, book.origin)
.into(binding.bgBook)
}
} }
} }
} }
@@ -399,9 +412,9 @@ class BookInfoActivity :
private fun upTvBookshelf() { private fun upTvBookshelf() {
if (viewModel.inBookshelf) { if (viewModel.inBookshelf) {
binding.tvShelf.text = getString(R.string.remove_from_bookshelf) binding.btnShelf?.text = getString(R.string.remove_from_bookshelf)
} else { } else {
binding.tvShelf.text = getString(R.string.add_to_bookshelf) binding.btnShelf?.text = getString(R.string.add_to_bookshelf)
} }
editMenuItem?.isVisible = viewModel.inBookshelf editMenuItem?.isVisible = viewModel.inBookshelf
} }
@@ -434,7 +447,7 @@ class BookInfoActivity :
} }
true true
} }
tvRead.setOnClickListener { btnRead?.setOnClickListener {
viewModel.getBook()?.let { book -> viewModel.getBook()?.let { book ->
if (book.isWebFile) { if (book.isWebFile) {
showWebFileDownloadAlert { showWebFileDownloadAlert {
@@ -445,7 +458,7 @@ class BookInfoActivity :
} }
} }
} }
tvShelf.setOnClickListener { btnShelf?.setOnClickListener {
viewModel.getBook()?.let { book -> viewModel.getBook()?.let { book ->
if (viewModel.inBookshelf) { if (viewModel.inBookshelf) {
deleteBook() deleteBook()
@@ -472,7 +485,7 @@ class BookInfoActivity :
} }
} }
} }
tvChangeSource.setOnClickListener { btnChangeSource?.setOnClickListener {
viewModel.getBook()?.let { book -> viewModel.getBook()?.let { book ->
showDialogFragment(ChangeBookSourceDialog(book.name, book.author)) showDialogFragment(ChangeBookSourceDialog(book.name, book.author))
} }
+121 -147
View File
@@ -10,24 +10,23 @@
android:id="@+id/bg_book" android:id="@+id/bg_book"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:foreground="@drawable/bg_book_mask"
android:contentDescription="@string/bg_image" android:contentDescription="@string/bg_image"
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/vw_bg" android:id="@+id/vw_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#50000000"
android:orientation="vertical"> android:orientation="vertical">
<io.legado.app.ui.widget.TitleBar <io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:themeMode="dark"
app:title="@string/book_info" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout" android:id="@+id/refresh_layout"
@@ -52,46 +51,121 @@
android:layout_height="0dp" android:layout_height="0dp"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"> android:background="@drawable/bg_gradient_mask"
android:padding="16dp">
<io.legado.app.ui.widget.image.ArcView
android:id="@+id/arc_view"
android:layout_width="match_parent"
android:layout_height="78dp"
android:layout_marginTop="90dp"
app:arcDirectionTop="true"
app:arcHeight="36dp"
app:bgColor="@color/background" />
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="3dp"
app:cardCornerRadius="5dp" app:cardCornerRadius="5dp"
app:cardElevation="8dp"> app:cardElevation="8dp">
<io.legado.app.ui.widget.image.CoverImageView <io.legado.app.ui.widget.image.CoverImageView
android:id="@+id/iv_cover" android:id="@+id/iv_cover"
android:layout_width="110dp" android:layout_width="90dp"
android:layout_height="160dp" android:layout_height="130dp"
android:contentDescription="@string/img_cover" android:contentDescription="@string/img_cover"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/image_cover_default" /> android:src="@drawable/image_cover_default" />
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
</RelativeLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:padding="12dp">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="@string/book_name"
style="@style/TextAppearance.Material3.ActionBar.Title"
tools:ignore="RtlHardcoded" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="2dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="18sp"
android:layout_height="18sp"
android:contentDescription="@string/author"
android:src="@drawable/ic_author"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_author"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="2dp"
android:ellipsize="end"
android:singleLine="true"
android:text="@string/author"
android:textSize="14sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_web"
android:layout_width="18sp"
android:layout_height="18sp"
android:contentDescription="@string/origin_format"
android:src="@drawable/ic_web_outline"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_origin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="2dp"
android:ellipsize="end"
android:paddingRight="6dp"
android:singleLine="true"
android:textSize="14sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry"
tools:text="@string/origin_format" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_change_source"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
android:layout_width="30dp"
android:layout_height="30dp"
app:iconGravity="textStart"
app:icon="@drawable/ic_change_source"
app:iconSize="18dp"
tools:contentDescription="@string/change_origin" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ll_info" android:id="@+id/ll_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/background_theme"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:paddingBottom="8dp"> android:paddingBottom="8dp">
@@ -112,16 +186,7 @@
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:scrollbars="none"> android:scrollbars="none">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:singleLine="true"
android:text="@string/book_name"
android:textColor="@color/primaryText"
android:textSize="18sp"
tools:ignore="RtlHardcoded" />
</HorizontalScrollView> </HorizontalScrollView>
<HorizontalScrollView <HorizontalScrollView
@@ -149,79 +214,42 @@
android:paddingBottom="8dp"> android:paddingBottom="8dp">
<LinearLayout <LinearLayout
android:id="@+id/ll_toc"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="3dp" android:paddingTop="4dp"
android:paddingBottom="3dp" android:paddingBottom="4dp">
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="18sp" android:layout_width="18sp"
android:layout_height="18sp" android:layout_height="18sp"
android:contentDescription="@string/author" android:contentDescription="@string/read_dur_progress"
android:paddingRight="2dp" android:paddingRight="2dp"
android:src="@drawable/ic_author" android:src="@drawable/ic_chapter"
app:tint="@color/tv_text_summary"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView <TextView
android:id="@+id/tv_author" android:id="@+id/tv_toc"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:includeFontPadding="false" android:includeFontPadding="false"
android:paddingRight="6dp" android:paddingRight="6dp"
android:singleLine="true" android:textSize="14sp"
android:text="@string/author"
android:textColor="@color/tv_text_summary"
android:textSize="13sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp">
<ImageView
android:id="@+id/iv_web"
android:layout_width="18sp"
android:layout_height="18sp"
android:contentDescription="@string/origin_format"
android:paddingRight="2dp"
android:src="@drawable/ic_web_outline"
app:tint="@color/tv_text_summary"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_origin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:includeFontPadding="false"
android:paddingRight="6dp"
android:singleLine="true"
android:textColor="@color/tv_text_summary"
android:textSize="13sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry"
tools:text="@string/origin_format" /> tools:text="@string/toc_s" />
<io.legado.app.ui.widget.text.AccentBgTextView <io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_change_source" android:id="@+id/tv_toc_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:paddingRight="5dp" android:paddingRight="5dp"
android:text="@string/change_origin" android:text="@string/view_toc"
android:textSize="13sp" android:textSize="13sp"
app:radius="2dp" /> app:radius="2dp" />
@@ -243,7 +271,6 @@
android:contentDescription="@string/read_dur_progress" android:contentDescription="@string/read_dur_progress"
android:paddingRight="2dp" android:paddingRight="2dp"
android:src="@drawable/ic_book_last" android:src="@drawable/ic_book_last"
app:tint="@color/tv_text_summary"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView <TextView
@@ -255,7 +282,6 @@
android:includeFontPadding="false" android:includeFontPadding="false"
android:paddingRight="6dp" android:paddingRight="6dp"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/tv_text_summary"
android:textSize="13sp" android:textSize="13sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry"
tools:text="@string/read_dur_progress" /> tools:text="@string/read_dur_progress" />
@@ -276,7 +302,6 @@
android:contentDescription="@string/read_dur_progress" android:contentDescription="@string/read_dur_progress"
android:paddingRight="2dp" android:paddingRight="2dp"
android:src="@drawable/ic_groups" android:src="@drawable/ic_groups"
app:tint="@color/tv_text_summary"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView <TextView
@@ -288,7 +313,6 @@
android:includeFontPadding="false" android:includeFontPadding="false"
android:paddingRight="6dp" android:paddingRight="6dp"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/tv_text_summary"
android:textSize="13sp" android:textSize="13sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry"
tools:text="@string/group_s" /> tools:text="@string/group_s" />
@@ -306,50 +330,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/ll_toc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp">
<ImageView
android:layout_width="18sp"
android:layout_height="18sp"
android:contentDescription="@string/read_dur_progress"
android:paddingRight="2dp"
android:src="@drawable/ic_folder_open"
app:tint="@color/tv_text_summary"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_toc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:includeFontPadding="false"
android:paddingRight="6dp"
android:singleLine="true"
android:textColor="@color/tv_text_summary"
android:textSize="13sp"
tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry"
tools:text="@string/toc_s" />
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_toc_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/view_toc"
android:textSize="13sp"
app:radius="2dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
@@ -364,9 +345,8 @@
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:text="@string/book_intro" android:text="@string/book_intro"
android:textColor="@color/secondaryText"
android:textIsSelectable="true" android:textIsSelectable="true"
android:textSize="14sp" android:textSize="16sp"
android:visibility="visible" android:visibility="visible"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
@@ -378,42 +358,36 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/bg_divider_line" />
<LinearLayout <LinearLayout
android:id="@+id/fl_action" android:id="@+id/fl_action"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background_menu"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="12dp"
android:background="@color/background_theme"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent">
<TextView <com.google.android.material.button.MaterialButton
android:id="@+id/tv_shelf" android:id="@+id/btn_shelf"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_weight="1" android:layout_weight="1"
android:background="?attr/selectableItemBackground" android:layout_marginEnd="6dp"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/remove_from_bookshelf" android:text="@string/remove_from_bookshelf"
android:textColor="@color/primaryText" android:textSize="15sp"
android:textSize="15sp" /> app:iconPadding="0dp" />
<io.legado.app.ui.widget.text.AccentBgTextView <com.google.android.material.button.MaterialButton
android:id="@+id/tv_read" android:id="@+id/btn_read"
style="@style/Widget.Material3.Button"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:layout_marginStart="6dp"
android:includeFontPadding="false"
android:text="@string/reading" android:text="@string/reading"
android:textSize="15sp" /> android:textSize="15sp"
app:iconPadding="0dp" />
</LinearLayout> </LinearLayout>