正文搜索
This commit is contained in:
@@ -31,11 +31,7 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
|
|
||||||
private val menuBottomIn: Animation = loadAnimation(context, R.anim.anim_readbook_bottom_in)
|
private val menuBottomIn: Animation = loadAnimation(context, R.anim.anim_readbook_bottom_in)
|
||||||
private val menuBottomOut: Animation = loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
private val menuBottomOut: Animation = loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
||||||
//private val bgColor: Int = context.bottomBackground
|
|
||||||
//private val textColor: Int = context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor))
|
|
||||||
// private val bottomBackgroundList: ColorStateList =
|
|
||||||
// Selector.colorBuild().setDefaultColor(bgColor)
|
|
||||||
// .setPressedColor(ColorUtils.darkenColor(bgColor)).create()
|
|
||||||
private var onMenuOutEnd: (() -> Unit)? = null
|
private var onMenuOutEnd: (() -> Unit)? = null
|
||||||
private var isMenuOutAnimating = false
|
private var isMenuOutAnimating = false
|
||||||
|
|
||||||
@@ -64,22 +60,6 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() = binding.run {
|
private fun initView() = binding.run {
|
||||||
// llSearchBaseInfo.setBackgroundColor(bgColor)
|
|
||||||
// tvCurrentSearchInfo.setTextColor(bottomBackgroundList)
|
|
||||||
// llBottomBg.setBackgroundColor(bgColor)
|
|
||||||
// fabLeft.backgroundTintList = bottomBackgroundList
|
|
||||||
// fabLeft.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// fabRight.backgroundTintList = bottomBackgroundList
|
|
||||||
// fabRight.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// tvMainMenu.setTextColor(textColor)
|
|
||||||
// tvSearchResults.setTextColor(textColor)
|
|
||||||
// tvSearchExit.setTextColor(textColor)
|
|
||||||
// ivMainMenu.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// ivSearchResults.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// ivSearchExit.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// ivSearchContentUp.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// ivSearchContentDown.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
|
||||||
// tvCurrentSearchInfo.setTextColor(textColor)
|
|
||||||
applyNavigationBarPadding()
|
applyNavigationBarPadding()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +84,6 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun updateSearchInfo() {
|
fun updateSearchInfo() {
|
||||||
ReadBook.curTextChapter?.let {
|
ReadBook.curTextChapter?.let {
|
||||||
binding.tvCurrentSearchInfo.text =
|
|
||||||
"${context.getString(R.string.search_content_size)}: ${searchResultList.size}"
|
|
||||||
binding.tvCurrentChapter.text = "当前章节: ${it.title}"
|
binding.tvCurrentChapter.text = "当前章节: ${it.title}"
|
||||||
}
|
}
|
||||||
updateSearchProgress()
|
updateSearchProgress()
|
||||||
@@ -125,9 +103,12 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
val total = searchResultList.size
|
val total = searchResultList.size
|
||||||
if (total == 0) {
|
if (total == 0) {
|
||||||
binding.tvSearchProgress.text = "0%"
|
binding.tvSearchProgress.text = "0%"
|
||||||
|
binding.tvSearchFraction.text = "0/0"
|
||||||
} else {
|
} else {
|
||||||
val progress = ((currentSearchResultIndex + 1) * 100 / total)
|
val current = currentSearchResultIndex + 1
|
||||||
|
val progress = (current * 100 / total)
|
||||||
binding.tvSearchProgress.text = "$progress%"
|
binding.tvSearchProgress.text = "$progress%"
|
||||||
|
binding.tvSearchFraction.text = "$current / $total"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,36 +66,28 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_current_search_info"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?attr/colorOnSecondaryContainer"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/tv_search_fraction"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/default_version"
|
|
||||||
android:textColor="?attr/colorOnSecondaryContainer"
|
android:textColor="?attr/colorOnSecondaryContainer"
|
||||||
android:layout_marginStart="2dp"
|
android:textSize="14sp"
|
||||||
android:layout_marginVertical="8dp"
|
android:textStyle="bold"
|
||||||
android:singleLine="true"
|
android:layout_gravity="center_vertical" />
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvSearchProgress"
|
android:id="@+id/tvSearchProgress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
android:textColor="?attr/colorOnSecondaryContainer"
|
android:textColor="?attr/colorOnSecondaryContainer"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:layout_marginVertical="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:textSize="12sp"
|
||||||
android:textSize="12sp" />
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -119,33 +111,24 @@
|
|||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.button.MaterialButtonGroup
|
||||||
android:id="@+id/ll_bottom_bg"
|
android:id="@+id/ll_bottom_bg"
|
||||||
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:layout_marginTop="8dp"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:importantForAccessibility="no" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/iv_search_results"
|
android:id="@+id/iv_search_results"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:elevation="16dp"
|
android:elevation="16dp"
|
||||||
style="@style/Widget.Material3Expressive.Button.TonalButton"
|
style="@style/Widget.Material3Expressive.Button.TonalButton"
|
||||||
android:text="@string/search_content_size"
|
android:text="@string/search_content_size"
|
||||||
app:icon="@drawable/ic_toc" />
|
app:icon="@drawable/ic_toc" />
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/iv_main_menu"
|
android:id="@+id/iv_main_menu"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -154,10 +137,6 @@
|
|||||||
style="@style/Widget.Material3Expressive.Button.TonalButton"
|
style="@style/Widget.Material3Expressive.Button.TonalButton"
|
||||||
android:text="@string/main_menu"
|
android:text="@string/main_menu"
|
||||||
app:icon="@drawable/ic_menu" />
|
app:icon="@drawable/ic_menu" />
|
||||||
<View
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/iv_search_exit"
|
android:id="@+id/iv_search_exit"
|
||||||
@@ -169,51 +148,7 @@
|
|||||||
app:icon="@drawable/ic_auto_page_stop"
|
app:icon="@drawable/ic_auto_page_stop"
|
||||||
tools:ignore="NestedWeights" />
|
tools:ignore="NestedWeights" />
|
||||||
|
|
||||||
<!-- <View-->
|
</com.google.android.material.button.MaterialButtonGroup>
|
||||||
<!-- android:layout_width="0dp"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- android:layout_weight="2" />-->
|
|
||||||
<!-- <!–设置按钮–>-->
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:id="@+id/ll_setting"-->
|
|
||||||
<!-- android:layout_width="50dp"-->
|
|
||||||
<!-- android:layout_height="50dp"-->
|
|
||||||
<!-- android:background="?attr/selectableItemBackgroundBorderless"-->
|
|
||||||
<!-- android:clickable="true"-->
|
|
||||||
<!-- android:contentDescription="@string/setting"-->
|
|
||||||
<!-- android:focusable="true"-->
|
|
||||||
<!-- android:orientation="vertical"-->
|
|
||||||
<!-- android:paddingBottom="7dp">-->
|
|
||||||
|
|
||||||
<!-- <androidx.appcompat.widget.AppCompatImageView-->
|
|
||||||
<!-- android:id="@+id/iv_setting"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="0dp"-->
|
|
||||||
<!-- android:layout_weight="1"-->
|
|
||||||
<!-- android:contentDescription="@string/aloud_config"-->
|
|
||||||
<!-- android:src="@drawable/ic_settings"-->
|
|
||||||
<!-- app:tint="@color/primaryText"-->
|
|
||||||
<!-- tools:ignore="NestedWeights" />-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:id="@+id/tv_setting"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_gravity="center_horizontal"-->
|
|
||||||
<!-- android:layout_marginTop="3dp"-->
|
|
||||||
<!-- android:maxLines="1"-->
|
|
||||||
<!-- android:text="@string/setting"-->
|
|
||||||
<!-- android:textColor="@color/primaryText"-->
|
|
||||||
<!-- android:textSize="12sp" />-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:importantForAccessibility="no" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user