Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removed deprecated geolocation APIs #11350

Merged
merged 7 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions apidoc/Titanium/Geolocation/Geolocation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ properties:
platforms: [iphone, ipad]
deprecated:
since: {iphone: "8.0.0", ipad: "8.0.0"}
removed: "9.0.0"

- name: country
summary: Country name.
Expand All @@ -1222,6 +1223,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.
Expand All @@ -1239,6 +1241,7 @@ properties:
platforms: [android]
deprecated:
since: {android: "8.0.0"}
removed: "9.0.0"

- name: address
summary: Full address.
Expand Down
5 changes: 2 additions & 3 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSMutableDictionary *> *places = (NSArray<NSMutableDictionary *> *)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 ]];
}
}
Expand Down