HapeLee 11 месяцев назад
Родитель
Сommit
4b60c5121a

+ 5 - 24
app/src/main/java/io/legado/app/ui/book/read/SearchMenu.kt

@@ -31,11 +31,7 @@ class SearchMenu @JvmOverloads constructor(
 
     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 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 isMenuOutAnimating = false
 
@@ -64,22 +60,6 @@ class SearchMenu @JvmOverloads constructor(
     }
 
     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()
     }
 
@@ -104,8 +84,6 @@ class SearchMenu @JvmOverloads constructor(
     @SuppressLint("SetTextI18n")
     fun updateSearchInfo() {
         ReadBook.curTextChapter?.let {
-            binding.tvCurrentSearchInfo.text =
-                "${context.getString(R.string.search_content_size)}: ${searchResultList.size}"
             binding.tvCurrentChapter.text = "当前章节: ${it.title}"
         }
         updateSearchProgress()
@@ -125,9 +103,12 @@ class SearchMenu @JvmOverloads constructor(
         val total = searchResultList.size
         if (total == 0) {
             binding.tvSearchProgress.text = "0%"
+            binding.tvSearchFraction.text = "0/0"
         } else {
-            val progress = ((currentSearchResultIndex + 1) * 100 / total)
+            val current = currentSearchResultIndex + 1
+            val progress = (current * 100 / total)
             binding.tvSearchProgress.text = "$progress%"
+            binding.tvSearchFraction.text = "$current / $total"
         }
     }
 

+ 14 - 79
app/src/main/res/layout/view_search_menu.xml

@@ -66,36 +66,28 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:padding="8dp"
                 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
+                    android:id="@+id/tv_search_fraction"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="@string/default_version"
                     android:textColor="?attr/colorOnSecondaryContainer"
-                    android:layout_marginStart="2dp"
-                    android:layout_marginVertical="8dp"
-                    android:singleLine="true"
-                    android:textSize="12sp" />
+                    android:textSize="14sp"
+                    android:textStyle="bold"
+                    android:layout_gravity="center_vertical" />
 
                 <TextView
                     android:id="@+id/tvSearchProgress"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
+                    android:layout_gravity="bottom"
                     android:textColor="?attr/colorOnSecondaryContainer"
                     android:singleLine="true"
-                    android:layout_marginVertical="8dp"
-                    android:layout_marginEnd="8dp"
-                    android:textSize="12sp" />
+                    android:layout_marginStart="8dp"
+                    android:textSize="12sp"
+                    android:textStyle="bold"/>
 
             </LinearLayout>
 
@@ -119,33 +111,24 @@
 
         </com.google.android.material.card.MaterialCardView>
 
-        <LinearLayout
+        <com.google.android.material.button.MaterialButtonGroup
             android:id="@+id/ll_bottom_bg"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="8dp"
+            android:layout_marginHorizontal="16dp"
             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
                 android:id="@+id/iv_search_results"
-                android:layout_width="wrap_content"
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
+                android:layout_weight="1"
                 android:elevation="16dp"
                 style="@style/Widget.Material3Expressive.Button.TonalButton"
                 android:text="@string/search_content_size"
                 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
                 android:id="@+id/iv_main_menu"
                 android:layout_width="wrap_content"
@@ -154,10 +137,6 @@
                 style="@style/Widget.Material3Expressive.Button.TonalButton"
                 android:text="@string/main_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
                 android:id="@+id/iv_search_exit"
@@ -169,51 +148,7 @@
                 app:icon="@drawable/ic_auto_page_stop"
                 tools:ignore="NestedWeights" />
 
-            <!--        <View-->
-            <!--            android:layout_width="0dp"-->
-            <!--            android:layout_height="match_parent"-->
-            <!--            android:layout_weight="2" />-->
-            <!--        &lt;!&ndash;设置按钮&ndash;&gt;-->
-            <!--        <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>
+        </com.google.android.material.button.MaterialButtonGroup>
 
     </LinearLayout>