Fixing ripple effect
This commit is contained in:
parent
8bcc594320
commit
42fca9bd6f
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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" />
|
||||
|
||||
<im.vector.app.features.location.view.LocationSharingOptionView
|
||||
android:id="@+id/locationSharingOptionUserCurrentLocation"
|
||||
android:id="@+id/locationSharingOptionUserCurrent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:iconBackground="@drawable/circle"
|
||||
app:iconBackgroundTint="?colorPrimary"
|
||||
app:iconDescription="@string/a11y_location_share_option_user_current_icon"
|
||||
app:iconPadding="3dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserLiveLocation"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserLive"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/locationSharingOptionPinned"
|
||||
@ -51,13 +51,13 @@
|
||||
android:layout_height="1dp"
|
||||
android:alpha="0.15"
|
||||
android:background="?vctr_content_secondary"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserLiveLocation"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationSharingOptionUserLive"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/locationSharingOptionUserCurrentLocation" />
|
||||
app:layout_constraintTop_toBottomOf="@id/locationSharingOptionUserCurrent" />
|
||||
|
||||
<im.vector.app.features.location.view.LocationSharingOptionView
|
||||
android:id="@+id/locationSharingOptionUserLiveLocation"
|
||||
android:id="@+id/locationSharingOptionUserLive"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_attachment_location_live_white"
|
||||
@ -68,7 +68,7 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/locationSharingOptionUserCurrentLocation"
|
||||
app:layout_constraintTop_toBottomOf="@id/locationSharingOptionUserCurrent"
|
||||
app:title="@string/location_share_option_user_live" />
|
||||
|
||||
</merge>
|
||||
|
Loading…
x
Reference in New Issue
Block a user