aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps/google
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/maps/google')
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleMapView.java30
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleOverlay.java18
2 files changed, 18 insertions, 30 deletions
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapView.java b/main/src/cgeo/geocaching/maps/google/GoogleMapView.java
index 3cf258e..d02e3c2 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleMapView.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleMapView.java
@@ -2,11 +2,9 @@ package cgeo.geocaching.maps.google;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.geopoint.Viewport;
import cgeo.geocaching.maps.CachesOverlay;
-import cgeo.geocaching.maps.PositionOverlay;
-import cgeo.geocaching.maps.ScaleOverlay;
+import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
import cgeo.geocaching.maps.interfaces.MapControllerImpl;
@@ -14,13 +12,15 @@ import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
import cgeo.geocaching.maps.interfaces.OnMapDragListener;
import cgeo.geocaching.maps.interfaces.OverlayImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl.OverlayType;
+import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.utils.Log;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
+import org.apache.commons.lang3.reflect.MethodUtils;
+
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
@@ -31,6 +31,7 @@ import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.FrameLayout;
+import android.widget.ZoomButtonsController;
public class GoogleMapView extends MapView implements MapViewImpl {
private GestureDetector gestureDetector;
@@ -71,9 +72,14 @@ public class GoogleMapView extends MapView implements MapViewImpl {
// Push zoom controls to the right
FrameLayout.LayoutParams zoomParams = new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
zoomParams.gravity = Gravity.RIGHT;
- getZoomButtonsController().getZoomControls().setLayoutParams(zoomParams);
+ // The call to retrieve the zoom buttons controller is undocumented and works so far on all devices
+ // supported by Google Play, but fails at least on one Jolla.
+ final ZoomButtonsController controller = (ZoomButtonsController) MethodUtils.invokeMethod(this, "getZoomButtonsController");
+ controller.getZoomControls().setLayoutParams(zoomParams);
super.displayZoomControls(takeFocus);
+ } catch (NoSuchMethodException e) {
+ Log.w("GoogleMapView.displayZoomControls: unable to explicitly place the zoom buttons");
} catch (Exception e) {
Log.e("GoogleMapView.displayZoomControls", e);
}
@@ -119,19 +125,11 @@ public class GoogleMapView extends MapView implements MapViewImpl {
}
@Override
- public PositionOverlay createAddPositionOverlay(Activity activity) {
-
- GoogleOverlay ovl = new GoogleOverlay(activity, OverlayType.PositionOverlay);
- getOverlays().add(ovl);
- return (PositionOverlay) ovl.getBase();
- }
-
- @Override
- public ScaleOverlay createAddScaleOverlay(Activity activity) {
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay(Activity activity) {
- GoogleOverlay ovl = new GoogleOverlay(activity, OverlayType.ScaleOverlay);
+ GoogleOverlay ovl = new GoogleOverlay(activity);
getOverlays().add(ovl);
- return (ScaleOverlay) ovl.getBase();
+ return (PositionAndScaleOverlay) ovl.getBase();
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
index bf4f606..e937773 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
@@ -1,7 +1,6 @@
package cgeo.geocaching.maps.google;
-import cgeo.geocaching.maps.PositionOverlay;
-import cgeo.geocaching.maps.ScaleOverlay;
+import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
import cgeo.geocaching.maps.interfaces.OverlayImpl;
@@ -17,20 +16,11 @@ import java.util.concurrent.locks.ReentrantLock;
public class GoogleOverlay extends Overlay implements OverlayImpl {
- private GeneralOverlay overlayBase = null;
+ private PositionAndScaleOverlay overlayBase = null;
private Lock lock = new ReentrantLock();
- public GoogleOverlay(Activity activityIn, OverlayType ovlType) {
- switch (ovlType) {
- case PositionOverlay:
- overlayBase = new PositionOverlay(activityIn, this);
- break;
- case ScaleOverlay:
- overlayBase = new ScaleOverlay(activityIn, this);
- break;
- default:
- throw new IllegalArgumentException();
- }
+ public GoogleOverlay(Activity activityIn) {
+ overlayBase = new PositionAndScaleOverlay(activityIn, this);
}
@Override