diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2016-08-16 18:13:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 18:13:56 +0200 |
commit | 31f15c6c62960c25deebf9475014090b696d42e1 (patch) | |
tree | e4868b922363ea18981950c2deba16bd23cbaf6b /platform/android/MapboxGLAndroidSDKTestApp/src/main | |
parent | 01a33749f9cd05f4b78c0463327821a47ae96baf (diff) | |
download | qtlocation-mapboxgl-31f15c6c62960c25deebf9475014090b696d42e1.tar.gz |
[android] - replaced default colors with material design colors, changed textcolor to white, added click event on toolbar arrow, made sanity test generation compatible (#6004)
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main')
2 files changed, 26 insertions, 52 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java index 65ccbf4c40..74f2e5806c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java @@ -2,14 +2,12 @@ package com.mapbox.mapboxsdk.testapp.activity.style; import android.graphics.Color; import android.os.Bundle; -import android.support.annotation.RawRes; +import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; -import android.view.Menu; import android.view.MenuItem; -import android.widget.Toast; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -17,60 +15,22 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.style.layers.CircleLayer; -import com.mapbox.mapboxsdk.style.layers.FillLayer; -import com.mapbox.mapboxsdk.style.layers.Function; -import com.mapbox.mapboxsdk.style.layers.Layer; -import com.mapbox.mapboxsdk.style.layers.LineLayer; -import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException; -import com.mapbox.mapboxsdk.style.layers.Property; -import com.mapbox.mapboxsdk.style.layers.PropertyValue; -import com.mapbox.mapboxsdk.style.layers.RasterLayer; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; -import com.mapbox.mapboxsdk.style.sources.RasterSource; -import com.mapbox.mapboxsdk.style.sources.Source; -import com.mapbox.mapboxsdk.style.sources.TileSet; -import com.mapbox.mapboxsdk.style.sources.VectorSource; import com.mapbox.mapboxsdk.testapp.R; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; import java.net.MalformedURLException; import java.net.URL; import static com.mapbox.mapboxsdk.style.layers.Filter.all; -import static com.mapbox.mapboxsdk.style.layers.Filter.eq; import static com.mapbox.mapboxsdk.style.layers.Filter.gte; import static com.mapbox.mapboxsdk.style.layers.Filter.lt; -import static com.mapbox.mapboxsdk.style.layers.Function.Stop; -import static com.mapbox.mapboxsdk.style.layers.Function.stop; -import static com.mapbox.mapboxsdk.style.layers.Function.zoom; -import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; /** * Sample Activity to show off geojson source clustering and filter usage @@ -79,6 +39,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { private static final String TAG = GeoJsonClusteringActivity.class.getSimpleName(); private MapView mapView; + private MapboxMap mapboxMap; @Override protected void onCreate(Bundle savedInstanceState) { @@ -92,19 +53,18 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { //noinspection ConstantConditions mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { @Override - public void onMapReady(MapboxMap mapboxMap) { + public void onMapReady(MapboxMap map) { + mapboxMap = map; mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0)); //Add a clustered source with some layers - addClusteredGeoJsonSource(mapboxMap); + addClusteredGeoJsonSource(); } }); } - @Override public void onResume() { super.onResume(); @@ -135,8 +95,18 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { mapView.onLowMemory(); } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } - private void addClusteredGeoJsonSource(MapboxMap mapboxMap) { + private void addClusteredGeoJsonSource() { //Add a clustered source try { mapboxMap.addSource( @@ -151,9 +121,9 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { //Add unclustered layer int[][] layers = new int[][]{ - new int[]{150, Color.RED}, - new int[]{20, Color.GREEN}, - new int[]{0, Color.BLUE} + new int[]{150, ResourcesCompat.getColor(getResources(), R.color.red_accent, getTheme())}, + new int[]{20, ResourcesCompat.getColor(getResources(), R.color.green_accent, getTheme())}, + new int[]{0, ResourcesCompat.getColor(getResources(), R.color.blue_accent, getTheme())} }; SymbolLayer unclustered = new SymbolLayer("unclustered-points", "earthquakes"); @@ -179,7 +149,8 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { SymbolLayer count = new SymbolLayer("count", "earthquakes"); count.setProperties( textField("{point_count}"), - textSize(12f) + textSize(12f), + textColor(Color.WHITE) ); mapboxMap.addLayer(count); @@ -188,7 +159,6 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1)); } - private void setupActionBar() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml index 891ab8d7a8..78fc76af1c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml @@ -5,4 +5,8 @@ <color name="accent">#E55E5E</color> <color name="white">#F9F9F9</color> <color name="mapbox_green">#56B881</color> + + <color name="red_accent">#D50000</color> + <color name="blue_accent">#2962FF</color> + <color name="green_accent">#1B5E20</color> </resources> |