From 0c1f30208d85cf53ae9aebf79e8876d858d616a2 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 19 Mar 2020 11:23:15 +0100 Subject: [PATCH] Fix / Epoxy divider not showing --- .../im/vector/riotx/core/extensions/RecyclerView.kt | 11 ++++++++++- .../timeline/reactions/ViewReactionsBottomSheet.kt | 2 +- .../devices/DeviceVerificationInfoBottomSheet.kt | 2 +- .../im/vector/riotx/features/themes/ThemeUtils.kt | 8 +++++--- .../main/res/drawable/divider_horizontal_black.xml | 5 +++++ .../src/main/res/drawable/divider_horizontal_dark.xml | 5 +++++ .../main/res/drawable/divider_horizontal_light.xml | 5 +++++ vector/src/main/res/values/theme_dark.xml | 2 -- vector/src/main/res/values/theme_light.xml | 2 -- 9 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 vector/src/main/res/drawable/divider_horizontal_black.xml create mode 100644 vector/src/main/res/drawable/divider_horizontal_dark.xml create mode 100644 vector/src/main/res/drawable/divider_horizontal_light.xml diff --git a/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt b/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt index 51f3ce611a..3b3132229c 100644 --- a/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt +++ b/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt @@ -16,10 +16,13 @@ package im.vector.riotx.core.extensions +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.airbnb.epoxy.EpoxyController +import im.vector.riotx.R +import im.vector.riotx.features.themes.ThemeUtils /** * Apply a Vertical LinearLayout Manager to the recyclerView and set the adapter from the epoxy controller @@ -40,7 +43,13 @@ fun RecyclerView.configureWith(epoxyController: EpoxyController, itemAnimator?.let { this.itemAnimator = it } } if (showDivider) { - addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL)) + addItemDecoration( + DividerItemDecoration(context, DividerItemDecoration.VERTICAL).apply { + ContextCompat.getDrawable(context, ThemeUtils.getResourceId(context, R.drawable.divider_horizontal_light))?.let { + setDrawable(it) + } + } + ) } setHasFixedSize(hasFixedSize) adapter = epoxyController.adapter diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt index aac48202c4..f7c9ff04e4 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt @@ -58,7 +58,7 @@ class ViewReactionsBottomSheet : VectorBaseBottomSheetDialogFragment(), ViewReac override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) sharedActionViewModel = activityViewModelProvider.get(MessageSharedActionViewModel::class.java) - recyclerView.configureWith(epoxyController, hasFixedSize = false) + recyclerView.configureWith(epoxyController, hasFixedSize = false, showDivider = true) bottomSheetTitle.text = context?.getString(R.string.reactions) epoxyController.listener = this } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt index 9863134cb7..8e18472499 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt @@ -62,7 +62,7 @@ class DeviceVerificationInfoBottomSheet : VectorBaseBottomSheetDialogFragment(), super.onActivityCreated(savedInstanceState) recyclerView.configureWith( epoxyController, - showDivider = true, + showDivider = false, hasFixedSize = false) epoxyController.callback = this bottomSheetTitle.isVisible = false diff --git a/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt b/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt index 40a14b3e6f..1f835164db 100644 --- a/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt +++ b/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt @@ -62,10 +62,10 @@ object ThemeUtils { */ fun setApplicationTheme(context: Context, aTheme: String) { when (aTheme) { - THEME_DARK_VALUE -> context.setTheme(R.style.AppTheme_Dark) - THEME_BLACK_VALUE -> context.setTheme(R.style.AppTheme_Black) + THEME_DARK_VALUE -> context.setTheme(R.style.AppTheme_Dark) + THEME_BLACK_VALUE -> context.setTheme(R.style.AppTheme_Black) THEME_STATUS_VALUE -> context.setTheme(R.style.AppTheme_Status) - else -> context.setTheme(R.style.AppTheme_Light) + else -> context.setTheme(R.style.AppTheme_Light) } // Clear the cache @@ -170,6 +170,7 @@ object ThemeUtils { R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_dark R.drawable.bg_unread_notification_light -> R.drawable.bg_unread_notification_dark R.drawable.vector_label_background_light -> R.drawable.vector_label_background_dark + R.drawable.divider_horizontal_light -> R.drawable.divider_horizontal_dark else -> { Timber.w("Warning, missing case for wanted drawable in dark theme") resourceId @@ -181,6 +182,7 @@ object ThemeUtils { R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_black R.drawable.bg_unread_notification_light -> R.drawable.bg_unread_notification_black R.drawable.vector_label_background_light -> R.drawable.vector_label_background_black + R.drawable.divider_horizontal_light -> R.drawable.divider_horizontal_black else -> { Timber.w("Warning, missing case for wanted drawable in black theme") resourceId diff --git a/vector/src/main/res/drawable/divider_horizontal_black.xml b/vector/src/main/res/drawable/divider_horizontal_black.xml new file mode 100644 index 0000000000..43a68bbe2d --- /dev/null +++ b/vector/src/main/res/drawable/divider_horizontal_black.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/divider_horizontal_dark.xml b/vector/src/main/res/drawable/divider_horizontal_dark.xml new file mode 100644 index 0000000000..24a9307799 --- /dev/null +++ b/vector/src/main/res/drawable/divider_horizontal_dark.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/divider_horizontal_light.xml b/vector/src/main/res/drawable/divider_horizontal_light.xml new file mode 100644 index 0000000000..4b215ecaa4 --- /dev/null +++ b/vector/src/main/res/drawable/divider_horizontal_light.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/theme_dark.xml b/vector/src/main/res/values/theme_dark.xml index 9bfdcc8231..09775d4d41 100644 --- a/vector/src/main/res/values/theme_dark.xml +++ b/vector/src/main/res/values/theme_dark.xml @@ -36,8 +36,6 @@ @drawable/highlighted_message_background_dark - @color/riotx_header_panel_border_mobile_dark - @color/riotx_accent @color/primary_color_dark_light diff --git a/vector/src/main/res/values/theme_light.xml b/vector/src/main/res/values/theme_light.xml index 3a479c9368..c63dfa9057 100644 --- a/vector/src/main/res/values/theme_light.xml +++ b/vector/src/main/res/values/theme_light.xml @@ -35,8 +35,6 @@ @drawable/highlighted_message_background_light - @color/riotx_header_panel_border_mobile_light - @color/riotx_accent