diff --git a/app/src/main/java/io/legado/app/lib/prefs/Preference.kt b/app/src/main/java/io/legado/app/lib/prefs/Preference.kt index 6ed4c9cfc..9f8fbf91d 100644 --- a/app/src/main/java/io/legado/app/lib/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/lib/prefs/Preference.kt @@ -37,7 +37,7 @@ class Preference(context: Context, attrs: AttributeSet) : fun bindView( context: Context, - it: PreferenceViewHolder?, + viewHolder: PreferenceViewHolder?, icon: Drawable?, title: CharSequence?, summary: CharSequence?, @@ -47,23 +47,25 @@ class Preference(context: Context, attrs: AttributeSet) : weightHeight: Int = 0, isBottomBackground: Boolean = false ): T? { - if (it == null) return null - val tvTitle = it.findViewById(R.id.preference_title) as TextView - tvTitle.text = title - tvTitle.isVisible = title != null && title.isNotEmpty() - val tvSummary = it.findViewById(R.id.preference_desc) as? TextView + if (viewHolder == null) return null + val tvTitle = viewHolder.findViewById(R.id.preference_title) as? TextView + tvTitle?.let { + tvTitle.text = title + tvTitle.isVisible = title != null && title.isNotEmpty() + } + val tvSummary = viewHolder.findViewById(R.id.preference_desc) as? TextView tvSummary?.let { tvSummary.text = summary tvSummary.isGone = summary.isNullOrEmpty() } - if (isBottomBackground && !tvTitle.isInEditMode) { + if (isBottomBackground && !viewHolder.itemView.isInEditMode) { val isLight = ColorUtils.isColorLight(context.bottomBackground) val pTextColor = context.getPrimaryTextColor(isLight) - tvTitle.setTextColor(pTextColor) + tvTitle?.setTextColor(pTextColor) val sTextColor = context.getSecondaryTextColor(isLight) tvSummary?.setTextColor(sTextColor) } - val iconView = it.findViewById(R.id.preference_icon) + val iconView = viewHolder.findViewById(R.id.preference_icon) if (iconView is ImageView) { iconView.isVisible = icon != null iconView.setImageDrawable(icon) @@ -71,10 +73,10 @@ class Preference(context: Context, attrs: AttributeSet) : } if (weightLayoutRes != null && weightLayoutRes != 0 && viewId != null && viewId != 0) { - val lay = it.findViewById(R.id.preference_widget) + val lay = viewHolder.findViewById(R.id.preference_widget) if (lay is FrameLayout) { var needRequestLayout = false - var v = it.itemView.findViewById(viewId) + var v = viewHolder.itemView.findViewById(viewId) if (v == null) { val inflater: LayoutInflater = LayoutInflater.from(context) val childView = inflater.inflate(weightLayoutRes, null) diff --git a/app/src/main/res/layout/activity_book_search.xml b/app/src/main/res/layout/activity_book_search.xml index b5250cb99..50e9ccee3 100644 --- a/app/src/main/res/layout/activity_book_search.xml +++ b/app/src/main/res/layout/activity_book_search.xml @@ -63,6 +63,7 @@ android:id="@+id/tv_toggle_search_scope" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:background="?attr/selectableItemBackgroundBorderless" android:padding="6dp" android:text="@string/toggle_search_scope" /> @@ -104,6 +105,7 @@ android:id="@+id/tv_clear_history" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground" android:padding="6dp" android:text="@string/clear" /> diff --git a/app/src/main/res/layout/dialog_search_scope.xml b/app/src/main/res/layout/dialog_search_scope.xml index 77d9ef65f..63d12a49d 100644 --- a/app/src/main/res/layout/dialog_search_scope.xml +++ b/app/src/main/res/layout/dialog_search_scope.xml @@ -3,4 +3,5 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + \ No newline at end of file