@customerglu/react-native-customerglu 1.0.0
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.
- package/LICENSE +15 -0
- package/README.md +74 -0
- package/android/build.gradle +71 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +0 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/Bannerwidget/BannerWidgetViewGroupManager.java +40 -0
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/Bannerwidget/bannerWidget.java +44 -0
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/wrapperview/WrapperView.java +61 -0
- package/android/src/main/java/com/reactnativerncustomerglu/RncustomergluModule.java +528 -0
- package/android/src/main/java/com/reactnativerncustomerglu/RncustomergluPackage.java +31 -0
- package/android/src/main/res/drawable/bottom_sheet_edges.xml +7 -0
- package/android/src/main/res/drawable/floating_close_layout.xml +10 -0
- package/android/src/main/res/drawable/ic_arrow_back.xml +5 -0
- package/android/src/main/res/drawable/ic_back.xml +10 -0
- package/android/src/main/res/drawable/ic_delete_bin.xml +5 -0
- package/android/src/main/res/drawable/ic_delete_bin_red.xml +5 -0
- package/android/src/main/res/drawable/ij.png +0 -0
- package/android/src/main/res/drawable/notification.png +0 -0
- package/android/src/main/res/drawable/progress_bg.xml +33 -0
- package/android/src/main/res/layout/activity_reward.xml +66 -0
- package/android/src/main/res/layout/banner_adapter.xml +44 -0
- package/android/src/main/res/layout/bannner.xml +14 -0
- package/android/src/main/res/layout/bottom_dialog.xml +37 -0
- package/android/src/main/res/layout/bottomsheet.xml +8 -0
- package/android/src/main/res/layout/customerbannermsg.xml +37 -0
- package/android/src/main/res/layout/detail_alert.xml +21 -0
- package/android/src/main/res/layout/floating_banner.xml +11 -0
- package/android/src/main/res/layout/floating_draggable_button.xml +17 -0
- package/android/src/main/res/layout/fragment_bottom_sheet_dialog.xml +21 -0
- package/android/src/main/res/layout/image_banner.xml +10 -0
- package/android/src/main/res/layout/middle_dialog.xml +42 -0
- package/android/src/main/res/layout/rewards.xml +31 -0
- package/android/src/main/res/layout/web_activity.xml +43 -0
- package/android/src/main/res/values/colors.xml +13 -0
- package/android/src/main/res/values/themes.xml +16 -0
- package/android/src/main/res/xml/provider_path.xml +4 -0
- package/ios/CustomPlayer.m +25 -0
- package/ios/Rncustomerglu-Bridging-Header.h +4 -0
- package/ios/Rncustomerglu.m +50 -0
- package/ios/Rncustomerglu.swift +341 -0
- package/ios/Rncustomerglu.xcodeproj/project.pbxproj +293 -0
- package/ios/Rncustomerglu.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/lib/commonjs/index.js +184 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +117 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +35 -0
- package/package.json +157 -0
- package/react-native-rncustomerglu.podspec +24 -0
- package/src/index.tsx +146 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
package com.reactnativerncustomerglu;
|
|
2
|
+
|
|
3
|
+
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
4
|
+
|
|
5
|
+
import android.app.Activity;
|
|
6
|
+
import android.content.BroadcastReceiver;
|
|
7
|
+
import android.content.Context;
|
|
8
|
+
import android.content.Intent;
|
|
9
|
+
import android.content.IntentFilter;
|
|
10
|
+
import android.net.Uri;
|
|
11
|
+
import android.os.Build;
|
|
12
|
+
import android.util.Log;
|
|
13
|
+
import android.widget.Toast;
|
|
14
|
+
|
|
15
|
+
import androidx.annotation.NonNull;
|
|
16
|
+
import androidx.annotation.Nullable;
|
|
17
|
+
import androidx.annotation.RequiresApi;
|
|
18
|
+
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
19
|
+
|
|
20
|
+
import com.customerglu.sdk.Banners.Banner;
|
|
21
|
+
import com.facebook.react.bridge.ActivityEventListener;
|
|
22
|
+
import com.facebook.react.bridge.LifecycleEventListener;
|
|
23
|
+
import com.facebook.react.bridge.ReactContext;
|
|
24
|
+
import com.facebook.react.bridge.WritableArray;
|
|
25
|
+
import com.facebook.react.bridge.WritableNativeArray;
|
|
26
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
27
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
28
|
+
import com.facebook.react.bridge.WritableMap;
|
|
29
|
+
import com.facebook.react.bridge.Arguments;
|
|
30
|
+
import com.customerglu.sdk.CustomerGlu;
|
|
31
|
+
import com.customerglu.sdk.Interface.DataListner;
|
|
32
|
+
import com.customerglu.sdk.Modal.RegisterModal;
|
|
33
|
+
import com.facebook.react.bridge.Promise;
|
|
34
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
35
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
36
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
37
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
38
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
39
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
40
|
+
import com.facebook.react.bridge.ReadableType;
|
|
41
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
42
|
+
import com.google.gson.Gson;
|
|
43
|
+
|
|
44
|
+
import org.json.JSONArray;
|
|
45
|
+
import org.json.JSONException;
|
|
46
|
+
import org.json.JSONObject;
|
|
47
|
+
|
|
48
|
+
import java.lang.reflect.Array;
|
|
49
|
+
import java.net.MalformedURLException;
|
|
50
|
+
import java.net.URL;
|
|
51
|
+
import java.util.ArrayList;
|
|
52
|
+
import java.util.EventListener;
|
|
53
|
+
import java.util.HashMap;
|
|
54
|
+
import java.util.Iterator;
|
|
55
|
+
import java.util.Map;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@ReactModule(name = RncustomergluModule.NAME)
|
|
59
|
+
public class RncustomergluModule extends ReactContextBaseJavaModule implements LifecycleEventListener
|
|
60
|
+
{
|
|
61
|
+
public static final String TAG = RncustomergluModule.class.getName();
|
|
62
|
+
public static String Myclassname = "";
|
|
63
|
+
public static final String NAME = "Rncustomerglu";
|
|
64
|
+
private static ReactApplicationContext mContext;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
public RncustomergluModule(ReactApplicationContext reactContext) {
|
|
68
|
+
super(reactContext);
|
|
69
|
+
mContext = reactContext;
|
|
70
|
+
reactContext.addLifecycleEventListener(this);
|
|
71
|
+
CustomerGlu.initializeSdk(getReactApplicationContext());
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
|
|
78
|
+
@Override
|
|
79
|
+
public void onReceive(Context context, Intent intent) {
|
|
80
|
+
Log.d(TAG,"on Received....");
|
|
81
|
+
try {
|
|
82
|
+
if (intent.getAction().equalsIgnoreCase("CUSTOMERGLU_ANALYTICS_EVENT")) {
|
|
83
|
+
/* If you want to listen CUSTOMERGLU_ANALYTICS_EVENT */
|
|
84
|
+
if (intent.getStringExtra("data") != null) {
|
|
85
|
+
String data = intent.getStringExtra("data");
|
|
86
|
+
JSONObject jsonObject = new JSONObject(data);
|
|
87
|
+
WritableMap map = jsonToWritableMap(jsonObject);
|
|
88
|
+
sendEventToJs("CUSTOMERGLU_ANALYTICS_EVENT", map);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* If you want to listen CUSTOMERGLU_DEEPLINK_EVENT */
|
|
93
|
+
|
|
94
|
+
if (intent.getAction().equalsIgnoreCase("CUSTOMERGLU_DEEPLINK_EVENT")) {
|
|
95
|
+
if (intent.getStringExtra("data") != null) {
|
|
96
|
+
String data = intent.getStringExtra("data");
|
|
97
|
+
JSONObject jsonObject = new JSONObject(data);
|
|
98
|
+
WritableMap map = jsonToWritableMap(jsonObject);
|
|
99
|
+
sendEventToJs("CUSTOMERGLU_DEEPLINK_EVENT", map);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if (intent.getAction().equalsIgnoreCase("CUSTOMERGLU_BANNER_LOADED")) {
|
|
107
|
+
/* If you want to listen CUSTOMERGLU_BANNER_LOADED */
|
|
108
|
+
if (intent.getStringExtra("data") != null) {
|
|
109
|
+
String data = intent.getStringExtra("data");
|
|
110
|
+
JSONObject jsonObject = new JSONObject(data);
|
|
111
|
+
WritableMap map = jsonToWritableMap(jsonObject);
|
|
112
|
+
sendEventToJs("CUSTOMERGLU_BANNER_LOADED", map);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
} catch (Exception e) {
|
|
119
|
+
System.out.println(e);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
private void registerBroadcastReceiver() {
|
|
126
|
+
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_ANALYTICS_EVENT"));
|
|
127
|
+
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_DEEPLINK_EVENT"));
|
|
128
|
+
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_BANNER_LOADED"));
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
private void sendEventToJs(String eventName, WritableMap map) {
|
|
134
|
+
try {
|
|
135
|
+
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
136
|
+
.emit(eventName, map);
|
|
137
|
+
} catch (Exception e) {
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@Override
|
|
144
|
+
@NonNull
|
|
145
|
+
public String getName() {
|
|
146
|
+
return NAME;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@Override
|
|
150
|
+
public void onHostResume() {
|
|
151
|
+
Log.e(TAG,"On Host Resume....");
|
|
152
|
+
CustomerGlu.getInstance().showEntryPoint(getReactApplicationContext().getCurrentActivity());
|
|
153
|
+
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_ANALYTICS_EVENT"));
|
|
154
|
+
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_DEEPLINK_EVENT"));
|
|
155
|
+
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_BANNER_LOADED"));
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@Override
|
|
160
|
+
public void onHostPause() {
|
|
161
|
+
// mContext.unregisterReceiver(mMessageReceiver);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Override
|
|
165
|
+
public void onHostDestroy() {
|
|
166
|
+
// mContext.unregisterReceiver(mMessageReceiver);
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Example method
|
|
171
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@ReactMethod
|
|
176
|
+
public void registerDevice(ReadableMap map, Promise promise) {
|
|
177
|
+
JSONObject jsonObject = convertMapToJson(map);
|
|
178
|
+
HashMap<String, Object> userData = new Gson().fromJson(jsonObject.toString(), HashMap.class);
|
|
179
|
+
Log.d(TAG, "userdata----> " + userData.toString());
|
|
180
|
+
|
|
181
|
+
CustomerGlu.getInstance().registerDevice(getReactApplicationContext(), userData, true, new DataListner() {
|
|
182
|
+
//this method registers the user
|
|
183
|
+
@Override
|
|
184
|
+
public void onSuccess(RegisterModal registerModal) {
|
|
185
|
+
Toast.makeText(getReactApplicationContext(), "Registered", Toast.LENGTH_SHORT).show();
|
|
186
|
+
RegisterModal remodal = registerModal;
|
|
187
|
+
promise.resolve(true);
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@Override
|
|
193
|
+
public void onFail(String message) {
|
|
194
|
+
Toast.makeText(getReactApplicationContext(), "" + message, Toast.LENGTH_SHORT).show();
|
|
195
|
+
promise.resolve(false);
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@ReactMethod
|
|
203
|
+
public void dataClear() {
|
|
204
|
+
CustomerGlu.getInstance().clearGluData(getCurrentActivity());
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@ReactMethod
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
public void sendData(ReadableMap readableMap) {
|
|
212
|
+
try {
|
|
213
|
+
JSONObject obj= convertMapToJson(readableMap);
|
|
214
|
+
HashMap<String,Object> eventProperties = new HashMap<>();
|
|
215
|
+
eventProperties.put("eventName",obj.get("eventName"));
|
|
216
|
+
eventProperties.put("eventProperties",obj.get("eventProperties"));
|
|
217
|
+
String evnt = (String) obj.get("eventName");
|
|
218
|
+
CustomerGlu.getInstance().sendEvent(getReactApplicationContext(),evnt,eventProperties);
|
|
219
|
+
|
|
220
|
+
} catch (JSONException e) {
|
|
221
|
+
e.printStackTrace();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@ReactMethod
|
|
227
|
+
public void openWallet(Boolean autoclosewebview) {
|
|
228
|
+
CustomerGlu.getInstance().openWallet(getReactApplicationContext(),autoclosewebview);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@ReactMethod
|
|
232
|
+
public void loadCampaignIdBy(String id, Boolean autoclosewebview) {
|
|
233
|
+
CustomerGlu.getInstance().loadCampaignById(getReactApplicationContext(), id, autoclosewebview);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@ReactMethod
|
|
237
|
+
public void enableAnalytic(Boolean bool) {
|
|
238
|
+
CustomerGlu.getInstance().enableAnalyticsEvent(bool);
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@ReactMethod
|
|
244
|
+
public void disableGluSdk(Boolean bool) {
|
|
245
|
+
CustomerGlu.getInstance().disableGluSdk(bool);
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@ReactMethod
|
|
250
|
+
public void configureLoaderColour(String color) {
|
|
251
|
+
CustomerGlu.getInstance().configureLoaderColour(getReactApplicationContext(), color);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@ReactMethod
|
|
255
|
+
public void enablePrecaching() {
|
|
256
|
+
CustomerGlu.getInstance().enablePrecaching(getReactApplicationContext());
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@ReactMethod
|
|
260
|
+
public void gluSDKDebuggingMode(Boolean bol) {
|
|
261
|
+
CustomerGlu.getInstance().gluSDKDebuggingMode(getCurrentActivity(), bol);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
@ReactMethod
|
|
265
|
+
public void enableEntryPoints(Boolean bol) {
|
|
266
|
+
CustomerGlu.getInstance().enableEntryPoints(getCurrentActivity(), bol);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@ReactMethod
|
|
270
|
+
public void closeWebView(Boolean bol) {
|
|
271
|
+
CustomerGlu.getInstance().closeWebviewOnDeeplinkEvent(bol);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@ReactMethod
|
|
275
|
+
public void SetDefaultBannerImage(String url) {
|
|
276
|
+
CustomerGlu.getInstance().setDefaultBannerImage(getCurrentActivity(), url);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
@ReactMethod
|
|
282
|
+
public void UpdateProfile(ReadableMap map, Promise promise) {
|
|
283
|
+
JSONObject jsonObject = convertMapToJson(map);
|
|
284
|
+
HashMap<String, Object> userData = new Gson().fromJson(jsonObject.toString(), HashMap.class);
|
|
285
|
+
CustomerGlu.getInstance().updateProfile(getReactApplicationContext(), userData, new DataListner() {
|
|
286
|
+
@Override
|
|
287
|
+
public void onSuccess(RegisterModal registerModal) {
|
|
288
|
+
Toast.makeText(getReactApplicationContext(), "Profile Updated", Toast.LENGTH_SHORT).show();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@Override
|
|
292
|
+
public void onFail(String message) {
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
@ReactMethod
|
|
299
|
+
public void DisplayBackGroundNotification(ReadableMap data,Boolean autoclosewebview) {
|
|
300
|
+
JSONObject jsonObject=convertMapToJson(data);
|
|
301
|
+
CustomerGlu.getInstance().displayCustomerGluNotification(getReactApplicationContext(),jsonObject,R.drawable.notification,0.5, autoclosewebview);
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@ReactMethod
|
|
306
|
+
public void CGApplication() {
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@ReactMethod
|
|
310
|
+
public void DisplayCustomerGluNotification() {
|
|
311
|
+
registerBroadcastReceiver();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@ReactMethod
|
|
315
|
+
public void GetRefferalId(String url, Promise promise) throws MalformedURLException {
|
|
316
|
+
Uri myURL = Uri.parse(url);
|
|
317
|
+
String referID = CustomerGlu.getInstance().getReferralId(myURL);
|
|
318
|
+
promise.resolve(referID);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@ReactMethod
|
|
322
|
+
public void LoadAllCampagins() {
|
|
323
|
+
CustomerGlu.getInstance().loadAllCampaigns(getReactApplicationContext());
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@ReactMethod
|
|
327
|
+
public void LoadCampaginsByFilter(ReadableMap readableMap) {
|
|
328
|
+
try {
|
|
329
|
+
JSONObject obj = convertMapToJson(readableMap);
|
|
330
|
+
HashMap<String, Object> campaignData = new HashMap<>();
|
|
331
|
+
campaignData.put("campaignId", obj.get("campaignId"));
|
|
332
|
+
campaignData.put("status", obj.get("status"));
|
|
333
|
+
campaignData.put("type", obj.get("type"));
|
|
334
|
+
CustomerGlu.getInstance().loadCampaignsByFilter(getReactApplicationContext(), campaignData);
|
|
335
|
+
} catch (JSONException e) {
|
|
336
|
+
e.printStackTrace();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@ReactMethod
|
|
341
|
+
public void SetCurrentClassName(String classname) {
|
|
342
|
+
this.Myclassname = classname;
|
|
343
|
+
runOnUiThread(new Runnable() {
|
|
344
|
+
@Override
|
|
345
|
+
public void run() {
|
|
346
|
+
CustomerGlu.getInstance().setScreenName(getReactApplicationContext(),classname);
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
@ReactMethod
|
|
353
|
+
public void OpenWalletWithUrl(String url) {
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@ReactMethod
|
|
357
|
+
public void configureWhiteListedDomains(ReadableArray readableArray) {
|
|
358
|
+
try {
|
|
359
|
+
JSONArray obj = convertArrayToJson(readableArray);
|
|
360
|
+
ArrayList<String> listdata = new ArrayList<String>();
|
|
361
|
+
for (int i=0;i<obj.length();i++){
|
|
362
|
+
listdata.add((String) obj.get(i));
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
CustomerGlu.getInstance().configureWhiteListedDomains(listdata);
|
|
366
|
+
} catch (JSONException e) {
|
|
367
|
+
e.printStackTrace();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
@ReactMethod
|
|
374
|
+
public void configureDomainCodeMsg(ReadableMap readableMap) {
|
|
375
|
+
try {
|
|
376
|
+
JSONObject obj = convertMapToJson(readableMap);
|
|
377
|
+
int code = (int) obj.get("code");
|
|
378
|
+
String msg = (String) obj.get("msg");
|
|
379
|
+
CustomerGlu.getInstance().configureDomainCodeMsg(code,msg);
|
|
380
|
+
} catch (JSONException e) {
|
|
381
|
+
e.printStackTrace();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
private JSONObject convertMapToJson(ReadableMap readableMap) {
|
|
388
|
+
JSONObject jsonObject = new JSONObject();
|
|
389
|
+
if (readableMap == null) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
393
|
+
if (!iterator.hasNextKey()) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
while (iterator.hasNextKey()) {
|
|
397
|
+
String key = iterator.nextKey();
|
|
398
|
+
ReadableType readableType = readableMap.getType(key);
|
|
399
|
+
try {
|
|
400
|
+
switch (readableType) {
|
|
401
|
+
case Null:
|
|
402
|
+
jsonObject.put(key, null);
|
|
403
|
+
break;
|
|
404
|
+
case Boolean:
|
|
405
|
+
jsonObject.put(key, readableMap.getBoolean(key));
|
|
406
|
+
break;
|
|
407
|
+
case Number:
|
|
408
|
+
// Can be int or double.
|
|
409
|
+
jsonObject.put(key, readableMap.getInt(key));
|
|
410
|
+
break;
|
|
411
|
+
case String:
|
|
412
|
+
jsonObject.put(key, readableMap.getString(key));
|
|
413
|
+
|
|
414
|
+
break;
|
|
415
|
+
case Array:
|
|
416
|
+
jsonObject.put(key, convertArrayToJson(readableMap.getArray(key)));
|
|
417
|
+
default:
|
|
418
|
+
// Do nothing and fail silently
|
|
419
|
+
}
|
|
420
|
+
} catch (JSONException ex) {
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return jsonObject;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
|
|
427
|
+
JSONArray array = new JSONArray();
|
|
428
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
429
|
+
switch (readableArray.getType(i)) {
|
|
430
|
+
case Null:
|
|
431
|
+
break;
|
|
432
|
+
case Boolean:
|
|
433
|
+
array.put(readableArray.getBoolean(i));
|
|
434
|
+
break;
|
|
435
|
+
case Number:
|
|
436
|
+
array.put(readableArray.getDouble(i));
|
|
437
|
+
break;
|
|
438
|
+
case String:
|
|
439
|
+
array.put(readableArray.getString(i));
|
|
440
|
+
break;
|
|
441
|
+
// case Map:
|
|
442
|
+
// array.put(readableMapToJson(readableArray.getMap(i)));
|
|
443
|
+
// break;
|
|
444
|
+
case Array:
|
|
445
|
+
array.put(convertArrayToJson(readableArray.getArray(i)));
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return array;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
public static WritableMap jsonToWritableMap(JSONObject jsonObject) {
|
|
454
|
+
WritableMap writableMap = new WritableNativeMap();
|
|
455
|
+
if (jsonObject == null) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
Iterator<String> iterator = jsonObject.keys();
|
|
459
|
+
if (!iterator.hasNext()) {
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
while (iterator.hasNext()) {
|
|
463
|
+
String key = iterator.next();
|
|
464
|
+
try {
|
|
465
|
+
Object value = jsonObject.get(key);
|
|
466
|
+
if (value == null) {
|
|
467
|
+
writableMap.putNull(key);
|
|
468
|
+
} else if (value instanceof Boolean) {
|
|
469
|
+
writableMap.putBoolean(key, (Boolean) value);
|
|
470
|
+
} else if (value instanceof Integer) {
|
|
471
|
+
writableMap.putInt(key, (Integer) value);
|
|
472
|
+
} else if (value instanceof Double) {
|
|
473
|
+
writableMap.putDouble(key, (Double) value);
|
|
474
|
+
} else if (value instanceof String) {
|
|
475
|
+
writableMap.putString(key, (String) value);
|
|
476
|
+
} else if (value instanceof JSONObject) {
|
|
477
|
+
writableMap.putMap(key, jsonToWritableMap((JSONObject) value));
|
|
478
|
+
} else if (value instanceof JSONArray) {
|
|
479
|
+
writableMap.putArray(key, jsonArrayToWritableArray((JSONArray) value));
|
|
480
|
+
}
|
|
481
|
+
} catch (JSONException ex) {
|
|
482
|
+
// Do nothing and fail silently
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return writableMap;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
public static WritableArray jsonArrayToWritableArray(JSONArray jsonArray) {
|
|
490
|
+
WritableArray writableArray = new WritableNativeArray();
|
|
491
|
+
|
|
492
|
+
if (jsonArray == null) {
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (jsonArray.length() <= 0) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
for (int i = 0; i < jsonArray.length(); i++) {
|
|
501
|
+
try {
|
|
502
|
+
Object value = jsonArray.get(i);
|
|
503
|
+
if (value == null) {
|
|
504
|
+
writableArray.pushNull();
|
|
505
|
+
} else if (value instanceof Boolean) {
|
|
506
|
+
writableArray.pushBoolean((Boolean) value);
|
|
507
|
+
} else if (value instanceof Integer) {
|
|
508
|
+
writableArray.pushInt((Integer) value);
|
|
509
|
+
} else if (value instanceof Double) {
|
|
510
|
+
writableArray.pushDouble((Double) value);
|
|
511
|
+
} else if (value instanceof String) {
|
|
512
|
+
writableArray.pushString((String) value);
|
|
513
|
+
} else if (value instanceof JSONObject) {
|
|
514
|
+
writableArray.pushMap(jsonToWritableMap((JSONObject) value));
|
|
515
|
+
} else if (value instanceof JSONArray) {
|
|
516
|
+
writableArray.pushArray(jsonArrayToWritableArray((JSONArray) value));
|
|
517
|
+
}
|
|
518
|
+
} catch (JSONException e) {
|
|
519
|
+
// Do nothing and fail silently
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return writableArray;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
// public static native int nativeMultiply(int a, int b);
|
|
528
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.reactnativerncustomerglu;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
import com.reactnativerncustomerglu.Bannerwidget.Bannerwidget.BannerWidgetViewGroupManager;
|
|
10
|
+
|
|
11
|
+
import java.util.ArrayList;
|
|
12
|
+
import java.util.Arrays;
|
|
13
|
+
import java.util.List;
|
|
14
|
+
|
|
15
|
+
public class RncustomergluPackage implements ReactPackage {
|
|
16
|
+
@NonNull
|
|
17
|
+
@Override
|
|
18
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
19
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
20
|
+
modules.add(new RncustomergluModule(reactContext));
|
|
21
|
+
return modules;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@NonNull
|
|
25
|
+
@Override
|
|
26
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
27
|
+
return Arrays.asList(
|
|
28
|
+
new BannerWidgetViewGroupManager()
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
|
3
|
+
<solid android:color="@color/white"/>
|
|
4
|
+
<stroke android:width="1dp" android:color="@color/white"/>
|
|
5
|
+
<corners android:radius="20dp"/>
|
|
6
|
+
|
|
7
|
+
</shape>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
android:shape="rectangle">
|
|
4
|
+
<!-- Gradient Bg for listrow -->
|
|
5
|
+
<gradient
|
|
6
|
+
android:startColor="#f1f1f2"
|
|
7
|
+
android:centerColor="#e7e7e8"
|
|
8
|
+
android:endColor="#474748"
|
|
9
|
+
android:angle="270" />
|
|
10
|
+
</shape>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<vector android:autoMirrored="true" android:height="24dp"
|
|
2
|
+
android:tint="#000" android:viewportHeight="24"
|
|
3
|
+
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
|
+
<path android:fillColor="@android:color/white" android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/>
|
|
5
|
+
</vector>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
android:width="24dp"
|
|
3
|
+
android:height="24dp"
|
|
4
|
+
android:viewportWidth="24"
|
|
5
|
+
android:viewportHeight="24"
|
|
6
|
+
android:tint="?attr/colorControlNormal">
|
|
7
|
+
<path
|
|
8
|
+
android:fillColor="@android:color/black"
|
|
9
|
+
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
|
10
|
+
</vector>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<vector android:height="24dp" android:tint="#FFFFFF"
|
|
2
|
+
android:viewportHeight="24" android:viewportWidth="24"
|
|
3
|
+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
|
+
<path android:fillColor="@android:color/white" android:pathData="M16,9v10H8V9h8m-1.5,-6h-5l-1,1H5v2h14V4h-3.5l-1,-1zM18,7H6v12c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7z"/>
|
|
5
|
+
</vector>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<vector android:alpha="0.95" android:height="24dp"
|
|
2
|
+
android:tint="#F62323" android:viewportHeight="24"
|
|
3
|
+
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
|
+
<path android:fillColor="@android:color/white" android:pathData="M16,9v10H8V9h8m-1.5,-6h-5l-1,1H5v2h14V4h-3.5l-1,-1zM18,7H6v12c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7z"/>
|
|
5
|
+
</vector>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--use rotate tag to rotate the drawable-->
|
|
3
|
+
<rotate
|
|
4
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
|
+
android:fromDegrees="0"
|
|
6
|
+
android:pivotX="50%"
|
|
7
|
+
android:pivotY="50%"
|
|
8
|
+
android:toDegrees="2080">
|
|
9
|
+
|
|
10
|
+
<!--shape tag is used to
|
|
11
|
+
build a shape in XML-->
|
|
12
|
+
<shape
|
|
13
|
+
android:innerRadiusRatio="2"
|
|
14
|
+
android:shape="ring"
|
|
15
|
+
android:thicknessRatio="9"
|
|
16
|
+
android:useLevel="false">
|
|
17
|
+
|
|
18
|
+
<!--set the size of the shape-->
|
|
19
|
+
<size
|
|
20
|
+
android:width="60dip"
|
|
21
|
+
android:height="90dip" />
|
|
22
|
+
|
|
23
|
+
<!--set the color gradients
|
|
24
|
+
of the shape-->
|
|
25
|
+
<gradient
|
|
26
|
+
android:angle="0"
|
|
27
|
+
android:endColor="#00ffffff"
|
|
28
|
+
android:startColor="#0462EB"
|
|
29
|
+
android:type="sweep"
|
|
30
|
+
android:useLevel="false" />
|
|
31
|
+
</shape>
|
|
32
|
+
|
|
33
|
+
</rotate>
|