Skip to content

Commit 8762ac9

Browse files
authored
Merge pull request #240 from praveek/staging
2 parents e3e52b9 + bb7bef9 commit 8762ac9

File tree

6 files changed

+186
-203
lines changed

6 files changed

+186
-203
lines changed

.circleci/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- run:
2323
name: Unit Tests
24-
command: yarn tests:jest
24+
command: yarn tests:jest --watchAll=false --runInBand
2525

2626
build-sample-app-android:
2727
docker:
@@ -50,7 +50,9 @@ jobs:
5050
# CircleCI puts xcode app in consistent path, RN looks for versioned path
5151
- run:
5252
name: Move xcode
53-
command: cd /Applications && mv Xcode.app Xcode-13.0.app
53+
command: |
54+
cd /Applications && mv Xcode.app Xcode-13.0.app
55+
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/Xcode-13.0.app/Contents/Developer/Applications/Simulator.app
5456
5557
- run:
5658
name: Install latest NodeJS

packages/campaignclassic/android/src/main/java/com/adobe/marketing/mobile/reactnative/campaignclassic/RCTAEPCampaignClassicModule.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public void registerDeviceWithToken(final String deviceToken,
5959
? RCTAEPCampaignClassicUtil.convertReadableMapToMap(
6060
additionalParams)
6161
: null;
62-
//TODO: fix this breaking change in Android 2.0
63-
// CampaignClassic.registerDevice(deviceToken, userKey, additionalParamsMap,
64-
// null);
62+
CampaignClassic.registerDevice(deviceToken, userKey, additionalParamsMap);
6563
}
6664

6765
@ReactMethod

packages/places/android/src/main/java/com/adobe/marketing/mobile/reactnative/places/RCTAEPPlacesDataBridge.java

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
import android.location.Location;
1616

17-
//TODO: fix this breaking change in Android 2.0
18-
//import com.adobe.marketing.mobile.PlacesAuthorizationStatus;
19-
//import com.adobe.marketing.mobile.PlacesPOI;
17+
import com.adobe.marketing.mobile.places.PlacesAuthorizationStatus;
18+
import com.adobe.marketing.mobile.places.PlacesPOI;
2019
import com.facebook.react.bridge.ReadableMap;
2120
import com.facebook.react.bridge.WritableArray;
2221
import com.facebook.react.bridge.WritableMap;
@@ -58,43 +57,41 @@ public class RCTAEPPlacesDataBridge {
5857
private final static String AEP_PLACES_GEOFENCE_RADIUS = "radius";
5958
private final static String AEP_PLACES_GEOFENCE_EXPIRATION_DURATION = "expirationDuration";
6059

61-
//TODO: fix this breaking change in Android 2.0
62-
// public static PlacesAuthorizationStatus placesAuthorizationStatusFromString(final String placesAuthStatus) {
63-
// if (placesAuthStatus == null) {
64-
// return PlacesAuthorizationStatus.UNKNOWN;
65-
// }
66-
//
67-
// if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_DENIED)) {
68-
// return PlacesAuthorizationStatus.DENIED;
69-
// } else if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_ALWAYS)) {
70-
// return PlacesAuthorizationStatus.ALWAYS;
71-
// } else if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_RESTRICTED)) {
72-
// return PlacesAuthorizationStatus.RESTRICTED;
73-
// } else if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_WHEN_IN_USE)) {
74-
// return PlacesAuthorizationStatus.WHEN_IN_USE;
75-
// }
76-
//
77-
// return PlacesAuthorizationStatus.UNKNOWN;
78-
// }
79-
80-
//TODO: fix this breaking change in Android 2.0
81-
// public static String stringFromPlacesAuthorizationStatus(final PlacesAuthorizationStatus placesAuthorizationStatus) {
82-
// if (placesAuthorizationStatus == null) {
83-
// return AEP_PLACES_AUTH_STATUS_UNKNOWN;
84-
// }
85-
//
86-
// if (placesAuthorizationStatus == PlacesAuthorizationStatus.DENIED) {
87-
// return AEP_PLACES_AUTH_STATUS_DENIED;
88-
// } else if (placesAuthorizationStatus == PlacesAuthorizationStatus.ALWAYS) {
89-
// return AEP_PLACES_AUTH_STATUS_ALWAYS;
90-
// } else if (placesAuthorizationStatus == PlacesAuthorizationStatus.WHEN_IN_USE) {
91-
// return AEP_PLACES_AUTH_STATUS_WHEN_IN_USE;
92-
// } else if (placesAuthorizationStatus == PlacesAuthorizationStatus.RESTRICTED) {
93-
// return AEP_PLACES_AUTH_STATUS_RESTRICTED;
94-
// }
95-
//
96-
// return AEP_PLACES_AUTH_STATUS_UNKNOWN;
97-
// }
60+
public static PlacesAuthorizationStatus placesAuthorizationStatusFromString(final String placesAuthStatus) {
61+
if (placesAuthStatus == null) {
62+
return PlacesAuthorizationStatus.UNKNOWN;
63+
}
64+
65+
if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_DENIED)) {
66+
return PlacesAuthorizationStatus.DENIED;
67+
} else if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_ALWAYS)) {
68+
return PlacesAuthorizationStatus.ALWAYS;
69+
} else if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_RESTRICTED)) {
70+
return PlacesAuthorizationStatus.RESTRICTED;
71+
} else if (placesAuthStatus.equals(AEP_PLACES_AUTH_STATUS_WHEN_IN_USE)) {
72+
return PlacesAuthorizationStatus.WHEN_IN_USE;
73+
}
74+
75+
return PlacesAuthorizationStatus.UNKNOWN;
76+
}
77+
78+
public static String stringFromPlacesAuthorizationStatus(final PlacesAuthorizationStatus placesAuthorizationStatus) {
79+
if (placesAuthorizationStatus == null) {
80+
return AEP_PLACES_AUTH_STATUS_UNKNOWN;
81+
}
82+
83+
if (placesAuthorizationStatus == PlacesAuthorizationStatus.DENIED) {
84+
return AEP_PLACES_AUTH_STATUS_DENIED;
85+
} else if (placesAuthorizationStatus == PlacesAuthorizationStatus.ALWAYS) {
86+
return AEP_PLACES_AUTH_STATUS_ALWAYS;
87+
} else if (placesAuthorizationStatus == PlacesAuthorizationStatus.WHEN_IN_USE) {
88+
return AEP_PLACES_AUTH_STATUS_WHEN_IN_USE;
89+
} else if (placesAuthorizationStatus == PlacesAuthorizationStatus.RESTRICTED) {
90+
return AEP_PLACES_AUTH_STATUS_RESTRICTED;
91+
}
92+
93+
return AEP_PLACES_AUTH_STATUS_UNKNOWN;
94+
}
9895

9996
public static WritableMap mapFromLocation(final Location location) {
10097
if (location == null) {
@@ -120,34 +117,33 @@ public static Location locationFromMap(final ReadableMap locationMap) {
120117
return location;
121118
}
122119

123-
//TODO: fix this breaking change in Android 2.0
124-
// public static WritableMap mapFromPlacesPOI(final PlacesPOI placesPOI) {
125-
// if (placesPOI == null) {
126-
// return null;
127-
// }
128-
//
129-
// WritableMap locationMap = new WritableNativeMap();
130-
// locationMap.putString(AEP_PLACES_POI_IDENTIFIER, placesPOI.getIdentifier());
131-
// locationMap.putString(AEP_PLACES_POI_NAME, placesPOI.getName());
132-
// locationMap.putDouble(AEP_PLACES_POI_LATITUDE, placesPOI.getLatitude());
133-
// locationMap.putDouble(AEP_PLACES_POI_LONGITUDE, placesPOI.getLongitude());
134-
// locationMap.putDouble(AEP_PLACES_POI_RADIUS, placesPOI.getRadius());
135-
// locationMap.putBoolean(AEP_PLACES_POI_USER_IS_WITHIN, placesPOI.containsUser());
136-
// locationMap.putString(AEP_PLACES_POI_LIBRARY, placesPOI.getLibrary());
137-
// locationMap.putInt(AEP_PLACES_POI_WEIGHT, placesPOI.getWeight());
138-
// locationMap.putMap(AEP_PLACES_POI_METADATA, RCTAEPMapUtil.toWritableMap(placesPOI.getMetadata()));
139-
//
140-
// return locationMap;
141-
// }
142-
//
143-
// public static WritableArray writableArrayFromListPOIs(List<PlacesPOI> placesPOIS) {
144-
// WritableArray arr = new WritableNativeArray();
145-
//
146-
// for (PlacesPOI poi : placesPOIS) {
147-
// arr.pushMap(RCTAEPPlacesDataBridge.mapFromPlacesPOI(poi));
148-
// }
149-
// return arr;
150-
// }
120+
public static WritableMap mapFromPlacesPOI(final PlacesPOI placesPOI) {
121+
if (placesPOI == null) {
122+
return null;
123+
}
124+
125+
WritableMap locationMap = new WritableNativeMap();
126+
locationMap.putString(AEP_PLACES_POI_IDENTIFIER, placesPOI.getIdentifier());
127+
locationMap.putString(AEP_PLACES_POI_NAME, placesPOI.getName());
128+
locationMap.putDouble(AEP_PLACES_POI_LATITUDE, placesPOI.getLatitude());
129+
locationMap.putDouble(AEP_PLACES_POI_LONGITUDE, placesPOI.getLongitude());
130+
locationMap.putDouble(AEP_PLACES_POI_RADIUS, placesPOI.getRadius());
131+
locationMap.putBoolean(AEP_PLACES_POI_USER_IS_WITHIN, placesPOI.containsUser());
132+
locationMap.putString(AEP_PLACES_POI_LIBRARY, placesPOI.getLibrary());
133+
locationMap.putInt(AEP_PLACES_POI_WEIGHT, placesPOI.getWeight());
134+
locationMap.putMap(AEP_PLACES_POI_METADATA, RCTAEPMapUtil.toWritableMap(placesPOI.getMetadata()));
135+
136+
return locationMap;
137+
}
138+
139+
public static WritableArray writableArrayFromListPOIs(List<PlacesPOI> placesPOIS) {
140+
WritableArray arr = new WritableNativeArray();
141+
142+
for (PlacesPOI poi : placesPOIS) {
143+
arr.pushMap(RCTAEPPlacesDataBridge.mapFromPlacesPOI(poi));
144+
}
145+
return arr;
146+
}
151147

152148
public static Geofence geofenceFromMap(ReadableMap geofenceMap, int transitionType) {
153149
if (geofenceMap == null) {

packages/places/android/src/main/java/com/adobe/marketing/mobile/reactnative/places/RCTAEPPlacesModule.java

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
import com.adobe.marketing.mobile.AdobeCallbackWithError;
1919
import com.adobe.marketing.mobile.AdobeError;
2020
import com.adobe.marketing.mobile.Places;
21-
//TODO: fix this breaking change in Android 2.0
22-
//import com.adobe.marketing.mobile.PlacesPOI;
23-
//import com.adobe.marketing.mobile.PlacesRequestError;
21+
import com.adobe.marketing.mobile.places.PlacesPOI;
22+
import com.adobe.marketing.mobile.places.PlacesRequestError;
2423
import com.facebook.react.bridge.Promise;
2524
import com.facebook.react.bridge.ReactApplicationContext;
2625
import com.facebook.react.bridge.ReactContextBaseJavaModule;
@@ -55,18 +54,17 @@ public void extensionVersion(final Promise promise) {
5554
@ReactMethod
5655
public void getNearbyPointsOfInterest(final ReadableMap locationMap, final int limit, final Promise promise) {
5756
Location location = RCTAEPPlacesDataBridge.locationFromMap(locationMap);
58-
//TODO: fix this breaking change in Android 2.0
59-
// Places.getNearbyPointsOfInterest(location, limit, new AdobeCallback<List<PlacesPOI>>() {
60-
// @Override
61-
// public void call(List<PlacesPOI> placesPOIS) {
62-
// promise.resolve(RCTAEPPlacesDataBridge.writableArrayFromListPOIs(placesPOIS));
63-
// }
64-
// }, new AdobeCallback<PlacesRequestError>() {
65-
// @Override
66-
// public void call(PlacesRequestError placesRequestError) {
67-
// promise.reject(String.valueOf(placesRequestError.getValue()), placesRequestError.name());
68-
// }
69-
// });
57+
Places.getNearbyPointsOfInterest(location, limit, new AdobeCallback<List<PlacesPOI>>() {
58+
@Override
59+
public void call(List<PlacesPOI> placesPOIS) {
60+
promise.resolve(RCTAEPPlacesDataBridge.writableArrayFromListPOIs(placesPOIS));
61+
}
62+
}, new AdobeCallback<PlacesRequestError>() {
63+
@Override
64+
public void call(PlacesRequestError placesRequestError) {
65+
promise.reject(String.valueOf(placesRequestError.getValue()), placesRequestError.name());
66+
}
67+
});
7068
}
7169

7270
@ReactMethod
@@ -76,13 +74,12 @@ public void processGeofence(final ReadableMap geofence, final int transitionType
7674

7775
@ReactMethod
7876
public void getCurrentPointsOfInterest(final Promise promise) {
79-
//TODO: fix this breaking change in Android 2.0
80-
// Places.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {
81-
// @Override
82-
// public void call(List<PlacesPOI> placesPOIS) {
83-
// promise.resolve(RCTAEPPlacesDataBridge.writableArrayFromListPOIs(placesPOIS));
84-
// }
85-
// });
77+
Places.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {
78+
@Override
79+
public void call(List<PlacesPOI> placesPOIS) {
80+
promise.resolve(RCTAEPPlacesDataBridge.writableArrayFromListPOIs(placesPOIS));
81+
}
82+
});
8683
}
8784

8885
@ReactMethod
@@ -102,7 +99,6 @@ public void clear() {
10299

103100
@ReactMethod
104101
public void setAuthorizationStatus(String authStatus) {
105-
//TODO: fix this breaking change in Android 2.0
106-
// Places.setAuthorizationStatus(RCTAEPPlacesDataBridge.placesAuthorizationStatusFromString(authStatus));
102+
Places.setAuthorizationStatus(RCTAEPPlacesDataBridge.placesAuthorizationStatusFromString(authStatus));
107103
}
108104
}

packages/target/android/src/main/java/com/adobe/marketing/mobile/reactnative/target/RCTAEPTargetDataBridge.java

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
package com.adobe.marketing.mobile.reactnative.target;
1313

1414
import com.adobe.marketing.mobile.AdobeCallback;
15-
//import com.adobe.marketing.mobile.TargetOrder;
16-
//import com.adobe.marketing.mobile.TargetParameters;
17-
//import com.adobe.marketing.mobile.TargetPrefetch;
18-
//import com.adobe.marketing.mobile.TargetProduct;
19-
//import com.adobe.marketing.mobile.TargetRequest;
15+
import com.adobe.marketing.mobile.target.TargetOrder;
16+
import com.adobe.marketing.mobile.target.TargetParameters;
17+
import com.adobe.marketing.mobile.target.TargetPrefetch;
18+
import com.adobe.marketing.mobile.target.TargetProduct;
19+
import com.adobe.marketing.mobile.target.TargetRequest;
2020
import com.facebook.react.bridge.Callback;
2121
import com.facebook.react.bridge.ReadableArray;
2222
import com.facebook.react.bridge.ReadableMap;
@@ -42,61 +42,60 @@ public class RCTAEPTargetDataBridge {
4242
final private static String PRODUCT_ID_KEY = "productId";
4343
final private static String CATEGORY_ID_KEY = "categoryId";
4444

45-
//TODO: fix this breaking change in Android 2.0
46-
// public static TargetPrefetch mapToPrefetch(ReadableMap map) {
47-
// if (map == null) {
48-
// return null;
49-
// }
50-
//
51-
// TargetParameters parameters = mapToParameters(getNullableMap(map, TARGET_PARAMETERS_KEY));
52-
// return new TargetPrefetch(getNullableString(map, NAME_KEY), parameters);
53-
// }
54-
//
55-
// public static TargetRequest mapToRequest(ReadableMap map, final Callback successCallback) {
56-
// if (map == null) {
57-
// return null;
58-
// }
59-
//
60-
// TargetParameters parameters = mapToParameters(getNullableMap(map, TARGET_PARAMETERS_KEY));
61-
// return new TargetRequest(getNullableString(map, NAME_KEY), parameters, getNullableString(map, DEFAULT_CONTENT_KEY), new AdobeCallback<String>() {
62-
// @Override
63-
// public void call(String content) {
64-
// successCallback.invoke(null, content);
65-
// }
66-
// });
67-
// }
68-
//
69-
// public static TargetParameters mapToParameters(ReadableMap map) {
70-
// if (map == null) {
71-
// return null;
72-
// }
73-
//
74-
// TargetOrder order = mapToOrder(getNullableMap(map, ORDER_KEY));
75-
// TargetProduct product = mapToProduct(getNullableMap(map, PRODUCT_KEY));
76-
//
77-
// Map<String, String> parameters = RCTAEPTargetMapUtil.toStringMap(getNullableMap(map, PARAMETERS_KEY));
78-
// Map<String, String> profileParameters = RCTAEPTargetMapUtil.toStringMap(getNullableMap(map, PROFILE_PARAMETERS_KEY));
79-
//
80-
// return new TargetParameters.Builder().order(order).product(product).parameters(parameters).profileParameters(profileParameters).build();
81-
// }
82-
//
83-
//
84-
// public static TargetOrder mapToOrder(ReadableMap map) {
85-
// if (map == null) {
86-
// return null;
87-
// }
88-
//
89-
// List<String> purchasedProductsIds = RCTAEPTargetArrayUtil.toStringArray(getNullableArray(map, PURCHASED_PRODUCTS_IDS_KEY));
90-
// return new TargetOrder(getNullableString(map, ORDER_ID_KEY), getNullableDouble(map, TOTAL_KEY), purchasedProductsIds);
91-
// }
92-
//
93-
// public static TargetProduct mapToProduct(ReadableMap map) {
94-
// if (map == null) {
95-
// return null;
96-
// }
97-
//
98-
// return new TargetProduct(getNullableString(map, PRODUCT_ID_KEY), getNullableString(map, CATEGORY_ID_KEY));
99-
// }
45+
public static TargetPrefetch mapToPrefetch(ReadableMap map) {
46+
if (map == null) {
47+
return null;
48+
}
49+
50+
TargetParameters parameters = mapToParameters(getNullableMap(map, TARGET_PARAMETERS_KEY));
51+
return new TargetPrefetch(getNullableString(map, NAME_KEY), parameters);
52+
}
53+
54+
public static TargetRequest mapToRequest(ReadableMap map, final Callback successCallback) {
55+
if (map == null) {
56+
return null;
57+
}
58+
59+
TargetParameters parameters = mapToParameters(getNullableMap(map, TARGET_PARAMETERS_KEY));
60+
return new TargetRequest(getNullableString(map, NAME_KEY), parameters, getNullableString(map, DEFAULT_CONTENT_KEY), new AdobeCallback<String>() {
61+
@Override
62+
public void call(String content) {
63+
successCallback.invoke(null, content);
64+
}
65+
});
66+
}
67+
68+
public static TargetParameters mapToParameters(ReadableMap map) {
69+
if (map == null) {
70+
return null;
71+
}
72+
73+
TargetOrder order = mapToOrder(getNullableMap(map, ORDER_KEY));
74+
TargetProduct product = mapToProduct(getNullableMap(map, PRODUCT_KEY));
75+
76+
Map<String, String> parameters = RCTAEPTargetMapUtil.toStringMap(getNullableMap(map, PARAMETERS_KEY));
77+
Map<String, String> profileParameters = RCTAEPTargetMapUtil.toStringMap(getNullableMap(map, PROFILE_PARAMETERS_KEY));
78+
79+
return new TargetParameters.Builder().order(order).product(product).parameters(parameters).profileParameters(profileParameters).build();
80+
}
81+
82+
83+
public static TargetOrder mapToOrder(ReadableMap map) {
84+
if (map == null) {
85+
return null;
86+
}
87+
88+
List<String> purchasedProductsIds = RCTAEPTargetArrayUtil.toStringArray(getNullableArray(map, PURCHASED_PRODUCTS_IDS_KEY));
89+
return new TargetOrder(getNullableString(map, ORDER_ID_KEY), getNullableDouble(map, TOTAL_KEY), purchasedProductsIds);
90+
}
91+
92+
public static TargetProduct mapToProduct(ReadableMap map) {
93+
if (map == null) {
94+
return null;
95+
}
96+
97+
return new TargetProduct(getNullableString(map, PRODUCT_ID_KEY), getNullableString(map, CATEGORY_ID_KEY));
98+
}
10099

101100
// Helper methods
102101

0 commit comments

Comments
 (0)