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

Removed ZoomButtonsController support #13198

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public class MapboxConstants {
public static final String STATE_SCROLL_ENABLED = "mapbox_scrollEnabled";
public static final String STATE_ROTATE_ENABLED = "mapbox_rotateEnabled";
public static final String STATE_TILT_ENABLED = "mapbox_tiltEnabled";
public static final String STATE_ZOOM_CONTROLS_ENABLED = "mapbox_zoomControlsEnabled";
public static final String STATE_DOUBLE_TAP_ENABLED = "mapbox_doubleTapEnabled";
public static final String STATE_DEBUG_ACTIVE = "mapbox_debugActive";
public static final String STATE_STYLE_URL = "mapbox_styleUrl";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;

import com.mapbox.android.gestures.AndroidGesturesManager;
import com.mapbox.mapboxsdk.MapStrictMode;
import com.mapbox.mapboxsdk.Mapbox;
Expand All @@ -35,6 +35,7 @@
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer;
Expand All @@ -43,12 +44,9 @@
import com.mapbox.mapboxsdk.offline.OfflineGeometryRegionDefinition;
import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition;
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.utils.BitmapUtils;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
Expand All @@ -57,6 +55,9 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_MAP_NORTH_ANIMATION;
import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_WAIT_IDLE;

Expand Down Expand Up @@ -94,7 +95,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {

private MapGestureDetector mapGestureDetector;
private MapKeyListener mapKeyListener;
private MapZoomButtonController mapZoomButtonController;
private Bundle savedInstanceState;

@UiThread
Expand Down Expand Up @@ -188,12 +188,6 @@ private void initialiseMap() {
annotationManager, cameraChangeDispatcher);
mapKeyListener = new MapKeyListener(transform, uiSettings, mapGestureDetector);

// overlain zoom buttons
mapZoomButtonController = new MapZoomButtonController(new ZoomButtonsController(this));
MapZoomControllerListener zoomListener = new MapZoomControllerListener(
mapGestureDetector, cameraChangeDispatcher, getWidth(), getHeight());
mapZoomButtonController.bind(uiSettings, zoomListener);

// compass
compassView.injectCompassAnimationListener(createCompassAnimationListener(cameraChangeDispatcher));
compassView.setOnClickListener(createCompassClickListener(cameraChangeDispatcher));
Expand Down Expand Up @@ -461,13 +455,10 @@ public boolean isDestroyed() {

@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isMapInitialized() || !isZoomButtonControllerInitialized() || !isGestureDetectorInitialized()) {
if (!isMapInitialized() || !isGestureDetectorInitialized()) {
return super.onTouchEvent(event);
}

if (event.getAction() == MotionEvent.ACTION_DOWN) {
mapZoomButtonController.setVisible(true);
}
return mapGestureDetector.onTouchEvent(event) || super.onTouchEvent(event);
}

Expand Down Expand Up @@ -499,28 +490,6 @@ public boolean onGenericMotionEvent(MotionEvent event) {
return mapGestureDetector.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
}

@Override
public boolean onHoverEvent(MotionEvent event) {
if (!isZoomButtonControllerInitialized()) {
return super.onHoverEvent(event);
}

switch (event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_MOVE:
mapZoomButtonController.setVisible(true);
return true;

case MotionEvent.ACTION_HOVER_EXIT:
mapZoomButtonController.setVisible(false);
return true;

default:
// We are not interested in this event
return false;
}
}

/**
* You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory().
*/
Expand Down Expand Up @@ -648,32 +617,6 @@ private float getPixelRatio() {
return pixelRatio;
}

//
// View events
//

// Called when view is no longer connected
@Override
@CallSuper
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (isZoomButtonControllerInitialized()) {
mapZoomButtonController.setVisible(false);
}
}

// Called when view is hidden and shown
@Override
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
if (isInEditMode()) {
return;
}

if (isZoomButtonControllerInitialized()) {
mapZoomButtonController.setVisible(visibility == View.VISIBLE);
}
}

//
// ViewCallback
//
Expand Down Expand Up @@ -1109,10 +1052,6 @@ private boolean isMapInitialized() {
return nativeMapView != null;
}

private boolean isZoomButtonControllerInitialized() {
return mapZoomButtonController != null;
}

private boolean isGestureDetectorInitialized() {
return mapGestureDetector != null;
}
Expand Down Expand Up @@ -1558,46 +1497,6 @@ public void cancelAllVelocityAnimations() {
}
}

private static class MapZoomControllerListener implements ZoomButtonsController.OnZoomListener {

private final MapGestureDetector mapGestureDetector;
private final CameraChangeDispatcher cameraChangeDispatcher;
private final float mapWidth;
private final float mapHeight;

MapZoomControllerListener(MapGestureDetector detector, CameraChangeDispatcher dispatcher,
float mapWidth, float mapHeight) {
this.mapGestureDetector = detector;
this.cameraChangeDispatcher = dispatcher;
this.mapWidth = mapWidth;
this.mapHeight = mapHeight;
}

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

// Called when user pushes a zoom button on the ZoomButtonController
@Override
public void onZoom(boolean zoomIn) {
cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_ANIMATION);
onZoom(zoomIn, mapGestureDetector.getFocalPoint());
}

private void onZoom(boolean zoomIn, @Nullable PointF focalPoint) {
if (focalPoint == null) {
focalPoint = new PointF(mapWidth / 2, mapHeight / 2);
}
if (zoomIn) {
mapGestureDetector.zoomInAnimated(focalPoint, true);
} else {
mapGestureDetector.zoomOutAnimated(focalPoint, true);
}
}
}

private static class MapCallback implements OnMapChangedListener {

private MapboxMap mapboxMap;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.view.Gravity;

import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
Expand Down Expand Up @@ -62,7 +63,6 @@ public class MapboxMapOptions implements Parcelable {
private boolean scrollGesturesEnabled = true;
private boolean tiltGesturesEnabled = true;
private boolean zoomGesturesEnabled = true;
private boolean zoomControlsEnabled = false;
private boolean doubleTapGesturesEnabled = true;

private boolean prefetchesTiles = true;
Expand Down Expand Up @@ -119,7 +119,6 @@ private MapboxMapOptions(Parcel in) {
rotateGesturesEnabled = in.readByte() != 0;
scrollGesturesEnabled = in.readByte() != 0;
tiltGesturesEnabled = in.readByte() != 0;
zoomControlsEnabled = in.readByte() != 0;
zoomGesturesEnabled = in.readByte() != 0;
doubleTapGesturesEnabled = in.readByte() != 0;

Expand Down Expand Up @@ -161,8 +160,6 @@ public static MapboxMapOptions createFromAttributes(@NonNull Context context, @N
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiRotateGestures, true));
mapboxMapOptions.tiltGesturesEnabled(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiTiltGestures, true));
mapboxMapOptions.zoomControlsEnabled(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiZoomControls, false));
mapboxMapOptions.doubleTapGesturesEnabled(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiDoubleTapGestures, true));

Expand Down Expand Up @@ -492,17 +489,6 @@ public MapboxMapOptions tiltGesturesEnabled(boolean enabled) {
return this;
}

/**
* Specifies if the zoom controls are enabled for a map view.
*
* @param enabled True and gesture will be enabled
* @return This
*/
public MapboxMapOptions zoomControlsEnabled(boolean enabled) {
zoomControlsEnabled = enabled;
return this;
}

/**
* Specifies if the zoom gesture is enabled for a map view.
*
Expand Down Expand Up @@ -803,15 +789,6 @@ public boolean getTiltGesturesEnabled() {
return tiltGesturesEnabled;
}

/**
* Get the current configured zoom controls state for a map view.
*
* @return True indicates gesture is enabled
*/
public boolean getZoomControlsEnabled() {
return zoomControlsEnabled;
}

/**
* Get the current configured zoom gesture state for a map view.
*
Expand Down Expand Up @@ -960,7 +937,6 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte((byte) (rotateGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (scrollGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (tiltGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (zoomControlsEnabled ? 1 : 0));
dest.writeByte((byte) (zoomGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (doubleTapGesturesEnabled ? 1 : 0));

Expand Down Expand Up @@ -1038,9 +1014,6 @@ public boolean equals(Object o) {
if (zoomGesturesEnabled != options.zoomGesturesEnabled) {
return false;
}
if (zoomControlsEnabled != options.zoomControlsEnabled) {
return false;
}
if (doubleTapGesturesEnabled != options.doubleTapGesturesEnabled) {
return false;
}
Expand Down Expand Up @@ -1113,7 +1086,6 @@ public int hashCode() {
result = 31 * result + (scrollGesturesEnabled ? 1 : 0);
result = 31 * result + (tiltGesturesEnabled ? 1 : 0);
result = 31 * result + (zoomGesturesEnabled ? 1 : 0);
result = 31 * result + (zoomControlsEnabled ? 1 : 0);
result = 31 * result + (doubleTapGesturesEnabled ? 1 : 0);
result = 31 * result + (apiBaseUrl != null ? apiBaseUrl.hashCode() : 0);
result = 31 * result + (textureMode ? 1 : 0);
Expand Down
Loading