Skip to content

Commit cfd0146

Browse files
committed
Merge branch “feature/marker-list-to-compose”
2 parents 4a4ae42 + 290d609 commit cfd0146

12 files changed

Lines changed: 596 additions & 238 deletions

File tree

‎app/build.gradle‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ dependencies {
168168
implementation 'androidx.activity:activity-compose:1.13.0'
169169
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.11.0'
170170
implementation 'androidx.compose.runtime:runtime-livedata'
171+
implementation 'androidx.compose.material:material-icons-core'
172+
implementation 'androidx.compose.material:material-icons-extended'
171173

172174
debugImplementation 'androidx.compose.ui:ui-tooling'
173175
debugImplementation 'androidx.compose.ui:ui-test-manifest'

‎app/src/main/java/org/nitri/opentopo/CacheSettingsFragment.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CacheSettingsFragment : DialogFragment() {
117117
// Required for Compose TextFields inside AppCompat AlertDialog.
118118
// Without this, Compose receives focus but the soft keyboard may not appear.
119119
dialog.window?.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
120-
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
120+
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
121121
}
122122

123123
return dialog

‎app/src/main/java/org/nitri/opentopo/MapFragment.kt‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import org.nitri.opentopo.util.MapOrientation
5757
import org.nitri.opentopo.util.OrientationSensor
5858
import org.nitri.opentopo.util.Utils
5959
import org.nitri.opentopo.view.AboutDialog
60+
import org.nitri.opentopo.view.MarkerEditorDialog
6061
import org.nitri.opentopo.viewmodel.LocationViewModel
6162
import org.nitri.opentopo.viewmodel.MarkerViewModel
6263
import org.nitri.ors.OrsClient
@@ -319,7 +320,7 @@ class MapFragment : Fragment(), LocationListener, PopupMenu.OnMenuItemClickListe
319320
locationOverlay?.isOptionsMenuEnabled = true
320321
compassOverlay?.enableCompass()
321322
mapView.visibility = View.VISIBLE
322-
overlayHelper = OverlayHelper(hostActivity, mapView)
323+
overlayHelper = OverlayHelper(hostActivity, mapView, parentFragmentManager)
323324
setTilesOverlay()
324325
}
325326

@@ -328,6 +329,30 @@ class MapFragment : Fragment(), LocationListener, PopupMenu.OnMenuItemClickListe
328329
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
329330
super.onViewCreated(view, savedInstanceState)
330331

332+
parentFragmentManager.setFragmentResultListener(
333+
MarkerEditorDialog.RESULT_REQUEST_KEY,
334+
viewLifecycleOwner
335+
) { _, result ->
336+
val markerId = result.getInt(MarkerEditorDialog.RESULT_MARKER_ID)
337+
when (result.getString(MarkerEditorDialog.RESULT_ACTION)) {
338+
MarkerEditorDialog.RESULT_ACTION_UPDATE -> {
339+
val currentMarker = markerViewModel.markers.value
340+
?.firstOrNull { it.id == markerId }
341+
?: return@setFragmentResultListener
342+
343+
val updated = currentMarker.copy(
344+
name = result.getString(MarkerEditorDialog.RESULT_NAME).orEmpty(),
345+
description = result.getString(MarkerEditorDialog.RESULT_DESCRIPTION).orEmpty()
346+
)
347+
markerViewModel.updateMarker(updated)
348+
}
349+
350+
MarkerEditorDialog.RESULT_ACTION_DELETE -> {
351+
markerViewModel.removeMarker(markerId)
352+
}
353+
}
354+
}
355+
331356
viewLifecycleOwner.lifecycleScope.launch {
332357
if (!mapViewInitialized) {
333358
initializeMapView()

0 commit comments

Comments
 (0)