13
13
import com .instabug .library .invocation .InstabugInvocationEvent ;
14
14
import com .instabug .library .invocation .InstabugInvocationMode ;
15
15
import com .instabug .library .invocation .util .InstabugFloatingButtonEdge ;
16
- import java .util .Locale ;
16
+ import java .util .ArrayList ;
17
17
import java .util .HashMap ;
18
+ import java .util .Locale ;
18
19
import android .net .Uri ;
19
20
import java .util .Map ;
20
21
@@ -36,13 +37,60 @@ public String getName() {
36
37
37
38
/**
38
39
* invoke sdk manually
39
- *
40
- * @param tags
40
+ *
41
41
*/
42
42
@ ReactMethod
43
43
public void invoke ()
44
44
{
45
- mInstabug .invoke ();
45
+ try {
46
+ mInstabug .invoke ();
47
+ } catch (Exception e ) {
48
+ e .printStackTrace ();
49
+ }
50
+ }
51
+
52
+ /**
53
+ * invoke sdk manually with desire invocation mode
54
+ *
55
+ * @param invocation mode
56
+ */
57
+ @ ReactMethod
58
+ public void invokeWithInvocationMode (String invocationMode )
59
+ {
60
+ InstabugInvocationMode mode = InstabugInvocationMode .PROMPT_OPTION ;
61
+ if (invocationMode .equals ("bug" )) {
62
+ mode = InstabugInvocationMode .NEW_BUG ;
63
+ } else if (invocationMode .equals ("feedback" )) {
64
+ mode = InstabugInvocationMode .NEW_FEEDBACK ;
65
+ }else if (invocationMode .equals ("chat" )){
66
+ mode = InstabugInvocationMode .NEW_CHAT ;
67
+ }else if (invocationMode .equals ("chats" )){
68
+ mode = InstabugInvocationMode .CHATS_LIST ;
69
+ }else {
70
+ mode = InstabugInvocationMode .PROMPT_OPTION ;
71
+ }
72
+
73
+ try {
74
+ mInstabug .invoke (mode );
75
+ } catch (Exception e ) {
76
+ e .printStackTrace ();
77
+ }
78
+
79
+ }
80
+
81
+
82
+ /**
83
+ * Dismisses all visible Instabug views
84
+ *
85
+ */
86
+ @ ReactMethod
87
+ public void dismiss ()
88
+ {
89
+ try {
90
+ mInstabug .dismiss ();
91
+ } catch (Exception e ) {
92
+ e .printStackTrace ();
93
+ }
46
94
}
47
95
48
96
/**
@@ -67,46 +115,14 @@ public void addTags(String tags) {
67
115
* @param languageTag
68
116
*/
69
117
@ ReactMethod
70
- public void changeLocale (String languageTag ) {
118
+ public void changeLocale (Locale languageTag ) {
71
119
try {
72
- switch (languageTag ) {
73
- case "CHINA" :
74
- case "CHINESE" :
75
- case "PRC" :
76
- case "SIMPLIFIED_CHINESE" :
77
- mInstabug .changeLocale (Locale .CHINESE );
78
- break ;
79
- case "TAIWAN" :
80
- case "TRADITIONAL_CHINESE" :
81
- mInstabug .changeLocale (Locale .TAIWAN );
82
- break ;
83
- case "ENGLISH" :
84
- mInstabug .changeLocale (Locale .ENGLISH );
85
- break ;
86
- case "UK" :
87
- mInstabug .changeLocale (Locale .UK );
88
- break ;
89
- case "US" :
90
- mInstabug .changeLocale (Locale .US );
91
- break ;
92
- }
93
-
120
+ mInstabug .changeLocale (languageTag );
94
121
} catch (Exception e ) {
95
122
e .printStackTrace ();
96
123
}
97
124
}
98
125
99
- @ ReactMethod
100
- public void report (String value ) {
101
- InstabugInvocationMode mode = InstabugInvocationMode .PROMPT_OPTION ;
102
- if (value .equals ("bug" )) {
103
- mode = InstabugInvocationMode .NEW_BUG ;
104
- } else if (value .equals ("feedback" )) {
105
- mode = InstabugInvocationMode .NEW_FEEDBACK ;
106
- }
107
-
108
- mInstabug .invoke (mode );
109
- }
110
126
111
127
/**
112
128
* The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension
@@ -181,6 +197,206 @@ public void showIntroMessage() {
181
197
}
182
198
}
183
199
200
+ /** Set the primary color that the SDK will use to tint certain UI elements in the SDK
201
+ *
202
+ * @param primaryColorValue The value of the primary color ,
203
+ * whatever this color was parsed from a resource color or hex color or RGB color values
204
+ */
205
+ @ ReactMethod
206
+ public void setPrimaryColor (int primaryColor ) {
207
+ try {
208
+ mInstabug .setPrimaryColor (primaryColor );
209
+ } catch (Exception e ) {
210
+ e .printStackTrace ();
211
+ }
212
+ }
213
+
214
+ /**
215
+ * Appends a log message to Instabug internal log
216
+ * <p>
217
+ * These logs are then sent along the next uploaded report. All log messages are timestamped <br/>
218
+ * Logs aren't cleared per single application run. If you wish to reset the logs, use {@link #clearLog()}
219
+ * </p>
220
+ * Note: logs passed to this method are <b>NOT</b> printed to Logcat
221
+ *
222
+ * @param message log message
223
+ */
224
+ @ ReactMethod
225
+ public void log (String message ) {
226
+ try {
227
+ mInstabug .log (message );
228
+ } catch (Exception e ) {
229
+ e .printStackTrace ();
230
+ }
231
+ }
232
+
233
+ /**
234
+ * @return all tags added using {@link #addTags(String...)}
235
+ * @see #resetTags()
236
+ */
237
+ @ ReactMethod
238
+ public ArrayList <String > getTags () {
239
+ ArrayList <String > tags = new ArrayList <String >();
240
+ try {
241
+ tags =mInstabug .getTags ();
242
+ } catch (Exception e ) {
243
+ e .printStackTrace ();
244
+ }
245
+ return tags ;
246
+ }
247
+
248
+ /**
249
+ * Reset ALL tags added using {@link #addTags(String...)}
250
+ *
251
+ */
252
+ @ ReactMethod
253
+ public void resetTags () {
254
+ try {
255
+ mInstabug .resetTags ();
256
+ } catch (Exception e ) {
257
+ e .printStackTrace ();
258
+ }
259
+ }
260
+
261
+ /**
262
+ * @return {@code true} if Instabug is enabled, {@code false} if it's disabled
263
+ * @see #enable()
264
+ * @see #disable()
265
+ */
266
+ @ ReactMethod
267
+ public boolean isEnabled () {
268
+ boolean isEnabled =false ;
269
+ try {
270
+ isEnabled =mInstabug .isEnabled ();
271
+ } catch (Exception e ) {
272
+ e .printStackTrace ();
273
+ }
274
+ return isEnabled ;
275
+ }
276
+
277
+
278
+ /**
279
+ * Enables all Instabug functionality
280
+ *
281
+ */
282
+ @ ReactMethod
283
+ public void enable () {
284
+ try {
285
+ mInstabug .enable ();
286
+ } catch (Exception e ) {
287
+ e .printStackTrace ();
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Disables all Instabug functionality
293
+ *
294
+ */
295
+ @ ReactMethod
296
+ public void disable () {
297
+ try {
298
+ mInstabug .disable ();
299
+ } catch (Exception e ) {
300
+ e .printStackTrace ();
301
+ }
302
+ }
303
+
304
+ /**
305
+ * @return application token
306
+ */
307
+ @ ReactMethod
308
+ public String getAppToken () {
309
+ String appToken ="" ;
310
+ try {
311
+ appToken = mInstabug .getAppToken ();
312
+ } catch (Exception e ) {
313
+ e .printStackTrace ();
314
+ }
315
+
316
+ return appToken ;
317
+ }
318
+
319
+
320
+ /**
321
+ * Get current unread count of messages for this user
322
+ *
323
+ * @return number of messages that are unread for this user
324
+ */
325
+ @ ReactMethod
326
+ public int getUnreadMessagesCount () {
327
+ int unreadMessages = 0 ;
328
+ try {
329
+ unreadMessages = mInstabug .getUnreadMessagesCount ();
330
+ } catch (Exception e ) {
331
+ e .printStackTrace ();
332
+ }
333
+
334
+ return unreadMessages ;
335
+ }
336
+
337
+ /**
338
+ * Changes the event used to invoke Instabug SDK
339
+ *
340
+ * @param instabugInvocationEvent to be used to invoke SDK
341
+ * @see InstabugInvocationEvent
342
+ */
343
+ @ ReactMethod
344
+ public void changeInvocationEvent (String invocationEventValue ) {
345
+ InstabugInvocationEvent invocationEvent =InstabugInvocationEvent .FLOATING_BUTTON ;
346
+ try {
347
+ //setting invocation event
348
+ if (invocationEventValue .equals ("button" )) {
349
+ invocationEvent =InstabugInvocationEvent .FLOATING_BUTTON ;
350
+ } else if (invocationEventValue .equals ("swipe" )) {
351
+ invocationEvent =InstabugInvocationEvent .TWO_FINGER_SWIPE_LEFT ;
352
+
353
+ } else if (invocationEventValue .equals ("shake" )) {
354
+ invocationEvent =InstabugInvocationEvent .SHAKE ;
355
+
356
+ } else if (invocationEventValue .equals ("screenshot" )){
357
+ invocationEvent =InstabugInvocationEvent .SCREENSHOT_GESTURE ;
358
+
359
+ } else if (invocationEventValue .equals ("none" )) {
360
+ invocationEvent =InstabugInvocationEvent .NONE ;
361
+ }
362
+ mInstabug .changeInvocationEvent (invocationEvent );
363
+ } catch (Exception e ) {
364
+ e .printStackTrace ();
365
+ }
366
+
367
+ }
368
+
369
+ /**
370
+ * Enabled/disable chat notification
371
+ *
372
+ * @param isChatNotificationEnable whether chat notification is reburied or not
373
+ */
374
+ @ ReactMethod
375
+ public void setChatNotificationEnabled (boolean isChatNotificationEnable ) {
376
+ try {
377
+ mInstabug .setChatNotificationEnabled (isChatNotificationEnable );
378
+ } catch (Exception e ) {
379
+ e .printStackTrace ();
380
+ }
381
+ }
382
+
383
+
384
+ /**
385
+ * Enable/Disable debug logs from Instabug SDK
386
+ * Default state: disabled
387
+ *
388
+ * @param isDebugEnabled whether debug logs should be printed or not into LogCat
389
+ */
390
+ @ ReactMethod
391
+ public void setDebugEnabled (boolean isDebugEnabled ) {
392
+ try {
393
+ mInstabug .setDebugEnabled (isDebugEnabled );
394
+ } catch (Exception e ) {
395
+ e .printStackTrace ();
396
+ }
397
+ }
398
+
399
+
184
400
@ Override
185
401
public Map <String , Object > getConstants () {
186
402
final Map <String , Object > constants = new HashMap <>();
0 commit comments