From 41cdcd2316ff89a0b0538cdf9d934b5bd11cc32c Mon Sep 17 00:00:00 2001 From: Altonss <66519591+Altonss@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:47:42 +0100 Subject: [PATCH 1/4] Update DirectionsFragment.kt --- .../grobox/transportr/trips/search/DirectionsFragment.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt index e5c50f545..fd6405e57 100644 --- a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt +++ b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt @@ -111,8 +111,10 @@ class DirectionsFragment : TransportrFragment() { fromLocation.setLocation(it) if (it != null) toLocation.requestFocus() }) + viewModel.fromLocation.observe(viewLifecycleOwner, { onLocationsChanged() }) viewModel.viaLocation.observe(viewLifecycleOwner, { viaLocation.setLocation(it) }) viewModel.toLocation.observe(viewLifecycleOwner, { toLocation.setLocation(it) }) + viewModel.toLocation.observe(viewLifecycleOwner, { onLocationsChanged() }) viewModel.viaSupported.observe(viewLifecycleOwner, { viaIcon.visibility = if (it) VISIBLE else GONE }) viewModel.isDeparture.observe(viewLifecycleOwner, { onIsDepartureChanged(it) }) viewModel.isExpanded.observe(viewLifecycleOwner, { onViaVisibleChanged(it) }) @@ -148,6 +150,12 @@ class DirectionsFragment : TransportrFragment() { TooltipCompat.setTooltipText(viaIcon, getString(R.string.action_navigation_expand)) } + private fun onLocationsChanged() { + val fromNotEmpty = this.viewModel.fromLocation.value != null + val toNotEmpty = this.viewModel.toLocation.value != null + swapIcon.visibility = if (fromNotEmpty || toNotEmpty) VISIBLE else GONE + } + override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) outState.putSerializable(DATE, viewModel.lastQueryCalendar.value) @@ -272,3 +280,4 @@ class DirectionsFragment : TransportrFragment() { } } + From 1b09e8cb82626f8b491b43b4af24f0173d8e4e0b Mon Sep 17 00:00:00 2001 From: Altonss <66519591+Altonss@users.noreply.github.com> Date: Thu, 4 Jan 2024 21:17:38 +0100 Subject: [PATCH 2/4] Update app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt Co-authored-by: ialokim --- .../de/grobox/transportr/trips/search/DirectionsFragment.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt index fd6405e57..c0a972fe7 100644 --- a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt +++ b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt @@ -113,8 +113,10 @@ class DirectionsFragment : TransportrFragment() { }) viewModel.fromLocation.observe(viewLifecycleOwner, { onLocationsChanged() }) viewModel.viaLocation.observe(viewLifecycleOwner, { viaLocation.setLocation(it) }) - viewModel.toLocation.observe(viewLifecycleOwner, { toLocation.setLocation(it) }) - viewModel.toLocation.observe(viewLifecycleOwner, { onLocationsChanged() }) + viewModel.toLocation.observe(viewLifecycleOwner, { + toLocation.setLocation(it) + onLocationsChanged() + }) viewModel.viaSupported.observe(viewLifecycleOwner, { viaIcon.visibility = if (it) VISIBLE else GONE }) viewModel.isDeparture.observe(viewLifecycleOwner, { onIsDepartureChanged(it) }) viewModel.isExpanded.observe(viewLifecycleOwner, { onViaVisibleChanged(it) }) From b45882e93a4d20c5a9f2adc6b4f756ccdae1339b Mon Sep 17 00:00:00 2001 From: Altonss Date: Fri, 5 Jan 2024 00:51:29 +0100 Subject: [PATCH 3/4] Update DirectionsFragment.kt --- .../de/grobox/transportr/trips/search/DirectionsFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt index c0a972fe7..5d3adbb5a 100644 --- a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt +++ b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt @@ -110,8 +110,8 @@ class DirectionsFragment : TransportrFragment() { viewModel.fromLocation.observe(viewLifecycleOwner, { fromLocation.setLocation(it) if (it != null) toLocation.requestFocus() + onLocationsChanged() }) - viewModel.fromLocation.observe(viewLifecycleOwner, { onLocationsChanged() }) viewModel.viaLocation.observe(viewLifecycleOwner, { viaLocation.setLocation(it) }) viewModel.toLocation.observe(viewLifecycleOwner, { toLocation.setLocation(it) From 5767e76e32080caa687c8eb1ce8747ae88c9c8df Mon Sep 17 00:00:00 2001 From: Altonss Date: Mon, 8 Jan 2024 00:51:03 +0100 Subject: [PATCH 4/4] Update DirectionsFragment.kt --- .../de/grobox/transportr/trips/search/DirectionsFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt index 5d3adbb5a..3ee22c175 100644 --- a/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt +++ b/app/src/main/java/de/grobox/transportr/trips/search/DirectionsFragment.kt @@ -155,7 +155,9 @@ class DirectionsFragment : TransportrFragment() { private fun onLocationsChanged() { val fromNotEmpty = this.viewModel.fromLocation.value != null val toNotEmpty = this.viewModel.toLocation.value != null - swapIcon.visibility = if (fromNotEmpty || toNotEmpty) VISIBLE else GONE + swapIcon.isEnabled = fromNotEmpty || toNotEmpty + // If icon disabled, grey it out + swapIcon.alpha = if (swapIcon.isEnabled) 1.0f else 0.5f } override fun onSaveInstanceState(outState: Bundle) {