@@ -78,6 +78,7 @@ import com.aws.amazonlocation.utils.DELAY_300
78
78
import com.aws.amazonlocation.utils.DELAY_500
79
79
import com.aws.amazonlocation.utils.Distance.DISTANCE_IN_METER_10
80
80
import com.aws.amazonlocation.utils.Durations
81
+ import com.aws.amazonlocation.utils.Durations.DELAY_FOR_BOTTOM_SHEET_LOAD
81
82
import com.aws.amazonlocation.utils.EventType
82
83
import com.aws.amazonlocation.utils.EventType.PLACE_SEARCH
83
84
import com.aws.amazonlocation.utils.EventType.ROUTE_OPTION_CHANGED
@@ -97,8 +98,6 @@ import com.aws.amazonlocation.utils.LANGUAGE_CODE_HEBREW_1
97
98
import com.aws.amazonlocation.utils.MAP_STYLE_ATTRIBUTION
98
99
import com.aws.amazonlocation.utils.MILES
99
100
import com.aws.amazonlocation.utils.MapHelper
100
- import com.aws.amazonlocation.utils.PREFS_KEY_IDENTITY_ID
101
- import com.aws.amazonlocation.utils.PREFS_NAME_AUTH
102
101
import com.aws.amazonlocation.utils.STRING_FORMAT
103
102
import com.aws.amazonlocation.utils.SignOutInterface
104
103
import com.aws.amazonlocation.utils.SimulationDialogInterface
@@ -124,6 +123,7 @@ import com.aws.amazonlocation.utils.isRunningTest3LiveLocation
124
123
import com.aws.amazonlocation.utils.isRunningTestLiveLocation
125
124
import com.aws.amazonlocation.utils.locationPermissionDialog
126
125
import com.aws.amazonlocation.utils.show
126
+ import com.aws.amazonlocation.utils.showKeyboard
127
127
import com.aws.amazonlocation.utils.showViews
128
128
import com.aws.amazonlocation.utils.simulationExit
129
129
import com.aws.amazonlocation.utils.textChanges
@@ -162,7 +162,6 @@ import org.maplibre.android.maps.MapLibreMap
162
162
import org.maplibre.android.maps.OnMapReadyCallback
163
163
import org.maplibre.geojson.Point
164
164
import org.maplibre.geojson.Point.fromLngLat
165
- import software.amazon.location.auth.EncryptedSharedPreferences
166
165
167
166
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
168
167
@@ -211,7 +210,6 @@ class ExploreFragment :
211
210
private var mTravelMode: String = RouteTravelMode .Car .value
212
211
private var mRouteFinish: Boolean = false
213
212
private var mRedirectionType: String? = null
214
- private var encryptedSharedPreferences: EncryptedSharedPreferences ? = null
215
213
216
214
private var gpsActivityResult =
217
215
registerForActivityResult(
@@ -726,10 +724,7 @@ class ExploreFragment :
726
724
collectionName : String ,
727
725
position1 : List <Double >? ,
728
726
) {
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()
733
728
identityId?.let {
734
729
mSimulationViewModel.evaluateGeofence(
735
730
collectionName,
@@ -1143,9 +1138,10 @@ class ExploreFragment :
1143
1138
}
1144
1139
} else {
1145
1140
bottomSheetDirectionSearch.apply {
1146
- clSearchLoaderDirectionSearch .root.show ()
1141
+ layoutNoDataFound .root.hide ()
1147
1142
rvSearchPlacesSuggestionDirection.hide()
1148
1143
rvSearchPlacesDirection.hide()
1144
+ clSearchLoaderDirectionSearch.root.show()
1149
1145
}
1150
1146
}
1151
1147
}.onSuccess {
@@ -1207,6 +1203,8 @@ class ExploreFragment :
1207
1203
bottomSheetDirection.apply {
1208
1204
groupDistanceLoad.show()
1209
1205
groupDistance.invisible()
1206
+ btnDirection.alpha = 0.5F
1207
+ btnDirection.isEnabled = false
1210
1208
}
1211
1209
}
1212
1210
} else {
@@ -1218,6 +1216,8 @@ class ExploreFragment :
1218
1216
if (! mBottomSheetHelper.isDirectionSearchSheetVisible()) {
1219
1217
bottomSheetDirection.apply {
1220
1218
groupDistanceLoad.hide()
1219
+ btnDirection.alpha = 1.0F
1220
+ btnDirection.isEnabled = true
1221
1221
groupDistance.show()
1222
1222
tvDirectionError.hide()
1223
1223
tvDirectionError2.hide()
@@ -1515,6 +1515,8 @@ class ExploreFragment :
1515
1515
if (! mBottomSheetHelper.isDirectionSearchSheetVisible()) {
1516
1516
bottomSheetDirection.apply {
1517
1517
groupDistanceLoad.hide()
1518
+ btnDirection.isEnabled = true
1519
+ btnDirection.alpha = 1.0F
1518
1520
groupDistance.show()
1519
1521
tvDirectionTime.hide()
1520
1522
tvDirectionDot.invisible()
@@ -2000,8 +2002,8 @@ class ExploreFragment :
2000
2002
val mText =
2001
2003
mBinding.bottomSheetSearch.edtSearchPlaces.text
2002
2004
.toString()
2003
- if (validateLatLng(mText) != null ) {
2004
- val mLatLng = validateLatLng(mText)
2005
+ if (validateLatLng(mText.trim() ) != null ) {
2006
+ val mLatLng = validateLatLng(mText.trim() )
2005
2007
if (it.text == (mLatLng?.latitude.toString() + " ," + mLatLng?.longitude.toString())) {
2006
2008
setPlaceData(it, searchPlaceIndexText)
2007
2009
}
@@ -2046,7 +2048,7 @@ class ExploreFragment :
2046
2048
it : SearchSuggestionResponse ,
2047
2049
searchPlaceIndexText : SearchApiEnum ,
2048
2050
) {
2049
- val mText: String =
2051
+ var mText: String =
2050
2052
if (! isDataSearchForDestination) {
2051
2053
mBinding.bottomSheetDirectionSearch.edtSearchDirection.text
2052
2054
.toString()
@@ -2056,6 +2058,10 @@ class ExploreFragment :
2056
2058
.toString()
2057
2059
.trim()
2058
2060
}
2061
+ if (validateLatLng(mText) != null ) {
2062
+ val mLatLng = validateLatLng(mText)
2063
+ mText = mLatLng?.latitude.toString() + " ," + mLatLng?.longitude.toString()
2064
+ }
2059
2065
if (! it.text.isNullOrEmpty() &&
2060
2066
it.text
2061
2067
.toString()
@@ -2111,7 +2117,7 @@ class ExploreFragment :
2111
2117
if (mPlaceList.isNotEmpty()) {
2112
2118
clNoInternetConnectionDirectionSearch.hide()
2113
2119
nsDirectionSearchPlaces.show()
2114
- layoutNoDataFound.groupNoSearchFound .hide()
2120
+ layoutNoDataFound.root .hide()
2115
2121
layoutCardError.groupCardErrorNoSearchFound.hide()
2116
2122
when (searchPlaceIndexText) {
2117
2123
SearchApiEnum .SEARCH_PLACE_INDEX_TEXT -> {
@@ -2126,7 +2132,7 @@ class ExploreFragment :
2126
2132
}
2127
2133
} else {
2128
2134
hideViews(rvSearchPlacesDirection, nsDirectionSearchPlaces)
2129
- layoutNoDataFound.groupNoSearchFound .show()
2135
+ layoutNoDataFound.root .show()
2130
2136
}
2131
2137
}
2132
2138
}
@@ -2211,7 +2217,17 @@ class ExploreFragment :
2211
2217
private fun clickListener () {
2212
2218
mBinding.apply {
2213
2219
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
+ }
2215
2231
}
2216
2232
2217
2233
cardNavigation.setOnClickListener {
@@ -2806,8 +2822,7 @@ class ExploreFragment :
2806
2822
lifecycleScope.launch {
2807
2823
activity?.hideKeyboard()
2808
2824
delay(DELAY_300 )
2809
- mBinding.bottomSheetSearch.clSearchLoaderSearchSheet.root
2810
- .hide()
2825
+ mBinding.bottomSheetSearch.clSearchLoaderSearchSheet.root.hide()
2811
2826
mMapHelper.addLiveLocationMarker(false )
2812
2827
mBottomSheetHelper.hideDirectionSearchBottomSheet(this @ExploreFragment)
2813
2828
hideDirectionBottomSheet()
@@ -2816,22 +2831,22 @@ class ExploreFragment :
2816
2831
2817
2832
mBinding.bottomSheetDirection.apply {
2818
2833
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()
2835
2850
}
2836
2851
}
2837
2852
ivInfo.setOnClickListener {
@@ -3104,6 +3119,7 @@ class ExploreFragment :
3104
3119
mIsAvoidFerries = mPreferenceManager.getValue(KEY_AVOID_FERRIES , false )
3105
3120
cardDirection.hide()
3106
3121
bottomSheetDirectionSearch.clSearchLoaderDirectionSearch.root.hide()
3122
+ bottomSheetDirectionSearch.layoutNoDataFound.root.hide()
3107
3123
bottomSheetSearch.edtSearchPlaces.setText(" " )
3108
3124
bottomSheetSearch.edtSearchPlaces.clearFocus()
3109
3125
mBaseActivity?.bottomNavigationVisibility(false )
@@ -3136,6 +3152,10 @@ class ExploreFragment :
3136
3152
mPlaceList.clear()
3137
3153
mAdapterDirection?.notifyDataSetChanged()
3138
3154
mSearchPlacesDirectionSuggestionAdapter?.notifyDataSetChanged()
3155
+ if (! edtSearchDest.hasFocus()) {
3156
+ edtSearchDirection.requestFocus()
3157
+ }
3158
+ mBaseActivity?.showKeyboard()
3139
3159
}
3140
3160
mBottomSheetHelper.expandDirectionSearchSheet(this @ExploreFragment)
3141
3161
mIsDirectionSheetHalfExpanded = false
@@ -3902,7 +3922,7 @@ class ExploreFragment :
3902
3922
tvTruckSelected,
3903
3923
tvWalkSelected,
3904
3924
layoutCardError.root,
3905
- layoutNoDataFound.groupNoSearchFound ,
3925
+ layoutNoDataFound.root ,
3906
3926
)
3907
3927
}
3908
3928
mBinding.bottomSheetDirection.apply {
0 commit comments