Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d602e07
[23657] - [WIP] refactor bottom sheet handling to support dynamic con…
MichaelReyes Jun 7, 2025
78f8206
Merge branch 'refs/heads/task/23642-home-card-items-refactoring' into…
MichaelReyes Jun 12, 2025
1ba3f9d
Rename .java to .kt
MichaelReyes Jun 13, 2025
a8def40
[23642] - TripPreview navigation initialization changes
MichaelReyes Jun 13, 2025
6af80d0
[23642] - [TripGo] update HomeFragment to implement TKUICardHost getM…
MichaelReyes Jun 13, 2025
41c34d9
[23657] - [TripGo] update RouteCardFragment and remove usages of even…
MichaelReyes Jun 18, 2025
39c473a
Merge branch 'refs/heads/develop' into task/23657-bottom-sheet-cards-…
MichaelReyes Jul 2, 2025
5192dd1
[23657] - [TripKitUI] fixing merge conflicts
MichaelReyes Jul 2, 2025
7eed1c4
Merge branch 'refs/heads/develop' into task/23657-bottom-sheet-cards-…
MichaelReyes Jul 7, 2025
1689b0a
[23657] - [TripKit] Fix OkHttp timeout configurations
MichaelReyes Jul 8, 2025
dff8f03
[23657] - [TripKit] Fix failing test
MichaelReyes Jul 11, 2025
bce5528
[23657] - Fix navigation from TripDetails screen that causes the user…
MichaelReyes Jul 16, 2025
3923c0a
[23657] - Navigation checking fixes by properly settings fragment tag…
MichaelReyes Jul 17, 2025
264fa4b
Merge branch 'refs/heads/develop' into task/23657-bottom-sheet-cards-…
MichaelReyes Jul 18, 2025
d1e194b
[23657] - fix for map pin inconsistent behavior and pin location bott…
MichaelReyes Jul 23, 2025
d48e400
[23657] - update HomeFragment to rename setShowPoiMarkers function fr…
MichaelReyes Jul 25, 2025
e33a282
Merge branch 'refs/heads/develop' into task/23657-bottom-sheet-cards-…
MichaelReyes Aug 4, 2025
0d13d8a
[23657] - add timeout to get location call to ensure it won't block u…
MichaelReyes Aug 7, 2025
82d5865
Merge branch 'refs/heads/develop' into task/23657-bottom-sheet-cards-…
MichaelReyes Aug 7, 2025
d55bafc
[23657] - update tripkit-android and tripkit-android-ui submodule ref…
MichaelReyes Aug 7, 2025
b95369a
[24457][24455] - Add dialog to ask to enable location and settings or…
MichaelReyes Aug 21, 2025
67b14b9
[23657] - convert ScheduledStopRepository to use Room database
MichaelReyes Aug 25, 2025
33aca08
[23657] - Fixed ZoomLevel.fromLevel() method that was returning null …
MichaelReyes Aug 26, 2025
6b676e7
[23657] - implement clear non regional markers with debounce if 500ms
MichaelReyes Aug 28, 2025
192639c
[23657] - zoom level stops fetcher logic update
MichaelReyes Aug 29, 2025
3c66410
Merge branch 'refs/heads/develop' into task/23657-bottom-sheet-cards-…
MichaelReyes Sep 3, 2025
dc915e2
[23657] - additional merge conflicts fixes
MichaelReyes Sep 3, 2025
06b5898
[23657] - additional merge conflicts fixes
MichaelReyes Sep 3, 2025
3c627e5
[23657] - additional merge conflicts fixes
MichaelReyes Sep 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.skedgo.tripkit.ui.controller.homeviewcontroller

import android.Manifest
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -63,6 +65,8 @@ import com.skedgo.tripkit.ui.utils.deFocusAndHideKeyboard
import com.skedgo.tripkit.ui.utils.hideKeyboard
import com.skedgo.tripkit.ui.utils.isPermissionGranted
import com.skedgo.tripkit.ui.utils.replaceFragment
import com.skedgo.tripkit.ui.utils.showConfirmationPopUpDialog
import com.skedgo.tripkit.checkIfLocationProviderIsEnabled
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
Expand Down Expand Up @@ -429,7 +433,8 @@ class TKUIHomeViewControllerFragment :
}

override fun reloadMapMarkers() {
mapFragment.setShowPoiMarkers(true, emptyList())
// Use the new restoration method to properly restore previous state
mapFragment.restorePoiMarkersState()

Observable.timer(500, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -668,6 +673,20 @@ class TKUIHomeViewControllerFragment :
}

private fun checkLocationPermission(callback: (Boolean) -> Unit) {
// First check if device location is enabled
if (!requireContext().checkIfLocationProviderIsEnabled()) {
requireContext().showConfirmationPopUpDialog(
title = getString(R.string.location_services_required),
message = getString(R.string.device_location_is_turned_off),
positiveLabel = getString(R.string.settings),
positiveCallback = {
val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
startActivity(intent)
}
)
return
}

ExcuseMe.couldYouGive(this)
.permissionFor(Manifest.permission.ACCESS_FINE_LOCATION) {
callback.invoke(it.granted.contains(Manifest.permission.ACCESS_FINE_LOCATION))
Expand Down Expand Up @@ -770,15 +789,13 @@ class TKUIHomeViewControllerFragment :
segmentId: Long,
fromTripAction: Boolean = false
) {
val pageIndexStream = PublishSubject.create<Pair<Long, String>>()
val paymentDataStream = PublishSubject.create<PaymentData>()
val ticketActionStream = PublishSubject.create<String>()

tripSegmentOnPreview = tripSegment

val headerFragment =
TripPreviewHeaderFragment.newInstance(
pageIndexStream,
tripSegment.trip?.hideExactTimes == true ||
tripSegment.trip?.segmentList?.any { it.isHideExactTimes } ?: false
)
Expand All @@ -789,7 +806,6 @@ class TKUIHomeViewControllerFragment :
tripSegment.trip!!.uuid, segmentId,
initTripPreviewPagerFragmentListener(tripSegment),
fromTripAction,
pageIndexStream,
paymentDataStream,
ticketActionStream
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ class TKUILocationSearchViewControllerFragment :
}

fun setQuery(query: String, isRouting: Boolean = false) {
locationSearchFragment?.setQuery(query, isRouting)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery(query, isRouting)
}
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.skedgo.tripkit.ui.controller.routeviewcontroller

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.provider.Settings
import android.text.Editable
import android.text.TextWatcher
import android.view.View
Expand Down Expand Up @@ -33,6 +35,8 @@ import com.skedgo.tripkit.ui.core.addTo
import com.skedgo.tripkit.ui.databinding.FragmentTkuiRouteBinding
import com.skedgo.tripkit.ui.search.FixedSuggestions
import com.skedgo.tripkit.ui.utils.showKeyboard
import com.skedgo.tripkit.ui.utils.showConfirmationPopUpDialog
import com.skedgo.tripkit.checkIfLocationProviderIsEnabled
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -71,7 +75,11 @@ class TKUIRouteFragment : BaseFragment<FragmentTkuiRouteBinding>() {
// Only pay attention if one of the EditText's has focus. When the swap button is pressed, both
// focuses are cleared so we won't trigger a new query
if (!ignoreNextTextChange && (binding.tieStartEdit.hasFocus() || binding.tieDestinationEdit.hasFocus())) {
locationSearchFragment?.setQuery(text.toString(), true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery(text.toString(), true)
}
}

if (text.toString().isEmpty()) {
setCorrectLocation(null)
Expand Down Expand Up @@ -113,17 +121,33 @@ class TKUIRouteFragment : BaseFragment<FragmentTkuiRouteBinding>() {
if (v == binding.tieStartEdit && hasFocus) {
focusedField = binding.tieStartEdit
if (viewModel.startLocation?.locationType != Location.TYPE_CURRENT_LOCATION) {
locationSearchFragment?.setQuery(binding.tieStartEdit.text.toString(), true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery(binding.tieStartEdit.text.toString(), true)
}
}
} else {
locationSearchFragment?.setQuery("", true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery("", true)
}
}
}
viewModel.focusedField = TKUIRouteViewModel.FocusedField.START
} else if (v == binding.tieDestinationEdit && hasFocus) {
focusedField = binding.tieDestinationEdit
if (viewModel.destinationLocation?.locationType != Location.TYPE_CURRENT_LOCATION) {
locationSearchFragment?.setQuery(binding.tieDestinationEdit.text.toString(), true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery(binding.tieDestinationEdit.text.toString(), true)
}
}
} else {
locationSearchFragment?.setQuery("", true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery("", true)
}
}
}
viewModel.focusedField = TKUIRouteViewModel.FocusedField.DESTINATION
}
Expand Down Expand Up @@ -232,14 +256,22 @@ class TKUIRouteFragment : BaseFragment<FragmentTkuiRouteBinding>() {
viewModel.startLocation = null
toggleShowCurrentLocation()
binding.tieStartEdit.requestFocus()
locationSearchFragment?.setQuery("", true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery("", true)
}
}
}
binding.tilDestinationEdit.setEndIconOnClickListener {
ignoreNextTextChange = true
viewModel.destinationLocation = null
toggleShowCurrentLocation()
binding.tieDestinationEdit.requestFocus()
locationSearchFragment?.setQuery("", true)
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery("", true)
}
}
}
}

Expand Down Expand Up @@ -345,6 +377,20 @@ class TKUIRouteFragment : BaseFragment<FragmentTkuiRouteBinding>() {
}

private suspend fun getCurrentLocation() {
// First check if device location is enabled
if (!requireContext().checkIfLocationProviderIsEnabled()) {
requireContext().showConfirmationPopUpDialog(
title = getString(R.string.location_services_required),
message = getString(R.string.device_location_is_turned_off),
positiveLabel = getString(R.string.settings),
positiveCallback = {
val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
startActivity(intent)
}
)
return
}

if (ExcuseMe.couldYouGive(this)
.permissionFor(android.Manifest.permission.ACCESS_FINE_LOCATION)
) {
Expand Down Expand Up @@ -448,7 +494,11 @@ class TKUIRouteFragment : BaseFragment<FragmentTkuiRouteBinding>() {
lat = 0.0
lon = 0.0
}
locationSearchFragment?.setQuery("") // To reset the list
locationSearchFragment?.let { fragment ->
if (fragment.isAdded && fragment.isVisible) {
fragment.setQuery("") // To reset the list
}
}
setCorrectLocation(fixedLocation)
lifecycleScope.launch {
getCurrentLocation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class TKUITimetableControllerFragment : BaseFragment<FragmentTkuiTimetableContro
time: Long
) {

mapFragment?.setShowPoiMarkers(false, null)
mapFragment?.setShowMarkers(false, null)

serviceDetailsFragment = ServiceDetailFragment.Builder()
.withStop(scheduledStop)
Expand All @@ -188,7 +188,7 @@ class TKUITimetableControllerFragment : BaseFragment<FragmentTkuiTimetableContro
}

private fun resetMapState() {
mapFragment?.setShowPoiMarkers(true, emptyList())
mapFragment?.setShowMarkers(true, emptyList())
val contributor = serviceDetailsFragment?.contributor()
if (contributor is TimetableMapContributor) {
contributor.getMapPreviousPosition().let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.skedgo.tripkit.ui.favorites.trips.FavoriteTrip
import com.skedgo.tripkit.ui.map.home.TripKitMapFragment
import com.skedgo.tripkit.ui.routingresults.TripGroupRepository
import com.skedgo.tripkit.ui.tripresult.TripResultPagerFragment
import com.skedgo.tripkit.ui.tripresult.TripResultPagerFragment.OnTripUpdatedListener
import com.skedgo.tripkit.ui.tripresult.TripSegmentListFragment
import com.skedgo.tripkit.ui.tripresults.actionbutton.ActionButtonHandlerFactory
import kotlinx.coroutines.CoroutineScope
Expand All @@ -30,7 +29,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.rx2.awaitFirstOrNull
import javax.inject.Inject


// TODO changes from TripDetailsFragment (TripGo) should also be applied here
class TKUITripDetailsViewControllerFragment :
BaseFragment<FragmentTkuiTripDetailsViewControllerBinding>() {

Expand Down Expand Up @@ -92,10 +91,18 @@ class TKUITripDetailsViewControllerFragment :
fun settled() {
tripKitMapFragment?.apply {
setContributor(pagerFragment?.contributor())
setShowPoiMarkers(false, null)
// Only disable POI markers temporarily while in trip details mode
setShowMarkers(false, null)
}
}

/**
* Restore map state when exiting trip details
*/
fun restoreMapState() {
tripKitMapFragment?.restorePoiMarkersState()
}

private fun initPagerFragment() {

if (pagerFragment == null) {
Expand Down Expand Up @@ -139,7 +146,7 @@ class TKUITripDetailsViewControllerFragment :
pagerFragment?.setOnCloseButtonListener {
eventBus.publish(ViewControllerEvent.OnCloseAction())
}
pagerFragment?.setOnTripUpdatedListener(object : OnTripUpdatedListener {
pagerFragment?.setOnTripUpdatedListener(object : TripResultPagerFragment.OnTripUpdatedListener {
override fun onTripUpdated(trip: Trip?) {
trip?.group?.let {
val list = ArrayList<TripGroup>()
Expand Down Expand Up @@ -192,6 +199,18 @@ class TKUITripDetailsViewControllerFragment :
pagerFragment?.updateTripGroupResult(tripGroup)
}

override fun onDestroyView() {
// Ensure map state is restored when fragment is destroyed
restoreMapState()
super.onDestroyView()
}

override fun onDetach() {
// Fallback restoration in case onDestroyView wasn't called
restoreMapState()
super.onDetach()
}

companion object {
const val TAG = "TKUITripDetailsViewControllerFragment"

Expand Down
Loading