diff options
Diffstat (limited to 'androidApp/src')
5 files changed, 25 insertions, 15 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index 06d3d97..17fc9d4 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -1,6 +1,7 @@ package mx.trackermap.TrackerMap.android.map import android.graphics.Bitmap +import android.graphics.Color import android.graphics.Typeface import android.os.Bundle import android.util.Log @@ -48,6 +49,11 @@ class MapFragment : GlobeMapFragment() { return MapDisplayType.Map } + override fun preControlCreated() { + super.preControlCreated() + mapSettings.clearColor = Color.WHITE + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -237,9 +243,11 @@ class MapFragment : GlobeMapFragment() { mbr.expandByFraction(0.1) mapControl?.addPostSurfaceRunnable { - val zoom = mapControl.findHeightToViewBounds(mbr, mbr.middle()) - .coerceAtLeast(mapControl.zoomLimitMin) - mapControl.setPositionGeo(mbr.middle(), zoom) + mapControl?.let { + val zoom = it.findHeightToViewBounds(mbr, mbr.middle()) + .coerceAtLeast(mapControl.zoomLimitMin) + it.setPositionGeo(mbr.middle(), zoom) + } } } } @@ -328,10 +336,7 @@ class MapFragment : GlobeMapFragment() { val lat = latitude * Math.PI / 180 val lon = longitude * Math.PI / 180 // Ensure height is equal or higher than bottom limit - Log.d("MapFragment", "Target: %7.7f".format(height)) - Log.d("MapFragment", "Min: %7.7f".format(mapControl.zoomLimitMin)) val z = height.coerceAtLeast(mapControl.zoomLimitMin) - Log.d("MapFragment", "Final: %7.7f".format(z)) if (animated) { mapControl.animatePositionGeo(lon, lat, z, 0.2) } else { @@ -346,7 +351,6 @@ class MapFragment : GlobeMapFragment() { val cacheDirMap = File(it.cacheDir, cacheDirName) cacheDirMap.mkdir() Log.d("MapFragment", "Cache dir for $url = ${cacheDirMap.absolutePath}") - (tileInfo as? RemoteTileInfoNew)?.cacheDir = cacheDirMap tileInfo } diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt index cb5edc3..0658f56 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt @@ -68,8 +68,7 @@ class UnitMapFragment(private val unitsViewModel: UnitsViewModel) : UnitFragment unitsMapFragment.display( units.mapNotNull(MarkerTransformations::unitToMarker).toTypedArray(), - isReport = false, - center = unitsViewModel.selectedUnit.value == null + isReport = false ) } @@ -102,8 +101,7 @@ class UnitMapFragment(private val unitsViewModel: UnitsViewModel) : UnitFragment unitsViewModel.mapLayerType.observe(viewLifecycleOwner) { type -> Log.d("UnitMapFragment", "Loading layer!") unitsMapFragment.updateLayer(type) - val selectedUnit = unitsViewModel.selectedUnit.value - selectedUnit?.let { + unitsViewModel.selectedUnit.value?.let { unitsMapFragment.focusOn(it.position!!.latitude!!, it.position!!.longitude!!) } val layer = MapLayer.layers[type]!! diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt index 25169fe..d8ced28 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt @@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.TooltipCompat import androidx.core.widget.doAfterTextChanged +import androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_FADE import androidx.fragment.app.commit import kotlinx.coroutines.DelicateCoroutinesApi import mx.trackermap.TrackerMap.android.R @@ -79,7 +80,9 @@ class UnitsActivity : AppCompatActivity() { } binding.searchInput.doAfterTextChanged { Log.d("UnitsActivity", "Search changed to ${it.toString()}") - binding.searchInput + if (unitsViewModel.unitsDisplayMode.value == UnitsViewModel.UnitsDisplayMode.MAP) { + unitsViewModel.setDisplayMode(UnitsViewModel.UnitsDisplayMode.LIST) + } unitsViewModel.search(it.toString()) } binding.searchInputLayout.setEndIconOnClickListener { @@ -150,6 +153,10 @@ class UnitsActivity : AppCompatActivity() { } supportFragmentManager.commit { replace(R.id.displayContainer, newFragment) + if (displayMode == UnitsViewModel.UnitsDisplayMode.LIST) { + addToBackStack(null) + } + setTransition(TRANSIT_FRAGMENT_FADE) } } unitsViewModel.selectedUnit.observe(this) { @@ -159,5 +166,6 @@ class UnitsActivity : AppCompatActivity() { private fun removeObservers() { unitsViewModel.unitsDisplayMode.removeObservers(this) + unitsViewModel.selectedUnit.removeObservers(this) } }
\ No newline at end of file diff --git a/androidApp/src/main/res/layout/unit_map_fragment.xml b/androidApp/src/main/res/layout/unit_map_fragment.xml index e2bee95..a86a7e9 100644 --- a/androidApp/src/main/res/layout/unit_map_fragment.xml +++ b/androidApp/src/main/res/layout/unit_map_fragment.xml @@ -15,7 +15,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" android:name="mx.trackermap.TrackerMap.android.map.MapFragment" - tools:visibility="invisible"/> + tools:visibility="visible"/> <androidx.cardview.widget.CardView android:id="@+id/mapUnitCard" diff --git a/androidApp/src/main/res/layout/units_activity.xml b/androidApp/src/main/res/layout/units_activity.xml index a468151..5abb95b 100644 --- a/androidApp/src/main/res/layout/units_activity.xml +++ b/androidApp/src/main/res/layout/units_activity.xml @@ -7,14 +7,14 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <FrameLayout + <androidx.fragment.app.FragmentContainerView android:id="@+id/displayContainer" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent"/> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/displayModeToggle" |