Skip to content

Commit

Permalink
Autofill improvements; Dependencies bump; SDK release (#92)
Browse files Browse the repository at this point in the history
* Autofill improvements

* Bump Native Search SDK, Maps SDK, Common SDK

* Bump SDK version to 1.0.0-beta.39
  • Loading branch information
DzmitryFomchyn committed Oct 21, 2022
1 parent fb54334 commit 15a8586
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 16 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Changelog for the Mapbox Search SDK for Android

## 1.0.0-beta.39-SNAPSHOT
## 1.0.0-beta.39

### New features
- [Autofill] Now `AutofillSuggestion` provides a new property `name`.
- [Autofill] Minimal allowed query name has been changed from `3` to `2`.

### Mapbox dependencies
- Search Native SDK `0.61.0`
- Common SDK `23.1.0-rc.1`
- Search Native SDK `0.62.0`
- Common SDK `23.1.0`
- Kotlin `1.5.31`


Expand Down
4 changes: 3 additions & 1 deletion MapboxSearch/autofill/api/api-metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ package com.mapbox.search.autofill {
@kotlinx.parcelize.Parcelize public final class AddressAutofillSuggestion implements android.os.Parcelable {
method public com.mapbox.geojson.Point getCoordinate();
method public String getFormattedAddress();
method public String getName();
method public com.mapbox.search.autofill.AddressAutofillResult result();
property public final com.mapbox.geojson.Point coordinate;
property public final String formattedAddress;
property public final String name;
}

@kotlinx.parcelize.Parcelize public final class AddressComponents implements android.os.Parcelable {
Expand Down Expand Up @@ -91,7 +93,7 @@ package com.mapbox.search.autofill {
method public String getQuery();
property public final String query;
field public static final com.mapbox.search.autofill.Query.Companion Companion;
field public static final int MIN_QUERY_LENGTH = 3; // 0x3
field public static final int MIN_QUERY_LENGTH = 2; // 0x2
}

public static final class Query.Companion {
Expand Down
1 change: 1 addition & 0 deletions MapboxSearch/autofill/api/autofill.api
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public final class com/mapbox/search/autofill/AddressAutofillSuggestion : androi
public fun equals (Ljava/lang/Object;)Z
public final fun getCoordinate ()Lcom/mapbox/geojson/Point;
public final fun getFormattedAddress ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public fun hashCode ()I
public final fun result ()Lcom/mapbox/search/autofill/AddressAutofillResult;
public fun toString ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ internal class AddressAutofillImpl(private val searchEngine: AutofillSearchEngin
fun BaseSearchResult.toAddressAutofillSuggestion(): AddressAutofillSuggestion? {
// Filtering incomplete results
val autofillAddress = AddressComponents.fromCoreSdkAddress(address) ?: return null
val formattedAddress = descriptionText ?: autofillAddress.formattedAddress()
val validCoordinate = coordinate

return AddressAutofillSuggestion(
formattedAddress = formattedAddress,
name = name,
formattedAddress = autofillAddress.formattedAddress(),
address = autofillAddress,
coordinate = validCoordinate,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import kotlinx.parcelize.Parcelize
@Parcelize
public class AddressAutofillSuggestion internal constructor(

/**
* Suggestion name.
*/
public val name: String,

/**
* Textual representation of the address.
*/
Expand Down Expand Up @@ -43,6 +48,7 @@ public class AddressAutofillSuggestion internal constructor(

other as AddressAutofillSuggestion

if (name != other.name) return false
if (formattedAddress != other.formattedAddress) return false
if (coordinate != other.coordinate) return false
if (address != other.address) return false
Expand All @@ -54,7 +60,8 @@ public class AddressAutofillSuggestion internal constructor(
* @suppress
*/
override fun hashCode(): Int {
var result = formattedAddress.hashCode()
var result = name.hashCode()
result = 31 * result + formattedAddress.hashCode()
result = 31 * result + coordinate.hashCode()
result = 31 * result + address.hashCode()
return result
Expand All @@ -64,6 +71,10 @@ public class AddressAutofillSuggestion internal constructor(
* @suppress
*/
override fun toString(): String {
return "AddressAutofillSuggestion(formattedAddress='$formattedAddress', coordinate=$coordinate)"
return "AddressAutofillSuggestion(" +
"name='$name', " +
"formattedAddress='$formattedAddress', " +
"coordinate=$coordinate" +
")"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Query internal constructor(
/**
* Minimal allowed query length for address autofill.
*/
public const val MIN_QUERY_LENGTH: Int = 3
public const val MIN_QUERY_LENGTH: Int = 2

/**
* Creates [Query] instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal class AddressAutofillResponseTest {
val blue = AddressAutofillResponse.Suggestions(
suggestions = listOf(
AddressAutofillSuggestion(
name = "test name",
formattedAddress = "test address",
coordinate = Point.fromLngLat(10.0, 20.0),
address = AddressComponents.fromCoreSdkAddress(BaseSearchAddress(country = "test"))!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ internal class AddressAutofillSuggestionTest {
@TestFactory
fun `Check AddressAutofillSuggestion result() function`() = TestCase {
Given("${AddressAutofillSuggestion::class.java.simpleName} instance") {
val name = "Test name"
val formattedAddress = "Test formatted address"
val coordinate = Point.fromLngLat(10.0, 11.0)
val address = AddressComponents.fromCoreSdkAddress(BaseSearchAddress(country = "test"))!!

val suggestion = AddressAutofillSuggestion(formattedAddress, coordinate, address)
val suggestion = AddressAutofillSuggestion(name, formattedAddress, coordinate, address)

When("result() function called") {
val result = AddressAutofillResult(suggestion, address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class QueryTest {
fun `Check Query's min length`() = TestCase {
Given("${Query::class.java.simpleName} class") {
When("MIN_QUERY_LENGTH accessed") {
Then("MIN_QUERY_LENGTH should be 3", 3, Query.MIN_QUERY_LENGTH)
Then("MIN_QUERY_LENGTH should be 2", 2, Query.MIN_QUERY_LENGTH)
}
}
}
Expand All @@ -23,7 +23,7 @@ internal class QueryTest {
.map { length -> "a".repeat(length) }
.forEach { query ->
When("create($query) called") {
val value = if (query.length < 3) {
val value = if (query.length < 2) {
null
} else {
Query(query)
Expand Down
2 changes: 1 addition & 1 deletion MapboxSearch/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android.enableJetifier=false
kotlin.code.style=official

# SDK version attributes
VERSION_NAME=1.0.0-beta.39-SNAPSHOT
VERSION_NAME=1.0.0-beta.39

# Artifact attributes
mapboxArtifactUserOrg=mapbox
Expand Down
6 changes: 3 additions & 3 deletions MapboxSearch/gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ ext {

pitest_version = '1.6.7'

mapbox_maps_version = '10.9.0-rc.1'
common_sdk_version = '23.1.0-rc.1'
mapbox_maps_version = '10.9.0'
common_sdk_version = '23.1.0'
mapbox_base_version = '0.8.0'
mapbox_android_core_version = '5.0.2'

search_native_version = '0.61.0'
search_native_version = '0.62.0'

detekt_version = '1.19.0'

Expand Down

0 comments on commit 15a8586

Please sign in to comment.