From 9ef870b9271ea215a97df183537f2f203f8ef7eb Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 9 Jul 2022 21:17:23 +0200 Subject: [PATCH] [merge] Live location theming Change-Id: Ia10af41b946cb5913ce6805095354d23ac3ca251 --- .../src/main/res/values/theme_sc.xml | 3 +++ .../src/main/res/values/theme_sc_light.xml | 3 +++ .../DefaultLiveLocationShareStatusItem.kt | 10 +++++++++- .../timeline/item/MessageLiveLocationItem.kt | 17 +++++++++++++++++ .../bg_no_location_map_themed.xml | 19 +++++++++++++++++++ ...line_event_live_location_inactive_stub.xml | 1 + 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 vector/src/main/res/drawable-v24/bg_no_location_map_themed.xml diff --git a/library/ui-styles/src/main/res/values/theme_sc.xml b/library/ui-styles/src/main/res/values/theme_sc.xml index ce3aef5dfd..5828f94d9c 100644 --- a/library/ui-styles/src/main/res/values/theme_sc.xml +++ b/library/ui-styles/src/main/res/values/theme_sc.xml @@ -125,6 +125,9 @@ ?colorBackgroundFloating + + + ?colorAccent diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultLiveLocationShareStatusItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultLiveLocationShareStatusItem.kt index c421efda12..ccc5ccfd6a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultLiveLocationShareStatusItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/DefaultLiveLocationShareStatusItem.kt @@ -18,6 +18,7 @@ package im.vector.app.features.home.room.detail.timeline.item import android.content.res.Resources import android.graphics.drawable.ColorDrawable +import android.os.Build import android.widget.ImageView import androidx.core.view.updateLayoutParams import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners @@ -42,6 +43,8 @@ class DefaultLiveLocationShareStatusItem : LiveLocationShareStatusItem { ) { val mapCornerTransformation = if (messageLayout is TimelineMessageLayout.Bubble) { messageLayout.cornersRadius.granularRoundedCorners() + } else if (messageLayout is TimelineMessageLayout.ScBubble) { + RoundedCorners(messageLayout.bubbleAppearance.getBubbleRadiusDp(mapImageView.context).toInt()) } else { RoundedCorners(getDefaultLayoutCornerRadiusInDp(mapImageView.resources)) } @@ -49,8 +52,10 @@ class DefaultLiveLocationShareStatusItem : LiveLocationShareStatusItem { width = mapWidth height = mapHeight } + // Yes, usually one would do this using drawable-v24... which glide seems to ignore? + val resource = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) R.drawable.bg_no_location_map_themed else R.drawable.bg_no_location_map GlideApp.with(mapImageView) - .load(R.drawable.bg_no_location_map) + .load(resource) .transform(mapCornerTransformation) .into(mapImageView) } @@ -63,6 +68,9 @@ class DefaultLiveLocationShareStatusItem : LiveLocationShareStatusItem { messageLayout.cornersRadius.bottomEndRadius, messageLayout.cornersRadius.bottomStartRadius ) + } else if (messageLayout is TimelineMessageLayout.ScBubble) { + val radius = messageLayout.bubbleAppearance.getBubbleRadiusDp(bannerImageView.context) + GranularRoundedCorners(0f, 0f, radius, radius) } else { val bottomCornerRadius = getDefaultLayoutCornerRadiusInDp(bannerImageView.resources).toFloat() GranularRoundedCorners(0f, 0f, bottomCornerRadius, bottomCornerRadius) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt index 795bd21cb2..f875509bc8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt @@ -78,6 +78,23 @@ abstract class MessageLiveLocationItem : AbsMessageLocationItem { + val radius = messageLayout.bubbleAppearance.getBubbleRadiusDp(holder.view.context) + LocationLiveMessageBannerViewState.Emitter( + remainingTimeInMillis = getRemainingTimeOfLiveInMillis(), + bottomStartCornerRadiusInDp = radius, + bottomEndCornerRadiusInDp = radius, + isStopButtonCenteredVertically = false + ) + } + messageLayout is TimelineMessageLayout.ScBubble -> { + val radius = messageLayout.bubbleAppearance.getBubbleRadiusDp(holder.view.context) + LocationLiveMessageBannerViewState.Watcher( + bottomStartCornerRadiusInDp = radius, + bottomEndCornerRadiusInDp = radius, + formattedLocalTimeOfEndOfLive = getFormattedLocalTimeEndOfLive(), + ) + } isEmitter -> { val cornerRadius = getBannerCornerRadiusForDefaultLayout(holder) LocationLiveMessageBannerViewState.Emitter( diff --git a/vector/src/main/res/drawable-v24/bg_no_location_map_themed.xml b/vector/src/main/res/drawable-v24/bg_no_location_map_themed.xml new file mode 100644 index 0000000000..bb39b92a4a --- /dev/null +++ b/vector/src/main/res/drawable-v24/bg_no_location_map_themed.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/vector/src/main/res/layout/item_timeline_event_live_location_inactive_stub.xml b/vector/src/main/res/layout/item_timeline_event_live_location_inactive_stub.xml index 40a0b76b25..84060c8e75 100644 --- a/vector/src/main/res/layout/item_timeline_event_live_location_inactive_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_live_location_inactive_stub.xml @@ -13,6 +13,7 @@ android:contentDescription="@string/a11y_static_map_image" android:src="@drawable/bg_no_location_map" android:scaleType="fitXY" + tools:src="@drawable/bg_no_location_map_themed" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />