summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Zugaldia <antonio@mapbox.com>2017-10-26 12:57:46 -0400
committerGitHub <noreply@github.com>2017-10-26 12:57:46 -0400
commitbd06e2f6fa3ca3367b831caeb52ecb6da3f199fd (patch)
tree4a73bae1fe333901653a95471add383e0ef6ed3c
parentbf9c1fb1b3f6121d4c939757ee043a70bef560e4 (diff)
downloadqtlocation-mapboxgl-bd06e2f6fa3ca3367b831caeb52ecb6da3f199fd.tar.gz
[android] - lower amount of external dependencies (#10268)
-rw-r--r--platform/android/MapboxGLAndroidSDK/build.gradle5
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java48
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/values/styles.xml6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java3
-rw-r--r--platform/android/dependencies.gradle2
8 files changed, 47 insertions, 28 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index c96587fce6..19587d0078 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
dependencies {
compile rootProject.ext.dep.supportAnnotations
- compile rootProject.ext.dep.supportV4
- compile rootProject.ext.dep.supportDesign
+ compile rootProject.ext.dep.supportFragmentV4
compile rootProject.ext.dep.timber
compile rootProject.ext.dep.okhttp3
compile(rootProject.ext.dep.lost) {
exclude group: 'com.google.guava'
+ exclude group: 'com.android.support'
}
testCompile rootProject.ext.dep.junit
testCompile rootProject.ext.dep.mockito
@@ -20,6 +20,7 @@ dependencies {
// Mapbox Android Services (Telemetry support)
compile(rootProject.ext.dep.mapboxAndroidTelemetry) {
transitive = true
+ exclude group: 'com.android.support'
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java
index 5113a0cc73..9ccff387f5 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java
@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.maps;
+import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
-import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@@ -56,7 +56,7 @@ class AttributionDialogManager implements View.OnClickListener, DialogInterface.
private void showAttributionDialog() {
attributionKeys = attributionMap.keySet().toArray(new String[attributionMap.size()]);
- AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.mapbox_AlertDialogStyle);
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.mapbox_attributionsDialogTitle);
builder.setAdapter(new ArrayAdapter<>(context, R.layout.mapbox_attribution_list_item, attributionKeys), this);
builder.show();
@@ -77,7 +77,7 @@ class AttributionDialogManager implements View.OnClickListener, DialogInterface.
}
private void showTelemetryDialog() {
- AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.mapbox_AlertDialogStyle);
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.mapbox_attributionTelemetryTitle);
builder.setMessage(R.string.mapbox_attributionTelemetryMessage);
builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
index 45f72af1c5..1e604c9bef 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
@@ -6,10 +6,10 @@ import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListenerAdapter;
-import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -22,7 +22,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
* use {@link com.mapbox.mapboxsdk.maps.UiSettings}.
* </p>
*/
-public final class CompassView extends AppCompatImageView implements Runnable {
+public final class CompassView extends ImageView implements Runnable {
public static final long TIME_WAIT_IDLE = 500;
public static final long TIME_MAP_NORTH_ANIMATION = 150;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
index 14b18b00dc..1c0e439afc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
@@ -5,6 +5,7 @@ import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.v4.graphics.drawable.DrawableCompat;
@@ -30,10 +31,15 @@ public class ColorUtils {
*/
@ColorInt
public static int getPrimaryColor(@NonNull Context context) {
- TypedValue typedValue = new TypedValue();
- Resources.Theme theme = context.getTheme();
- theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
- return typedValue.data;
+ try {
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = context.getTheme();
+ int id = context.getResources().getIdentifier("colorPrimary", "attrs", context.getPackageName());
+ theme.resolveAttribute(id, typedValue, true);
+ return typedValue.data;
+ } catch (Exception exception) {
+ return getColorCompat(context, R.color.mapbox_blue);
+ }
}
/**
@@ -44,10 +50,15 @@ public class ColorUtils {
*/
@ColorInt
public static int getPrimaryDarkColor(@NonNull Context context) {
- TypedValue typedValue = new TypedValue();
- Resources.Theme theme = context.getTheme();
- theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
- return typedValue.data;
+ try {
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = context.getTheme();
+ int id = context.getResources().getIdentifier("colorPrimaryDark", "attrs", context.getPackageName());
+ theme.resolveAttribute(id, typedValue, true);
+ return typedValue.data;
+ } catch (Exception exception) {
+ return getColorCompat(context, R.color.mapbox_blue);
+ }
}
/**
@@ -58,10 +69,15 @@ public class ColorUtils {
*/
@ColorInt
public static int getAccentColor(@NonNull Context context) {
- TypedValue typedValue = new TypedValue();
- Resources.Theme theme = context.getTheme();
- theme.resolveAttribute(R.attr.colorAccent, typedValue, true);
- return typedValue.data;
+ try {
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = context.getTheme();
+ int id = context.getResources().getIdentifier("colorAccent", "attrs", context.getPackageName());
+ theme.resolveAttribute(id, typedValue, true);
+ return typedValue.data;
+ } catch (Exception exception) {
+ return getColorCompat(context, R.color.mapbox_gray);
+ }
}
/**
@@ -122,4 +138,12 @@ public class ColorUtils {
throw new ConversionException("Not a valid rgb/rgba value");
}
}
+
+ private static int getColorCompat(Context context, int id) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ return context.getResources().getColor(id, context.getTheme());
+ } else {
+ return context.getResources().getColor(id);
+ }
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/styles.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/styles.xml
deleted file mode 100644
index eba1fb3a7d..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <style name="mapbox_AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"/>
-
-</resources>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index 0bac90d2c2..ad910ddf10 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -59,6 +59,7 @@ dependencies {
// Support libraries
compile rootProject.ext.dep.supportAppcompatV7
compile rootProject.ext.dep.supportRecyclerView
+ compile rootProject.ext.dep.supportDesign
// Leak Canary
debugCompile rootProject.ext.dep.leakCanaryDebug
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
index d35eb83f7d..e5c6a3f584 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
@@ -68,8 +68,7 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe
public void onClick(View view) {
Context context = view.getContext();
final View dialogContent = LayoutInflater.from(context).inflate(R.layout.dialog_camera_position, null);
- AlertDialog.Builder builder = new AlertDialog.Builder(
- context, com.mapbox.mapboxsdk.R.style.mapbox_AlertDialogStyle);
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.dialog_camera_position);
builder.setView(onInflateDialogContent(dialogContent));
builder.setPositiveButton("Animate", new DialogClickListener(mapboxMap, dialogContent));
diff --git a/platform/android/dependencies.gradle b/platform/android/dependencies.gradle
index 0a8278a7b7..2c43eafd3b 100644
--- a/platform/android/dependencies.gradle
+++ b/platform/android/dependencies.gradle
@@ -35,7 +35,7 @@ ext {
// support
supportAnnotations : "com.android.support:support-annotations:${supportLibVersion}",
supportAppcompatV7 : "com.android.support:appcompat-v7:${supportLibVersion}",
- supportV4 : "com.android.support:support-v4:${supportLibVersion}",
+ supportFragmentV4 : "com.android.support:support-fragment:${supportLibVersion}",
supportDesign : "com.android.support:design:${supportLibVersion}",
supportRecyclerView : "com.android.support:recyclerview-v7:${supportLibVersion}",