Skip to content

Commit

Permalink
[port] Adopt standard style 2.0 (#2652) (#2661)
Browse files Browse the repository at this point in the history
  • Loading branch information
flasher297 authored Aug 2, 2024
1 parent b1188c0 commit 1c246b9
Show file tree
Hide file tree
Showing 24 changed files with 950 additions and 204 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ Mapbox welcomes participation and contributions from everyone.
# 11.6.0-rc.1
## Features ✨ and improvements 🏁
* Support negative values for `CircleLayer.circleBlur` to render inner glow effect.
* Add new `Style.STANDARD_SATELLITE` style that combines updated satellite imagery and vector layers.
* Introduce new import configuration properties for `Style.STANDARD`: `theme`, `show3dObjects` which could be set with `Style.setStyleImportConfigProperty`.
* [compose] Extend `StandardStyleConfigurationState` with `theme: ThemeValue` and `show3dObjects: BooleanValue` properties.
* [compose] Introduce composable function `MapboxStandardSatelliteStyle` with dedicated `StandardSatelliteStyleConfigurationState`.

## Bug fixes 🐞
* Fix elevated line occlusion issue in 2D mode.

## Dependencies
* Update gl-native to v11.6.0-rc.1 and common to v24.6.0-rc.1.


## Known issues
* `ClipLayer` property `clipLayerTypes` is not updated in runtime. The fix is expected to land in stable 11.6.0.

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/assets/fragment-realestate-NY.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"showPointOfInterestLabels": true,
"showTransitLabels": false,
"showPlaceLabels": true,
"showRoadLabels": false
"showRoadLabels": false,
"theme": "monochrome",
"show3dObjects": true
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.mapbox.maps.testapp.examples

import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.bindgen.Value
import com.mapbox.geojson.LineString
Expand All @@ -17,16 +19,18 @@ import com.mapbox.maps.testapp.databinding.ActivityStandardStyleBinding
* Example of working with style imports and the Standard style.
*/
class StandardStyleActivity : AppCompatActivity() {

private lateinit var mapboxMap: MapboxMap
private val line = LineString.fromLngLats(LINE_COORDINATES)
private var lightSetting: LightPresets = LightPresets.DUSK
private var themeSetting: Theme = Theme.DEFAULT
private var labelsSetting = true
private var show3dObjectsSetting = true
private lateinit var binding: ActivityStandardStyleBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityStandardStyleBinding.inflate(layoutInflater)
setContentView(binding.root)
mapboxMap = binding.mapView.mapboxMap
setContentView(binding.root)

Expand Down Expand Up @@ -60,6 +64,22 @@ class StandardStyleActivity : AppCompatActivity() {
}

private fun addOnClickListeners() {
binding.fabThemeSetting.setOnClickListener {
mapboxMap.getStyle { style ->
themeSetting = when (themeSetting) {
Theme.DEFAULT -> Theme.FADED
Theme.FADED -> Theme.MONOCHROME
Theme.MONOCHROME -> Theme.DEFAULT
}
style.setStyleImportConfigProperty(
IMPORT_ID_FOR_STANDARD_STYLE,
"theme",
themeSetting.value
)
showAction(it, themeSetting.value.toString())
}
}

// When a user clicks the light setting button change the `lightPreset` config property on the Standard style import
binding.fabLightSetting.setOnClickListener {
mapboxMap.getStyle { style ->
Expand All @@ -74,6 +94,7 @@ class StandardStyleActivity : AppCompatActivity() {
"lightPreset",
lightSetting.value
)
showAction(it, lightSetting.value.toString())
}
}

Expand All @@ -82,21 +103,63 @@ class StandardStyleActivity : AppCompatActivity() {
binding.fabLabelsSetting.setOnClickListener {
mapboxMap.getStyle { style ->
labelsSetting = !labelsSetting
style.setStyleImportConfigProperty(IMPORT_ID_FOR_STANDARD_STYLE, "showPlaceLabels", Value.valueOf(labelsSetting))
style.setStyleImportConfigProperty(IMPORT_ID_FOR_STANDARD_STYLE, "showRoadLabels", Value.valueOf(labelsSetting))
style.setStyleImportConfigProperty(IMPORT_ID_FOR_STANDARD_STYLE, "showPointInterestLabels", Value.valueOf(labelsSetting))
style.setStyleImportConfigProperty(IMPORT_ID_FOR_STANDARD_STYLE, "showTransitLabels", Value.valueOf(labelsSetting))
style.setStyleImportConfigProperty(
IMPORT_ID_FOR_STANDARD_STYLE,
"showPlaceLabels",
Value.valueOf(labelsSetting)
)
style.setStyleImportConfigProperty(
IMPORT_ID_FOR_STANDARD_STYLE,
"showRoadLabels",
Value.valueOf(labelsSetting)
)
style.setStyleImportConfigProperty(
IMPORT_ID_FOR_STANDARD_STYLE,
"showPointInterestLabels",
Value.valueOf(labelsSetting)
)
style.setStyleImportConfigProperty(
IMPORT_ID_FOR_STANDARD_STYLE,
"showTransitLabels",
Value.valueOf(labelsSetting)
)
showAction(it, labelsSetting.toString())
}
}
binding.fab3dObjectsSetting.setOnClickListener {
mapboxMap.getStyle { style ->
show3dObjectsSetting = !show3dObjectsSetting
style.setStyleImportConfigProperty(
IMPORT_ID_FOR_STANDARD_STYLE,
"show3dObjects",
Value.valueOf(show3dObjectsSetting)
)
showAction(it, show3dObjectsSetting.toString())
}
}
}

private fun showAction(it: View, value: String) {
Toast.makeText(
this@StandardStyleActivity,
it.contentDescription.toString() + value,
Toast.LENGTH_SHORT
).show()
}

private enum class LightPresets(val value: Value) {
DAY(Value.valueOf("day")),
DAWN(Value.valueOf("dawn")),
DUSK(Value.valueOf("dusk")),
NIGHT(Value.valueOf("night"))
}

private enum class Theme(val value: Value) {
FADED(Value.valueOf("faded")),
MONOCHROME(Value.valueOf("monochrome")),
DEFAULT(Value.valueOf("default"))
}

companion object {
/**
* The ID used in [STYLE_URL] that references the `standard` style.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ class StyleSwitchActivity : AppCompatActivity() {
binding.outdoorsButton.setOnClickListener {
mapboxMap.loadStyle(Style.OUTDOORS)
}
binding.standardButton.setOnClickListener {
mapboxMap.loadStyle(Style.STANDARD)
}
binding.standardSatelliteButton.setOnClickListener {
mapboxMap.loadStyle(Style.STANDARD_SATELLITE)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ViewPagerActivity : AppCompatActivity() {
}

companion object {
private const val NUM_ITEMS = 5
private const val NUM_ITEMS = 6
}
}
}
Expand All @@ -75,6 +75,7 @@ fun getStyleFromIndex(index: Int): String {
2 -> Style.SATELLITE
3 -> Style.LIGHT
4 -> Style.TRAFFIC_NIGHT
5 -> Style.STANDARD_SATELLITE
else -> Style.STANDARD
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import java.util.*
*/
object AnnotationUtils {
private const val TAG = "AnnotationUtils"

val STYLES =
arrayOf(Style.STANDARD, Style.OUTDOORS, Style.LIGHT, Style.DARK, Style.SATELLITE_STREETS)
arrayOf(Style.STANDARD, Style.OUTDOORS, Style.LIGHT, Style.DARK, Style.SATELLITE_STREETS, Style.STANDARD_SATELLITE)
val SLOTS = arrayOf("top", "middle", "bottom")

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class CircleAnnotationActivity : AppCompatActivity() {
private fun switchToNextStyle() {
val style = nextStyle
binding.mapView.mapboxMap.loadStyle(style)
// only standard supports slots
binding.changeSlot.isEnabled = style == Style.STANDARD
// only standard based styles support slots
binding.changeSlot.isEnabled = (style == Style.STANDARD || style == Style.STANDARD_SATELLITE)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PointAnnotationClusterActivity : AppCompatActivity(), CoroutineScope {
private var slotIndex: Int = 0

// STANDARD style doesn't support ICON_FIRE_STATION image
private val styles = AnnotationUtils.STYLES.filterNot { it == Style.STANDARD }
private val styles = AnnotationUtils.STYLES.filterNot { it == Style.STANDARD || it == Style.STANDARD_SATELLITE }
private val nextStyle: String
get() = styles[styleIndex++ % styles.size]
private val nextSlot: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ViewAnnotationBasicAddActivity : AppCompatActivity(), OnMapClickListener {
binding.fabStyleToggle.setOnClickListener {
when (style?.styleURI) {
Style.STANDARD -> loadStyle(Style.SATELLITE_STREETS)
Style.SATELLITE_STREETS -> loadStyle(Style.STANDARD)
Style.SATELLITE_STREETS -> loadStyle(Style.STANDARD_SATELLITE)
Style.STANDARD_SATELLITE -> loadStyle(Style.STANDARD)
}
}
Toast.makeText(this@ViewAnnotationBasicAddActivity, STARTUP_TEXT, Toast.LENGTH_LONG).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class ViewAnnotationShowcaseActivity :
binding.fabStyleToggle.setOnClickListener {
when (style?.styleURI) {
Style.STANDARD -> loadStyle(prepareStyle(Style.SATELLITE_STREETS, bitmap))
Style.SATELLITE_STREETS -> loadStyle(prepareStyle(Style.STANDARD, bitmap))
Style.SATELLITE_STREETS -> loadStyle(prepareStyle(Style.STANDARD_SATELLITE, bitmap))
Style.STANDARD_SATELLITE -> loadStyle(prepareStyle(Style.STANDARD, bitmap))
}
}
Toast.makeText(this@ViewAnnotationShowcaseActivity, STARTUP_TEXT, Toast.LENGTH_LONG).show()
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/res/layout/activity_standard_style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,38 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab3dObjectsSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="16dp"
android:layout_marginBottom="214dp"
android:contentDescription="3dObjects: "
android:src="@android:drawable/ic_popup_reminder"
app:backgroundTint="@color/blue"
app:layout_anchorGravity="top" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabThemeSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="16dp"
android:layout_marginBottom="148dp"
android:contentDescription="Theme: "
android:src="@android:drawable/ic_menu_mapmode"
app:backgroundTint="@color/accent"
app:layout_anchorGravity="top" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabLightSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="16dp"
android:layout_marginBottom="82dp"
android:contentDescription="LightPreset: "
android:src="@android:drawable/ic_menu_view"
app:backgroundTint="@color/red"
app:layout_anchorGravity="top" />
Expand All @@ -26,6 +51,7 @@
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:contentDescription="Label visibility: "
android:src="@android:drawable/ic_dialog_info"
app:backgroundTint="@color/primary" />

Expand Down
44 changes: 36 additions & 8 deletions app/src/main/res/layout/activity_style_switch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,36 @@
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:mapbox_attributionEnabled="true"
app:mapbox_attributionGravity="top|right"
app:mapbox_attributionMarginBottom="32dp"
app:mapbox_attributionMarginLeft="32dp"
app:mapbox_attributionMarginRight="32dp"
app:mapbox_attributionMarginTop="32dp"
app:mapbox_compassImage="@drawable/custom_compass"
app:mapbox_compassEnabled="true"
app:mapbox_compassFadeWhenFacingNorth="false"
app:mapbox_compassGravity="left|top"
app:mapbox_compassImage="@drawable/custom_compass"
app:mapbox_compassMarginBottom="32dp"
app:mapbox_compassMarginLeft="32dp"
app:mapbox_compassMarginRight="32dp"
app:mapbox_compassMarginTop="32dp"
app:mapbox_gesturesDoubleTapToZoomInEnabled="false"
app:mapbox_gesturesPinchToZoomEnabled="false"
app:mapbox_gesturesPitchEnabled="false"
app:mapbox_gesturesQuickZoomEnabled="false"
app:mapbox_gesturesRotateEnabled="true"
app:mapbox_gesturesScrollEnabled="false"
app:mapbox_logoEnabled="true"
app:mapbox_logoGravity="bottom|right"
app:mapbox_logoMarginBottom="32dp"
app:mapbox_logoMarginLeft="32dp"
app:mapbox_logoMarginRight="32dp"
app:mapbox_logoMarginTop="32dp"
app:mapbox_gesturesQuickZoomEnabled="false"
app:mapbox_gesturesRotateEnabled="true"
app:mapbox_gesturesScrollEnabled="false"
app:mapbox_gesturesPitchEnabled="false"
app:mapbox_gesturesPinchToZoomEnabled="false" />
app:mapbox_logoMarginTop="32dp" />

<Button
android:id="@+id/satellite_streets_button"
Expand All @@ -76,6 +78,19 @@
app:layout_constraintTop_toTopOf="@+id/outdoors_button"
app:layout_constraintVertical_bias="0.0" />

<Button
android:id="@+id/standard_satellite_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/menu_map_style_standard_satellite"
android:textAllCaps="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/satellite_button"
app:layout_constraintStart_toStartOf="@+id/satellite_button"
app:layout_constraintTop_toBottomOf="@+id/satellite_button"
app:layout_constraintVertical_bias="0.0" />

<Button
android:id="@+id/dark_button"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -112,11 +127,24 @@
app:layout_constraintStart_toStartOf="@+id/dark_button"
app:layout_constraintTop_toBottomOf="@+id/dark_button" />

<Button
android:id="@+id/standard_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/menu_map_style_standard"
android:textAllCaps="false"
app:layout_constraintEnd_toEndOf="@+id/outdoors_button"
app:layout_constraintHorizontal_bias="0.784"
app:layout_constraintStart_toEndOf="@+id/light_button"
app:layout_constraintStart_toStartOf="@+id/outdoors_button"
app:layout_constraintTop_toBottomOf="@+id/outdoors_button" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.7" />
app:layout_constraintGuide_percent="0.67" />

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<string name="menu_map_style_dark">Dark</string>
<string name="menu_map_style_light">Light</string>
<string name="menu_map_style_outdoors">Outdoors</string>
<string name="menu_map_style_standard">Standard</string>
<string name="menu_map_style_satellite">Satellite</string>
<string name="menu_map_style_standard_satellite">Standard Satellite</string>
<string name="menu_map_style_satellite_streets">Satellite Streets</string>
<string name="toggle_focus_on_a_point">Toggle focus on a point</string>
<string name="toggle_velocity_animations">Toggle deceleration animations</string>
Expand Down
Loading

0 comments on commit 1c246b9

Please sign in to comment.