From 4143c3330f2199b4e88c94c6c30c39f712e36768 Mon Sep 17 00:00:00 2001 From: LooKeR Date: Tue, 19 Oct 2021 16:50:44 +0530 Subject: [PATCH] Improve: Switch Themeing and usage --- .../looker/droidify/screen/ProductAdapter.kt | 5 ++-- src/main/res/color/switch_thumb_tint.xml | 2 +- src/main/res/color/switch_track_color.xml | 4 +-- src/main/res/layout/switch_item.xml | 27 +++++-------------- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/com/looker/droidify/screen/ProductAdapter.kt b/src/main/kotlin/com/looker/droidify/screen/ProductAdapter.kt index 481ba5fc..5a237b17 100644 --- a/src/main/kotlin/com/looker/droidify/screen/ProductAdapter.kt +++ b/src/main/kotlin/com/looker/droidify/screen/ProductAdapter.kt @@ -334,11 +334,10 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int) } private class SwitchViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val title = itemView.findViewById(R.id.title)!! val enabled = itemView.findViewById(R.id.enabled)!! val statefulViews: Sequence - get() = sequenceOf(itemView, title, enabled) + get() = sequenceOf(itemView, enabled) } private class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { @@ -1200,7 +1199,6 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int) ViewType.SWITCH -> { holder as SwitchViewHolder item as Item.SwitchItem - holder.title.setText(item.switchType.titleResId) val (checked, enabled) = when (item.switchType) { SwitchType.IGNORE_ALL_UPDATES -> { val productPreference = ProductPreferences[item.packageName] @@ -1214,6 +1212,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int) ) } } + holder.enabled.setText(item.switchType.titleResId) holder.enabled.isChecked = checked holder.statefulViews.forEach { it.isEnabled = enabled } } diff --git a/src/main/res/color/switch_thumb_tint.xml b/src/main/res/color/switch_thumb_tint.xml index 96704736..b0cdab6d 100644 --- a/src/main/res/color/switch_thumb_tint.xml +++ b/src/main/res/color/switch_thumb_tint.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/src/main/res/color/switch_track_color.xml b/src/main/res/color/switch_track_color.xml index 890022ee..00cc3422 100644 --- a/src/main/res/color/switch_track_color.xml +++ b/src/main/res/color/switch_track_color.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/src/main/res/layout/switch_item.xml b/src/main/res/layout/switch_item.xml index 754caa7a..31afbdfd 100644 --- a/src/main/res/layout/switch_item.xml +++ b/src/main/res/layout/switch_item.xml @@ -1,27 +1,14 @@ - - - + android:layout_height="wrap_content"> - - + android:singleLine="true" + android:textSize="15sp" /> +