[android] removed ZoomButtonsController support

This commit is contained in:
Łukasz Paczos
2018-10-25 15:35:43 +02:00
committed by Tobrun
parent f236cc6163
commit 11f00c4393
11 changed files with 4 additions and 249 deletions

View File

@@ -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";

View File

@@ -21,7 +21,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;
import com.mapbox.android.gestures.AndroidGesturesManager;
import com.mapbox.mapboxsdk.MapStrictMode;
@@ -94,7 +93,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private MapGestureDetector mapGestureDetector;
private MapKeyListener mapKeyListener;
private MapZoomButtonController mapZoomButtonController;
private Bundle savedInstanceState;
@UiThread
@@ -184,12 +182,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
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));
@@ -449,13 +441,10 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isZoomButtonControllerInitialized() || !isGestureDetectorInitialized()) {
if (!isGestureDetectorInitialized()) {
return super.onTouchEvent(event);
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mapZoomButtonController.setVisible(true);
}
return mapGestureDetector.onTouchEvent(event) || super.onTouchEvent(event);
}
@@ -487,28 +476,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
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().
*/
@@ -621,32 +588,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
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
//
@@ -1078,10 +1019,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
}
}
private boolean isZoomButtonControllerInitialized() {
return mapZoomButtonController != null;
}
private boolean isGestureDetectorInitialized() {
return mapGestureDetector != null;
}
@@ -1508,46 +1445,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
}
}
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 class MapCallback implements OnWillStartLoadingMapListener, OnDidFinishLoadingStyleListener,
OnDidFinishRenderingFrameListener, OnDidFinishLoadingMapListener,
OnCameraIsChangingListener, OnCameraDidChangeListener {

View File

@@ -1,35 +0,0 @@
package com.mapbox.mapboxsdk.maps;
import android.support.annotation.NonNull;
import android.widget.ZoomButtonsController;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
/**
* The MapZoomButtonController is a ui interface element shown on top of the map.
* <p>
* Allows single touch only devices to zoom in and out.
* </p>
*/
final class MapZoomButtonController {
private UiSettings uiSettings;
private ZoomButtonsController zoomButtonsController;
MapZoomButtonController(@NonNull ZoomButtonsController zoomButtonsController) {
this.zoomButtonsController = zoomButtonsController;
this.zoomButtonsController.setZoomSpeed(MapboxConstants.ANIMATION_DURATION);
}
void bind(UiSettings uiSettings, ZoomButtonsController.OnZoomListener onZoomListener) {
this.uiSettings = uiSettings;
zoomButtonsController.setOnZoomListener(onZoomListener);
}
void setVisible(boolean visible) {
if (uiSettings != null && !uiSettings.isZoomControlsEnabled()) {
return;
}
zoomButtonsController.setVisible(visible);
}
}

View File

@@ -63,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;
@@ -120,7 +119,6 @@ public class MapboxMapOptions implements Parcelable {
rotateGesturesEnabled = in.readByte() != 0;
scrollGesturesEnabled = in.readByte() != 0;
tiltGesturesEnabled = in.readByte() != 0;
zoomControlsEnabled = in.readByte() != 0;
zoomGesturesEnabled = in.readByte() != 0;
doubleTapGesturesEnabled = in.readByte() != 0;
@@ -162,8 +160,6 @@ public class MapboxMapOptions implements Parcelable {
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));
@@ -493,20 +489,6 @@ public class MapboxMapOptions implements Parcelable {
return this;
}
/**
* Specifies if the zoom controls are enabled for a map view.
*
* @param enabled True and gesture will be enabled
* @return This
* @deprecated {@link android.widget.ZoomButtonsController}, this functionality and UI is better handled with
* custom views and layouts rather than a dedicated zoom-control widget.
*/
@Deprecated
public MapboxMapOptions zoomControlsEnabled(boolean enabled) {
zoomControlsEnabled = enabled;
return this;
}
/**
* Specifies if the zoom gesture is enabled for a map view.
*
@@ -807,15 +789,6 @@ public class MapboxMapOptions implements Parcelable {
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.
*
@@ -964,7 +937,6 @@ public class MapboxMapOptions implements Parcelable {
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));
@@ -1042,9 +1014,6 @@ public class MapboxMapOptions implements Parcelable {
if (zoomGesturesEnabled != options.zoomGesturesEnabled) {
return false;
}
if (zoomControlsEnabled != options.zoomControlsEnabled) {
return false;
}
if (doubleTapGesturesEnabled != options.doubleTapGesturesEnabled) {
return false;
}
@@ -1117,7 +1086,6 @@ public class MapboxMapOptions implements Parcelable {
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);

View File

@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.maps;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PointF;
@@ -52,8 +51,6 @@ public final class UiSettings {
private boolean scrollGesturesEnabled = true;
private boolean zoomControlsEnabled;
private boolean doubleTapGesturesEnabled = true;
private boolean scaleVelocityAnimationEnabled = true;
@@ -84,7 +81,6 @@ public final class UiSettings {
initialiseCompass(options, resources);
initialiseLogo(options, resources);
initialiseAttribution(context, options);
initialiseZoomControl(context);
}
void onSaveInstanceState(Bundle outState) {
@@ -92,7 +88,6 @@ public final class UiSettings {
saveCompass(outState);
saveLogo(outState);
saveAttribution(outState);
saveZoomControl(outState);
saveDeselectMarkersOnTap(outState);
saveFocalPoint(outState);
}
@@ -102,7 +97,6 @@ public final class UiSettings {
restoreCompass(savedInstanceState);
restoreLogo(savedInstanceState);
restoreAttribution(savedInstanceState);
restoreZoomControl(savedInstanceState);
restoreDeselectMarkersOnTap(savedInstanceState);
restoreFocalPoint(savedInstanceState);
}
@@ -112,7 +106,6 @@ public final class UiSettings {
setScrollGesturesEnabled(options.getScrollGesturesEnabled());
setRotateGesturesEnabled(options.getRotateGesturesEnabled());
setTiltGesturesEnabled(options.getTiltGesturesEnabled());
setZoomControlsEnabled(options.getZoomControlsEnabled());
setDoubleTapGesturesEnabled(options.getDoubleTapGesturesEnabled());
}
@@ -259,20 +252,6 @@ public final class UiSettings {
savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM));
}
private void initialiseZoomControl(Context context) {
if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
setZoomControlsEnabled(true);
}
}
private void saveZoomControl(Bundle outState) {
outState.putBoolean(MapboxConstants.STATE_ZOOM_CONTROLS_ENABLED, isZoomControlsEnabled());
}
private void restoreZoomControl(Bundle savedInstanceState) {
setZoomControlsEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ZOOM_CONTROLS_ENABLED));
}
/**
* <p>
* Enables or disables the compass. The compass is an icon on the map that indicates the
@@ -720,34 +699,6 @@ public final class UiSettings {
return zoomGesturesEnabled;
}
/**
* <p>
* Sets whether the zoom controls are enabled.
* If enabled, the zoom controls are a pair of buttons
* (one for zooming in, one for zooming out) that appear on the screen.
* When pressed, they cause the camera to zoom in (or out) by one zoom level.
* If disabled, the zoom controls are not shown.
* </p>
* By default the zoom controls are enabled if the device is only single touch capable;
*
* @param zoomControlsEnabled If true, the zoom controls are enabled.
* @deprecated {@link android.widget.ZoomButtonsController}, this functionality and UI is better handled with
* custom views and layouts rather than a dedicated zoom-control widget.
*/
@Deprecated
public void setZoomControlsEnabled(boolean zoomControlsEnabled) {
this.zoomControlsEnabled = zoomControlsEnabled;
}
/**
* Gets whether the zoom controls are enabled.
*
* @return If true, the zoom controls are enabled.
*/
public boolean isZoomControlsEnabled() {
return zoomControlsEnabled;
}
/**
* <p>
* Changes whether the user may zoom the map with a double tap.