@capgo/nativegeocoder 8.0.3 → 8.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,6 @@ import android.location.Address;
5
5
  import android.location.Geocoder;
6
6
  import android.net.ConnectivityManager;
7
7
  import android.net.NetworkInfo;
8
- import android.os.Build;
9
8
  import com.getcapacitor.JSObject;
10
9
  import com.getcapacitor.PluginCall;
11
10
  import java.util.List;
@@ -216,15 +215,7 @@ public class NativeGeocoder {
216
215
  */
217
216
  private Geocoder createGeocoderWithOptions(NativeGeocoderOptions geocoderOptions) {
218
217
  if (geocoderOptions.defaultLocale != null && !geocoderOptions.defaultLocale.isEmpty()) {
219
- Locale locale;
220
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
221
- locale = Locale.forLanguageTag(geocoderOptions.defaultLocale);
222
- } else {
223
- String[] parts = geocoderOptions.defaultLocale.split("[-_]", -1);
224
- if (parts.length == 1) locale = new Locale(parts[0]);
225
- else if (parts.length == 2 || (parts.length == 3 && parts[2].startsWith("#"))) locale = new Locale(parts[0], parts[1]);
226
- else locale = new Locale(parts[0], parts[1], parts[2]);
227
- }
218
+ Locale locale = Locale.forLanguageTag(geocoderOptions.defaultLocale);
228
219
  geocoder = new Geocoder(context.getApplicationContext(), locale);
229
220
  } else {
230
221
  if (geocoderOptions.useLocale) {
@@ -9,7 +9,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
9
9
  @CapacitorPlugin(name = "NativeGeocoder")
10
10
  public class NativeGeocoderPlugin extends Plugin {
11
11
 
12
- private final String pluginVersion = "8.0.3";
12
+ private final String pluginVersion = "8.0.5";
13
13
 
14
14
  private NativeGeocoder implementation = new NativeGeocoder();
15
15
 
@@ -42,27 +42,18 @@ struct NativeGeocoderOptions: Decodable {
42
42
  private func reverseGeocodeLocationHandler(_ location: CLLocation, options: NativeGeocoderOptions, completionHandler: @escaping ReverseGeocodeCompletionHandler) {
43
43
  let geocoderOptions = getNativeGeocoderOptions(from: options)
44
44
 
45
- if #available(iOS 11, *) {
46
- var locale: Locale?
47
- if let defaultLocaleString = geocoderOptions.defaultLocale {
48
- locale = Locale.init(identifier: defaultLocaleString)
49
- } else if geocoderOptions.useLocale == false {
50
- locale = Locale.init(identifier: "en_US")
51
- }
45
+ var locale: Locale?
46
+ if let defaultLocaleString = geocoderOptions.defaultLocale {
47
+ locale = Locale.init(identifier: defaultLocaleString)
48
+ } else if geocoderOptions.useLocale == false {
49
+ locale = Locale.init(identifier: "en_US")
50
+ }
52
51
 
53
- CLGeocoder().reverseGeocodeLocation(location, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
54
- self?.createReverseGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
55
- completionHandler(resultObj, error)
56
- })
57
- })
58
- } else {
59
- // fallback for < iOS 11
60
- CLGeocoder().reverseGeocodeLocation(location, completionHandler: { [weak self] (placemarks, error) in
61
- self?.createReverseGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
62
- completionHandler(resultObj, error)
63
- })
52
+ CLGeocoder().reverseGeocodeLocation(location, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
53
+ self?.createReverseGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
54
+ completionHandler(resultObj, error)
64
55
  })
65
- }
56
+ })
66
57
  }
67
58
 
68
59
  private func createReverseGeocodeResult(_ placemarks: [CLPlacemark]?, _ error: Error?, maxResults: Int, completionHandler: @escaping ReverseGeocodeCompletionHandler) {
@@ -129,27 +120,18 @@ struct NativeGeocoderOptions: Decodable {
129
120
  func forwardGeocodeHandler(_ address: String, options: NativeGeocoderOptions, completionHandler: @escaping ForwardGeocodeCompletionHandler) {
130
121
  let geocoderOptions = getNativeGeocoderOptions(from: options)
131
122
 
132
- if #available(iOS 11, *) {
133
- var locale: Locale?
134
- if let defaultLocaleString = geocoderOptions.defaultLocale {
135
- locale = Locale.init(identifier: defaultLocaleString)
136
- } else if geocoderOptions.useLocale == false {
137
- locale = Locale.init(identifier: "en_US")
138
- }
123
+ var locale: Locale?
124
+ if let defaultLocaleString = geocoderOptions.defaultLocale {
125
+ locale = Locale.init(identifier: defaultLocaleString)
126
+ } else if geocoderOptions.useLocale == false {
127
+ locale = Locale.init(identifier: "en_US")
128
+ }
139
129
 
140
- CLGeocoder().geocodeAddressString(address, in: nil, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
141
- self?.createForwardGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
142
- completionHandler(resultObj, error)
143
- })
144
- })
145
- } else {
146
- // fallback for < iOS 11
147
- CLGeocoder().geocodeAddressString(address, completionHandler: { [weak self] (placemarks, error) in
148
- self?.createForwardGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
149
- completionHandler(resultObj, error)
150
- })
130
+ CLGeocoder().geocodeAddressString(address, in: nil, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
131
+ self?.createForwardGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
132
+ completionHandler(resultObj, error)
151
133
  })
152
- }
134
+ })
153
135
  }
154
136
 
155
137
  private func makePosition(_ placemark: CLPlacemark) -> JSObject {
@@ -7,7 +7,7 @@ import Capacitor
7
7
  */
8
8
  @objc(NativeGeocoderPlugin)
9
9
  public class NativeGeocoderPlugin: CAPPlugin, CAPBridgedPlugin {
10
- private let pluginVersion: String = "8.0.3"
10
+ private let pluginVersion: String = "8.0.5"
11
11
  public let identifier = "NativeGeocoderPlugin"
12
12
  public let jsName = "NativeGeocoder"
13
13
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/nativegeocoder",
3
- "version": "8.0.3",
3
+ "version": "8.0.5",
4
4
  "description": "Capacitor plugin for native forward and reverse geocoding",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",