Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[location-component] Remove stale state, max/min zoom scale options and puck presets. #19

Merged
merged 3 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.appcompat.content.res.AppCompatResources
import com.mapbox.maps.Style
import com.mapbox.maps.plugin.LocationPuck2D
import com.mapbox.maps.plugin.LocationPuck3D
import com.mapbox.maps.plugin.PresetPuckStyle
import com.mapbox.maps.plugin.locationcomponent.getLocationComponentPlugin
import com.mapbox.maps.testapp.R
import com.mapbox.maps.testapp.utils.LocationPermissionHelper
Expand All @@ -35,16 +34,8 @@ class LocationComponentActivity : AppCompatActivity() {

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_puck_style_preset_change -> {
togglePresetPuckStyle()
return true
}
R.id.action_3d_puck_style_change -> {
toggle3DPuck()
return true
}
R.id.action_2d_puck_style_change -> {
toggle2DPuck()
R.id.action_customise_location_puck_change -> {
toggleCustomisedPuck()
return true
}
R.id.action_map_style_change -> {
Expand All @@ -63,27 +54,27 @@ class LocationComponentActivity : AppCompatActivity() {
}
}

private fun toggle3DPuck() {
private fun toggleCustomisedPuck() {
mapView.getLocationComponentPlugin().let {
if (it.locationPuck == null) {
it.locationPuck = LocationPuck3D(
when (it.locationPuck) {
is LocationPuck3D -> it.locationPuck = LocationPuck2D(
topImage = AppCompatResources.getDrawable(
this,
com.mapbox.maps.plugin.locationcomponent.R.drawable.mapbox_user_icon
),
bearingImage = AppCompatResources.getDrawable(
this,
com.mapbox.maps.plugin.locationcomponent.R.drawable.mapbox_user_bearing_icon
),
shadowImage = AppCompatResources.getDrawable(
this,
com.mapbox.maps.plugin.locationcomponent.R.drawable.mapbox_user_stroke_icon
),
)
is LocationPuck2D -> it.locationPuck = LocationPuck3D(
pengdev marked this conversation as resolved.
Show resolved Hide resolved
modelUri = "asset://race_car_model.gltf",
modelScale = listOf(0.1f, 0.1f, 0.1f)
)
} else {
it.locationPuck = null
}
}
}

private fun toggle2DPuck() {
mapView.getLocationComponentPlugin().let {
if (it.locationPuck == null) {
it.locationPuck = LocationPuck2D(
bearingImage = ContextCompat.getDrawable(this, R.drawable.android_symbol)
)
} else {
it.locationPuck = null
}
}
}
Expand All @@ -95,25 +86,6 @@ class LocationComponentActivity : AppCompatActivity() {
}
}

private fun togglePresetPuckStyle() {
mapView.getLocationComponentPlugin().let {
if (it.locationPuck != null) {
it.locationPuck = null
}
when (it.presetPuckStyle) {
PresetPuckStyle.PRECISE -> {
it.presetPuckStyle = PresetPuckStyle.APPROXIMATE
}
PresetPuckStyle.APPROXIMATE -> {
it.presetPuckStyle = PresetPuckStyle.HEADING_ARROW
}
PresetPuckStyle.HEADING_ARROW -> {
it.presetPuckStyle = PresetPuckStyle.PRECISE
}
}
}
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/layout/activity_location_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_locationComponentEnabled = "true"
mapbox:mapbox_locationComponentStaleStateEnabled = "true"
mapbox:mapbox_locationComponentStaleStateTimeout = "500"
mapbox:mapbox_locationComponentPresetPuckStyle = "precise"
tools:context=".examples.LocationComponentActivity" />
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_locationComponentEnabled="true"
mapbox:mapbox_locationComponentStaleStateEnabled="true"
mapbox:mapbox_locationComponentPresetPuckStyle="heading_arrow"
mapbox:mapbox_locationComponentPulsingEnabled="true"
mapbox:mapbox_locationComponentPulsingMaxRadius="30dp"
tools:context=".examples.LocationComponentActivity" />
5 changes: 0 additions & 5 deletions app/src/main/res/layout/generated_test_locationcomponent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
mapbox:mapbox_locationComponentEnabled = "false"
mapbox:mapbox_locationComponentStaleStateEnabled = "false"
mapbox:mapbox_locationComponentStaleStateTimeout = "1000000"
mapbox:mapbox_locationComponentMinZoomIconScale = "0.9"
mapbox:mapbox_locationComponentMaxZoomIconScale = "0.9"
mapbox:mapbox_locationComponentPulsingEnabled = "false"
mapbox:mapbox_locationComponentPulsingColor = "#000000"
mapbox:mapbox_locationComponentPulsingMaxRadius = "10dp"
mapbox:mapbox_locationComponentLayerAbove = "testString"
mapbox:mapbox_locationComponentLayerBelow = "testString"
mapbox:mapbox_locationComponentPresetPuckStyle = "precise"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- End of generated file. -->
12 changes: 2 additions & 10 deletions app/src/main/res/menu/menu_location_component.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_puck_style_preset_change"
android:title="@string/toggle_preset_puck_style"
app:showAsAction="never"/>

<item android:id="@+id/action_3d_puck_style_change"
android:title="@string/toggle_3d_puck_style"
app:showAsAction="never"/>

<item android:id="@+id/action_2d_puck_style_change"
android:title="@string/toggle_2d_puck_style"
<item android:id="@+id/action_customise_location_puck_change"
android:title="@string/toggle_customised_puck"
app:showAsAction="never"/>

<item android:id="@+id/action_map_style_change"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
<string name="location_normal">Normal</string>
<string name="location_tracking">Tracking:</string>
<string name="location_none">None</string>
<string name="toggle_preset_puck_style">Toggle preset puck style</string>
<string name="toggle_3d_puck_style">Toggle 3D puck style</string>
<string name="toggle_2d_puck_style">Toggle 2D puck style</string>
<string name="toggle_customised_puck">Toggle customised puck style</string>
<string name="toggle_custom_locationlayer_style">Toggle custom LocationLayer style</string>
<string name="toggle_custom_map_style">Toggle custom Map style</string>
<string name="location_disable_component">Disable Component</string>
Expand Down
1 change: 1 addition & 0 deletions plugin-locationcomponent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
android {
compileSdkVersion(AndroidVersions.compileSdkVersion)
defaultConfig {
vectorDrawables.useSupportLibrary = true
minSdkVersion(AndroidVersions.minSdkVersion)
targetSdkVersion(AndroidVersions.targetSdkVersion)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down

This file was deleted.

Loading