[android] #4396 - fixup mason build issue
This commit is contained in:
@@ -121,9 +121,10 @@
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera" />
|
||||
</activity>
|
||||
<activity android:name=".activity.customlayer.CustomLayerActivity"
|
||||
android:description="@string/description_custom_layer"
|
||||
android:label="@string/activity_custom_layer">
|
||||
<activity
|
||||
android:name=".activity.customlayer.CustomLayerActivity"
|
||||
android:description="@string/description_custom_layer"
|
||||
android:label="@string/activity_custom_layer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_custom_layer" />
|
||||
@@ -136,6 +137,14 @@
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.userlocation.MyLocationCustomisationActivity"
|
||||
android:description="@string/description_user_location_customization"
|
||||
android:label="@string/activity_user_tracking_mode">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.PolygonActivity"
|
||||
android:description="@string/description_polygon"
|
||||
@@ -192,7 +201,7 @@
|
||||
android:label="@string/activity_debug_mode">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.offline.OfflineActivity"
|
||||
|
||||
@@ -6,8 +6,10 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@@ -120,7 +122,7 @@ public class FeatureOverviewActivity extends AppCompatActivity {
|
||||
for (ActivityInfo info : app.activities) {
|
||||
if (info.name.startsWith(packageName) && !info.name.equals(FeatureOverviewActivity.class.getName())) {
|
||||
String label = getString(info.labelRes);
|
||||
String description = getString(info.descriptionRes);
|
||||
String description = resolveString(info.descriptionRes);
|
||||
String category = resolveMetaData(info.metaData, metaDataKey);
|
||||
features.add(new Feature(info.name, label, description, category));
|
||||
}
|
||||
@@ -147,6 +149,14 @@ public class FeatureOverviewActivity extends AppCompatActivity {
|
||||
return category;
|
||||
}
|
||||
|
||||
private String resolveString(@StringRes int stringRes){
|
||||
try{
|
||||
return getString(stringRes);
|
||||
}catch (Resources.NotFoundException e){
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<Feature> features) {
|
||||
super.onPostExecute(features);
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.location.LocationListener;
|
||||
import com.mapbox.mapboxsdk.location.LocationServices;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
public class MyLocationCustomisationActivity extends AppCompatActivity implements LocationListener, OnMapReadyCallback {
|
||||
|
||||
private MapView mMapView;
|
||||
private MapboxMap mMapboxMap;
|
||||
private Location mLocation;
|
||||
|
||||
private Bundle savedState;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_location_customisation);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
savedState = savedInstanceState;
|
||||
|
||||
LocationServices locationServices = LocationServices.getLocationServices(this);
|
||||
locationServices.addLocationListener(this);
|
||||
locationServices.toggleGPS(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
if (mMapView == null) {
|
||||
findViewById(R.id.progress).setVisibility(View.GONE);
|
||||
|
||||
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
|
||||
mapboxMapOptions.accessToken(getString(R.string.mapbox_access_token));
|
||||
mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
|
||||
mapboxMapOptions.locationEnabled(true);
|
||||
mapboxMapOptions.camera(new CameraPosition.Builder()
|
||||
.target(new LatLng(location))
|
||||
.zoom(11)
|
||||
.tilt(25)
|
||||
.build());
|
||||
|
||||
mMapView = new MapView(this, mapboxMapOptions);
|
||||
((ViewGroup) findViewById(R.id.container)).addView(mMapView);
|
||||
|
||||
mMapView.onCreate(savedState);
|
||||
mMapView.getMapAsync(this);
|
||||
mMapView.onResume();
|
||||
mLocation = location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
MyLocationViewSettings locationViewSettings = mapboxMap.getMyLocationViewSettings();
|
||||
|
||||
locationViewSettings.setBackgroundTintColor(Color.YELLOW);
|
||||
locationViewSettings.setBackgroundOffset(32, 32, 0, 0);
|
||||
|
||||
locationViewSettings.setForegroundTintColor(Color.GREEN);
|
||||
|
||||
locationViewSettings.setAccuracyTintColor(Color.RED);
|
||||
locationViewSettings.setAccuracyAlpha(100);
|
||||
}
|
||||
|
||||
private void showSnackBar() {
|
||||
String desc = "Loc Chg: ";
|
||||
boolean noInfo = true;
|
||||
if (mLocation.hasSpeed()) {
|
||||
desc += String.format("Spd = %.1f km/h ", mLocation.getSpeed() * 3.6f);
|
||||
noInfo = false;
|
||||
}
|
||||
if (mLocation.hasAltitude()) {
|
||||
desc += String.format("Alt = %.0f m ", mLocation.getAltitude());
|
||||
noInfo = false;
|
||||
}
|
||||
if (noInfo) {
|
||||
desc += "No extra info";
|
||||
}
|
||||
Snackbar.make(findViewById(android.R.id.content), desc, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mMapView != null) {
|
||||
mMapView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (mMapView != null) {
|
||||
mMapView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (mMapView != null) {
|
||||
mMapView.onSaveInstanceState(outState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mMapView != null) {
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
if (mMapView != null) {
|
||||
mMapView.onLowMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_tracking, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
case R.id.action_toggle_dismissible_tracking:
|
||||
boolean state = !item.isChecked();
|
||||
mMapboxMap.getTrackingSettings().setDismissTrackingOnGesture(state);
|
||||
Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show();
|
||||
item.setChecked(state);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
public class MyLocationTrackingModeActivity extends AppCompatActivity implements MapboxMap.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener {
|
||||
@@ -56,6 +57,9 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
mMapboxMap = mapboxMap;
|
||||
|
||||
MyLocationViewSettings locationViewSettings = mapboxMap.getMyLocationViewSettings();
|
||||
locationViewSettings.setPadding(0, (int) getResources().getDimension(R.dimen.locationview_padding_top), 0, 0);
|
||||
|
||||
mapboxMap.setOnMyLocationChangeListener(MyLocationTrackingModeActivity.this);
|
||||
|
||||
ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item);
|
||||
@@ -70,14 +74,6 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
|
||||
mBearingSpinner.setAdapter(bearingTrackingAdapter);
|
||||
mBearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
|
||||
try {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
} catch (SecurityException e) {
|
||||
//should not occur, permission was checked in FeatureOverviewActivity
|
||||
Toast.makeText(MyLocationTrackingModeActivity.this,
|
||||
"Location permission is not available", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() {
|
||||
@Override
|
||||
@@ -110,6 +106,7 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
|
||||
if (mLocation == null) {
|
||||
// initial location to reposition map
|
||||
mMapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 14));
|
||||
mMapboxMap.setMyLocationEnabled(true);
|
||||
mLocationSpinner.setEnabled(true);
|
||||
mBearingSpinner.setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/primary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v4.widget.ContentLoadingProgressBar
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -7,4 +7,6 @@
|
||||
<dimen name="map_padding_bottom">256dp</dimen>
|
||||
<dimen name="map_padding_right">32dp</dimen>
|
||||
<dimen name="toolbar_shadow">4dp</dimen>
|
||||
|
||||
<dimen name="locationview_padding_top">350dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
<item name="mapView" type="id" />
|
||||
<item name="fab" type="id" />
|
||||
<item name="progress" type="id" />
|
||||
<item name="imageView" type="id" />
|
||||
<item name="toolbar" type="id" />
|
||||
<item name="container" type="id" />
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<string name="activity_double_map">Double Map Activity</string>
|
||||
<string name="activity_snapshot">Snapshot Activity</string>
|
||||
<string name="activity_user_tracking_mode">User tracking mode</string>
|
||||
<string name="activity_user_tracking_customization">User location customization</string>
|
||||
<string name="activity_custom_layer">Custom Layer</string>
|
||||
<string name="activity_map_padding">Map Padding</string>
|
||||
<string name="activity_debug_mode">Debug Mode</string>
|
||||
@@ -44,6 +45,7 @@
|
||||
|
||||
<!-- Description -->
|
||||
<string name="description_user_location_tracking">Tracks the location of the user</string>
|
||||
<string name="description_user_location_customization">Customize the location of the user</string>
|
||||
<string name="description_custom_layer">Overlay a custom native layer on the map</string>
|
||||
<string name="description_info_window_adapter">Learn how to create a custom InfoWindow</string>
|
||||
<string name="description_cameraposition">CameraPosition capabilities</string>
|
||||
|
||||
@@ -166,5 +166,6 @@ public class MapboxMapOptionsTest {
|
||||
assertEquals("test", new MapboxMapOptions().accessToken("test").getAccessToken());
|
||||
assertNotEquals("nottest", new MapboxMapOptions().accessToken("test").getStyle());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.mapbox.mapboxsdk.maps.widgets;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class MyLocationViewSettingsTest {
|
||||
|
||||
@InjectMocks
|
||||
MapView mMapView = mock(MapView.class);
|
||||
|
||||
@InjectMocks
|
||||
UserLocationView userLocationView = mock(UserLocationView.class);
|
||||
|
||||
MyLocationViewSettings locationViewSettings;
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
locationViewSettings = new MyLocationViewSettings(mMapView, userLocationView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
assertNotNull("should not be null", locationViewSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForegroundDrawables() {
|
||||
Drawable foregroundDrawable = mock(Drawable.class);
|
||||
Drawable foregroundBearingDrawable = mock(Drawable.class);
|
||||
locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable);
|
||||
assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable());
|
||||
assertEquals("foreground bearing should match", foregroundBearingDrawable, locationViewSettings.getForegroundBearingDrawable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundDrawable() {
|
||||
Drawable backgroundDrawable = mock(Drawable.class);
|
||||
locationViewSettings.setBackgroundDrawable(backgroundDrawable);
|
||||
assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOffset() {
|
||||
int[] offset = new int[]{1, 2, 3, 4};
|
||||
locationViewSettings.setBackgroundOffset(1, 2, 3, 4);
|
||||
assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForegroundTint() {
|
||||
int color = Color.RED;
|
||||
locationViewSettings.setForegroundTintColor(Color.RED);
|
||||
assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundTint(){
|
||||
int color = Color.RED;
|
||||
locationViewSettings.setBackgroundTintColor(Color.RED);
|
||||
assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnabled() {
|
||||
assertFalse("initial state should be false", locationViewSettings.isEnabled());
|
||||
locationViewSettings.setEnabled(true);
|
||||
assertTrue("state should be true", locationViewSettings.isEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user