1
1
2
2
package com .instabug .reactlibrary ;
3
3
4
+ import android .net .Uri ;
5
+
4
6
import com .facebook .react .bridge .ReactApplicationContext ;
5
7
import com .facebook .react .bridge .ReactContextBaseJavaModule ;
6
8
import com .facebook .react .bridge .ReactMethod ;
7
- import com .facebook .react .bridge .Callback ;
8
- import android .app .Application ;
9
9
import com .instabug .library .Instabug ;
10
- import com .instabug .library .InstabugColorTheme ;
11
- import com .instabug .library .InstabugTrackingDelegate ;
12
10
import com .instabug .library .internal .module .InstabugLocale ;
13
11
import com .instabug .library .invocation .InstabugInvocationEvent ;
14
12
import com .instabug .library .invocation .InstabugInvocationMode ;
15
- import com . instabug . library . invocation . util . InstabugFloatingButtonEdge ;
13
+
16
14
import java .util .ArrayList ;
17
15
import java .util .HashMap ;
18
16
import java .util .Locale ;
19
- import android .net .Uri ;
20
17
import java .util .Map ;
21
18
22
19
@@ -53,75 +50,70 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
53
50
private final String LOCALE_SWEDISH = "swedish" ;
54
51
private final String LOCALE_TURKISH = "turkish" ;
55
52
56
- public RNInstabugReactnativeModule (ReactApplicationContext reactContext ,Instabug mInstabug ) {
57
- super (reactContext );
58
- this .mInstabug = mInstabug ;
59
- }
53
+ public RNInstabugReactnativeModule (ReactApplicationContext reactContext , Instabug mInstabug ) {
54
+ super (reactContext );
55
+ this .mInstabug = mInstabug ;
56
+ }
60
57
61
- @ Override
62
- public String getName () {
63
- return "Instabug" ;
64
- }
58
+ @ Override
59
+ public String getName () {
60
+ return "Instabug" ;
61
+ }
65
62
66
- /**
63
+ /**
67
64
* invoke sdk manually
68
- *
69
65
*/
70
66
@ ReactMethod
71
- public void invoke ()
72
- {
67
+ public void invoke () {
73
68
try {
74
- mInstabug .invoke ();
69
+ mInstabug .invoke ();
75
70
} catch (Exception e ) {
76
71
e .printStackTrace ();
77
72
}
78
73
}
79
74
80
- /**
75
+ /**
81
76
* invoke sdk manually with desire invocation mode
82
77
*
83
78
* @param invocation mode
84
79
*/
85
80
@ ReactMethod
86
- public void invokeWithInvocationMode (String invocationMode )
87
- {
81
+ public void invokeWithInvocationMode (String invocationMode ) {
88
82
InstabugInvocationMode mode ;
89
83
90
84
if (invocationMode .equals (INVOCATION_MODE_NEW_BUG )) {
91
85
mode = InstabugInvocationMode .NEW_BUG ;
92
86
} else if (invocationMode .equals (INVOCATION_MODE_NEW_FEEDBACK )) {
93
87
mode = InstabugInvocationMode .NEW_FEEDBACK ;
94
- }else if (invocationMode .equals (INVOCATION_MODE_NEW_CHAT )){
88
+ } else if (invocationMode .equals (INVOCATION_MODE_NEW_CHAT )) {
95
89
mode = InstabugInvocationMode .NEW_CHAT ;
96
- }else if (invocationMode .equals (INVOCATION_MODE_CHATS_LIST )){
90
+ } else if (invocationMode .equals (INVOCATION_MODE_CHATS_LIST )) {
97
91
mode = InstabugInvocationMode .CHATS_LIST ;
98
92
} else {
99
93
mode = InstabugInvocationMode .PROMPT_OPTION ;
100
94
}
101
95
102
- try {
103
- mInstabug .invoke (mode );
96
+ try {
97
+ mInstabug .invoke (mode );
104
98
} catch (Exception e ) {
105
99
e .printStackTrace ();
106
100
}
107
101
}
108
102
109
103
110
- /**
104
+ /**
111
105
* Dismisses all visible Instabug views
112
- *
113
106
*/
114
107
@ ReactMethod
115
- public void dismiss ()
116
- {
108
+ public void dismiss () {
117
109
try {
118
- mInstabug .dismiss ();
110
+ mInstabug .dismiss ();
119
111
} catch (Exception e ) {
120
112
e .printStackTrace ();
121
113
}
122
114
}
123
115
124
- /**
116
+ /**
125
117
* Adds tag(s) to issues before sending them
126
118
*
127
119
* @param tags
@@ -225,14 +217,15 @@ public void showIntroMessage() {
225
217
}
226
218
}
227
219
228
- /** Set the primary color that the SDK will use to tint certain UI elements in the SDK
220
+ /**
221
+ * Set the primary color that the SDK will use to tint certain UI elements in the SDK
229
222
*
230
223
* @param primaryColorValue The value of the primary color ,
231
- * whatever this color was parsed from a resource color or hex color or RGB color values
224
+ * whatever this color was parsed from a resource color or hex color or RGB color values
232
225
*/
233
226
@ ReactMethod
234
227
public void setPrimaryColor (int primaryColor ) {
235
- try {
228
+ try {
236
229
mInstabug .setPrimaryColor (primaryColor );
237
230
} catch (Exception e ) {
238
231
e .printStackTrace ();
@@ -241,6 +234,7 @@ public void setPrimaryColor(int primaryColor) {
241
234
242
235
/**
243
236
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
237
+ *
244
238
* @param {boolean} screenShot A boolean to enable or disable screenshot attachments.
245
239
* @param {boolean} extraScreenShot A boolean to enable or disable extra screenshot attachments.
246
240
* @param {boolean} galleryImage A boolean to enable or disable gallery image attachments.
@@ -281,9 +275,9 @@ public void log(String message) {
281
275
*/
282
276
@ ReactMethod
283
277
public ArrayList <String > getTags () {
284
- ArrayList <String > tags = new ArrayList <String >();
278
+ ArrayList <String > tags = new ArrayList <String >();
285
279
try {
286
- tags = mInstabug .getTags ();
280
+ tags = mInstabug .getTags ();
287
281
} catch (Exception e ) {
288
282
e .printStackTrace ();
289
283
}
@@ -292,7 +286,6 @@ public ArrayList<String> getTags() {
292
286
293
287
/**
294
288
* Reset ALL tags added using {@link #addTags(String...)}
295
- *
296
289
*/
297
290
@ ReactMethod
298
291
public void resetTags () {
@@ -310,9 +303,9 @@ public void resetTags() {
310
303
*/
311
304
@ ReactMethod
312
305
public boolean isEnabled () {
313
- boolean isEnabled = false ;
306
+ boolean isEnabled = false ;
314
307
try {
315
- isEnabled = mInstabug .isEnabled ();
308
+ isEnabled = mInstabug .isEnabled ();
316
309
} catch (Exception e ) {
317
310
e .printStackTrace ();
318
311
}
@@ -322,7 +315,6 @@ public boolean isEnabled() {
322
315
323
316
/**
324
317
* Enables all Instabug functionality
325
- *
326
318
*/
327
319
@ ReactMethod
328
320
public void enable () {
@@ -335,7 +327,6 @@ public void enable() {
335
327
336
328
/**
337
329
* Disables all Instabug functionality
338
- *
339
330
*/
340
331
@ ReactMethod
341
332
public void disable () {
@@ -351,9 +342,9 @@ public void disable() {
351
342
*/
352
343
@ ReactMethod
353
344
public String getAppToken () {
354
- String appToken = "" ;
345
+ String appToken = "" ;
355
346
try {
356
- appToken = mInstabug .getAppToken ();
347
+ appToken = mInstabug .getAppToken ();
357
348
} catch (Exception e ) {
358
349
e .printStackTrace ();
359
350
}
@@ -369,9 +360,9 @@ public String getAppToken() {
369
360
*/
370
361
@ ReactMethod
371
362
public int getUnreadMessagesCount () {
372
- int unreadMessages = 0 ;
363
+ int unreadMessages = 0 ;
373
364
try {
374
- unreadMessages = mInstabug .getUnreadMessagesCount ();
365
+ unreadMessages = mInstabug .getUnreadMessagesCount ();
375
366
} catch (Exception e ) {
376
367
e .printStackTrace ();
377
368
}
@@ -387,22 +378,22 @@ public int getUnreadMessagesCount() {
387
378
*/
388
379
@ ReactMethod
389
380
public void changeInvocationEvent (String invocationEventValue ) {
390
- InstabugInvocationEvent invocationEvent = InstabugInvocationEvent .FLOATING_BUTTON ;
381
+ InstabugInvocationEvent invocationEvent = InstabugInvocationEvent .FLOATING_BUTTON ;
391
382
try {
392
383
//setting invocation event
393
- if (invocationEventValue .equals (INVOCATION_EVENT_FLOATING_BUTTON )) {
394
- invocationEvent = InstabugInvocationEvent .FLOATING_BUTTON ;
395
- } else if (invocationEventValue .equals (INVOCATION_EVENT_TWO_FINGERS_SWIPE )) {
396
- invocationEvent = InstabugInvocationEvent .TWO_FINGER_SWIPE_LEFT ;
397
- } else if (invocationEventValue .equals (INVOCATION_EVENT_SHAKE )) {
398
- invocationEvent = InstabugInvocationEvent .SHAKE ;
399
- } else if (invocationEventValue .equals (INVOCATION_EVENT_SCREENSHOT )){
400
- invocationEvent = InstabugInvocationEvent .SCREENSHOT_GESTURE ;
401
- } else if (invocationEventValue .equals (INVOCATION_EVENT_NONE )) {
402
- invocationEvent = InstabugInvocationEvent .NONE ;
384
+ if (invocationEventValue .equals (INVOCATION_EVENT_FLOATING_BUTTON )) {
385
+ invocationEvent = InstabugInvocationEvent .FLOATING_BUTTON ;
386
+ } else if (invocationEventValue .equals (INVOCATION_EVENT_TWO_FINGERS_SWIPE )) {
387
+ invocationEvent = InstabugInvocationEvent .TWO_FINGER_SWIPE_LEFT ;
388
+ } else if (invocationEventValue .equals (INVOCATION_EVENT_SHAKE )) {
389
+ invocationEvent = InstabugInvocationEvent .SHAKE ;
390
+ } else if (invocationEventValue .equals (INVOCATION_EVENT_SCREENSHOT )) {
391
+ invocationEvent = InstabugInvocationEvent .SCREENSHOT_GESTURE ;
392
+ } else if (invocationEventValue .equals (INVOCATION_EVENT_NONE )) {
393
+ invocationEvent = InstabugInvocationEvent .NONE ;
403
394
}
404
395
405
- mInstabug .changeInvocationEvent (invocationEvent );
396
+ mInstabug .changeInvocationEvent (invocationEvent );
406
397
} catch (Exception e ) {
407
398
e .printStackTrace ();
408
399
}
@@ -417,7 +408,7 @@ public void changeInvocationEvent(String invocationEventValue) {
417
408
@ ReactMethod
418
409
public void setChatNotificationEnabled (boolean isChatNotificationEnable ) {
419
410
try {
420
- mInstabug .setChatNotificationEnabled (isChatNotificationEnable );
411
+ mInstabug .setChatNotificationEnabled (isChatNotificationEnable );
421
412
} catch (Exception e ) {
422
413
e .printStackTrace ();
423
414
}
@@ -433,48 +424,48 @@ public void setChatNotificationEnabled(boolean isChatNotificationEnable) {
433
424
@ ReactMethod
434
425
public void setDebugEnabled (boolean isDebugEnabled ) {
435
426
try {
436
- mInstabug .setDebugEnabled (isDebugEnabled );
427
+ mInstabug .setDebugEnabled (isDebugEnabled );
437
428
} catch (Exception e ) {
438
429
e .printStackTrace ();
439
430
}
440
431
}
441
432
442
433
private Locale getLocaleByKey (String instabugLocale ) {
443
- String localeInLowerCase = instabugLocale .toLowerCase ();
434
+ String localeInLowerCase = instabugLocale .toLowerCase ();
444
435
case LOCALE_ARABIC :
445
- return new Locale (InstabugLocale .ARABIC .getCode (), InstabugLocale .ARABIC .getCountry ());
436
+ return new Locale (InstabugLocale .ARABIC .getCode (), InstabugLocale .ARABIC .getCountry ());
446
437
case LOCALE_ENGLISH :
447
- return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH .getCountry ());
438
+ return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH .getCountry ());
448
439
case LOCALE_CZECH :
449
- return new Locale (InstabugLocale .CZECH .getCode (), InstabugLocale .CZECH .getCountry ());
440
+ return new Locale (InstabugLocale .CZECH .getCode (), InstabugLocale .CZECH .getCountry ());
450
441
case LOCALE_FRENCH :
451
- return new Locale (InstabugLocale .FRENCH .getCode (), InstabugLocale .FRENCH .getCountry ());
442
+ return new Locale (InstabugLocale .FRENCH .getCode (), InstabugLocale .FRENCH .getCountry ());
452
443
case LOCALE_GERMAN :
453
- return new Locale (InstabugLocale .GERMAN .getCode (), InstabugLocale .GERMAN .getCountry ());
444
+ return new Locale (InstabugLocale .GERMAN .getCode (), InstabugLocale .GERMAN .getCountry ());
454
445
case LOCALE_ITALIAN :
455
- return new Locale (InstabugLocale .ITALIAN .getCode (), InstabugLocale .ITALIAN .getCountry ());
446
+ return new Locale (InstabugLocale .ITALIAN .getCode (), InstabugLocale .ITALIAN .getCountry ());
456
447
case LOCALE_JAPANESE :
457
- return new Locale (InstabugLocale .JAPANESE .getCode (), InstabugLocale .JAPANESE .getCountry ());
448
+ return new Locale (InstabugLocale .JAPANESE .getCode (), InstabugLocale .JAPANESE .getCountry ());
458
449
case LOCALE_POLISH :
459
- return new Locale (InstabugLocale .POLISH .getCode (), InstabugLocale .POLISH .getCountry ());
450
+ return new Locale (InstabugLocale .POLISH .getCode (), InstabugLocale .POLISH .getCountry ());
460
451
case LOCALE_RUSSIAN :
461
- return new Locale (InstabugLocale .RUSSIAN .getCode (), InstabugLocale .RUSSIAN .getCountry ());
452
+ return new Locale (InstabugLocale .RUSSIAN .getCode (), InstabugLocale .RUSSIAN .getCountry ());
462
453
case LOCALE_SPANISH :
463
- return new Locale (InstabugLocale .SPANISH .getCode (), InstabugLocale .SPANISH .getCountry ());
454
+ return new Locale (InstabugLocale .SPANISH .getCode (), InstabugLocale .SPANISH .getCountry ());
464
455
case LOCALE_SWEDISH :
465
- return new Locale (InstabugLocale .SWEDISH .getCode (), InstabugLocale .SWEDISH .getCountry ());
456
+ return new Locale (InstabugLocale .SWEDISH .getCode (), InstabugLocale .SWEDISH .getCountry ());
466
457
case LOCALE_TURKISH :
467
- return new Locale (InstabugLocale .TURKISH .getCode (), InstabugLocale .TURKISH .getCountry ());
458
+ return new Locale (InstabugLocale .TURKISH .getCode (), InstabugLocale .TURKISH .getCountry ());
468
459
case LOCALE_PORTUGUESE_BRAZIL :
469
- return new Locale (InstabugLocale .PORTUGUESE_BRAZIL .getCode (), InstabugLocale .PORTUGUESE_BRAZIL .getCountry ());
460
+ return new Locale (InstabugLocale .PORTUGUESE_BRAZIL .getCode (), InstabugLocale .PORTUGUESE_BRAZIL .getCountry ());
470
461
case LOCALE_CHINESE_SIMPLIFIED :
471
- return new Locale (InstabugLocale .SIMPLIFIED_CHINESE .getCode (), InstabugLocale .SIMPLIFIED_CHINESE .getCountry ());
462
+ return new Locale (InstabugLocale .SIMPLIFIED_CHINESE .getCode (), InstabugLocale .SIMPLIFIED_CHINESE .getCountry ());
472
463
case LOCALE_CHINESE_TRADITIONAL :
473
- return new Locale (InstabugLocale .TRADITIONAL_CHINESE .getCode (), InstabugLocale .TRADITIONAL_CHINESE .getCountry ());
464
+ return new Locale (InstabugLocale .TRADITIONAL_CHINESE .getCode (), InstabugLocale .TRADITIONAL_CHINESE .getCountry ());
474
465
case LOCALE_KOREAN :
475
- return new Locale (InstabugLocale .KOREAN .getCode (), InstabugLocale .KOREAN .getCountry ());
466
+ return new Locale (InstabugLocale .KOREAN .getCode (), InstabugLocale .KOREAN .getCountry ());
476
467
default :
477
- return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH .getCountry ());
468
+ return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH .getCountry ());
478
469
}
479
470
480
471
@ Override
0 commit comments