Skip to content

Commit deec317

Browse files
AttributesSets option for Forward Api (#305)
* Attributes sets support for the Forward Api * Bump version and update changelog
1 parent 5506df1 commit deec317

File tree

8 files changed

+276
-7
lines changed

8 files changed

+276
-7
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog for the Mapbox Search SDK for Android
22

3+
## 2.7.1
4+
5+
### New features
6+
- New option `ForwardSearchOptions.attributeSets` is available. It allows to request additional metadata attributes besides the basic ones.
7+
8+
### Mapbox dependencies
9+
- Search Native SDK `2.7.0`
10+
- Common SDK `24.9.0`
11+
12+
13+
314
## 2.7.0
415

516
### New features

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Mapbox Search SDK for Android version 1.0
44

55
Mapbox Search Android SDK
66

7-
Copyright © 2021 - 2024 Mapbox, Inc. All rights reserved.
7+
Copyright © 2021 - 2025 Mapbox, Inc. All rights reserved.
88

99
The software and files in this repository (collectively, "Software") are licensed under the Mapbox TOS for use only with the relevant Mapbox product(s) listed at www.mapbox.com/pricing. This license allows developers with a current active Mapbox account to use and modify the authorized portions of the Software as needed for use only with the relevant Mapbox product(s) through their Mapbox account in accordance with the Mapbox TOS. This license terminates automatically if a developer no longer has a Mapbox account in good standing or breaches the Mapbox TOS. For the license terms, please see the Mapbox TOS at https://www.mapbox.com/legal/tos/ which incorporates the Mapbox Product Terms at www.mapbox.com/legal/service-terms. If this Software is a SDK, modifications that change or interfere with marked portions of the code related to billing, accounting, or data collection are not authorized and the SDK sends limited de-identified location and usage data which is used in accordance with the Mapbox TOS. [Updated 2023-03]
1010
---------------------------------------

MapboxSearch/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android.enableJetifier=false
2121
kotlin.code.style=official
2222

2323
# SDK version attributes
24-
VERSION_NAME=2.7.0
24+
VERSION_NAME=2.7.1
2525

2626
# Artifact attributes
2727
mapboxArtifactUserOrg=mapbox

MapboxSearch/sample/src/main/java/com/mapbox/search/sample/api/ForwardApiKotlinExampleActivity.kt

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.mapbox.search.sample.api
22

33
import android.os.Bundle
4+
import com.mapbox.geojson.Point
45
import com.mapbox.search.ApiType
6+
import com.mapbox.search.AttributeSet
57
import com.mapbox.search.ForwardSearchOptions
68
import com.mapbox.search.ResponseInfo
79
import com.mapbox.search.SearchCallback
@@ -32,9 +34,21 @@ class ForwardApiKotlinExampleActivity : BaseKotlinExampleActivity() {
3234
}
3335

3436
override fun startExample() {
37+
val options = ForwardSearchOptions.Builder()
38+
.proximity(Point.fromLngLat(-77.03400742663874, 38.904863105693586))
39+
.attributeSets(
40+
listOf(
41+
AttributeSet.BASIC,
42+
AttributeSet.PHOTOS,
43+
AttributeSet.VENUE,
44+
AttributeSet.VISIT,
45+
)
46+
)
47+
.build()
48+
3549
task = searchEngine.forward(
36-
query = "Mapbox DC",
37-
options = ForwardSearchOptions.Builder().build(),
50+
query = "Starbucks",
51+
options = options,
3852
callback = object : SearchCallback {
3953
override fun onResults(results: List<SearchResult>, responseInfo: ResponseInfo) {
4054
logI("SearchApiExample", "Forward request results:", results)

MapboxSearch/sdk/api/api-metalava.txt

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ package com.mapbox.search {
106106
}
107107

108108
@kotlinx.parcelize.Parcelize public final class ForwardSearchOptions implements android.os.Parcelable {
109+
method public java.util.List<com.mapbox.search.AttributeSet>? getAttributeSets();
109110
method public com.mapbox.geojson.BoundingBox? getBoundingBox();
110111
method public java.util.List<com.mapbox.search.common.IsoCountryCode>? getCountries();
111112
method public boolean getIgnoreIndexableRecords();
@@ -119,6 +120,7 @@ package com.mapbox.search {
119120
method public java.util.List<com.mapbox.search.QueryType>? getTypes();
120121
method public java.util.Map<java.lang.String,java.lang.String>? getUnsafeParameters();
121122
method public com.mapbox.search.ForwardSearchOptions.Builder toBuilder();
123+
property public final java.util.List<com.mapbox.search.AttributeSet>? attributeSets;
122124
property public final com.mapbox.geojson.BoundingBox? boundingBox;
123125
property public final java.util.List<com.mapbox.search.common.IsoCountryCode>? countries;
124126
property public final boolean ignoreIndexableRecords;
@@ -135,6 +137,7 @@ package com.mapbox.search {
135137

136138
public static final class ForwardSearchOptions.Builder {
137139
ctor public ForwardSearchOptions.Builder();
140+
method public com.mapbox.search.ForwardSearchOptions.Builder attributeSets(java.util.List<? extends com.mapbox.search.AttributeSet>? attributeSets);
138141
method public com.mapbox.search.ForwardSearchOptions.Builder boundingBox(com.mapbox.geojson.BoundingBox boundingBox);
139142
method public com.mapbox.search.ForwardSearchOptions build();
140143
method public com.mapbox.search.ForwardSearchOptions.Builder countries(com.mapbox.search.common.IsoCountryCode... countries);

MapboxSearch/sdk/api/sdk.api

+8-3
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ public final class com/mapbox/search/EtaType$Creator : android/os/Parcelable$Cre
122122

123123
public final class com/mapbox/search/ForwardSearchOptions : android/os/Parcelable {
124124
public static final field CREATOR Landroid/os/Parcelable$Creator;
125-
public synthetic fun <init> (Lcom/mapbox/search/common/IsoLanguageCode;Ljava/lang/Integer;Lcom/mapbox/geojson/Point;Lcom/mapbox/geojson/BoundingBox;Ljava/util/List;Ljava/util/List;Lcom/mapbox/search/SearchNavigationOptions;Lcom/mapbox/geojson/Point;Ljava/lang/Integer;Ljava/util/Map;ZLjava/lang/Double;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
126-
public final synthetic fun copy (Lcom/mapbox/geojson/Point;Lcom/mapbox/geojson/BoundingBox;Ljava/util/List;Lcom/mapbox/search/common/IsoLanguageCode;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/Integer;Lcom/mapbox/geojson/Point;Lcom/mapbox/search/SearchNavigationOptions;Ljava/util/Map;ZLjava/lang/Double;)Lcom/mapbox/search/ForwardSearchOptions;
127-
public static synthetic fun copy$default (Lcom/mapbox/search/ForwardSearchOptions;Lcom/mapbox/geojson/Point;Lcom/mapbox/geojson/BoundingBox;Ljava/util/List;Lcom/mapbox/search/common/IsoLanguageCode;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/Integer;Lcom/mapbox/geojson/Point;Lcom/mapbox/search/SearchNavigationOptions;Ljava/util/Map;ZLjava/lang/Double;ILjava/lang/Object;)Lcom/mapbox/search/ForwardSearchOptions;
125+
public synthetic fun <init> (Lcom/mapbox/search/common/IsoLanguageCode;Ljava/lang/Integer;Lcom/mapbox/geojson/Point;Lcom/mapbox/geojson/BoundingBox;Ljava/util/List;Ljava/util/List;Lcom/mapbox/search/SearchNavigationOptions;Lcom/mapbox/geojson/Point;Ljava/lang/Integer;Ljava/util/Map;ZLjava/lang/Double;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
126+
public final synthetic fun copy (Lcom/mapbox/geojson/Point;Lcom/mapbox/geojson/BoundingBox;Ljava/util/List;Lcom/mapbox/search/common/IsoLanguageCode;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/Integer;Lcom/mapbox/geojson/Point;Lcom/mapbox/search/SearchNavigationOptions;Ljava/util/Map;ZLjava/lang/Double;Ljava/util/List;)Lcom/mapbox/search/ForwardSearchOptions;
127+
public static synthetic fun copy$default (Lcom/mapbox/search/ForwardSearchOptions;Lcom/mapbox/geojson/Point;Lcom/mapbox/geojson/BoundingBox;Ljava/util/List;Lcom/mapbox/search/common/IsoLanguageCode;Ljava/lang/Integer;Ljava/util/List;Ljava/lang/Integer;Lcom/mapbox/geojson/Point;Lcom/mapbox/search/SearchNavigationOptions;Ljava/util/Map;ZLjava/lang/Double;Ljava/util/List;ILjava/lang/Object;)Lcom/mapbox/search/ForwardSearchOptions;
128128
public fun describeContents ()I
129+
public fun equals (Ljava/lang/Object;)Z
130+
public final fun getAttributeSets ()Ljava/util/List;
129131
public final fun getBoundingBox ()Lcom/mapbox/geojson/BoundingBox;
130132
public final fun getCountries ()Ljava/util/List;
131133
public final fun getIgnoreIndexableRecords ()Z
@@ -138,12 +140,15 @@ public final class com/mapbox/search/ForwardSearchOptions : android/os/Parcelabl
138140
public final fun getRequestDebounce ()Ljava/lang/Integer;
139141
public final fun getTypes ()Ljava/util/List;
140142
public final fun getUnsafeParameters ()Ljava/util/Map;
143+
public fun hashCode ()I
141144
public final fun toBuilder ()Lcom/mapbox/search/ForwardSearchOptions$Builder;
145+
public fun toString ()Ljava/lang/String;
142146
public fun writeToParcel (Landroid/os/Parcel;I)V
143147
}
144148

145149
public final class com/mapbox/search/ForwardSearchOptions$Builder {
146150
public fun <init> ()V
151+
public final fun attributeSets (Ljava/util/List;)Lcom/mapbox/search/ForwardSearchOptions$Builder;
147152
public final fun boundingBox (Lcom/mapbox/geojson/BoundingBox;)Lcom/mapbox/search/ForwardSearchOptions$Builder;
148153
public final fun build ()Lcom/mapbox/search/ForwardSearchOptions;
149154
public final fun countries (Ljava/util/List;)Lcom/mapbox/search/ForwardSearchOptions$Builder;

MapboxSearch/sdk/src/main/java/com/mapbox/search/ForwardSearchOptions.kt

+82
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.mapbox.search.base.core.CoreSearchOptions
88
import com.mapbox.search.base.core.createCoreSearchOptions
99
import com.mapbox.search.base.defaultLocaleLanguage
1010
import com.mapbox.search.base.utils.extension.mapToCore
11+
import com.mapbox.search.base.utils.extension.safeCompareTo
1112
import com.mapbox.search.common.IsoCountryCode
1213
import com.mapbox.search.common.IsoLanguageCode
1314
import kotlinx.parcelize.Parcelize
@@ -113,6 +114,11 @@ public class ForwardSearchOptions private constructor(
113114
* Threshold specified in meters.
114115
*/
115116
public val indexableRecordsDistanceThresholdMeters: Double? = null,
117+
118+
/**
119+
* Request additional metadata attributes besides the basic ones.
120+
*/
121+
public val attributeSets: List<AttributeSet>? = null,
116122
) : Parcelable {
117123

118124
init {
@@ -143,6 +149,7 @@ public class ForwardSearchOptions private constructor(
143149
unsafeParameters: Map<String, String>? = this.unsafeParameters,
144150
ignoreIndexableRecords: Boolean = this.ignoreIndexableRecords,
145151
indexableRecordsDistanceThresholdMeters: Double? = this.indexableRecordsDistanceThresholdMeters,
152+
attributeSets: List<AttributeSet>? = this.attributeSets,
146153
): ForwardSearchOptions {
147154
return ForwardSearchOptions(
148155
proximity = proximity,
@@ -157,6 +164,7 @@ public class ForwardSearchOptions private constructor(
157164
unsafeParameters = unsafeParameters,
158165
ignoreIndexableRecords = ignoreIndexableRecords,
159166
indexableRecordsDistanceThresholdMeters = indexableRecordsDistanceThresholdMeters,
167+
attributeSets = attributeSets,
160168
)
161169
}
162170

@@ -170,6 +178,69 @@ public class ForwardSearchOptions private constructor(
170178
/**
171179
* @suppress
172180
*/
181+
override fun equals(other: Any?): Boolean {
182+
if (this === other) return true
183+
if (javaClass != other?.javaClass) return false
184+
185+
other as ForwardSearchOptions
186+
187+
if (language != other.language) return false
188+
if (limit != other.limit) return false
189+
if (proximity != other.proximity) return false
190+
if (boundingBox != other.boundingBox) return false
191+
if (countries != other.countries) return false
192+
if (types != other.types) return false
193+
if (navigationOptions != other.navigationOptions) return false
194+
if (origin != other.origin) return false
195+
if (requestDebounce != other.requestDebounce) return false
196+
if (unsafeParameters != other.unsafeParameters) return false
197+
if (ignoreIndexableRecords != other.ignoreIndexableRecords) return false
198+
if (!indexableRecordsDistanceThresholdMeters.safeCompareTo(other.indexableRecordsDistanceThresholdMeters)) return false
199+
if (attributeSets != other.attributeSets) return false
200+
201+
return true
202+
}
203+
204+
/**
205+
* @suppress
206+
*/
207+
override fun hashCode(): Int {
208+
var result = language?.hashCode() ?: 0
209+
result = 31 * result + (limit ?: 0)
210+
result = 31 * result + (proximity?.hashCode() ?: 0)
211+
result = 31 * result + (boundingBox?.hashCode() ?: 0)
212+
result = 31 * result + (countries?.hashCode() ?: 0)
213+
result = 31 * result + (types?.hashCode() ?: 0)
214+
result = 31 * result + (navigationOptions?.hashCode() ?: 0)
215+
result = 31 * result + (origin?.hashCode() ?: 0)
216+
result = 31 * result + (requestDebounce ?: 0)
217+
result = 31 * result + (unsafeParameters?.hashCode() ?: 0)
218+
result = 31 * result + ignoreIndexableRecords.hashCode()
219+
result = 31 * result + (indexableRecordsDistanceThresholdMeters?.hashCode() ?: 0)
220+
result = 31 * result + (attributeSets?.hashCode() ?: 0)
221+
return result
222+
}
223+
224+
/**
225+
* @suppress
226+
*/
227+
override fun toString(): String {
228+
return "ForwardSearchOptions(" +
229+
"language=$language, " +
230+
"limit=$limit, " +
231+
"proximity=$proximity, " +
232+
"boundingBox=$boundingBox, " +
233+
"countries=$countries, " +
234+
"types=$types, " +
235+
"navigationOptions=$navigationOptions, " +
236+
"origin=$origin, " +
237+
"requestDebounce=$requestDebounce, " +
238+
"unsafeParameters=$unsafeParameters, " +
239+
"ignoreIndexableRecords=$ignoreIndexableRecords, " +
240+
"indexableRecordsDistanceThresholdMeters=$indexableRecordsDistanceThresholdMeters, " +
241+
"attributeSets=$attributeSets" +
242+
")"
243+
}
173244

174245
/**
175246
* Builder for comfortable creation of [ForwardSearchOptions] instance.
@@ -189,6 +260,7 @@ public class ForwardSearchOptions private constructor(
189260
private var unsafeParameters: Map<String, String>? = null
190261
private var ignoreIndexableRecords: Boolean = false
191262
private var indexableRecordsDistanceThresholdMeters: Double? = null
263+
private var attributeSets: List<AttributeSet>? = null
192264

193265
internal constructor(options: ForwardSearchOptions) : this() {
194266
proximity = options.proximity
@@ -204,6 +276,7 @@ public class ForwardSearchOptions private constructor(
204276
ignoreIndexableRecords = options.ignoreIndexableRecords
205277
indexableRecordsDistanceThresholdMeters =
206278
options.indexableRecordsDistanceThresholdMeters
279+
attributeSets = options.attributeSets
207280
}
208281

209282
/**
@@ -325,6 +398,13 @@ public class ForwardSearchOptions private constructor(
325398
this.indexableRecordsDistanceThresholdMeters = threshold
326399
}
327400

401+
/**
402+
* Request additional metadata attributes besides the basic ones.
403+
*/
404+
public fun attributeSets(attributeSets: List<AttributeSet>?): Builder = apply {
405+
this.attributeSets = attributeSets
406+
}
407+
328408
/**
329409
* Create [ForwardSearchOptions] instance from builder data.
330410
*/
@@ -341,6 +421,7 @@ public class ForwardSearchOptions private constructor(
341421
unsafeParameters = unsafeParameters,
342422
ignoreIndexableRecords = ignoreIndexableRecords,
343423
indexableRecordsDistanceThresholdMeters = indexableRecordsDistanceThresholdMeters,
424+
attributeSets = attributeSets,
344425
)
345426
}
346427
}
@@ -360,4 +441,5 @@ internal fun ForwardSearchOptions.mapToCore(): CoreSearchOptions = createCoreSea
360441
urDistanceThreshold = indexableRecordsDistanceThresholdMeters,
361442
requestDebounce = requestDebounce,
362443
addonAPI = unsafeParameters?.let { (it as? HashMap) ?: HashMap(it) },
444+
attributeSets = attributeSets?.map { it.mapToCore() },
363445
)

0 commit comments

Comments
 (0)