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

Commit

Permalink
[android] - add zMediaOverlay configuration, add bottom sheet test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jul 26, 2017
1 parent 55faa23 commit 6921e42
Show file tree
Hide file tree
Showing 11 changed files with 418 additions and 7 deletions.
2 changes: 1 addition & 1 deletion platform/android/MapboxGLAndroidSDK/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ POM_PACKAGING=aar

# Only build native dependencies for the current ABI
# See https://code.google.com/p/android/issues/detail?id=221098#c20
android.buildOnlyTargetAbi=true
android.buildOnlyTargetAbi=true
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onGlobalLayout() {
} else {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
initialiseDrawingSurface(mapboxMapOptions.getTextureMode());
initialiseDrawingSurface(mapboxMapOptions);
}
});
}
Expand Down Expand Up @@ -229,13 +229,14 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
}

private void initialiseDrawingSurface(boolean textureMode) {
if (textureMode) {
private void initialiseDrawingSurface(MapboxMapOptions mapboxMapOptions) {
if (mapboxMapOptions.getTextureMode()) {
TextureView textureView = new TextureView(getContext());
textureView.setSurfaceTextureListener(new SurfaceTextureListener());
addView(textureView, 0);
} else {
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop());
surfaceView.getHolder().addCallback(new SurfaceCallback());
surfaceView.setVisibility(View.VISIBLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class MapboxMapOptions implements Parcelable {
private int myLocationAccuracyAlpha;
private float myLocationAccuracyThreshold;
private boolean prefetchesTiles = true;
private boolean zMediaOverlay = false;

private String apiBaseUrl;

Expand Down Expand Up @@ -156,6 +157,7 @@ private MapboxMapOptions(Parcel in) {
apiBaseUrl = in.readString();
textureMode = in.readByte() != 0;
prefetchesTiles = in.readByte() != 0;
zMediaOverlay = in.readByte() != 0;
}

static Bitmap getBitmapFromDrawable(Drawable drawable) {
Expand Down Expand Up @@ -301,6 +303,8 @@ public static MapboxMapOptions createFromAttributes(@NonNull Context context, @N
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_renderTextureMode, false));
mapboxMapOptions.setPrefetchesTiles(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableTilePrefetch, true));
mapboxMapOptions.renderSurfaceOnTop(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableZMediaOverlay, false));
} finally {
typedArray.recycle();
}
Expand Down Expand Up @@ -718,7 +722,6 @@ public MapboxMapOptions textureMode(boolean textureMode) {
/**
* Enable tile pre-fetching. Loads tiles at a lower zoom-level to pre-render
* a low resolution preview while more detailed tiles are loaded.
*
* Enabled by default
*
* @param enable true to enable
Expand All @@ -739,6 +742,25 @@ public boolean getPrefetchesTiles() {
return prefetchesTiles;
}


/**
* Set the flag to render the map surface on top of another surface.
*
* @param renderOnTop true if this map is shown on top of another one, false if bottom.
*/
public void renderSurfaceOnTop(boolean renderOnTop) {
this.zMediaOverlay = renderOnTop;
}

/**
* Get the flag to render the map surface on top of another surface.
*
* @return true if this map is
*/
public boolean getRenderSurfaceOnTop() {
return zMediaOverlay;
}

/**
* Get the current configured API endpoint base URL.
*
Expand Down Expand Up @@ -1123,6 +1145,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(apiBaseUrl);
dest.writeByte((byte) (textureMode ? 1 : 0));
dest.writeByte((byte) (prefetchesTiles ? 1 : 0));
dest.writeByte((byte) (zMediaOverlay ? 1 : 0));
}

@Override
Expand Down Expand Up @@ -1249,6 +1272,10 @@ public boolean equals(Object o) {
if (prefetchesTiles != options.prefetchesTiles) {
return false;
}
if (zMediaOverlay != options.zMediaOverlay) {
return false;
}

return false;
}

Expand Down Expand Up @@ -1296,6 +1323,7 @@ public int hashCode() {
result = 31 * result + (textureMode ? 1 : 0);
result = 31 * result + (style != null ? style.hashCode() : 0);
result = 31 * result + (prefetchesTiles ? 1 : 0);
result = 31 * result + (zMediaOverlay ? 1 : 0);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
<!-- Deprecated to use TextureView-->
<public name="mapbox_renderTextureMode" type="attr" />

<public name="mapbox_enableTilePrefetch" type="attr" />
<public name="mapbox_enableZMediaOverlay" type="attr" />

<!-- Exposed content descriptions -->
<public name="mapbox_logoContentDescription" type="string" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<attr name="mapbox_renderTextureMode" format="boolean"/>

<attr name="mapbox_enableTilePrefetch" format="boolean"/>
<attr name="mapbox_enableZMediaOverlay" format="boolean"/>

</declare-styleable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,13 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity"/>
</activity>

<activity android:name=".activity.maplayout.BottomSheetActivity"
android:description="@string/description_bottom_sheet"
android:label="@string/activity_bottom_sheet">
<meta-data
android:name="@string/category"
android:value="@string/category_basic"/>
</activity>

<!-- For Instrumentation tests -->
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {
.zoom(11)
.build());

mapFragment = SupportMapFragment.newInstance();
mapFragment = SupportMapFragment.newInstance(options);

transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
transaction.commit();
Expand Down
Loading

0 comments on commit 6921e42

Please sign in to comment.