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

[SDK] Added a graphics preset switcher to the navigation #225

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
16 changes: 16 additions & 0 deletions app/src/main/java/ru/dgis/sdk/demo/NavigationActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.RadioGroup
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -25,6 +26,7 @@ import ru.dgis.sdk.demo.databinding.ActivityNavigationBinding
import ru.dgis.sdk.demo.vm.NavigationViewModel
import ru.dgis.sdk.geometry.point
import ru.dgis.sdk.map.DgisMapObject
import ru.dgis.sdk.map.GraphicsPreset
import ru.dgis.sdk.map.Map
import ru.dgis.sdk.map.MapView
import ru.dgis.sdk.map.ScreenDistance
Expand All @@ -42,6 +44,7 @@ class NavigationActivity : AppCompatActivity(), TouchEventsObserver {

private var viewModel: NavigationViewModel? = null

private lateinit var graphicPreset: RadioGroup
private lateinit var map: Map
private lateinit var mapView: MapView
private lateinit var binding: ActivityNavigationBinding
Expand All @@ -56,6 +59,8 @@ class NavigationActivity : AppCompatActivity(), TouchEventsObserver {
binding = ActivityNavigationBinding.inflate(layoutInflater)
setContentView(binding.root)

graphicPreset = findViewById(R.id.graphicPreset)
graphicPreset.check(R.id.normalPreset)
mapView = findViewById(R.id.mapView)
routeEditorView = findViewById(R.id.routeEditorView)
navigationView = findViewById(R.id.navigationView)
Expand All @@ -76,6 +81,17 @@ class NavigationActivity : AppCompatActivity(), TouchEventsObserver {
)
}
)
it.graphicsPreset = GraphicsPreset.NORMAL
}
}

graphicPreset.setOnCheckedChangeListener { _, checkedId ->
mapView.getMapAsync { map ->
when (checkedId) {
R.id.litePreset -> map.graphicsPreset = GraphicsPreset.LITE
R.id.normalPreset -> map.graphicsPreset = GraphicsPreset.NORMAL
R.id.immersivePreset -> map.graphicsPreset = GraphicsPreset.IMMERSIVE
}
}
}

Expand Down
36 changes: 36 additions & 0 deletions app/src/main/res/layout/activity_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,41 @@
android:text="Use simulation"
tools:ignore="HardcodedText" />

<RadioGroup
android:id="@+id/graphicPreset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:paddingStart="24dp"
android:paddingEnd="24dp">

<RadioButton
android:id="@+id/litePreset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lite"
tools:ignore="HardcodedText" />

<RadioButton
android:id="@+id/normalPreset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Normal"
tools:ignore="HardcodedText" />

<RadioButton
android:id="@+id/immersivePreset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Immersive"
tools:ignore="HardcodedText" />

</RadioGroup>

<TextView
android:id="@+id/availabilityTextView"
android:layout_width="match_parent"
Expand All @@ -173,6 +208,7 @@
tools:ignore="HardcodedText" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

<androidx.constraintlayout.widget.Group
android:id="@+id/route_editing_group"
android:layout_width="wrap_content"
Expand Down
Loading