summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Mace <cameron@mapbox.com>2016-12-14 12:51:04 -0500
committerGitHub <noreply@github.com>2016-12-14 12:51:04 -0500
commit3d5983f6f666bb75574a1b9040323fa401e01388 (patch)
tree5811a6260e3c4b155dc25a301bfbbb752b56db21
parent8f24119bd0eb8e5e03f9d8c4422c5bcb3baeafce (diff)
downloadqtlocation-mapboxgl-3d5983f6f666bb75574a1b9040323fa401e01388.tar.gz
Allows for setting the user location icon to transparent (#7393)
* allows for setting the user location icon to transparent * removed color check
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java20
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml43
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java14
6 files changed, 73 insertions, 25 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index db46e7a162..4892c18ab5 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -211,8 +211,8 @@ public class MapboxMapOptions implements Parcelable {
, (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginBottom, DIMENSION_SEVEN_DP * screenDensity))});
mapboxMapOptions.locationEnabled(typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_myLocation, false));
- mapboxMapOptions.myLocationForegroundTintColor(typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationTintColor, Color.TRANSPARENT));
- mapboxMapOptions.myLocationBackgroundTintColor(typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundTintColor, Color.TRANSPARENT));
+ mapboxMapOptions.myLocationForegroundTintColor(typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationTintColor, ColorUtils.getPrimaryColor(context)));
+ mapboxMapOptions.myLocationBackgroundTintColor(typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundTintColor, Color.WHITE));
Drawable foregroundDrawable = typedArray.getDrawable(R.styleable.mapbox_MapView_mapbox_myLocationDrawable);
if (foregroundDrawable == null) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index ca070a8864..677b59bea8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -173,13 +173,11 @@ public class MyLocationView extends View {
}
public final void setForegroundDrawableTint(@ColorInt int color) {
- if (color != Color.TRANSPARENT) {
- if (foregroundDrawable != null) {
- foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
- }
- if (foregroundBearingDrawable != null) {
- foregroundBearingDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
- }
+ if (foregroundDrawable != null) {
+ foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+ }
+ if (foregroundBearingDrawable != null) {
+ foregroundBearingDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
invalidate();
}
@@ -202,12 +200,10 @@ public class MyLocationView extends View {
}
public final void setShadowDrawableTint(@ColorInt int color) {
- if (color != Color.TRANSPARENT) {
- if (backgroundDrawable == null) {
- return;
- }
- backgroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+ if (backgroundDrawable == null) {
+ return;
}
+ backgroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
invalidate();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
index 0c77b60d9a..d40747918a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
+import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.IdRes;
@@ -81,6 +82,7 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
MyLocationTintActivity.this, R.color.mapbox_my_location_ring));
myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
MyLocationTintActivity.this, R.color.mapbox_blue));
+ myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
}
});
@@ -95,6 +97,7 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green));
myLocationViewSettings.setForegroundTintColor(
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green));
+ myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
}
});
@@ -109,8 +112,21 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
myLocationViewSettings.setForegroundTintColor(
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
+ myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
}
});
+
+ ViewUtils.attachClickListener(
+ MyLocationTintActivity.this,
+ R.id.user_dot_transparent_button,
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
+ myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
+ }
+ }
+ );
}
});
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml
index af755c72a1..d41cc79326 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml
@@ -1,50 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:mapbox="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
<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" />
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<com.mapbox.mapboxsdk.maps.MapView
android:id="@id/mapView"
- android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
- android:layout_height="match_parent"/>
+ android:layout_height="match_parent"
+ android:layout_below="@+id/toolbar"
+ mapbox:mapbox_uiAttribution="false"
+ mapbox:mapbox_uiLogo="false"/>
<LinearLayout
+ style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
+ android:background="@color/accent"
android:orientation="horizontal"
- android:weightSum="3">
+ android:weightSum="4">
<Button
android:id="@+id/default_user_dot_coloring_button"
+ style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/button_user_dot_default" />
+ android:text="@string/button_user_dot_default"
+ android:textColor="@color/white"/>
<Button
android:id="@+id/tint_user_dot_button"
+ style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/button_user_dot_tint" />
+ android:text="@string/button_user_dot_tint"
+ android:textColor="@color/white"/>
<Button
android:id="@+id/user_accuracy_ring_tint_button"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/button_user_accuracy_ring_tint"
+ android:textColor="@color/white"/>
+
+ <Button
+ android:id="@+id/user_dot_transparent_button"
+ style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/button_user_accuracy_ring_tint" />
+ android:text="@string/button_user_transparent_tint"
+ android:textColor="@color/white"/>
- </LinearLayout>
+ </LinearLayout>
</RelativeLayout> \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
index f4a83d10d9..72b0ecb69c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
@@ -169,6 +169,7 @@
<string name="button_user_dot_default">Default</string>
<string name="button_user_dot_tint">Tint dot</string>
<string name="button_user_accuracy_ring_tint">Tint ring</string>
+ <string name="button_user_transparent_tint">tran</string>
<string name="button_open_dialog">Open dialog</string>
<string name="label_fps">FPS:</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
index a13b030dcf..24f28567ba 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
@@ -75,6 +75,13 @@ public class MyLocationViewSettingsTest {
}
@Test
+ public void testForegroundTransparentTint() {
+ int color = Color.TRANSPARENT;
+ locationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
+ assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
+ }
+
+ @Test
public void testBackgroundTint() {
int color = Color.RED;
locationViewSettings.setBackgroundTintColor(Color.RED);
@@ -82,6 +89,13 @@ public class MyLocationViewSettingsTest {
}
@Test
+ public void testBackgroundTransparentTint() {
+ int color = Color.TRANSPARENT;
+ locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
+ assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
+ }
+
+ @Test
public void testEnabled() {
assertFalse("initial state should be false", locationViewSettings.isEnabled());
locationViewSettings.setEnabled(true);