搜索与发现项目
This commit is contained in:
@@ -3,6 +3,7 @@ package io.legato.kazusa.ui.book.explore
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.view.isVisible
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.adapter.ItemViewHolder
|
||||
@@ -11,7 +12,10 @@ import io.legato.kazusa.data.entities.Book
|
||||
import io.legato.kazusa.data.entities.SearchBook
|
||||
import io.legato.kazusa.databinding.ItemSearchBinding
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.ui.widget.text.AccentBgTextView
|
||||
import io.legato.kazusa.utils.dpToPx
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.spToPx
|
||||
import io.legato.kazusa.utils.visible
|
||||
|
||||
|
||||
@@ -53,13 +57,25 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
|
||||
tvIntroduce.text = item.trimIntro(context)
|
||||
val kinds = item.getKindList()
|
||||
if (kinds.isEmpty()) {
|
||||
tvKind.gone()
|
||||
tvAuthorKind.gone()
|
||||
kindContainer.gone()
|
||||
} else {
|
||||
tvAuthorKind.visible()
|
||||
tvKind.visible()
|
||||
val kindText = kinds.joinToString(" • ")
|
||||
tvKind.text = kindText
|
||||
kindContainer.visible()
|
||||
kindContainer.removeAllViews()
|
||||
kinds.forEach { kind ->
|
||||
val kindTextView = AccentBgTextView(context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
marginEnd = 6.dpToPx()
|
||||
}
|
||||
textSize = 11f
|
||||
text = kind
|
||||
setLines(1)
|
||||
setSingleLine(true)
|
||||
}
|
||||
kindContainer.addView(kindTextView)
|
||||
}
|
||||
}
|
||||
ivCover.load(
|
||||
item.coverUrl,
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.legato.kazusa.ui.book.search
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import io.legato.kazusa.R
|
||||
@@ -11,6 +12,8 @@ import io.legato.kazusa.base.adapter.ItemViewHolder
|
||||
import io.legato.kazusa.data.entities.SearchBook
|
||||
import io.legato.kazusa.databinding.ItemSearchBinding
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.ui.widget.text.AccentBgTextView
|
||||
import io.legato.kazusa.utils.dpToPx
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.visible
|
||||
|
||||
@@ -135,13 +138,25 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
|
||||
|
||||
private fun upKind(binding: ItemSearchBinding, kinds: List<String>) = binding.run {
|
||||
if (kinds.isEmpty()) {
|
||||
tvKind.gone()
|
||||
tvAuthorKind.gone()
|
||||
kindContainer.gone()
|
||||
} else {
|
||||
tvAuthorKind.visible()
|
||||
tvKind.visible()
|
||||
val kindText = kinds.joinToString(" • ")
|
||||
tvKind.text = kindText
|
||||
kindContainer.visible()
|
||||
kindContainer.removeAllViews()
|
||||
kinds.forEach { kind ->
|
||||
val kindTextView = AccentBgTextView(context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
marginEnd = 4.dpToPx()
|
||||
}
|
||||
textSize = 11f
|
||||
text = kind
|
||||
setLines(1)
|
||||
setSingleLine(true)
|
||||
}
|
||||
kindContainer.addView(kindTextView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.legato.kazusa.ui.widget.text
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import io.legato.kazusa.R
|
||||
@@ -9,6 +10,7 @@ import io.legato.kazusa.lib.theme.Selector
|
||||
import io.legato.kazusa.utils.ColorUtils
|
||||
import io.legato.kazusa.utils.dpToPx
|
||||
import androidx.core.content.withStyledAttributes
|
||||
import io.legato.kazusa.utils.spToPx
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
|
||||
class AccentBgTextView @JvmOverloads constructor(
|
||||
@@ -16,13 +18,14 @@ class AccentBgTextView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null
|
||||
) : MaterialTextView(context, attrs) {
|
||||
|
||||
private var radiusPx = 32
|
||||
private var radiusPx = 20
|
||||
|
||||
init {
|
||||
// context.withStyledAttributes(attrs, R.styleable.AccentBgTextView) {
|
||||
// val radiusDp = getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, 0)
|
||||
// radiusPx = radiusDp
|
||||
// }
|
||||
gravity = Gravity.CENTER
|
||||
includeFontPadding = false
|
||||
val horizontalPadding = 6.dpToPx()
|
||||
val verticalPadding = 2.dpToPx()
|
||||
setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding)
|
||||
updateBackground()
|
||||
}
|
||||
|
||||
@@ -32,8 +35,8 @@ class AccentBgTextView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun updateBackground() {
|
||||
val backgroundColor = context.themeColor(com.google.android.material.R.attr.colorPrimaryContainer)
|
||||
val textColor = context.themeColor(com.google.android.material.R.attr.colorOnPrimaryContainer)
|
||||
val backgroundColor = context.themeColor(com.google.android.material.R.attr.colorSecondaryContainer)
|
||||
val textColor = context.themeColor(com.google.android.material.R.attr.colorOnSecondaryContainer)
|
||||
|
||||
background = Selector.shapeBuild()
|
||||
.setCornerRadius(radiusPx)
|
||||
@@ -43,5 +46,4 @@ class AccentBgTextView @JvmOverloads constructor(
|
||||
|
||||
setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:strokeWidth="0dp"
|
||||
app:cardBackgroundColor="?attr/colorSurfaceContainerLow"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:layout_marginVertical="6dp">
|
||||
android:layout_marginVertical="4dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_content"
|
||||
android:layout_width="match_parent"
|
||||
@@ -83,13 +82,11 @@
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:singleLine="true"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@id/cd_count"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -121,77 +118,48 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/horizontal_scroll"
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:id="@+id/tv_author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scrollbars="none"
|
||||
android:overScrollMode="never">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/author"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_author_kind"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="4dp"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:text=" | "
|
||||
android:textSize="12sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_kind"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="1"
|
||||
android:paddingEnd="32dp"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:textSize="12sp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
tools:ignore="RtlSymmetry" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/author"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<!-- 最后阅读 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_lasted"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:text="@string/last_read"
|
||||
android:textSize="12sp" />
|
||||
android:textSize="11sp" />
|
||||
|
||||
<!-- 简介 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_introduce"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="3dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:text="@string/book_intro"
|
||||
android:textSize="12sp" />
|
||||
android:textSize="11sp" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:layout_marginTop="2dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/kind_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
</HorizontalScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
@@ -168,4 +168,5 @@
|
||||
<item>仅显示滑动条</item>
|
||||
</string-array>
|
||||
|
||||
<string name="all_version">所有版本</string>
|
||||
</resources>
|
||||
@@ -1309,7 +1309,7 @@
|
||||
<string name="text_shadow_y">Y轴距离</string>
|
||||
<string name="text_shadow_radius">阴影半径</string>
|
||||
<string name="text_shadow_color">阴影颜色</string>
|
||||
<string name="global_read_setting">全局阅读设置</string>
|
||||
<string name="global_read_setting">阅读显示 • 漫画相关</string>
|
||||
<string name="screen_settings">屏幕显示与亮度</string>
|
||||
<string name="reading_behavior">阅读行为</string>
|
||||
<string name="page_control">翻页控制</string>
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
<string-array name="default_app_variant">
|
||||
<item>@string/official_version</item>
|
||||
<item>@string/beta_release_version</item>
|
||||
<item>@string/all_version</item>
|
||||
<item>@string/beta_releaseA_version</item>
|
||||
</string-array>
|
||||
|
||||
@@ -207,6 +208,7 @@
|
||||
<string-array name="default_app_variant_value">
|
||||
<item>official_version</item>
|
||||
<item>beta_release_version</item>
|
||||
<item>all_version</item>
|
||||
<item>beta_releaseA_version</item>
|
||||
</string-array>
|
||||
|
||||
@@ -237,4 +239,5 @@
|
||||
<item>Unlabeled</item>
|
||||
</string-array>
|
||||
|
||||
<string name="all_version">所有版本</string>
|
||||
</resources>
|
||||
|
||||
@@ -1310,7 +1310,7 @@
|
||||
<string name="text_shadow_y">Y轴距离</string>
|
||||
<string name="text_shadow_radius">阴影半径</string>
|
||||
<string name="text_shadow_color">阴影颜色</string>
|
||||
<string name="global_read_setting">全局阅读设置</string>
|
||||
<string name="global_read_setting">阅读显示 • 漫画相关</string>
|
||||
<string name="screen_settings">屏幕显示与亮度</string>
|
||||
<string name="reading_behavior">阅读行为</string>
|
||||
<string name="page_control">翻页控制</string>
|
||||
|
||||
Reference in New Issue
Block a user