@@ -78,6 +78,7 @@ import com.aws.amazonlocation.utils.DELAY_300
7878import com.aws.amazonlocation.utils.DELAY_500
7979import com.aws.amazonlocation.utils.Distance.DISTANCE_IN_METER_10
8080import com.aws.amazonlocation.utils.Durations
81+ import com.aws.amazonlocation.utils.Durations.DELAY_FOR_BOTTOM_SHEET_LOAD
8182import com.aws.amazonlocation.utils.EventType
8283import com.aws.amazonlocation.utils.EventType.PLACE_SEARCH
8384import com.aws.amazonlocation.utils.EventType.ROUTE_OPTION_CHANGED
@@ -97,8 +98,6 @@ import com.aws.amazonlocation.utils.LANGUAGE_CODE_HEBREW_1
9798import com.aws.amazonlocation.utils.MAP_STYLE_ATTRIBUTION
9899import com.aws.amazonlocation.utils.MILES
99100import com.aws.amazonlocation.utils.MapHelper
100- import com.aws.amazonlocation.utils.PREFS_KEY_IDENTITY_ID
101- import com.aws.amazonlocation.utils.PREFS_NAME_AUTH
102101import com.aws.amazonlocation.utils.STRING_FORMAT
103102import com.aws.amazonlocation.utils.SignOutInterface
104103import com.aws.amazonlocation.utils.SimulationDialogInterface
@@ -124,6 +123,7 @@ import com.aws.amazonlocation.utils.isRunningTest3LiveLocation
124123import com.aws.amazonlocation.utils.isRunningTestLiveLocation
125124import com.aws.amazonlocation.utils.locationPermissionDialog
126125import com.aws.amazonlocation.utils.show
126+ import com.aws.amazonlocation.utils.showKeyboard
127127import com.aws.amazonlocation.utils.showViews
128128import com.aws.amazonlocation.utils.simulationExit
129129import com.aws.amazonlocation.utils.textChanges
@@ -162,7 +162,6 @@ import org.maplibre.android.maps.MapLibreMap
162162import org.maplibre.android.maps.OnMapReadyCallback
163163import org.maplibre.geojson.Point
164164import org.maplibre.geojson.Point.fromLngLat
165- import software.amazon.location.auth.EncryptedSharedPreferences
166165
167166// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
168167
@@ -211,7 +210,6 @@ class ExploreFragment :
211210 private var mTravelMode: String = RouteTravelMode .Car .value
212211 private var mRouteFinish: Boolean = false
213212 private var mRedirectionType: String? = null
214- private var encryptedSharedPreferences: EncryptedSharedPreferences ? = null
215213
216214 private var gpsActivityResult =
217215 registerForActivityResult(
@@ -726,10 +724,7 @@ class ExploreFragment :
726724 collectionName : String ,
727725 position1 : List <Double >? ,
728726 ) {
729- if (encryptedSharedPreferences == null ) {
730- encryptedSharedPreferences = EncryptedSharedPreferences (requireContext(), PREFS_NAME_AUTH ).apply { initEncryptedSharedPreferences() }
731- }
732- val identityId = encryptedSharedPreferences?.get(PREFS_KEY_IDENTITY_ID )
727+ val identityId = mLocationProvider.getIdentityId()
733728 identityId?.let {
734729 mSimulationViewModel.evaluateGeofence(
735730 collectionName,
@@ -1143,9 +1138,10 @@ class ExploreFragment :
11431138 }
11441139 } else {
11451140 bottomSheetDirectionSearch.apply {
1146- clSearchLoaderDirectionSearch .root.show ()
1141+ layoutNoDataFound .root.hide ()
11471142 rvSearchPlacesSuggestionDirection.hide()
11481143 rvSearchPlacesDirection.hide()
1144+ clSearchLoaderDirectionSearch.root.show()
11491145 }
11501146 }
11511147 }.onSuccess {
@@ -1207,6 +1203,8 @@ class ExploreFragment :
12071203 bottomSheetDirection.apply {
12081204 groupDistanceLoad.show()
12091205 groupDistance.invisible()
1206+ btnDirection.alpha = 0.5F
1207+ btnDirection.isEnabled = false
12101208 }
12111209 }
12121210 } else {
@@ -1218,6 +1216,8 @@ class ExploreFragment :
12181216 if (! mBottomSheetHelper.isDirectionSearchSheetVisible()) {
12191217 bottomSheetDirection.apply {
12201218 groupDistanceLoad.hide()
1219+ btnDirection.alpha = 1.0F
1220+ btnDirection.isEnabled = true
12211221 groupDistance.show()
12221222 tvDirectionError.hide()
12231223 tvDirectionError2.hide()
@@ -1515,6 +1515,8 @@ class ExploreFragment :
15151515 if (! mBottomSheetHelper.isDirectionSearchSheetVisible()) {
15161516 bottomSheetDirection.apply {
15171517 groupDistanceLoad.hide()
1518+ btnDirection.isEnabled = true
1519+ btnDirection.alpha = 1.0F
15181520 groupDistance.show()
15191521 tvDirectionTime.hide()
15201522 tvDirectionDot.invisible()
@@ -2000,8 +2002,8 @@ class ExploreFragment :
20002002 val mText =
20012003 mBinding.bottomSheetSearch.edtSearchPlaces.text
20022004 .toString()
2003- if (validateLatLng(mText) != null ) {
2004- val mLatLng = validateLatLng(mText)
2005+ if (validateLatLng(mText.trim() ) != null ) {
2006+ val mLatLng = validateLatLng(mText.trim() )
20052007 if (it.text == (mLatLng?.latitude.toString() + " ," + mLatLng?.longitude.toString())) {
20062008 setPlaceData(it, searchPlaceIndexText)
20072009 }
@@ -2046,7 +2048,7 @@ class ExploreFragment :
20462048 it : SearchSuggestionResponse ,
20472049 searchPlaceIndexText : SearchApiEnum ,
20482050 ) {
2049- val mText: String =
2051+ var mText: String =
20502052 if (! isDataSearchForDestination) {
20512053 mBinding.bottomSheetDirectionSearch.edtSearchDirection.text
20522054 .toString()
@@ -2056,6 +2058,10 @@ class ExploreFragment :
20562058 .toString()
20572059 .trim()
20582060 }
2061+ if (validateLatLng(mText) != null ) {
2062+ val mLatLng = validateLatLng(mText)
2063+ mText = mLatLng?.latitude.toString() + " ," + mLatLng?.longitude.toString()
2064+ }
20592065 if (! it.text.isNullOrEmpty() &&
20602066 it.text
20612067 .toString()
@@ -2111,7 +2117,7 @@ class ExploreFragment :
21112117 if (mPlaceList.isNotEmpty()) {
21122118 clNoInternetConnectionDirectionSearch.hide()
21132119 nsDirectionSearchPlaces.show()
2114- layoutNoDataFound.groupNoSearchFound .hide()
2120+ layoutNoDataFound.root .hide()
21152121 layoutCardError.groupCardErrorNoSearchFound.hide()
21162122 when (searchPlaceIndexText) {
21172123 SearchApiEnum .SEARCH_PLACE_INDEX_TEXT -> {
@@ -2126,7 +2132,7 @@ class ExploreFragment :
21262132 }
21272133 } else {
21282134 hideViews(rvSearchPlacesDirection, nsDirectionSearchPlaces)
2129- layoutNoDataFound.groupNoSearchFound .show()
2135+ layoutNoDataFound.root .show()
21302136 }
21312137 }
21322138 }
@@ -2211,7 +2217,17 @@ class ExploreFragment :
22112217 private fun clickListener () {
22122218 mBinding.apply {
22132219 cardGeofenceMap.setOnClickListener {
2214- (activity as MainActivity ).geofenceClick()
2220+ lifecycleScope.launch {
2221+ if (mBottomSheetHelper.isDirectionSearchSheetVisible()) {
2222+ bottomSheetDirectionSearch.ivDirectionCloseDirectionSearch.performClick()
2223+ }
2224+ if (mBottomSheetHelper.isDirectionSheetVisible()) {
2225+ bottomSheetDirection.ivDirectionCloseDirection.performClick()
2226+ }
2227+ (activity as MainActivity ).geofenceClick()
2228+ delay(DELAY_FOR_BOTTOM_SHEET_LOAD )
2229+ mBottomSheetHelper.hideSearchBottomSheet(true )
2230+ }
22152231 }
22162232
22172233 cardNavigation.setOnClickListener {
@@ -2806,8 +2822,7 @@ class ExploreFragment :
28062822 lifecycleScope.launch {
28072823 activity?.hideKeyboard()
28082824 delay(DELAY_300 )
2809- mBinding.bottomSheetSearch.clSearchLoaderSearchSheet.root
2810- .hide()
2825+ mBinding.bottomSheetSearch.clSearchLoaderSearchSheet.root.hide()
28112826 mMapHelper.addLiveLocationMarker(false )
28122827 mBottomSheetHelper.hideDirectionSearchBottomSheet(this @ExploreFragment)
28132828 hideDirectionBottomSheet()
@@ -2816,22 +2831,22 @@ class ExploreFragment :
28162831
28172832 mBinding.bottomSheetDirection.apply {
28182833 btnDirection.setOnClickListener {
2819- if (checkInternetConnection()) {
2820- if (activity?.checkLocationPermission() == true ) {
2821- if (isGPSEnabled(requireContext()) ) {
2822- if ( mViewModel.mCarData?.routes?.get( 0 )?.legs ! = null ) {
2823- routeOption ()
2824- } else {
2825- openDirectionWithError()
2826- }
2827- } else {
2828- mViewModel.mCarData = null
2829- openDirectionWithError()
2830- }
2831- } else {
2832- mViewModel.mCarData = null
2833- openDirectionWithError()
2834- }
2834+ if (! checkInternetConnection()) return @setOnClickListener
2835+ if (cardLoaderSheet1.isVisible) return @setOnClickListener
2836+ if (activity?.checkLocationPermission() != true ) {
2837+ mViewModel.mCarData = null
2838+ openDirectionWithError ()
2839+ return @setOnClickListener
2840+ }
2841+ if ( ! isGPSEnabled(requireContext())) {
2842+ mViewModel.mCarData = null
2843+ openDirectionWithError()
2844+ return @setOnClickListener
2845+ }
2846+ if (mViewModel.mCarData?.routes?.get( 0 )?.legs == null ) {
2847+ openDirectionWithError()
2848+ } else {
2849+ routeOption()
28352850 }
28362851 }
28372852 ivInfo.setOnClickListener {
@@ -3104,6 +3119,7 @@ class ExploreFragment :
31043119 mIsAvoidFerries = mPreferenceManager.getValue(KEY_AVOID_FERRIES , false )
31053120 cardDirection.hide()
31063121 bottomSheetDirectionSearch.clSearchLoaderDirectionSearch.root.hide()
3122+ bottomSheetDirectionSearch.layoutNoDataFound.root.hide()
31073123 bottomSheetSearch.edtSearchPlaces.setText(" " )
31083124 bottomSheetSearch.edtSearchPlaces.clearFocus()
31093125 mBaseActivity?.bottomNavigationVisibility(false )
@@ -3136,6 +3152,10 @@ class ExploreFragment :
31363152 mPlaceList.clear()
31373153 mAdapterDirection?.notifyDataSetChanged()
31383154 mSearchPlacesDirectionSuggestionAdapter?.notifyDataSetChanged()
3155+ if (! edtSearchDest.hasFocus()) {
3156+ edtSearchDirection.requestFocus()
3157+ }
3158+ mBaseActivity?.showKeyboard()
31393159 }
31403160 mBottomSheetHelper.expandDirectionSearchSheet(this @ExploreFragment)
31413161 mIsDirectionSheetHalfExpanded = false
@@ -3902,7 +3922,7 @@ class ExploreFragment :
39023922 tvTruckSelected,
39033923 tvWalkSelected,
39043924 layoutCardError.root,
3905- layoutNoDataFound.groupNoSearchFound ,
3925+ layoutNoDataFound.root ,
39063926 )
39073927 }
39083928 mBinding.bottomSheetDirection.apply {
0 commit comments