From 3d32e334987e67967c9ef0b513fe88b220ac9e19 Mon Sep 17 00:00:00 2001 From: Vijay Vikram Singh Date: Mon, 9 Dec 2019 07:23:18 -0800 Subject: [PATCH] refactor(ios, android): removed deprecated geolocation APIs (#11350) BREAKING CHANGES: Ti.Geoclocation.reverseGeocoder now uses consistent properties postalCode (in place of zipcode) and countryCode (in place of country_code) Fixes TIMOB-25578 --- .../modules/titanium/geolocation/TiLocation.java | 14 +++----------- .../src/java/org/appcelerator/titanium/TiC.java | 3 +-- apidoc/Titanium/Geolocation/Geolocation.yml | 3 +++ iphone/Classes/GeolocationModule.m | 5 ++--- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/TiLocation.java b/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/TiLocation.java index ff8a17562d1..498bb26fe30 100644 --- a/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/TiLocation.java +++ b/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/TiLocation.java @@ -321,26 +321,18 @@ private KrollDict buildReverseGeocodeResponse(JSONObject jsonResponse) throws JS private KrollDict buildAddress(JSONObject place) { - Log.w( - TAG, - "GeocodedAddress properties country_code, displayAddress, and zipcode are deprecated in SDK 8.0.0 and will be removed in 9.0.0"); - Log.w(TAG, "Please replace usage with the respective properties: countryCode, address, and postalCode"); KrollDict address = new KrollDict(); address.put(TiC.PROPERTY_STREET1, place.optString(TiC.PROPERTY_STREET, "")); address.put(TiC.PROPERTY_STREET, place.optString(TiC.PROPERTY_STREET, "")); address.put(TiC.PROPERTY_CITY, place.optString(TiC.PROPERTY_CITY, "")); - address.put(TiC.PROPERTY_REGION1, ""); // AdminArea - address.put(TiC.PROPERTY_REGION2, ""); // SubAdminArea - address.put("zipcode", place.optString("zipcode", "")); // TODO: To be removed in SDK 9.0.0! + address.put(TiC.PROPERTY_REGION1, ""); // AdminArea + address.put(TiC.PROPERTY_REGION2, ""); // SubAdminArea address.put(TiC.PROPERTY_POSTAL_CODE, place.optString("zipcode", "")); address.put(TiC.PROPERTY_COUNTRY, place.optString(TiC.PROPERTY_COUNTRY, "")); address.put(TiC.PROPERTY_STATE, place.optString(TiC.PROPERTY_STATE, "")); - // Replace TiC.PROPERTY_COUNTRY_CODE value with "countryCode" in SDK 9.0.0 - address.put("countryCode", place.optString(TiC.PROPERTY_COUNTRY_CODE, "")); - address.put(TiC.PROPERTY_COUNTRY_CODE, place.optString(TiC.PROPERTY_COUNTRY_CODE, "")); + address.put(TiC.PROPERTY_COUNTRY_CODE, place.optString("country_code", "")); address.put(TiC.PROPERTY_LONGITUDE, place.optDouble(TiC.PROPERTY_LONGITUDE, 0.0d)); address.put(TiC.PROPERTY_LATITUDE, place.optDouble(TiC.PROPERTY_LATITUDE, 0.0d)); - address.put(TiC.PROPERTY_DISPLAY_ADDRESS, place.optString(TiC.PROPERTY_ADDRESS)); address.put(TiC.PROPERTY_ADDRESS, place.optString(TiC.PROPERTY_ADDRESS)); return address; diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiC.java b/android/titanium/src/java/org/appcelerator/titanium/TiC.java index 33335b0db83..c42014693c1 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiC.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiC.java @@ -1439,9 +1439,8 @@ public class TiC /** * @module.api - * @deprecated Value will be changed to "countryCode" in SDK 9.0.0 */ - public static final String PROPERTY_COUNTRY_CODE = "country_code"; + public static final String PROPERTY_COUNTRY_CODE = "countryCode"; /** * @module.api diff --git a/apidoc/Titanium/Geolocation/Geolocation.yml b/apidoc/Titanium/Geolocation/Geolocation.yml index e905f950361..c1da668ac5f 100644 --- a/apidoc/Titanium/Geolocation/Geolocation.yml +++ b/apidoc/Titanium/Geolocation/Geolocation.yml @@ -1206,6 +1206,7 @@ properties: platforms: [iphone, ipad] deprecated: since: {iphone: "8.0.0", ipad: "8.0.0"} + removed: "9.0.0" - name: country summary: Country name. @@ -1223,6 +1224,7 @@ properties: platforms: [android, iphone, ipad] deprecated: since: {android: "8.0.0", iphone: "8.0.0", ipad: "8.0.0"} + removed: "9.0.0" - name: longitude summary: Longitude of the geocoded point. @@ -1240,6 +1242,7 @@ properties: platforms: [android] deprecated: since: {android: "8.0.0"} + removed: "9.0.0" - name: address summary: Full address. diff --git a/iphone/Classes/GeolocationModule.m b/iphone/Classes/GeolocationModule.m index 49153b2e106..918f7d18d6d 100644 --- a/iphone/Classes/GeolocationModule.m +++ b/iphone/Classes/GeolocationModule.m @@ -143,14 +143,13 @@ - (void)requestSuccess:(NSString *)locationString BOOL success = [TiUtils boolValue:@"success" properties:event def:YES]; NSMutableDictionary *revisedEvent = [TiUtils dictionaryWithCode:success ? 0 : -1 message:success ? nil : @"error reverse geocoding"]; [revisedEvent setValuesForKeysWithDictionary:event]; - // TODO: Remove the zipcode and country_code values after on SDK 9.0.0! NSArray *places = (NSArray *)revisedEvent[@"places"]; for (NSMutableDictionary *dict in places) { dict[@"postalCode"] = dict[@"zipcode"]; + [dict removeObjectForKey:@"zipcode"]; dict[@"countryCode"] = dict[@"country_code"]; + [dict removeObjectForKey:@"country_code"]; } - NSLog(@"[WARN] GeocodedAddress properties country_code and zipcode are deprecated in SDK 8.0.0 and will be removed in 9.0.0"); - NSLog(@"[WARN] Please replace usage with the respective properties: countryCode and postalCode"); [callback callWithArguments:@[ revisedEvent ]]; } }