Skip to content

Commit

Permalink
Renaming "btn" into "button"
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Naturel committed Mar 15, 2022
1 parent 9ecf12a commit b72c87d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions library/ui-styles/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<!-- Location sharing -->
<dimen name="location_sharing_option_default_padding">10dp</dimen>
<dimen name="location_sharing_locate_btn_margin_vertical">16dp</dimen>
<dimen name="location_sharing_locate_btn_margin_horizontal">12dp</dimen>
<dimen name="location_sharing_compass_btn_margin_horizontal">8dp</dimen>
<dimen name="location_sharing_locate_button_margin_vertical">16dp</dimen>
<dimen name="location_sharing_locate_button_margin_horizontal">12dp</dimen>
<dimen name="location_sharing_compass_button_margin_horizontal">8dp</dimen>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LocationSharingFragment @Inject constructor(
}

private fun initLocateButton() {
views.mapView.locateBtn.setOnClickListener {
views.mapView.locateButton.setOnClickListener {
viewModel.handle(LocationSharingAction.ZoomToUserLocation)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class MapTilerMapView @JvmOverloads constructor(
private val userLocationDrawable by lazy {
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 initZoomDone = false
private var showLocationBtn = false
private var showLocationButton = false

init {
context.theme.obtainStyledAttributes(
Expand All @@ -66,15 +66,15 @@ class MapTilerMapView @JvmOverloads constructor(
0
).run {
try {
setLocateBtnVisibility(this)
setLocateButtonVisibility(this)
} finally {
recycle()
}
}
}

private fun setLocateBtnVisibility(typedArray: TypedArray) {
showLocationBtn = typedArray.getBoolean(R.styleable.MapTilerMapView_showLocateButton, false)
private fun setLocateButtonVisibility(typedArray: TypedArray) {
showLocationButton = typedArray.getBoolean(R.styleable.MapTilerMapView_showLocateButton, false)
}

/**
Expand All @@ -87,7 +87,7 @@ class MapTilerMapView @JvmOverloads constructor(
Timber.d("## Location: initialize")
getMapAsync { map ->
initMapStyle(map, url)
initLocateBtn(map)
initLocateButton(map)
notifyLocationOfMapCenter(locationTargetChangeListener)
listenCameraMove(map, locationTargetChangeListener)
}
Expand All @@ -105,32 +105,32 @@ class MapTilerMapView @JvmOverloads constructor(
}
}

private fun initLocateBtn(map: MapboxMap) {
if (showLocationBtn) {
addView(locateBtn)
adjustCompassBtn(map)
private fun initLocateButton(map: MapboxMap) {
if (showLocationButton) {
addView(locateButton)
adjustCompassButton(map)
}
}

private fun createLocateBtn(): ImageView =
private fun createLocateButton(): ImageView =
ImageView(context).apply {
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)
updateLayoutParams<MarginLayoutParams> {
val marginHorizontal = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_btn_margin_horizontal)
val marginVertical = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_btn_margin_vertical)
val marginHorizontal = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_button_margin_horizontal)
val marginVertical = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_locate_button_margin_vertical)
setMargins(marginHorizontal, marginVertical, marginHorizontal, marginVertical)
}
updateLayoutParams<LayoutParams> {
gravity = Gravity.TOP or Gravity.END
}
}

private fun adjustCompassBtn(map: MapboxMap) {
locateBtn.post {
val marginTop = locateBtn.height + locateBtn.marginTop + locateBtn.marginBottom
val marginRight = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_compass_btn_margin_horizontal)
private fun adjustCompassButton(map: MapboxMap) {
locateButton.post {
val marginTop = locateButton.height + locateButton.marginTop + locateButton.marginBottom
val marginRight = context.resources.getDimensionPixelOffset(R.dimen.location_sharing_compass_button_margin_horizontal)
map.uiSettings.setCompassMargins(0, marginTop, marginRight, 0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@
<!-- TODO delete -->
<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_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="a11y_location_share_option_user_current_icon">Share my current location</string>
<string name="location_share_option_user_live">Share live location</string>
Expand Down

0 comments on commit b72c87d

Please sign in to comment.