Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] - rounded zoom when zooming with zoom button controller #7630

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to

## 5.0.0 - TBA

<<<<<<< HEAD
* MapZoomButtonController zooms to rounded zoom levels [#7630](https://github.com/mapbox/mapbox-gl-native/pull/7630)
* Consistent double tap zoom acceleration [#7514](https://github.com/mapbox/mapbox-gl-native/issues/7514)
* Cleanup inconsistencies float vs double [#4445](https://github.com/mapbox/mapbox-gl-native/issues/4445)
* Add `mapbox_` prefix to attributes [#6482](https://github.com/mapbox/mapbox-gl-native/issues/6482)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ViewConfiguration;
import android.widget.ZoomButtonsController;

import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
import com.almeros.android.multitouch.gesturedetectors.ShoveGestureDetector;
Expand Down Expand Up @@ -595,34 +594,6 @@ public boolean onShove(ShoveGestureDetector detector) {
}
}

// This class handles input events from the zoom control buttons
// Zoom controls allow single touch only devices to zoom in and out
private static class OnZoomListener implements ZoomButtonsController.OnZoomListener {

private UiSettings uiSettings;
private Transform transform;

OnZoomListener(UiSettings uiSettings, Transform transform) {
this.uiSettings = uiSettings;
this.transform = transform;
}

// Not used
@Override
public void onVisibilityChanged(boolean visible) {
// Ignore
}

// Called when user pushes a zoom button
@Override
public void onZoom(boolean zoomIn) {
if (!uiSettings.isZoomGesturesEnabled()) {
return;
}
transform.zoom(zoomIn);
}
}

void setOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) {
this.onMapClickListener = onMapClickListener;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ private long getDurationNano(long durationMs) {
}

void zoom(boolean zoomIn) {
zoom(zoomIn, -1.0f, -1.0f);
CameraPosition currentPosition = invalidateCameraPosition();
if (currentPosition != null) {
int newZoom = (int) Math.round(currentPosition.zoom + (zoomIn? 1 : -1));
mapView.setZoom(newZoom, MapboxConstants.ANIMATION_DURATION);
}
}

void zoom(boolean zoomIn, float x, float y) {
Expand Down