diff options
Diffstat (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android')
3 files changed, 22 insertions, 12 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 |