Skip to content

Commit

Permalink
Use cases improvements; 1.0.0-rc.4 (#153)
Browse files Browse the repository at this point in the history
* Fix distanceMeters not being requested; ETA for place autocomplete results

* AddressAutofill api refactoring

* Bump SDK version to 1.0.0-rc.4
  • Loading branch information
DzmitryFomchyn authored May 10, 2023
1 parent f2fcb1e commit b6778b3
Show file tree
Hide file tree
Showing 41 changed files with 331 additions and 212 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog for the Mapbox Search SDK for Android

## 1.0.0-rc.4

### New features
- [Place Autocomplete] Now `PlaceAutocompleteSuggestion` and `PlaceAutocompleteResult` provide new property `etaMinutes`.
- [Place Autocomplete] Now `PlaceAutocompleteOptions` accepts an additional parameter `navigationProfile` that determines how the distance and time of arrival (ETA) will be calculated.

### Breaking changes
- [CORE] `SearchNavigationProfile` type has been renamed to `NavigationProfile` and moved to `com.mapbox.search.common` package.
- [Address Autofill] `AddressAutofillSuggestion.result()` function has been removed. Use `AddressAutofill.select(AddressAutofillSuggestion)` instead. Note that developers must call this function when user selects a search suggestion in the UI.

### Bug fixes
- [Place Autocomplete] Fixed a bug with missing `PlaceAutocompleteSuggestion.distanceMeters`.

### Mapbox dependencies
- Search Native SDK `0.68.0`
- Common SDK `23.3.1`
- Kotlin `1.5.31`



## 1.0.0-rc.3

### New features
Expand Down
2 changes: 1 addition & 1 deletion MapboxSearch/autofill/api/api-metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package com.mapbox.search.autofill {
public interface AddressAutofill {
method public default static com.mapbox.search.autofill.AddressAutofill create(String accessToken, com.mapbox.android.core.location.LocationEngine locationEngine = defaultLocationEngine());
method public default static final com.mapbox.search.autofill.AddressAutofill create(String accessToken);
method public suspend Object? select(com.mapbox.search.autofill.AddressAutofillSuggestion suggestion, kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,com.mapbox.search.autofill.AddressAutofillResult>> p);
method public suspend Object? suggestions(com.mapbox.geojson.Point point, com.mapbox.search.autofill.AddressAutofillOptions options, kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,java.util.List<com.mapbox.search.autofill.AddressAutofillSuggestion>>> p);
method public suspend Object? suggestions(com.mapbox.search.autofill.Query query, com.mapbox.search.autofill.AddressAutofillOptions options, kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,java.util.List<com.mapbox.search.autofill.AddressAutofillSuggestion>>> p);
field public static final com.mapbox.search.autofill.AddressAutofill.Companion Companion;
Expand Down Expand Up @@ -34,7 +35,6 @@ package com.mapbox.search.autofill {
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;
Expand Down
2 changes: 1 addition & 1 deletion MapboxSearch/autofill/api/autofill.api
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ public abstract interface class com/mapbox/search/autofill/AddressAutofill {
public static final field Companion Lcom/mapbox/search/autofill/AddressAutofill$Companion;
public static fun create (Ljava/lang/String;)Lcom/mapbox/search/autofill/AddressAutofill;
public static fun create (Ljava/lang/String;Lcom/mapbox/android/core/location/LocationEngine;)Lcom/mapbox/search/autofill/AddressAutofill;
public abstract fun select (Lcom/mapbox/search/autofill/AddressAutofillSuggestion;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun suggestions (Lcom/mapbox/geojson/Point;Lcom/mapbox/search/autofill/AddressAutofillOptions;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun suggestions (Lcom/mapbox/search/autofill/Query;Lcom/mapbox/search/autofill/AddressAutofillOptions;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
Expand Down Expand Up @@ -46,7 +47,6 @@ public final class com/mapbox/search/autofill/AddressAutofillSuggestion : androi
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;
public fun writeToParcel (Landroid/os/Parcel;I)V
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ internal class AddressAutofillIntegrationTest {
assertEquals("740 15th St NW", firstSuggestion.name)
assertEquals(Point.fromLngLat(-77.03375, 38.89936), firstSuggestion.coordinate)

val resultAddress = firstSuggestion.result().address
val selectionResponse = runBlocking {
addressAutofill.select(firstSuggestion)
}
assertTrue(selectionResponse.isValue)

val resultAddress = requireNotNull(selectionResponse.value).address
assertEquals("740", resultAddress.houseNumber)
assertEquals("15th St NW", resultAddress.street)
assertEquals(null, resultAddress.neighborhood)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public interface AddressAutofill {
options: AddressAutofillOptions
): Expected<Exception, List<AddressAutofillSuggestion>>

/**
* Retrieves detailed information about the [AddressAutofillSuggestion].
* Use this function to end search session even if you don't need detailed information.
*
* Subject to change: in future, you may be charged for a suggestion call in case your UX flow
* accepts one of suggestions as selected and uses the coordinates,
* but you don’t call [select] method to confirm this. Other than that suggestions calls are not billed.
*
* @param suggestion Suggestion to select
* @return Result of the select request, one of error or value.
*/
public suspend fun select(suggestion: AddressAutofillSuggestion): Expected<Exception, AddressAutofillResult>

/**
* Companion object.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.mapbox.search.autofill
import android.app.Application
import com.mapbox.android.core.location.LocationEngine
import com.mapbox.bindgen.Expected
import com.mapbox.bindgen.ExpectedFactory
import com.mapbox.geojson.Point
import com.mapbox.search.base.MapboxApiClient
import com.mapbox.search.base.SearchRequestContextProvider
Expand Down Expand Up @@ -67,6 +68,14 @@ internal class AddressAutofillImpl(
}
}

override suspend fun select(
suggestion: AddressAutofillSuggestion
): Expected<Exception, AddressAutofillResult> {
activityReporter.reportActivity("address-autofill-suggestion-select")

return ExpectedFactory.createValue(AddressAutofillResult(suggestion, suggestion.address))
}

internal companion object {

private val DEFAULT_EXECUTOR: ExecutorService = Executors.newSingleThreadExecutor { runnable ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,10 @@ public class AddressAutofillSuggestion internal constructor(
/**
* @suppress
*/
private val address: AddressComponents,
@JvmSynthetic
internal val address: AddressComponents,
) : Parcelable {

/**
* Returns resolved [AddressAutofillResult] object.
* @return resolved [AddressAutofillResult] object.
*/
public fun result(): AddressAutofillResult {
return AddressAutofillResult(this, address)
}

/**
* @suppress
*/
Expand All @@ -51,7 +44,6 @@ public class AddressAutofillSuggestion internal constructor(
if (name != other.name) return false
if (formattedAddress != other.formattedAddress) return false
if (coordinate != other.coordinate) return false
if (address != other.address) return false

return true
}
Expand All @@ -63,7 +55,6 @@ public class AddressAutofillSuggestion internal constructor(
var result = name.hashCode()
result = 31 * result + formattedAddress.hashCode()
result = 31 * result + coordinate.hashCode()
result = 31 * result + address.hashCode()
return result
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
package com.mapbox.search.autofill

import com.mapbox.geojson.Point
import com.mapbox.search.base.result.BaseSearchAddress
import com.mapbox.search.common.tests.CommonSdkTypeObjectCreators
import com.mapbox.search.common.tests.ReflectionObjectsFactory
import com.mapbox.search.common.tests.ToStringVerifier
import com.mapbox.search.common.tests.withPrefabTestBoundingBox
import com.mapbox.search.common.tests.withPrefabTestPoint
import io.mockk.mockk
import nl.jqno.equalsverifier.EqualsVerifier
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

internal class AddressAutofillSuggestionTest {

@Test
fun `Check AddressAutofillSuggestion result() function`() {
val address = requireNotNull(
AddressComponents.fromCoreSdkAddress(
BaseSearchAddress(country = "test"),
mockk()
)
)

val suggestion = AddressAutofillSuggestion(
name = "Test name",
formattedAddress = "Test formatted address",
coordinate = Point.fromLngLat(10.0, 11.0),
address = address
)

assertEquals(
AddressAutofillResult(suggestion, address),
suggestion.result()
)
}

@Test
fun `equals() and hashCode() functions are correct`() {
EqualsVerifier.forClass(AddressAutofillSuggestion::class.java)
Expand Down
10 changes: 10 additions & 0 deletions MapboxSearch/discover/api/api-metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ package com.mapbox.search.discover {
method public suspend Object? search(com.mapbox.search.discover.DiscoverQuery query, java.util.List<com.mapbox.geojson.Point> route, com.mapbox.search.discover.RouteDeviationOptions deviation = RouteDeviationOptions.DEFAULT_DEVIATION, com.mapbox.search.discover.DiscoverOptions options = DiscoverOptions(), kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,java.util.List<com.mapbox.search.discover.DiscoverResult>>> p = DiscoverOptions());
method public com.mapbox.search.common.AsyncOperationTask search(com.mapbox.search.discover.DiscoverQuery query, java.util.List<com.mapbox.geojson.Point> route, com.mapbox.search.discover.RouteDeviationOptions deviation, com.mapbox.search.discover.DiscoverOptions options, java.util.concurrent.Executor executor, com.mapbox.search.common.CompletionCallback<java.util.List<com.mapbox.search.discover.DiscoverResult>> callback);
method public default com.mapbox.search.common.AsyncOperationTask search(com.mapbox.search.discover.DiscoverQuery query, java.util.List<com.mapbox.geojson.Point> route, com.mapbox.search.discover.RouteDeviationOptions deviation, com.mapbox.search.discover.DiscoverOptions options, com.mapbox.search.common.CompletionCallback<java.util.List<com.mapbox.search.discover.DiscoverResult>> callback);
field public static final com.mapbox.search.discover.Discover.Companion Companion;
}

public static final class Discover.Companion {
method public com.mapbox.search.discover.Discover create(String accessToken, com.mapbox.android.core.location.LocationEngine locationEngine = defaultLocationEngine());
method public com.mapbox.search.discover.Discover create(String accessToken);
}

@kotlinx.parcelize.Parcelize public final class DiscoverAddress implements android.os.Parcelable {
Expand Down Expand Up @@ -112,9 +118,13 @@ package com.mapbox.search.discover {
ctor public RouteDeviationOptions.SarType(String rawName);
method public String getRawName();
property public final String rawName;
field public static final com.mapbox.search.discover.RouteDeviationOptions.SarType.Companion Companion;
field public static final com.mapbox.search.discover.RouteDeviationOptions.SarType ISOCHROME;
}

public static final class RouteDeviationOptions.SarType.Companion {
}

@kotlinx.parcelize.Parcelize public static final class RouteDeviationOptions.Time extends com.mapbox.search.discover.RouteDeviationOptions {
ctor public RouteDeviationOptions.Time(long value, java.util.concurrent.TimeUnit unit, com.mapbox.search.discover.RouteDeviationOptions.SarType? sarType = com.mapbox.search.discover.RouteDeviationOptions.SarType.ISOCHROME);
ctor public RouteDeviationOptions.Time(long value, java.util.concurrent.TimeUnit unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public interface Discover {
}

/**
* @suppress
* Companion object.
*/
public companion object {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class RouteDeviationOptions internal constructor() : Parcelable
}

/**
* @suppress
* Companion object.
*/
public companion object {

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-rc.3
VERSION_NAME=1.0.0-rc.4

# Artifact attributes
mapboxArtifactUserOrg=mapbox
Expand Down
13 changes: 13 additions & 0 deletions MapboxSearch/place-autocomplete/api/api-metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ package com.mapbox.search.autocomplete {
method public suspend Object? select(com.mapbox.search.autocomplete.PlaceAutocompleteSuggestion suggestion, kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,com.mapbox.search.autocomplete.PlaceAutocompleteResult>> p);
method public suspend Object? suggestions(String query, com.mapbox.geojson.BoundingBox? region = null, com.mapbox.geojson.Point? proximity = null, com.mapbox.search.autocomplete.PlaceAutocompleteOptions options = PlaceAutocompleteOptions(), kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,java.util.List<com.mapbox.search.autocomplete.PlaceAutocompleteSuggestion>>> p = PlaceAutocompleteOptions());
method public suspend Object? suggestions(com.mapbox.geojson.Point point, com.mapbox.search.autocomplete.PlaceAutocompleteOptions options = PlaceAutocompleteOptions(), kotlin.coroutines.Continuation<? super com.mapbox.bindgen.Expected<java.lang.Exception,java.util.List<com.mapbox.search.autocomplete.PlaceAutocompleteSuggestion>>> p = PlaceAutocompleteOptions());
field public static final com.mapbox.search.autocomplete.PlaceAutocomplete.Companion Companion;
}

public static final class PlaceAutocomplete.Companion {
method public com.mapbox.search.autocomplete.PlaceAutocomplete create(String accessToken, com.mapbox.android.core.location.LocationEngine locationEngine = defaultLocationEngine());
method public com.mapbox.search.autocomplete.PlaceAutocomplete create(String accessToken);
}

@kotlinx.parcelize.Parcelize public final class PlaceAutocompleteAddress implements android.os.Parcelable {
Expand Down Expand Up @@ -37,17 +43,20 @@ package com.mapbox.search.autocomplete {
}

@kotlinx.parcelize.Parcelize public final class PlaceAutocompleteOptions implements android.os.Parcelable {
ctor public PlaceAutocompleteOptions(int limit = 10, java.util.List<com.mapbox.search.common.IsoCountryCode>? countries = null, com.mapbox.search.common.IsoLanguageCode language = defaultLocaleLanguage(), java.util.List<? extends com.mapbox.search.autocomplete.PlaceAutocompleteType>? types = null, com.mapbox.search.common.NavigationProfile? navigationProfile = null);
ctor public PlaceAutocompleteOptions(int limit = 10, java.util.List<com.mapbox.search.common.IsoCountryCode>? countries = null, com.mapbox.search.common.IsoLanguageCode language = defaultLocaleLanguage(), java.util.List<? extends com.mapbox.search.autocomplete.PlaceAutocompleteType>? types = null);
ctor public PlaceAutocompleteOptions(int limit = 10, java.util.List<com.mapbox.search.common.IsoCountryCode>? countries = null, com.mapbox.search.common.IsoLanguageCode language = defaultLocaleLanguage());
ctor public PlaceAutocompleteOptions(int limit = 10, java.util.List<com.mapbox.search.common.IsoCountryCode>? countries = null);
ctor public PlaceAutocompleteOptions(int limit = 10);
method public java.util.List<com.mapbox.search.common.IsoCountryCode>? getCountries();
method public com.mapbox.search.common.IsoLanguageCode getLanguage();
method public int getLimit();
method public com.mapbox.search.common.NavigationProfile? getNavigationProfile();
method public java.util.List<com.mapbox.search.autocomplete.PlaceAutocompleteType>? getTypes();
property public final java.util.List<com.mapbox.search.common.IsoCountryCode>? countries;
property public final com.mapbox.search.common.IsoLanguageCode language;
property public final int limit;
property public final com.mapbox.search.common.NavigationProfile? navigationProfile;
property public final java.util.List<com.mapbox.search.autocomplete.PlaceAutocompleteType>? types;
}

Expand All @@ -57,6 +66,7 @@ package com.mapbox.search.autocomplete {
method public java.util.List<java.lang.String>? getCategories();
method public com.mapbox.geojson.Point getCoordinate();
method public Double? getDistanceMeters();
method public Double? getEtaMinutes();
method public String? getMakiIcon();
method public String getName();
method public com.mapbox.search.common.metadata.OpenHours? getOpenHours();
Expand All @@ -72,6 +82,7 @@ package com.mapbox.search.autocomplete {
property public final java.util.List<java.lang.String>? categories;
property public final com.mapbox.geojson.Point coordinate;
property public final Double? distanceMeters;
property public final Double? etaMinutes;
property public final String? makiIcon;
property public final String name;
property public final com.mapbox.search.common.metadata.OpenHours? openHours;
Expand All @@ -88,6 +99,7 @@ package com.mapbox.search.autocomplete {
method public java.util.List<java.lang.String>? getCategories();
method public com.mapbox.geojson.Point getCoordinate();
method public Double? getDistanceMeters();
method public Double? getEtaMinutes();
method public String? getFormattedAddress();
method public String? getMakiIcon();
method public String getName();
Expand All @@ -96,6 +108,7 @@ package com.mapbox.search.autocomplete {
property public final java.util.List<java.lang.String>? categories;
property public final com.mapbox.geojson.Point coordinate;
property public final Double? distanceMeters;
property public final Double? etaMinutes;
property public final String? formattedAddress;
property public final String? makiIcon;
property public final String name;
Expand Down
Loading

0 comments on commit b6778b3

Please sign in to comment.