Add style string resources
Use _ in public resources ids Make visibility attributes enums Make attrs public Remove info window margin public value Reformat XML code Test app uses XML map properties for InfoWindow activities Fixes #2703
This commit is contained in:
@@ -23,6 +23,8 @@ public class Style {
|
||||
public @interface StyleUrl {
|
||||
}
|
||||
|
||||
// IMPORTANT: If you change any of these you also need to edit them in strings.xml
|
||||
|
||||
/**
|
||||
* Mapbox Streets: Our signature style.
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.graphics.Matrix;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
@@ -38,7 +37,6 @@ import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.Gravity;
|
||||
import android.view.InputDevice;
|
||||
@@ -684,26 +682,26 @@ public final class MapView extends FrameLayout {
|
||||
// Load the attributes
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MapView, 0, 0);
|
||||
try {
|
||||
double centerLatitude = typedArray.getFloat(R.styleable.MapView_centerLatitude, 0.0f);
|
||||
double centerLongitude = typedArray.getFloat(R.styleable.MapView_centerLongitude, 0.0f);
|
||||
double centerLatitude = typedArray.getFloat(R.styleable.MapView_center_latitude, 0.0f);
|
||||
double centerLongitude = typedArray.getFloat(R.styleable.MapView_center_longitude, 0.0f);
|
||||
LatLng centerCoordinate = new LatLng(centerLatitude, centerLongitude);
|
||||
setCenterCoordinate(centerCoordinate);
|
||||
// need to set zoom level first because of limitation on rotating when zoomed out
|
||||
setZoomLevel(typedArray.getFloat(R.styleable.MapView_zoomLevel, 0.0f));
|
||||
setZoomLevel(typedArray.getFloat(R.styleable.MapView_zoom_level, 0.0f));
|
||||
setDirection(typedArray.getFloat(R.styleable.MapView_direction, 0.0f));
|
||||
setZoomEnabled(typedArray.getBoolean(R.styleable.MapView_zoomEnabled, true));
|
||||
setScrollEnabled(typedArray.getBoolean(R.styleable.MapView_scrollEnabled, true));
|
||||
setRotateEnabled(typedArray.getBoolean(R.styleable.MapView_rotateEnabled, true));
|
||||
setDebugActive(typedArray.getBoolean(R.styleable.MapView_debugActive, false));
|
||||
if (typedArray.getString(R.styleable.MapView_styleUrl) != null) {
|
||||
setStyleUrl(typedArray.getString(R.styleable.MapView_styleUrl));
|
||||
setZoomEnabled(typedArray.getBoolean(R.styleable.MapView_zoom_enabled, true));
|
||||
setScrollEnabled(typedArray.getBoolean(R.styleable.MapView_scroll_enabled, true));
|
||||
setRotateEnabled(typedArray.getBoolean(R.styleable.MapView_rotate_enabled, true));
|
||||
setDebugActive(typedArray.getBoolean(R.styleable.MapView_debug_active, false));
|
||||
if (typedArray.getString(R.styleable.MapView_style_url) != null) {
|
||||
setStyleUrl(typedArray.getString(R.styleable.MapView_style_url));
|
||||
}
|
||||
if (typedArray.getString(R.styleable.MapView_accessToken) != null) {
|
||||
setAccessToken(typedArray.getString(R.styleable.MapView_accessToken));
|
||||
if (typedArray.getString(R.styleable.MapView_access_token) != null) {
|
||||
setAccessToken(typedArray.getString(R.styleable.MapView_access_token));
|
||||
}
|
||||
if (typedArray.getString(R.styleable.MapView_styleClasses) != null) {
|
||||
if (typedArray.getString(R.styleable.MapView_style_classes) != null) {
|
||||
List<String> styleClasses = Arrays.asList(typedArray
|
||||
.getString(R.styleable.MapView_styleClasses).split("\\s*,\\s*"));
|
||||
.getString(R.styleable.MapView_style_classes).split("\\s*,\\s*"));
|
||||
for (String styleClass : styleClasses) {
|
||||
if (styleClass.length() == 0) {
|
||||
styleClasses.remove(styleClass);
|
||||
@@ -713,31 +711,31 @@ public final class MapView extends FrameLayout {
|
||||
}
|
||||
|
||||
// Compass
|
||||
setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compassEnabled, true));
|
||||
setCompassGravity(typedArray.getInt(R.styleable.MapView_compassGravity, Gravity.TOP | Gravity.END));
|
||||
setWidgetMargins(mCompassView, typedArray.getDimension(R.styleable.MapView_compassMarginLeft, DIMENSION_TEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_compassMarginTop, DIMENSION_TEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_compassMarginRight, DIMENSION_TEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_compassMarginBottom, DIMENSION_TEN_DP));
|
||||
setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compass_enabled, true));
|
||||
setCompassGravity(typedArray.getInt(R.styleable.MapView_compass_gravity, Gravity.TOP | Gravity.END));
|
||||
setWidgetMargins(mCompassView, typedArray.getDimension(R.styleable.MapView_compass_margin_left, DIMENSION_TEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_compass_margin_top, DIMENSION_TEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_compass_margin_right, DIMENSION_TEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_compass_margin_bottom, DIMENSION_TEN_DP));
|
||||
|
||||
// Logo
|
||||
setLogoVisibility(typedArray.getInt(R.styleable.MapView_logoVisibility, VISIBLE));
|
||||
setLogoGravity(typedArray.getInt(R.styleable.MapView_logoGravity, Gravity.BOTTOM | Gravity.START));
|
||||
setWidgetMargins(mLogoView, typedArray.getDimension(R.styleable.MapView_logoMarginLeft, DIMENSION_SIXTEEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_logoMarginTop, DIMENSION_SIXTEEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_logoMarginRight, DIMENSION_SIXTEEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_logoMarginBottom, DIMENSION_SIXTEEN_DP));
|
||||
setLogoVisibility(typedArray.getInt(R.styleable.MapView_logo_visibility, View.VISIBLE));
|
||||
setLogoGravity(typedArray.getInt(R.styleable.MapView_logo_gravity, Gravity.BOTTOM | Gravity.START));
|
||||
setWidgetMargins(mLogoView, typedArray.getDimension(R.styleable.MapView_logo_margin_left, DIMENSION_SIXTEEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_logo_margin_top, DIMENSION_SIXTEEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_logo_margin_right, DIMENSION_SIXTEEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_logo_margin_bottom, DIMENSION_SIXTEEN_DP));
|
||||
|
||||
// Attribution
|
||||
setAttributionVisibility(typedArray.getInt(R.styleable.MapView_attributionVisibility, VISIBLE));
|
||||
setAttributionGravity(typedArray.getInt(R.styleable.MapView_attributionGravity, Gravity.BOTTOM));
|
||||
setWidgetMargins(mAttributionsView, typedArray.getDimension(R.styleable.MapView_attributionMarginLeft, DIMENSION_SEVENTYSIX_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_attributionMarginTop, DIMENSION_SEVEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_attributionMarginRight, DIMENSION_SEVEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_attributionMarginBottom, DIMENSION_SEVEN_DP));
|
||||
setAttributionVisibility(typedArray.getInt(R.styleable.MapView_attribution_visibility, View.VISIBLE));
|
||||
setAttributionGravity(typedArray.getInt(R.styleable.MapView_attribution_gravity, Gravity.BOTTOM));
|
||||
setWidgetMargins(mAttributionsView, typedArray.getDimension(R.styleable.MapView_attribution_margin_left, DIMENSION_SEVENTYSIX_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_attribution_margin_top, DIMENSION_SEVEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_attribution_margin_right, DIMENSION_SEVEN_DP)
|
||||
, typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP));
|
||||
|
||||
// User location
|
||||
setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_myLocationEnabled, false));
|
||||
setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
|
||||
} finally {
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@@ -2,5 +2,41 @@
|
||||
<resources>
|
||||
<!--Add references to exposed resources-->
|
||||
<public name="AttributionAlertDialogStyle" type="style" />
|
||||
<public name="infowindow_margin" type="dimen" />
|
||||
|
||||
<public name="style_mapbox_streets" type="string" />
|
||||
<public name="style_emerald" type="string" />
|
||||
<public name="style_light" type="string" />
|
||||
<public name="style_dark" type="string" />
|
||||
<public name="style_satellite" type="string" />
|
||||
|
||||
<public name="center_longitude" type="attr" />
|
||||
<public name="center_latitude" type="attr" />
|
||||
<public name="zoom_level" type="attr" />
|
||||
<public name="direction" type="attr" />
|
||||
<public name="zoom_enabled" type="attr" />
|
||||
<public name="scroll_enabled" type="attr" />
|
||||
<public name="rotate_enabled" type="attr" />
|
||||
<public name="debug_active" type="attr" />
|
||||
<public name="style_url" type="attr" />
|
||||
<public name="access_token" type="attr" />
|
||||
<public name="style_classes" type="attr" />
|
||||
<public name="my_location_enabled" type="attr" />
|
||||
<public name="compass_enabled" type="attr" />
|
||||
<public name="compass_gravity" type="attr" />
|
||||
<public name="compass_margin_left" type="attr" />
|
||||
<public name="compass_margin_top" type="attr" />
|
||||
<public name="compass_margin_right" type="attr" />
|
||||
<public name="compass_margin_bottom" type="attr" />
|
||||
<public name="logo_gravity" type="attr" />
|
||||
<public name="logo_margin_left" type="attr" />
|
||||
<public name="logo_margin_top" type="attr" />
|
||||
<public name="logo_margin_right" type="attr" />
|
||||
<public name="logo_margin_bottom" type="attr" />
|
||||
<public name="logo_visibility" type="attr" />
|
||||
<public name="attribution_gravity" type="attr" />
|
||||
<public name="attribution_margin_left" type="attr" />
|
||||
<public name="attribution_margin_top" type="attr" />
|
||||
<public name="attribution_margin_right" type="attr" />
|
||||
<public name="attribution_margin_bottom" type="attr" />
|
||||
<public name="attribution_visibility" type="attr" />
|
||||
</resources>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:color="?attr/colorPrimaryDark"
|
||||
android:state_pressed="true"/>
|
||||
<item
|
||||
android:color="?attr/colorPrimary" />
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorPrimaryDark" android:state_pressed="true" />
|
||||
<item android:color="?attr/colorPrimary" />
|
||||
</selector>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/ic_info_blue_pressed" />
|
||||
<item android:drawable="@drawable/ic_info_blue_normal" />
|
||||
<item android:drawable="@drawable/ic_info_blue_pressed" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/ic_info_blue_normal" />
|
||||
</selector>
|
||||
@@ -3,9 +3,9 @@
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall" />
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="@android:color/white" />
|
||||
|
||||
@@ -1,54 +1,53 @@
|
||||
<?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"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/infowindow_content"
|
||||
android:background="@color/white"
|
||||
android:padding="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infowindow_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
android:maxEms="17"
|
||||
android:layout_gravity="left"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/infoWindowTitle"/>
|
||||
android:maxEms="17"
|
||||
android:text="@string/infoWindowTitle"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infowindow_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:maxEms="17"
|
||||
android:text="@string/infoWindowDescription"/>
|
||||
android:text="@string/infoWindowDescription"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infowindow_subdescription"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:maxEms="17"
|
||||
android:text="@string/infoWindowAddress"
|
||||
android:visibility="gone"/>
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.mapbox.mapboxsdk.annotations.InfoWindowTipView
|
||||
android:id="@+id/infowindow_tipview"
|
||||
android:layout_below="@+id/infowindow_content"
|
||||
android:layout_width="@dimen/infowindow_tipview_width"
|
||||
android:layout_height="8dp"/>
|
||||
android:layout_height="8dp"
|
||||
android:layout_below="@+id/infowindow_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mapbox.mapboxsdk.annotations.InfoWindowView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<resources>
|
||||
<!-- these are public -->
|
||||
<declare-styleable name="MapView">
|
||||
<attr name="centerLongitude" format="float" />
|
||||
<attr name="centerLatitude" format="float" />
|
||||
<attr name="zoomLevel" format="float" />
|
||||
<attr name="center_longitude" format="float" />
|
||||
<attr name="center_latitude" format="float" />
|
||||
<attr name="zoom_level" format="float" />
|
||||
<attr name="direction" format="float" />
|
||||
<attr name="zoomEnabled" format="boolean" />
|
||||
<attr name="scrollEnabled" format="boolean" />
|
||||
<attr name="rotateEnabled" format="boolean" />
|
||||
<attr name="debugActive" format="boolean" />
|
||||
<attr name="styleUrl" format="string" />
|
||||
<attr name="accessToken" format="string"/>
|
||||
<attr name="styleClasses" format="string"/>
|
||||
<attr name="myLocationEnabled" format="boolean" />
|
||||
<attr name="compassEnabled" format="boolean" />
|
||||
<attr name="compassGravity">
|
||||
<attr name="zoom_enabled" format="boolean" />
|
||||
<attr name="scroll_enabled" format="boolean" />
|
||||
<attr name="rotate_enabled" format="boolean" />
|
||||
<attr name="debug_active" format="boolean" />
|
||||
<attr name="style_url" format="string" />
|
||||
<attr name="access_token" format="string" />
|
||||
<attr name="style_classes" format="string" />
|
||||
<attr name="my_location_enabled" format="boolean" />
|
||||
<attr name="compass_enabled" format="boolean" />
|
||||
<attr name="compass_gravity">
|
||||
<flag name="top" value="0x30" />
|
||||
<flag name="bottom" value="0x50" />
|
||||
<flag name="left" value="0x03" />
|
||||
@@ -29,11 +30,11 @@
|
||||
<flag name="start" value="0x00800003" />
|
||||
<flag name="end" value="0x00800005" />
|
||||
</attr>
|
||||
<attr name="compassMarginLeft" format="dimension"/>
|
||||
<attr name="compassMarginTop" format="dimension"/>
|
||||
<attr name="compassMarginRight" format="dimension"/>
|
||||
<attr name="compassMarginBottom" format="dimension"/>
|
||||
<attr name="logoGravity">
|
||||
<attr name="compass_margin_left" format="dimension" />
|
||||
<attr name="compass_margin_top" format="dimension" />
|
||||
<attr name="compass_margin_right" format="dimension" />
|
||||
<attr name="compass_margin_bottom" format="dimension" />
|
||||
<attr name="logo_gravity">
|
||||
<flag name="top" value="0x30" />
|
||||
<flag name="bottom" value="0x50" />
|
||||
<flag name="left" value="0x03" />
|
||||
@@ -49,12 +50,16 @@
|
||||
<flag name="start" value="0x00800003" />
|
||||
<flag name="end" value="0x00800005" />
|
||||
</attr>
|
||||
<attr name="logoMarginLeft" format="dimension"/>
|
||||
<attr name="logoMarginTop" format="dimension"/>
|
||||
<attr name="logoMarginRight" format="dimension"/>
|
||||
<attr name="logoMarginBottom" format="dimension"/>
|
||||
<attr name="logoVisibility" format="integer"/>
|
||||
<attr name="attributionGravity">
|
||||
<attr name="logo_margin_left" format="dimension" />
|
||||
<attr name="logo_margin_top" format="dimension" />
|
||||
<attr name="logo_margin_right" format="dimension" />
|
||||
<attr name="logo_margin_bottom" format="dimension" />
|
||||
<attr name="logo_visibility">
|
||||
<enum name="visible" value="0x0" />
|
||||
<enum name="invisible" value="0x4" />
|
||||
<enum name="gone" value="0x8" />
|
||||
</attr>
|
||||
<attr name="attribution_gravity">
|
||||
<flag name="top" value="0x30" />
|
||||
<flag name="bottom" value="0x50" />
|
||||
<flag name="left" value="0x03" />
|
||||
@@ -70,10 +75,14 @@
|
||||
<flag name="start" value="0x00800003" />
|
||||
<flag name="end" value="0x00800005" />
|
||||
</attr>
|
||||
<attr name="attributionMarginLeft" format="dimension"/>
|
||||
<attr name="attributionMarginTop" format="dimension"/>
|
||||
<attr name="attributionMarginRight" format="dimension"/>
|
||||
<attr name="attributionMarginBottom" format="dimension"/>
|
||||
<attr name="attributionVisibility" format="integer"/>
|
||||
<attr name="attribution_margin_left" format="dimension" />
|
||||
<attr name="attribution_margin_top" format="dimension" />
|
||||
<attr name="attribution_margin_right" format="dimension" />
|
||||
<attr name="attribution_margin_bottom" format="dimension" />
|
||||
<attr name="attribution_visibility">
|
||||
<enum name="visible" value="0x0" />
|
||||
<enum name="invisible" value="0x4" />
|
||||
<enum name="gone" value="0x8" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
||||
@@ -7,4 +7,11 @@
|
||||
<string name="infoWindowTitle">Title</string>
|
||||
<string name="infoWindowDescription">Description</string>
|
||||
<string name="infoWindowAddress">Address</string>
|
||||
|
||||
<!-- these are public -->
|
||||
<string name="style_mapbox_streets">asset://styles/streets-v8.json</string>
|
||||
<string name="style_emerald">asset://styles/emerald-v8.json</string>
|
||||
<string name="style_light">asset://styles/light-v8.json</string>
|
||||
<string name="style_dark">asset://styles/dark-v8.json</string>
|
||||
<string name="style_satellite">asset://styles/satellite-v8.json</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- these are public -->
|
||||
<style name="AttributionAlertDialogStyle" parent="Theme.AppCompat.Dialog.Alert">
|
||||
<item name="android:textColorPrimary">@android:color/white</item>
|
||||
<item name="android:background">@color/mapbox_blue</item>
|
||||
|
||||
Reference in New Issue
Block a user