From e1ea10e0a22a85523abf932587463d751d7e5174 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 25 Jul 2022 14:17:07 +0200 Subject: [PATCH] Adding attribute to set the start margin of icon --- .../values/stylable_location_live_ended_banner_view.xml | 1 + .../location/live/LocationLiveEndedBannerView.kt | 9 +++++++++ .../main/res/layout/fragment_location_live_map_view.xml | 1 + .../item_timeline_event_live_location_inactive_stub.xml | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/library/ui-styles/src/main/res/values/stylable_location_live_ended_banner_view.xml b/library/ui-styles/src/main/res/values/stylable_location_live_ended_banner_view.xml index cd187586e7..81e377d39b 100644 --- a/library/ui-styles/src/main/res/values/stylable_location_live_ended_banner_view.xml +++ b/library/ui-styles/src/main/res/values/stylable_location_live_ended_banner_view.xml @@ -3,6 +3,7 @@ + diff --git a/vector/src/main/java/im/vector/app/features/location/live/LocationLiveEndedBannerView.kt b/vector/src/main/java/im/vector/app/features/location/live/LocationLiveEndedBannerView.kt index dc4938fe7a..49d6985840 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/LocationLiveEndedBannerView.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/LocationLiveEndedBannerView.kt @@ -21,6 +21,7 @@ import android.content.res.TypedArray import android.util.AttributeSet import android.view.LayoutInflater import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.updateLayoutParams import im.vector.app.R import im.vector.app.databinding.ViewLocationLiveEndedBannerBinding @@ -44,6 +45,7 @@ class LocationLiveEndedBannerView @JvmOverloads constructor( ).run { try { setBackgroundAlpha(this) + setIconMarginStart(this) } finally { recycle() } @@ -54,4 +56,11 @@ class LocationLiveEndedBannerView @JvmOverloads constructor( val withAlpha = typedArray.getBoolean(R.styleable.LocationLiveEndedBannerView_locLiveEndedBkgWithAlpha, false) binding.locationLiveEndedBannerBackground.alpha = if (withAlpha) 0.75f else 1f } + + private fun setIconMarginStart(typedArray: TypedArray) { + val margin = typedArray.getDimensionPixelOffset(R.styleable.LocationLiveEndedBannerView_locLiveEndedIconMarginStart, 0) + binding.locationLiveEndedBannerIcon.updateLayoutParams { + marginStart = margin + } + } } diff --git a/vector/src/main/res/layout/fragment_location_live_map_view.xml b/vector/src/main/res/layout/fragment_location_live_map_view.xml index ac8f18479b..f0a3fbfc89 100644 --- a/vector/src/main/res/layout/fragment_location_live_map_view.xml +++ b/vector/src/main/res/layout/fragment_location_live_map_view.xml @@ -56,6 +56,7 @@ android:layout_gravity="bottom" android:visibility="gone" app:locLiveEndedBkgWithAlpha="false" + app:locLiveEndedIconMarginStart="16dp" tools:visibility="visible" /> 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 074ebf2f86..53b740bb4e 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 @@ -22,7 +22,8 @@ app:layout_constraintBottom_toBottomOf="@id/locationLiveInactiveMap" app:layout_constraintEnd_toEndOf="@id/locationLiveInactiveMap" app:layout_constraintStart_toStartOf="@id/locationLiveInactiveMap" - app:locLiveEndedBkgWithAlpha="true" /> + app:locLiveEndedBkgWithAlpha="true" + app:locLiveEndedIconMarginStart="8dp" />