Renaming "btn" into "button"

This commit is contained in:
Maxime Naturel 2022-03-15 15:08:32 +01:00
parent 9ecf12a7ba
commit b72c87da44
4 changed files with 23 additions and 23 deletions

View file

@ -64,7 +64,7 @@
<!-- Location sharing --> <!-- Location sharing -->
<dimen name="location_sharing_option_default_padding">10dp</dimen> <dimen name="location_sharing_option_default_padding">10dp</dimen>
<dimen name="location_sharing_locate_btn_margin_vertical">16dp</dimen> <dimen name="location_sharing_locate_button_margin_vertical">16dp</dimen>
<dimen name="location_sharing_locate_btn_margin_horizontal">12dp</dimen> <dimen name="location_sharing_locate_button_margin_horizontal">12dp</dimen>
<dimen name="location_sharing_compass_btn_margin_horizontal">8dp</dimen> <dimen name="location_sharing_compass_button_margin_horizontal">8dp</dimen>
</resources> </resources>

View file

@ -144,7 +144,7 @@ class LocationSharingFragment @Inject constructor(
} }
private fun initLocateButton() { private fun initLocateButton() {
views.mapView.locateBtn.setOnClickListener { views.mapView.locateButton.setOnClickListener {
viewModel.handle(LocationSharingAction.ZoomToUserLocation) viewModel.handle(LocationSharingAction.ZoomToUserLocation)
} }
} }

View file

@ -53,10 +53,10 @@ class MapTilerMapView @JvmOverloads constructor(
private val userLocationDrawable by lazy { private val userLocationDrawable by lazy {
ContextCompat.getDrawable(context, R.drawable.ic_location_user) ContextCompat.getDrawable(context, R.drawable.ic_location_user)
} }
val locateBtn by lazy { createLocateBtn() } val locateButton by lazy { createLocateButton() }
private var mapRefs: MapRefs? = null private var mapRefs: MapRefs? = null
private var initZoomDone = false private var initZoomDone = false
private var showLocationBtn = false private var showLocationButton = false
init { init {
context.theme.obtainStyledAttributes( context.theme.obtainStyledAttributes(
@ -66,15 +66,15 @@ class MapTilerMapView @JvmOverloads constructor(
0 0
).run { ).run {
try { try {
setLocateBtnVisibility(this) setLocateButtonVisibility(this)
} finally { } finally {
recycle() recycle()
} }
} }
} }
private fun setLocateBtnVisibility(typedArray: TypedArray) { private fun setLocateButtonVisibility(typedArray: TypedArray) {
showLocationBtn = typedArray.getBoolean(R.styleable.MapTilerMapView_showLocateButton, false) showLocationButton = typedArray.getBoolean(R.styleable.MapTilerMapView_showLocateButton, false)
} }
/** /**
@ -87,7 +87,7 @@ class MapTilerMapView @JvmOverloads constructor(
Timber.d("## Location: initialize") Timber.d("## Location: initialize")
getMapAsync { map -> getMapAsync { map ->
initMapStyle(map, url) initMapStyle(map, url)
initLocateBtn(map) initLocateButton(map)
notifyLocationOfMapCenter(locationTargetChangeListener) notifyLocationOfMapCenter(locationTargetChangeListener)
listenCameraMove(map, locationTargetChangeListener) listenCameraMove(map, locationTargetChangeListener)
} }
@ -105,21 +105,21 @@ class MapTilerMapView @JvmOverloads constructor(
} }
} }
private fun initLocateBtn(map: MapboxMap) { private fun initLocateButton(map: MapboxMap) {
if (showLocationBtn) { if (showLocationButton) {
addView(locateBtn) addView(locateButton)
adjustCompassBtn(map) adjustCompassButton(map)
} }
} }
private fun createLocateBtn(): ImageView = private fun createLocateButton(): ImageView =
ImageView(context).apply { ImageView(context).apply {
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.btn_locate)) setImageDrawable(ContextCompat.getDrawable(context, R.drawable.btn_locate))
contentDescription = context.getString(R.string.a11y_location_share_locate_btn) contentDescription = context.getString(R.string.a11y_location_share_locate_button)
layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
updateLayoutParams<MarginLayoutParams> { updateLayoutParams<MarginLayoutParams> {
val marginHorizontal = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_btn_margin_horizontal) val marginHorizontal = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_button_margin_horizontal)
val marginVertical = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_btn_margin_vertical) val marginVertical = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_button_margin_vertical)
setMargins(marginHorizontal, marginVertical, marginHorizontal, marginVertical) setMargins(marginHorizontal, marginVertical, marginHorizontal, marginVertical)
} }
updateLayoutParams<LayoutParams> { updateLayoutParams<LayoutParams> {
@ -127,10 +127,10 @@ class MapTilerMapView @JvmOverloads constructor(
} }
} }
private fun adjustCompassBtn(map: MapboxMap) { private fun adjustCompassButton(map: MapboxMap) {
locateBtn.post { locateButton.post {
val marginTop = locateBtn.height + locateBtn.marginTop + locateBtn.marginBottom val marginTop = locateButton.height + locateButton.marginTop + locateButton.marginBottom
val marginRight = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_compass_btn_margin_horizontal) val marginRight = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_compass_button_margin_horizontal)
map.uiSettings.setCompassMargins(0, marginTop, marginRight, 0) map.uiSettings.setCompassMargins(0, marginTop, marginRight, 0)
} }
} }

View file

@ -2930,7 +2930,7 @@
<!-- TODO delete --> <!-- TODO delete -->
<string name="location_share" tools:ignore="UnusedResources">Share location</string> <string name="location_share" tools:ignore="UnusedResources">Share location</string>
<string name="a11y_location_share_pin_on_map">Pin of selected location on map</string> <string name="a11y_location_share_pin_on_map">Pin of selected location on map</string>
<string name="a11y_location_share_locate_btn">Zoom to current location</string> <string name="a11y_location_share_locate_button">Zoom to current location</string>
<string name="location_share_option_user_current">Share my current location</string> <string name="location_share_option_user_current">Share my current location</string>
<string name="a11y_location_share_option_user_current_icon">Share my current location</string> <string name="a11y_location_share_option_user_current_icon">Share my current location</string>
<string name="location_share_option_user_live">Share live location</string> <string name="location_share_option_user_live">Share live location</string>