From 512e01c0ca36b336b3dc6437c6fb326614d020d0 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Thu, 30 Dec 2021 18:13:49 -0600 Subject: Accessibility fixes and removed bindings from MapFragment --- .../mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt | 1 + .../java/mx/trackermap/TrackerMap/android/map/MapFragment.kt | 9 +-------- .../java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt | 9 ++++++++- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'androidApp/src/main/java/mx/trackermap') diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt index 933316a..eb8dcbc 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt @@ -28,6 +28,7 @@ class DevicesFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View { + super.onCreateView(inflater, container, savedInstanceState) _binding = DevicesFragmentBinding.inflate(inflater, container, false) return binding.root } 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 f0ec769..289cc2d 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 @@ -19,8 +19,6 @@ import java.io.File @DelicateCoroutinesApi class MapFragment: GlobeMapFragment() { - private var _binding: MapFragmentBinding? = null - private val binding get() = _binding!! private val unitsViewModel: UnitsViewModel by viewModel() @@ -64,11 +62,6 @@ class MapFragment: GlobeMapFragment() { mapControl.animatePositionGeo(longitude, latitude, zoom, 1.0) } - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -133,7 +126,7 @@ class MapFragment: GlobeMapFragment() { val latitude = position.latitude!! * Math.PI / 180 val longitude = position.longitude!! * Math.PI / 180 val zoom = 0.000008 - mapControl.animatePositionGeo(longitude, latitude, zoom, 1.0) + mapControl.setPositionGeo(longitude, latitude, zoom) } } } 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 452ece7..ff8929e 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 @@ -66,12 +66,19 @@ class UnitsActivity : AppCompatActivity() { else -> R.drawable.ic_baseline_map_24 } ) + binding.displayModeToggle.contentDescription = getString( + when (displayMode) { + UnitsViewModel.UnitsDisplayMode.LIST -> R.string.toggle_map + UnitsViewModel.UnitsDisplayMode.MAP -> R.string.toggle_list + else -> R.string.toggle_map + } + ) val newFragment = when (displayMode) { UnitsViewModel.UnitsDisplayMode.LIST -> devicesFragment UnitsViewModel.UnitsDisplayMode.MAP -> mapFragment - else -> DevicesFragment() + else -> devicesFragment } supportFragmentManager.commit { replace(R.id.displayContainer, newFragment) -- cgit v1.2.3