Adding locate button view on the map for live location preview
This commit is contained in:
parent
81cb0d40c6
commit
8eff831382
|
@ -24,6 +24,8 @@ import android.view.ViewGroup
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.view.marginBottom
|
||||||
|
import androidx.core.view.marginTop
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
|
@ -192,6 +194,7 @@ class LiveLocationMapViewFragment :
|
||||||
updateMap(viewState.userLocations)
|
updateMap(viewState.userLocations)
|
||||||
}
|
}
|
||||||
updateUserListBottomSheet(viewState.userLocations)
|
updateUserListBottomSheet(viewState.userLocations)
|
||||||
|
updateLocateButton(showLocateButton = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
|
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
|
||||||
|
@ -236,6 +239,20 @@ class LiveLocationMapViewFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateLocateButton(showLocateButton: Boolean) {
|
||||||
|
views.liveLocationMapLocateButton.isVisible = showLocateButton
|
||||||
|
adjustCompassButton()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun adjustCompassButton() {
|
||||||
|
val locateButton = views.liveLocationMapLocateButton
|
||||||
|
locateButton.post {
|
||||||
|
val marginTop = locateButton.height + locateButton.marginTop + locateButton.marginBottom
|
||||||
|
val marginRight = locateButton.context.resources.getDimensionPixelOffset(R.dimen.location_sharing_compass_button_margin_horizontal)
|
||||||
|
mapboxMap?.get()?.uiSettings?.setCompassMargins(0, marginTop, marginRight, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateMap(userLiveLocations: List<UserLiveLocationViewState>) {
|
private fun updateMap(userLiveLocations: List<UserLiveLocationViewState>) {
|
||||||
symbolManager?.let { sManager ->
|
symbolManager?.let { sManager ->
|
||||||
val latLngBoundsBuilder = LatLngBounds.Builder()
|
val latLngBoundsBuilder = LatLngBounds.Builder()
|
||||||
|
|
|
@ -17,6 +17,20 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/liveLocationMapLocateButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top|end"
|
||||||
|
android:layout_marginHorizontal="@dimen/location_sharing_locate_button_margin_horizontal"
|
||||||
|
android:layout_marginVertical="@dimen/location_sharing_locate_button_margin_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
android:contentDescription="@string/a11y_location_share_locate_button"
|
||||||
|
android:focusable="true"
|
||||||
|
android:src="@drawable/btn_locate"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<im.vector.app.features.location.MapLoadingErrorView
|
<im.vector.app.features.location.MapLoadingErrorView
|
||||||
android:id="@+id/mapPreviewLoadingError"
|
android:id="@+id/mapPreviewLoadingError"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue