From a98f502c01c0571f172c801962c2a521aad19d62 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Tue, 1 Mar 2022 17:30:21 +0100 Subject: [PATCH 01/25] Adding custom view for options picker --- .../location/LocationSharingOption.kt | 23 +++++ .../view/LocationSharingOptionPickerView.kt | 43 +++++++++ .../view/LocationSharingOptionView.kt | 95 +++++++++++++++++++ .../res/layout/fragment_location_sharing.xml | 32 +------ .../layout/view_location_sharing_option.xml | 42 ++++++++ .../view_location_sharing_option_picker.xml | 22 +++++ vector/src/main/res/values/attrs.xml | 10 ++ 7 files changed, 238 insertions(+), 29 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/LocationSharingOption.kt create mode 100644 vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt create mode 100644 vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt create mode 100644 vector/src/main/res/layout/view_location_sharing_option.xml create mode 100644 vector/src/main/res/layout/view_location_sharing_option_picker.xml create mode 100644 vector/src/main/res/values/attrs.xml diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingOption.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingOption.kt new file mode 100644 index 00000000000..38f4bff16e3 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingOption.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.location + +enum class LocationSharingOption { + USER_CURRENT, // current user's location + USER_LIVE, // user's location during a certain amount of time + PINNED // static location pinned by the user +} diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt new file mode 100644 index 00000000000..896edb55580 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.location.view + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import im.vector.app.databinding.ViewLocationSharingOptionPickerBinding + +/** + * Custom view to display the location sharing option picker. + */ +class LocationSharingOptionPickerView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + /*private val binding = */ + init { + ViewLocationSharingOptionPickerBinding.inflate( + LayoutInflater.from(context), + this + ) + } + + /*fun setOptions(vararg options: LocationSharingOption) { + // TODO show only the options passed in argument + }*/ +} diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt new file mode 100644 index 00000000000..b9cb6cf3d0f --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.location.view + +import android.content.Context +import android.content.res.TypedArray +import android.util.AttributeSet +import android.util.TypedValue +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.DrawableCompat +import im.vector.app.R +import im.vector.app.databinding.ViewLocationSharingOptionBinding + +/** + * Custom view to display a location sharing option. + */ +class LocationSharingOptionView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + private val binding = ViewLocationSharingOptionBinding.inflate( + LayoutInflater.from(context), + this + ) + + init { + applyRipple() + context.theme.obtainStyledAttributes( + attrs, + R.styleable.LocationSharingOptionView, + 0, + 0 + ).run { + try { + setIcon(this) + setTitle(this) + } finally { + recycle() + } + } + } + + private fun applyRipple() { + val outValue = TypedValue() + context.theme.resolveAttribute( + android.R.attr.selectableItemBackground, + outValue, + true + ) + binding.root.background = ContextCompat.getDrawable( + context, + outValue.resourceId + ) + } + + private fun setIcon(typedArray: TypedArray) { + val icon = typedArray.getDrawable(R.styleable.LocationSharingOptionView_icon) + val background = typedArray.getDrawable(R.styleable.LocationSharingOptionView_iconBackground) + val backgroundTint = typedArray.getColor( + R.styleable.LocationSharingOptionView_iconBackgroundTint, + ContextCompat.getColor(context, android.R.color.transparent) + ) + val description = typedArray.getString(R.styleable.LocationSharingOptionView_iconDescription) + + binding.shareLocationOptionIcon.setImageDrawable(icon) + val bkg = background?.let { + val backgroundDrawable = DrawableCompat.wrap(it) + DrawableCompat.setTint(backgroundDrawable, backgroundTint) + backgroundDrawable + } ?: background + binding.shareLocationOptionIcon.background = bkg + binding.shareLocationOptionIcon.contentDescription = description + } + + private fun setTitle(typedArray: TypedArray) { + val title = typedArray.getString(R.styleable.LocationSharingOptionView_title) + binding.shareLocationOptionTitle.text = title + } +} diff --git a/vector/src/main/res/layout/fragment_location_sharing.xml b/vector/src/main/res/layout/fragment_location_sharing.xml index ad418f3e1cc..1d64a56fdc1 100644 --- a/vector/src/main/res/layout/fragment_location_sharing.xml +++ b/vector/src/main/res/layout/fragment_location_sharing.xml @@ -14,40 +14,14 @@ app:mapbox_renderTextureMode="true" tools:background="#4F00" /> - - - - - - \ No newline at end of file + diff --git a/vector/src/main/res/layout/view_location_sharing_option.xml b/vector/src/main/res/layout/view_location_sharing_option.xml new file mode 100644 index 00000000000..a399c438dd8 --- /dev/null +++ b/vector/src/main/res/layout/view_location_sharing_option.xml @@ -0,0 +1,42 @@ + + + + + + + + + + diff --git a/vector/src/main/res/layout/view_location_sharing_option_picker.xml b/vector/src/main/res/layout/view_location_sharing_option_picker.xml new file mode 100644 index 00000000000..13c93611d02 --- /dev/null +++ b/vector/src/main/res/layout/view_location_sharing_option_picker.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/vector/src/main/res/values/attrs.xml b/vector/src/main/res/values/attrs.xml new file mode 100644 index 00000000000..e35e111794a --- /dev/null +++ b/vector/src/main/res/values/attrs.xml @@ -0,0 +1,10 @@ + + + + + + + + + + From 1c6b31001f09fd7a7aacf3ae0fbe2656dccc29be Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Tue, 1 Mar 2022 17:32:03 +0100 Subject: [PATCH 02/25] Adding changelog entry --- changelog.d/5395.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5395.feature diff --git a/changelog.d/5395.feature b/changelog.d/5395.feature new file mode 100644 index 00000000000..eb16c6cd818 --- /dev/null +++ b/changelog.d/5395.feature @@ -0,0 +1 @@ +Add a custom view to display a picker for share location options From 55c6383074fa76f42e916b4773bb5e04f13944eb Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Tue, 1 Mar 2022 17:43:34 +0100 Subject: [PATCH 03/25] Set options method --- .../location/LocationSharingFragment.kt | 2 ++ .../view/LocationSharingOptionPickerView.kt | 19 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index a7e93a3f6cb..9333c579b44 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -59,6 +59,8 @@ class LocationSharingFragment @Inject constructor( views.mapView.initialize(urlMapProvider.getMapUrl()) } + // TODO change the options dynamically depending on the current chosen location + views.shareLocationContainer.setOptions(LocationSharingOption.PINNED) views.shareLocationContainer.debouncedClicks { viewModel.handle(LocationSharingAction.OnShareLocation) } diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt index 896edb55580..aa72bb17f25 100644 --- a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt @@ -20,7 +20,9 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import im.vector.app.databinding.ViewLocationSharingOptionPickerBinding +import im.vector.app.features.location.LocationSharingOption /** * Custom view to display the location sharing option picker. @@ -29,15 +31,12 @@ class LocationSharingOptionPickerView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { - /*private val binding = */ - init { - ViewLocationSharingOptionPickerBinding.inflate( - LayoutInflater.from(context), - this - ) - } + private val binding = ViewLocationSharingOptionPickerBinding.inflate( + LayoutInflater.from(context), + this + ) - /*fun setOptions(vararg options: LocationSharingOption) { - // TODO show only the options passed in argument - }*/ + fun setOptions(vararg options: LocationSharingOption) { + binding.locationSharingOptionPinned.isVisible = options.contains(LocationSharingOption.PINNED) + } } From 4586426958d0dd25bce76669fe12bc482d094aad Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Tue, 1 Mar 2022 18:02:38 +0100 Subject: [PATCH 04/25] Adding other options --- .../location/LocationSharingFragment.kt | 5 +-- .../view/LocationSharingOptionPickerView.kt | 7 +++- .../res/layout/fragment_location_sharing.xml | 10 +++--- .../view_location_sharing_option_picker.xml | 34 ++++++++++++++++++- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index 9333c579b44..368b4651dc0 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -60,8 +60,9 @@ class LocationSharingFragment @Inject constructor( } // TODO change the options dynamically depending on the current chosen location - views.shareLocationContainer.setOptions(LocationSharingOption.PINNED) - views.shareLocationContainer.debouncedClicks { + // set correct click listener on each option + views.shareLocationOptionsPicker.setOptions(LocationSharingOption.PINNED) + views.shareLocationOptionsPicker.debouncedClicks { viewModel.handle(LocationSharingAction.OnShareLocation) } diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt index aa72bb17f25..1795bad197c 100644 --- a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt @@ -37,6 +37,11 @@ class LocationSharingOptionPickerView @JvmOverloads constructor( ) fun setOptions(vararg options: LocationSharingOption) { - binding.locationSharingOptionPinned.isVisible = options.contains(LocationSharingOption.PINNED) + binding.locationSharingOptionUserCurrentLocation.isVisible = + options.contains(LocationSharingOption.USER_CURRENT) + binding.locationSharingOptionUserLiveLocation.isVisible = + options.contains(LocationSharingOption.USER_LIVE) + binding.locationSharingOptionPinned.isVisible = + options.contains(LocationSharingOption.PINNED) } } diff --git a/vector/src/main/res/layout/fragment_location_sharing.xml b/vector/src/main/res/layout/fragment_location_sharing.xml index 1d64a56fdc1..b2279ed1463 100644 --- a/vector/src/main/res/layout/fragment_location_sharing.xml +++ b/vector/src/main/res/layout/fragment_location_sharing.xml @@ -9,13 +9,13 @@ android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="0dp" - app:layout_constraintBottom_toTopOf="@id/shareLocationContainer" + app:layout_constraintBottom_toTopOf="@id/shareLocationOptionsPicker" app:layout_constraintTop_toTopOf="parent" app:mapbox_renderTextureMode="true" tools:background="#4F00" /> + android:layout_marginBottom="@dimen/layout_vertical_margin" + app:layout_constraintBottom_toBottomOf="@id/shareLocationOptionsPicker" + app:layout_constraintEnd_toEndOf="@id/shareLocationOptionsPicker" /> diff --git a/vector/src/main/res/layout/view_location_sharing_option_picker.xml b/vector/src/main/res/layout/view_location_sharing_option_picker.xml index 13c93611d02..359c9331f48 100644 --- a/vector/src/main/res/layout/view_location_sharing_option_picker.xml +++ b/vector/src/main/res/layout/view_location_sharing_option_picker.xml @@ -6,17 +6,49 @@ android:layout_height="wrap_content" tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> + + + + + + + From 3bbb7167f1f6b404d205add8e7f8f3872ce8de0f Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Wed, 2 Mar 2022 10:44:02 +0100 Subject: [PATCH 05/25] Adding icon for live location --- library/ui-styles/src/main/res/values/dimens.xml | 5 ++++- .../location/view/LocationSharingOptionView.kt | 6 ++++++ .../res/drawable/ic_attachment_location_live_white.xml | 10 ++++++++++ .../main/res/layout/view_location_sharing_option.xml | 2 +- .../res/layout/view_location_sharing_option_picker.xml | 3 ++- vector/src/main/res/values/attrs.xml | 1 + 6 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 vector/src/main/res/drawable/ic_attachment_location_live_white.xml diff --git a/library/ui-styles/src/main/res/values/dimens.xml b/library/ui-styles/src/main/res/values/dimens.xml index db42cfa12ce..4719d77fbe9 100644 --- a/library/ui-styles/src/main/res/values/dimens.xml +++ b/library/ui-styles/src/main/res/values/dimens.xml @@ -70,4 +70,7 @@ 0.15 0.05 - \ No newline at end of file + + + 10dp + diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt index b9cb6cf3d0f..a9675375921 100644 --- a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt @@ -24,6 +24,7 @@ import android.view.LayoutInflater import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.DrawableCompat +import androidx.core.view.setPadding import im.vector.app.R import im.vector.app.databinding.ViewLocationSharingOptionBinding @@ -76,6 +77,10 @@ class LocationSharingOptionView @JvmOverloads constructor( R.styleable.LocationSharingOptionView_iconBackgroundTint, ContextCompat.getColor(context, android.R.color.transparent) ) + val padding = typedArray.getDimensionPixelOffset( + R.styleable.LocationSharingOptionView_iconPadding, + context.resources.getDimensionPixelOffset(R.dimen.location_sharing_option_default_padding) + ) val description = typedArray.getString(R.styleable.LocationSharingOptionView_iconDescription) binding.shareLocationOptionIcon.setImageDrawable(icon) @@ -85,6 +90,7 @@ class LocationSharingOptionView @JvmOverloads constructor( backgroundDrawable } ?: background binding.shareLocationOptionIcon.background = bkg + binding.shareLocationOptionIcon.setPadding(padding) binding.shareLocationOptionIcon.contentDescription = description } diff --git a/vector/src/main/res/drawable/ic_attachment_location_live_white.xml b/vector/src/main/res/drawable/ic_attachment_location_live_white.xml new file mode 100644 index 00000000000..da6a37232d0 --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_location_live_white.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/layout/view_location_sharing_option.xml b/vector/src/main/res/layout/view_location_sharing_option.xml index a399c438dd8..e7aa4aa6a98 100644 --- a/vector/src/main/res/layout/view_location_sharing_option.xml +++ b/vector/src/main/res/layout/view_location_sharing_option.xml @@ -26,9 +26,9 @@ android:layout_width="40dp" android:layout_height="40dp" android:contentDescription="@string/a11y_location_share_icon" - android:padding="10dp" tools:background="@drawable/circle" tools:backgroundTint="?colorPrimary" + tools:padding="10dp" tools:src="@drawable/ic_attachment_location_white" /> + From 0707877b3c925ba447e405a5cd2bc63245cbe409 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Wed, 2 Mar 2022 11:07:33 +0100 Subject: [PATCH 06/25] Using correct string resources for options --- .../layout/view_location_sharing_option_picker.xml | 12 ++++++------ vector/src/main/res/values/strings.xml | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/vector/src/main/res/layout/view_location_sharing_option_picker.xml b/vector/src/main/res/layout/view_location_sharing_option_picker.xml index 277f0f06041..ecb96fc1e40 100644 --- a/vector/src/main/res/layout/view_location_sharing_option_picker.xml +++ b/vector/src/main/res/layout/view_location_sharing_option_picker.xml @@ -16,12 +16,12 @@ app:icon="@drawable/ic_attachment_location_white" app:iconBackground="@drawable/circle" app:iconBackgroundTint="?colorPrimary" - app:iconDescription="@string/a11y_location_share_icon" + app:iconDescription="@string/a11y_location_share_option_pinned_icon" app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserCurrentLocation" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:title="@string/location_share" /> + app:title="@string/location_share_option_pinned" /> + app:title="@string/location_share_option_user_current" /> + app:title="@string/location_share_option_user_live" /> diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index dc52d2cf5d0..8cdbe122f34 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2924,9 +2924,17 @@ Share location Location + Share location Map + Share location + Share my current location + Share my current location + Share live location + Share live location + Share this location + Share this location ${app_name} could not access your location ${app_name} could not access your location. Please try again later. Open with From fb764028c9e66a83da95b6a4a3e4fd50a483dbbb Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Wed, 2 Mar 2022 12:15:04 +0100 Subject: [PATCH 07/25] Adding dividers --- .../view/LocationSharingOptionPickerView.kt | 16 ++++++++----- .../view/LocationSharingOptionView.kt | 9 +++++++ .../view_location_sharing_option_picker.xml | 24 ++++++++++++++++++- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt index 1795bad197c..de8c6dc8f3c 100644 --- a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionPickerView.kt @@ -37,11 +37,15 @@ class LocationSharingOptionPickerView @JvmOverloads constructor( ) fun setOptions(vararg options: LocationSharingOption) { - binding.locationSharingOptionUserCurrentLocation.isVisible = - options.contains(LocationSharingOption.USER_CURRENT) - binding.locationSharingOptionUserLiveLocation.isVisible = - options.contains(LocationSharingOption.USER_LIVE) - binding.locationSharingOptionPinned.isVisible = - options.contains(LocationSharingOption.PINNED) + val optionsNumber = options.toSet().size + val isPinnedVisible = options.contains(LocationSharingOption.PINNED) + val isUserCurrentVisible = options.contains(LocationSharingOption.USER_CURRENT) + val isUserLiveVisible = options.contains(LocationSharingOption.USER_LIVE) + + binding.locationSharingOptionPinned.isVisible = isPinnedVisible + binding.locationSharingOptionsDivider1.isVisible = isPinnedVisible && optionsNumber > 1 + binding.locationSharingOptionUserCurrentLocation.isVisible = isUserCurrentVisible + binding.locationSharingOptionsDivider2.isVisible = isUserCurrentVisible && isUserLiveVisible + binding.locationSharingOptionUserLiveLocation.isVisible = isUserLiveVisible } } diff --git a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt index a9675375921..a5d97ca9556 100644 --- a/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt +++ b/vector/src/main/java/im/vector/app/features/location/view/LocationSharingOptionView.kt @@ -18,6 +18,7 @@ package im.vector.app.features.location.view import android.content.Context import android.content.res.TypedArray +import android.graphics.drawable.Drawable import android.util.AttributeSet import android.util.TypedValue import android.view.LayoutInflater @@ -57,6 +58,14 @@ class LocationSharingOptionView @JvmOverloads constructor( } } + fun setIcon(icon: Drawable) { + binding.shareLocationOptionIcon.setImageDrawable(icon) + } + + fun setIconBackground(bkg: Drawable) { + binding.shareLocationOptionIcon.background = bkg + } + private fun applyRipple() { val outValue = TypedValue() context.theme.resolveAttribute( diff --git a/vector/src/main/res/layout/view_location_sharing_option_picker.xml b/vector/src/main/res/layout/view_location_sharing_option_picker.xml index ecb96fc1e40..fdabae7ca28 100644 --- a/vector/src/main/res/layout/view_location_sharing_option_picker.xml +++ b/vector/src/main/res/layout/view_location_sharing_option_picker.xml @@ -23,20 +23,42 @@ app:layout_constraintTop_toTopOf="parent" app:title="@string/location_share_option_pinned" /> + + + + Date: Wed, 2 Mar 2022 15:00:16 +0100 Subject: [PATCH 08/25] Changing color of the live location icon --- library/ui-styles/src/main/res/values/colors.xml | 4 ++++ library/ui-styles/src/main/res/values/theme_dark.xml | 2 ++ library/ui-styles/src/main/res/values/theme_light.xml | 2 ++ .../main/res/layout/view_location_sharing_option_picker.xml | 5 +---- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/library/ui-styles/src/main/res/values/colors.xml b/library/ui-styles/src/main/res/values/colors.xml index 6610c0f45d5..e4e8b1d9001 100644 --- a/library/ui-styles/src/main/res/values/colors.xml +++ b/library/ui-styles/src/main/res/values/colors.xml @@ -139,4 +139,8 @@ @color/palette_gray_100 @color/palette_gray_450 + + + @color/palette_prune + @color/palette_prune diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml index 607f0084537..8cd4dc23994 100644 --- a/library/ui-styles/src/main/res/values/theme_dark.xml +++ b/library/ui-styles/src/main/res/values/theme_dark.xml @@ -145,6 +145,8 @@ @style/Widget.Vector.ActionButton + + @color/vctr_live_location_dark