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 368b4651dc..ad8054d2ab 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,12 +59,7 @@ class LocationSharingFragment @Inject constructor(
views.mapView.initialize(urlMapProvider.getMapUrl())
}
- // TODO change the options dynamically depending on the current chosen location
- // set correct click listener on each option
- views.shareLocationOptionsPicker.setOptions(LocationSharingOption.PINNED)
- views.shareLocationOptionsPicker.debouncedClicks {
- viewModel.handle(LocationSharingAction.OnShareLocation)
- }
+ initOptionsPicker()
viewModel.observeViewEvents {
when (it) {
@@ -110,6 +105,11 @@ class LocationSharingFragment @Inject constructor(
super.onDestroy()
}
+ override fun invalidate() = withState(viewModel) { state ->
+ views.mapView.render(state.toMapState())
+ views.shareLocationGpsLoading.isGone = state.lastKnownLocation != null
+ }
+
private fun handleLocationNotAvailableError() {
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.location_not_available_dialog_title)
@@ -121,8 +121,19 @@ class LocationSharingFragment @Inject constructor(
.show()
}
- override fun invalidate() = withState(viewModel) { state ->
- views.mapView.render(state.toMapState())
- views.shareLocationGpsLoading.isGone = state.lastKnownLocation != null
+ private fun initOptionsPicker() {
+ // TODO
+ // set avatar and user color for the current user location option
+ // change the options dynamically depending on the current chosen location
+ views.shareLocationOptionsPicker.setOptions(LocationSharingOption.PINNED)
+ views.shareLocationOptionsPicker.optionPinned.debouncedClicks {
+ viewModel.handle(LocationSharingAction.OnShareLocation)
+ }
+ views.shareLocationOptionsPicker.optionUserCurrent.debouncedClicks {
+ // TODO
+ }
+ views.shareLocationOptionsPicker.optionUserLive.debouncedClicks {
+ // TODO
+ }
}
}
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 de8c6dc8f3..1e863e6fb0 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
@@ -19,6 +19,7 @@ package im.vector.app.features.location.view
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
+import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import im.vector.app.databinding.ViewLocationSharingOptionPickerBinding
@@ -31,6 +32,21 @@ class LocationSharingOptionPickerView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
+ val optionPinned: LocationSharingOptionView
+ get() = binding.locationSharingOptionPinned
+
+ val optionUserCurrent: LocationSharingOptionView
+ get() = binding.locationSharingOptionUserCurrent
+
+ val optionUserLive: LocationSharingOptionView
+ get() = binding.locationSharingOptionUserLive
+
+ private val divider1: View
+ get() = binding.locationSharingOptionsDivider1
+
+ private val divider2: View
+ get() = binding.locationSharingOptionsDivider2
+
private val binding = ViewLocationSharingOptionPickerBinding.inflate(
LayoutInflater.from(context),
this
@@ -42,10 +58,10 @@ class LocationSharingOptionPickerView @JvmOverloads constructor(
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
+ optionPinned.isVisible = isPinnedVisible
+ divider1.isVisible = isPinnedVisible && optionsNumber > 1
+ optionUserCurrent.isVisible = isUserCurrentVisible
+ divider2.isVisible = isUserCurrentVisible && isUserLiveVisible
+ optionUserLive.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 a5d97ca955..95a3ce23ff 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
@@ -42,7 +42,6 @@ class LocationSharingOptionView @JvmOverloads constructor(
)
init {
- applyRipple()
context.theme.obtainStyledAttributes(
attrs,
R.styleable.LocationSharingOptionView,
@@ -66,19 +65,6 @@ class LocationSharingOptionView @JvmOverloads constructor(
binding.shareLocationOptionIcon.background = bkg
}
- 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)
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 e7aa4aa6a9..814d6660ba 100644
--- a/vector/src/main/res/layout/view_location_sharing_option.xml
+++ b/vector/src/main/res/layout/view_location_sharing_option.xml
@@ -10,7 +10,8 @@
android:id="@+id/shareLocationOptionContainer"
android:layout_width="0dp"
android:layout_height="72dp"
- android:background="?android:colorBackground"
+ android:background="?selectableItemBackground"
+ android:duplicateParentState="true"
android:paddingStart="@dimen/layout_horizontal_margin"
android:paddingEnd="@dimen/layout_horizontal_margin"
app:constraint_referenced_ids="shareLocationOptionIcon,shareLocationOptionTitle"
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 1261ad8986..c479da4a69 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
@@ -14,7 +14,7 @@
app:iconBackground="@drawable/circle"
app:iconBackgroundTint="?colorPrimary"
app:iconDescription="@string/a11y_location_share_option_pinned_icon"
- app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserCurrentLocation"
+ app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserCurrent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
@@ -26,20 +26,20 @@
android:layout_height="1dp"
android:alpha="0.15"
android:background="?vctr_content_secondary"
- app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserCurrentLocation"
+ app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserCurrent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/locationSharingOptionPinned" />
+ app:layout_constraintTop_toBottomOf="@id/locationSharingOptionUserCurrent" />