diff --git a/README.md b/README.md index c053375c..b3d738c4 100644 --- a/README.md +++ b/README.md @@ -81,14 +81,14 @@ Include the dependency in your app `build.gradle`: ```groovy dependencies { - implementation 'com.adevinta.android:leku:9.1.0' + implementation 'com.adevinta.android:leku:9.1.1' } ``` Alternatively, if you are using a different version of Google Play Services and AndroidX use this instead: ```groovy -implementation ('com.adevinta.android:leku:9.1.0') { +implementation ('com.adevinta.android:leku:9.1.1') { exclude group: 'com.google.android.gms' exclude group: 'androidx.appcompat' } diff --git a/app/src/main/java/com/adevinta/mappicker/MainActivity.kt b/app/src/main/java/com/adevinta/mappicker/MainActivity.kt index 13f2eb33..b7933544 100644 --- a/app/src/main/java/com/adevinta/mappicker/MainActivity.kt +++ b/app/src/main/java/com/adevinta/mappicker/MainActivity.kt @@ -72,7 +72,7 @@ class MainActivity : AppCompatActivity() { .withLocation(DEMO_LATITUDE, DEMO_LONGITUDE) // .withGeolocApiKey("") // .withGooglePlacesApiKey("") - // .withSearchZone("es_ES") + .withSearchZone("es_ES") // .withSearchZone(SearchZoneRect(LatLng(26.525467, -18.910366), LatLng(43.906271, 5.394197))) .withDefaultLocaleSearchZone() // .shouldReturnOkOnBackPressed() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 795723cb..70c67c41 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,5 +5,5 @@ LAUNCH LEGACY MAP LOCATION ACTIVITY LAUNCH MAP WITH POIS LAUNCH MAP WITH STYLE - version 9.1.0 + version 9.1.1 diff --git a/gradle.properties b/gradle.properties index f34d0e45..a61eaa0f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx2048m org.gradle.configureondemand=false android.useAndroidX=true libGroup=com.adevinta.android -libVersion=9.1.0 +libVersion=9.1.1 diff --git a/leku/src/main/AndroidManifest.xml b/leku/src/main/AndroidManifest.xml index d5d8f891..4311f13a 100644 --- a/leku/src/main/AndroidManifest.xml +++ b/leku/src/main/AndroidManifest.xml @@ -20,8 +20,8 @@ - + diff --git a/leku/src/main/java/com/adevinta/leku/LocationPickerActivity.kt b/leku/src/main/java/com/adevinta/leku/LocationPickerActivity.kt index deb83250..1f1f8aba 100644 --- a/leku/src/main/java/com/adevinta/leku/LocationPickerActivity.kt +++ b/leku/src/main/java/com/adevinta/leku/LocationPickerActivity.kt @@ -364,10 +364,12 @@ class LocationPickerActivity : AppCompatActivity(), adapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, locationNameList) listResult?.let { it.adapter = adapter - it.setOnItemClickListener { _, _, i, _ -> - setNewLocation(locationList[i]) - changeListResultVisibility(View.GONE) - closeKeyboard() + it.setOnItemClickListener { _, _, position, _ -> + if (locationList[position].hasLatitude() && locationList[position].hasLongitude()) { + setNewLocation(locationList[position]) + changeListResultVisibility(View.GONE) + closeKeyboard() + } } } } else { @@ -375,10 +377,12 @@ class LocationPickerActivity : AppCompatActivity(), searchAdapter = LocationSearchAdapter( locationNameList, object : LocationSearchAdapter.SearchItemClickListener { override fun onItemClick(position: Int) { - setNewLocation(locationList[position]) - changeListResultVisibility(View.GONE) - closeKeyboard() - hideSearchLayout() + if (locationList[position].hasLatitude() && locationList[position].hasLongitude()) { + setNewLocation(locationList[position]) + changeListResultVisibility(View.GONE) + closeKeyboard() + hideSearchLayout() + } } } ) @@ -731,14 +735,24 @@ class LocationPickerActivity : AppCompatActivity(), fillLocationList(addresses) if (addresses.isNotEmpty()) { updateLocationNameList(addresses) - if (isLegacyLayoutEnabled) { - adapter?.notifyDataSetChanged() - } else { - searchAdapter?.notifyDataSetChanged() - } + } else { + setNoSearchResultsOnList() + } + + if (isLegacyLayoutEnabled) { + adapter?.notifyDataSetChanged() + } else { + searchAdapter?.notifyDataSetChanged() } } + private fun setNoSearchResultsOnList() { + val noResultsAddress = Address(Locale.getDefault()) + locationList.add(noResultsAddress) + locationNameList.clear() + locationNameList.add(getString(R.string.leku_no_search_results)) + } + override fun didLoadLocation() { progressBar?.visibility = View.GONE @@ -1048,10 +1062,16 @@ class LocationPickerActivity : AppCompatActivity(), } private fun getFormattedAddress(address: Address): String { - return if (address.subThoroughfare.isNullOrEmpty()) { - address.thoroughfare - } else { + return if (!address.thoroughfare.isNullOrEmpty() && !address.subThoroughfare.isNullOrEmpty()) { getString(R.string.leku_formatted_address, address.thoroughfare, address.subThoroughfare) + } else { + if (address.subThoroughfare.isNullOrEmpty() && !address.thoroughfare.isNullOrEmpty()) { + address.thoroughfare + } else if (address.thoroughfare.isNullOrEmpty() && !address.subThoroughfare.isNullOrEmpty()) { + address.subThoroughfare + } else { + address.getAddressLine(0) + } } } diff --git a/leku/src/main/res/values-es/strings.xml b/leku/src/main/res/values-es/strings.xml index 4650993a..f5380ba0 100644 --- a/leku/src/main/res/values-es/strings.xml +++ b/leku/src/main/res/values-es/strings.xml @@ -3,7 +3,7 @@ Location Picker Servicio no disponible Algo ha ido mal. Por favor inténtelo de nuevo. - No hay resultados para su búsqueda + No se han encontrado resultados network ubicación desconocida Búsqueda por voz… diff --git a/leku/src/main/res/values/strings.xml b/leku/src/main/res/values/strings.xml index 3120b040..f3c889c8 100644 --- a/leku/src/main/res/values/strings.xml +++ b/leku/src/main/res/values/strings.xml @@ -4,7 +4,7 @@ Location Picker Service not available Something went wrong. Please try again. - There are no results for your search + There are no search results network unknown location Search by voice…