Commit 34f7e505 authored by Schoumi's avatar Schoumi

prepare integration of anymaps in the project to maintain it and keep it

working with new version of osmdroid
parent 96d0d81a
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
ext {
name = 'AnyMaps - Base Library'
artifactId = 'anymaps.base'
description = 'Base library for AnyMaps libraries. Contains common interface'
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
testImplementation 'junit:junit:4.12'
}
\ No newline at end of file
<!--
~ Copyright (c) 2015 Daimler AG / Moovel GmbH
~
~ All rights reserved
-->
<manifest package="com.car2go.maps"/>
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.view.View;
import com.car2go.maps.model.CameraPosition;
import com.car2go.maps.model.Circle;
import com.car2go.maps.model.CircleOptions;
import com.car2go.maps.model.LatLng;
import com.car2go.maps.model.Marker;
import com.car2go.maps.model.MarkerOptions;
import com.car2go.maps.model.Polygon;
import com.car2go.maps.model.PolygonOptions;
import com.car2go.maps.model.Polyline;
import com.car2go.maps.model.PolylineOptions;
/**
* Provider-independent map controller. Originally was designed to mimic Google Map API and being
* adapted to other providers. For detailed documentation on each method please refer Google Maps
* documentation.
*/
public interface AnyMap {
void moveCamera(CameraUpdate cameraUpdate);
void animateCamera(CameraUpdate cameraUpdate);
void animateCamera(CameraUpdate cameraUpdate, CancelableCallback callback);
void animateCamera(CameraUpdate cameraUpdate, int duration, CancelableCallback callback);
CameraPosition getCameraPosition();
Projection getProjection();
Marker addMarker(MarkerOptions options);
Circle addCircle(CircleOptions options);
Polygon addPolygon(PolygonOptions options);
Polyline addPolyline(PolylineOptions options);
UiSettings getUiSettings();
void setOnMapClickListener(OnMapClickListener listener);
void setOnMapLongClickListener(OnMapLongClickListener listener);
void setOnCameraChangeListener(OnCameraChangeListener listener);
void setOnMarkerClickListener(OnMarkerClickListener listener);
void setInfoWindowAdapter(InfoWindowAdapter adapter);
void setTrafficEnabled(boolean enabled);
void setMyLocationEnabled(boolean enabled);
void setMapType(Type type);
void setPadding(int left, int top, int right, int bottom);
void onUserLocationChanged(LatLng location, float accuracy);
enum Type {
NORMAL,
SATELLITE
}
/**
* Features of {@link AnyMap} which might be supported or not supported
* by each particular implementation.
*/
enum Feature {
/**
* Displaying layer with traffic jams on the map
*/
TRAFFIC_LAYER,
/**
* Supporting several {@link com.car2go.maps.AnyMap.Type}. If this capability is not present,
* only one of types is implemented (which one - is not specified).
*/
MAP_TYPES,
/**
* Supports being invisible at first and being revealed (or simply made visible) later on.
*/
REVEALABLE
}
interface OnMapClickListener {
OnMapClickListener NULL = new OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
// Do nothing
}
};
void onMapClick(LatLng latLng);
}
interface OnMapLongClickListener {
OnMapLongClickListener NULL = new OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng latLng) {
// Do nothing
}
};
void onMapLongClick(LatLng latLng);
}
interface OnCameraChangeListener {
void onCameraChange(CameraPosition cameraPosition);
}
interface OnMarkerClickListener {
OnMarkerClickListener NULL = new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
// Do nothing
return false;
}
};
boolean onMarkerClick(Marker marker);
}
interface CancelableCallback {
void onFinish();
void onCancel();
}
interface InfoWindowAdapter {
View getInfoWindow(Marker marker);
View getInfoContents(Marker marker);
}
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.graphics.Bitmap;
import android.support.annotation.DrawableRes;
import com.car2go.maps.model.BitmapDescriptor;
/**
* Factory for creating BitmapDescriptors.
*/
public interface BitmapDescriptorFactory {
/**
* @return new {@link BitmapDescriptor} from given {@link Bitmap}
*/
BitmapDescriptor fromBitmap(Bitmap bitmap);
/**
* @return new {@link BitmapDescriptor} from given resource
*/
BitmapDescriptor fromResource(@DrawableRes int resourceId);
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
/**
* Mimics Google CameraUpdate
*/
public interface CameraUpdate {
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import com.car2go.maps.model.LatLng;
import com.car2go.maps.model.LatLngBounds;
/**
* Creates {@link CameraUpdate} objects which can be used to update map camera
*/
public interface CameraUpdateFactory {
/**
* @return {@link CameraUpdate} which moves camera to given position with given zoom level.
*/
CameraUpdate newLatLngZoom(LatLng latLng, float zoomLevel);
/**
* @return {@link CameraUpdate} which moves camera so it displays given bounds with given padding.
*/
CameraUpdate newLatLngBounds(LatLngBounds bounds, int padding);
/**
* @return {@link CameraUpdate} which zooms camera to given zoom level.
*/
CameraUpdate zoomTo(float zoomLevel);
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* View container for an {@link AnyMap}.
*/
public abstract class MapContainerView extends FrameLayout {
protected MapContainerView(Context context) {
super(context);
}
protected MapContainerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Gets the wrapped {@link AnyMap} asynchronously.
*
* @param callback the callback to use when the map has been got
*/
public abstract void getMapAsync(OnMapReadyCallback callback);
/**
* Propagate the onCreate lifecycle call to the AnyMap.
*
* @param savedInstanceState the savedInstanceState
*/
public abstract void onCreate(Bundle savedInstanceState);
/**
* Propagate the onResume lifecycle call to the AnyMap.
*/
public abstract void onResume();
/**
* Propagate the onPause lifecycle call to the AnyMap.
*/
public abstract void onPause();
/**
* Propagate the onDestroy lifecycle call to the AnyMap.
*/
public abstract void onDestroy();
/**
* Propagate the onLowMemory lifecycle call to the AnyMap.
*/
public abstract void onLowMemory();
/**
* Propagate the onSaveInstanceState lifecycle call to the AnyMap.
*
* @param outState the outState
*/
public abstract void onSaveInstanceState(Bundle outState);
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.content.Context;
import java.util.Set;
/**
* A util class for initializing the map and retrieving its capabilities.
*/
public interface MapsConfiguration {
/**
* Initializes the maps.
*
* @param context the context
*/
void initialize(Context context);
/**
* Gets the supported features of the {@link AnyMap} implementation. If some features are not supported
* and you will try to call them - nothing will happen.
*
* @return capabilities of the {@link AnyMap} implementation.
*/
Set<AnyMap.Feature> getSupportedFeatures();
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
/**
* Mimics Google OnMapReadyCallback
*/
public interface OnMapReadyCallback {
void onMapReady(AnyMap anyMap);
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import com.car2go.maps.model.VisibleRegion;
/**
* Mimics Google Projection
*/
public interface Projection {
VisibleRegion getVisibleRegion();
}
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
/**
* Mimics Google UiSettings
*/
public interface UiSettings {
void setAllGesturesEnabled(boolean enabled);
void setMyLocationButtonEnabled(boolean enabled);
void setMapToolbarEnabled(boolean enabled);
}
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Mimics Google BitmapDescriptor
*/
public interface BitmapDescriptor {
}
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Contains information about camera position on the map.
* Immutable.
*/
public class CameraPosition implements Parcelable {
/**
* Center of the camera viewport
*/
public final LatLng target;
/**
* Zoom level of the camera
*/
public final float zoom;
public CameraPosition(LatLng target, float zoom) {
this.target = target;
this.zoom = zoom;
}
protected CameraPosition(Parcel in) {
this.target = in.readParcelable(LatLng.class.getClassLoader());
this.zoom = in.readFloat();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CameraPosition)) {
return false;
}
CameraPosition that = (CameraPosition) o;
return Float.compare(that.zoom, zoom) == 0 && target.equals(that.target);
}
@Override
public int hashCode() {
int result = target.hashCode();
result = 31 * result + (zoom != +0.0f ? Float.floatToIntBits(zoom) : 0);
return result;
}
@Override
public String toString() {
return "CameraPosition{" +
"target=" + target +
", zoom=" + zoom +
'}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.target, flags);
dest.writeFloat(this.zoom);
}
public static final Creator<CameraPosition> CREATOR = new Creator<CameraPosition>() {
public CameraPosition createFromParcel(Parcel source) {
return new CameraPosition(source);
}
public CameraPosition[] newArray(int size) {
return new CameraPosition[size];
}
};
}
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Draws circle on the map
*/
public interface Circle extends DrawableComponent {
}
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.support.annotation.ColorInt;
/**
* Accumulates parameters which are required to create {@link Circle} component.
* Mutable.
*/
public class CircleOptions {
private LatLng center;
private double radius;
private int fillColor;
private int strokeColor;
private float strokeWidth;
/**
* @param point center of the circle
* @return same {@link CircleOptions}
*/
public CircleOptions center(LatLng point) {
center = point;
return this;
}
/**
* @param radius radius of the circle in meters
* @return same {@link CircleOptions}
*/
public CircleOptions radius(double radius) {
this.radius = radius;
return this;
}
/**
* @param color color used to fill the circle
* @return same {@link CircleOptions}
*/
public CircleOptions fillColor(@ColorInt int color) {
fillColor = color;
return this;
}
/**
* @param color color of the circle outline (stroke)
* @return same {@link CircleOptions}
*/
public CircleOptions strokeColor(@ColorInt int color) {
strokeColor = color;
return this;
}
/**
* @param width width of the stroke in pixels
* @return same {@link CircleOptions}
*/
public CircleOptions strokeWidth(float width) {
strokeWidth = width;
return this;
}
/**
* @see #center(LatLng)
*/
public LatLng getCenter() {
return center;
}
/**
* @see #radius(double)
*/
public double getRadius() {
return radius;
}
/**
* @see #fillColor(int)
*/
public int getFillColor() {
return fillColor;
}
/**
* @see #strokeColor(int)
*/
public int getStrokeColor() {
return strokeColor;
}
/**
* @see #strokeWidth(float)
*/
public float getStrokeWidth() {
return strokeWidth;
}
}
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Entity which can be drawn on map
*/
public interface DrawableComponent {
/**
* Changes visibility of the component
*
* @param visible {@code true} to make component visible.
* {@code false} to make component invisible.
*/
void setVisible(boolean visible);
/**
* Removes component from the map. If it's already removed, does nothing.
*/
void remove();
}