[android] #4800 - correct background offsets from attributes
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
@@ -56,12 +58,17 @@ public class MyLocationCustomisationActivity extends AppCompatActivity implement
|
||||
.tilt(25)
|
||||
.build());
|
||||
|
||||
mapboxMapOptions.myLocationForegroundDrawables(ContextCompat.getDrawable(this, R.drawable.ic_chelsea),
|
||||
ContextCompat.getDrawable(this, R.drawable.ic_chelsea));
|
||||
mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arsenal));
|
||||
mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN);
|
||||
mapboxMapOptions.myLocationBackgroundTintColor(Color.YELLOW);
|
||||
// mapboxMapOptions.myLocationBackgroundPadding(new int[]{32, 32, 0, 0});
|
||||
mapboxMapOptions.myLocationBackgroundPadding(new int[]{0, 0,
|
||||
(int) getResources().getDimension(R.dimen.locationview_background_drawable_padding),
|
||||
(int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)});
|
||||
|
||||
// mapboxMapOptions.myLocationAccuracyTint(Color.RED);
|
||||
// mapboxMapOptions.myLocationAccuracyAlpha(155);
|
||||
mapboxMapOptions.myLocationAccuracyTint(Color.RED);
|
||||
mapboxMapOptions.myLocationAccuracyAlpha(155);
|
||||
|
||||
mapView = new MapView(this, mapboxMapOptions);
|
||||
ViewGroup parent = (ViewGroup) findViewById(R.id.container);
|
||||
|
||||
@@ -7,6 +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_background_drawable_padding">2dp</dimen>
|
||||
<dimen name="locationview_padding_top">350dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -49,14 +49,9 @@ public class MyLocationViewSettingsTest {
|
||||
@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);
|
||||
locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset);
|
||||
assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable());
|
||||
assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset()));
|
||||
}
|
||||
|
||||
@@ -68,7 +63,7 @@ public class MyLocationViewSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundTint(){
|
||||
public void testBackgroundTint() {
|
||||
int color = Color.RED;
|
||||
locationViewSettings.setBackgroundTintColor(Color.RED);
|
||||
assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
|
||||
|
||||
Reference in New Issue
Block a user