diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-08-24 19:53:56 +0200 |
---|---|---|
committer | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-09-04 11:43:52 +0200 |
commit | e01f7fc92ce4110b9e565644ad3b52149d3b46f8 (patch) | |
tree | ecb9b8a0451e8bc39f0a4c619782b578f73be068 | |
parent | 1099bb4920f670017327efaf9db24097d60e34e8 (diff) | |
download | qtlocation-mapboxgl-upstream/lp-minor-reference-app-fixes.tar.gz |
[android] minor reference app fixesupstream/lp-minor-reference-app-fixes
9 files changed, 79 insertions, 33 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index e23b1d64f3..d9e2001479 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -266,6 +266,9 @@ <meta-data android:name="@string/category" android:value="@string/category_basic" /> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity" /> </activity> <activity android:name=".activity.offline.OfflineActivity" @@ -706,6 +709,9 @@ <meta-data android:name="@string/category" android:value="@string/category_maplayout" /> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity" /> </activity> <!-- TextureView --> @@ -716,6 +722,9 @@ <meta-data android:name="@string/category" android:value="@string/category_textureview" /> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity" /> </activity> <activity android:name=".activity.textureview.TextureViewResizeActivity" @@ -724,6 +733,9 @@ <meta-data android:name="@string/category" android:value="@string/category_textureview" /> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity" /> </activity> <activity android:name=".activity.textureview.TextureViewTransparentBackgroundActivity" @@ -743,6 +755,9 @@ <meta-data android:name="@string/category" android:value="@string/category_textureview" /> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity" /> </activity> <activity android:name=".activity.maplayout.LocalGlyphActivity" diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java index fbf439448f..28a89f4b42 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java @@ -68,7 +68,7 @@ public class PolylineActivity extends AppCompatActivity { mapboxMap.setOnPolylineClickListener(polyline -> Toast.makeText( PolylineActivity.this, - "You clicked on polygon with id = " + polyline.getId(), + "You clicked on polyline with id = " + polyline.getId(), Toast.LENGTH_SHORT ).show()); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java index 29c0ae0fca..67fe05eaa6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java @@ -43,13 +43,15 @@ public class PressForMarkerActivity extends AppCompatActivity { mapboxMap = map; resetMap(); - mapboxMap.setOnMapLongClickListener(point -> addMarker(point)); + mapboxMap.addOnMapLongClickListener(point -> addMarker(point)); - mapboxMap.setOnMapClickListener(point -> addMarker(point)); + mapboxMap.addOnMapClickListener(point -> addMarker(point)); if (savedInstanceState != null) { markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST); - mapboxMap.addMarkers(markerList); + if (markerList != null) { + mapboxMap.addMarkers(markerList); + } } }); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java index e069a7fd08..4ee8354981 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java @@ -61,12 +61,18 @@ public class LatLngBoundsActivity extends AppCompatActivity implements View.OnCl } private void initMap() { + disableGestures(); addMarkers(); initFab(); initBottomSheet(); moveToBounds(bottomSheet.getMeasuredHeight(), BOUNDS_PADDING_DIVIDER_SMALL, ANIMATION_DURATION_SHORT); } + private void disableGestures() { + mapboxMap.getUiSettings().setTiltGesturesEnabled(false); + mapboxMap.getUiSettings().setRotateGesturesEnabled(false); + } + private void addMarkers() { for (LatLng location : LOCATIONS) { mapboxMap.addMarker(new MarkerOptions().position(location)); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java index 79069a26f7..3a52a22f6e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java @@ -1,6 +1,8 @@ package com.mapbox.mapboxsdk.testapp.activity.feature; import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; @@ -9,7 +11,7 @@ import com.mapbox.geojson.Feature; import com.mapbox.geojson.FeatureCollection; import com.mapbox.geojson.Point; import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.CircleLayer; import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; import com.mapbox.mapboxsdk.testapp.R; @@ -27,7 +29,6 @@ import static com.mapbox.mapboxsdk.style.expressions.Expression.neq; public class QuerySourceFeaturesActivity extends AppCompatActivity { public MapView mapView; - private MapboxMap mapboxMap; @Override protected void onCreate(Bundle savedInstanceState) { @@ -38,31 +39,45 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity { mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapboxMap -> { - QuerySourceFeaturesActivity.this.mapboxMap = mapboxMap; - JsonObject properties = new JsonObject(); properties.addProperty("key1", "value1"); final GeoJsonSource source = new GeoJsonSource("test-source", FeatureCollection.fromFeatures(new Feature[] { - Feature.fromGeometry(Point.fromLngLat(0, 0), properties) + Feature.fromGeometry(Point.fromLngLat(17.1, 51), properties), + Feature.fromGeometry(Point.fromLngLat(17.2, 51), properties), + Feature.fromGeometry(Point.fromLngLat(17.3, 51), properties), + Feature.fromGeometry(Point.fromLngLat(17.4, 51), properties), })); mapboxMap.addSource(source); - mapboxMap.addLayer(new CircleLayer("test-layer", source.getId()).withFilter(neq(get("key1"), literal("value1")))); + Expression visible = eq(get("key1"), literal("value1")); + Expression invisible = neq(get("key1"), literal("value1")); + + CircleLayer layer = new CircleLayer("test-layer", source.getId()) + .withFilter(visible); + mapboxMap.addLayer(layer); // Add a click listener - mapboxMap.setOnMapClickListener(point -> { + mapboxMap.addOnMapClickListener(point -> { // Query List<Feature> features = source.querySourceFeatures(eq(get("key1"), literal("value1"))); Toast.makeText(QuerySourceFeaturesActivity.this, String.format("Found %s features", features.size()), Toast.LENGTH_SHORT).show(); }); - }); - } - - public MapboxMap getMapboxMap() { - return mapboxMap; + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setColorFilter(ContextCompat.getColor(this, R.color.primary)); + fab.setOnClickListener(view -> { + Expression visibility = layer.getFilter(); + if (visibility != null && visibility.equals(visible)) { + layer.setFilter(invisible); + fab.setImageResource(R.drawable.ic_layers_clear); + } else { + layer.setFilter(visible); + fab.setImageResource(R.drawable.ic_layers); + } + }); + }); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java index 01c0477610..13d0ad4240 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java @@ -97,7 +97,7 @@ public class DoubleMapActivity extends AppCompatActivity { uiSettings.setAttributionEnabled(false); uiSettings.setLogoEnabled(false); - mapboxMap.setOnMapClickListener(point -> { + mapboxMap.addOnMapClickListener(point -> { // test if we can open 2 activities after each other Toast.makeText(mapViewMini.getContext(), "Creating a new Activity instance",Toast.LENGTH_SHORT).show(); startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class)); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterReuseActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterReuseActivity.java index 302fa1ff77..1191b47c11 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterReuseActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterReuseActivity.java @@ -64,14 +64,12 @@ public class MapSnapshotterReuseActivity extends AppCompatActivity implements Ma } private LatLngBounds getRandomBounds() { - return new LatLngBounds.Builder() - .include(new LatLng( - randomInRange(-5, 5), - randomInRange(-5, 5))) - .include(new LatLng( - randomInRange(5, 10), - randomInRange(5, 10)) - ).build(); + return LatLngBounds.from( + randomInRange(5, 10), + randomInRange(-5, 5), + randomInRange(-5, 5), + randomInRange(5, 10) + ); } private CameraPosition getRandomCameraPosition() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java index 3a11a7e020..61b4eaad1b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java @@ -94,7 +94,7 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR } private void addSymbolClickListener() { - mapboxMap.setOnMapClickListener(point -> { + mapboxMap.addOnMapClickListener(point -> { PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point); List<Feature> features = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID); if (!features.isEmpty()) { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_source_features.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_source_features.xml index 1c439a5ecc..27c77cf004 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_source_features.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_source_features.xml @@ -1,16 +1,26 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout - xmlns:android="http://schemas.android.com/apk/res/android" +<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/coordinator_layout" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:orientation="vertical"> <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - app:mapbox_cameraTargetLat="0" - app:mapbox_cameraTargetLng="0" - app:mapbox_cameraZoom="16"/> + app:mapbox_cameraTargetLat="51" + app:mapbox_cameraTargetLng="17.25" + app:mapbox_cameraZoom="8" /> -</RelativeLayout> + <android.support.design.widget.FloatingActionButton + android:id="@+id/fab" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end|bottom" + android:layout_margin="@dimen/fab_margin" + android:src="@drawable/ic_layers" + app:backgroundTint="@android:color/white" /> + +</android.support.design.widget.CoordinatorLayout> |