8
8
import com .facebook .react .bridge .ReactMethod ;
9
9
import com .facebook .react .bridge .ReadableArray ;
10
10
import com .facebook .react .bridge .ReadableMap ;
11
+
11
12
import com .instabug .library .Instabug ;
12
13
import com .instabug .library .internal .module .InstabugLocale ;
13
14
import com .instabug .library .invocation .InstabugInvocationEvent ;
14
15
import com .instabug .library .invocation .InstabugInvocationMode ;
15
16
import com .instabug .library .logging .InstabugLog ;
17
+ import com .instabug .library .bugreporting .model .ReportCategory ;
16
18
17
19
import java .util .ArrayList ;
18
20
import java .util .HashMap ;
@@ -64,7 +66,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
64
66
* @param reactContext the react context
65
67
* @param mInstabug the m instabug
66
68
*/
67
- public RNInstabugReactnativeModule (ReactApplicationContext reactContext , Application androidApplication ) {
69
+ public RNInstabugReactnativeModule (ReactApplicationContext reactContext , Application
70
+ androidApplication ) {
68
71
super (reactContext );
69
72
this .androidApplication = androidApplication ;
70
73
}
@@ -166,7 +169,8 @@ public void changeLocale(String instabugLocale) {
166
169
}
167
170
168
171
/**
169
- * The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension
172
+ * The file at filePath will be uploaded along upcoming reports with the name
173
+ * fileNameWithExtension
170
174
*
171
175
* @param fileUri the file uri
172
176
* @param fileNameWithExtension the file name with extension
@@ -204,7 +208,7 @@ public void setUserEmail(String userEmail) {
204
208
@ ReactMethod
205
209
public void setUserName (String username ) {
206
210
try {
207
- mInstabug .setUserName (username );
211
+ mInstabug .setUsername (username );
208
212
} catch (Exception e ) {
209
213
e .printStackTrace ();
210
214
}
@@ -242,7 +246,8 @@ public void showIntroMessage() {
242
246
* Set the primary color that the SDK will use to tint certain UI elements in the SDK
243
247
*
244
248
* @param primaryColorValue The value of the primary color ,
245
- * whatever this color was parsed from a resource color or hex color or RGB color values
249
+ * whatever this color was parsed from a resource color or hex color
250
+ * or RGB color values
246
251
*/
247
252
@ ReactMethod
248
253
public void setPrimaryColor (int primaryColor ) {
@@ -263,9 +268,11 @@ public void setPrimaryColor(int primaryColor) {
263
268
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
264
269
*/
265
270
@ ReactMethod
266
- public void setAttachmentTypesEnabled (boolean screenshot , boolean extraScreenshot , boolean galleryImage , boolean voiceNote , boolean screenRecording ) {
271
+ public void setAttachmentTypesEnabled (boolean screenshot , boolean extraScreenshot , boolean
272
+ galleryImage , boolean voiceNote , boolean screenRecording ) {
267
273
try {
268
- mInstabug .setAttachmentTypesEnabled (screenshot , extraScreenshot , galleryImage , voiceNote , screenRecording );
274
+ mInstabug .setAttachmentTypesEnabled (screenshot , extraScreenshot , galleryImage ,
275
+ voiceNote , screenRecording );
269
276
} catch (Exception e ) {
270
277
e .printStackTrace ();
271
278
}
@@ -274,8 +281,10 @@ public void setAttachmentTypesEnabled(boolean screenshot, boolean extraScreensho
274
281
/**
275
282
* Appends a log message to Instabug internal log
276
283
* <p>
277
- * These logs are then sent along the next uploaded report. All log messages are timestamped <br/>
278
- * Logs aren't cleared per single application run. If you wish to reset the logs, use {@link #clearLog()}
284
+ * These logs are then sent along the next uploaded report. All log messages are timestamped
285
+ * <br/>
286
+ * Logs aren't cleared per single application run. If you wish to reset the logs, use
287
+ * {@link #clearLog()}
279
288
* </p>
280
289
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
281
290
*
@@ -478,7 +487,8 @@ public void reportJsException(ReadableArray stack, String message, String errorI
478
487
String fileName = frame .getString ("file" );
479
488
int lineNumber = frame .getInt ("lineNumber" );
480
489
481
- stackTraceElements [i ] = new StackTraceElement (fileName , methodName , fileName , lineNumber );
490
+ stackTraceElements [i ] = new StackTraceElement (fileName , methodName , fileName ,
491
+ lineNumber );
482
492
}
483
493
Throwable throwable = new Throwable (message );
484
494
throwable .setStackTrace (stackTraceElements );
@@ -617,43 +627,84 @@ public void clearAllUserAttributes() {
617
627
}
618
628
}
619
629
630
+ /**
631
+ * Allows you to show a predefined set of categories for users to choose
632
+ * from when reporting a bug or sending feedback. Selected category
633
+ * shows up on your Instabug dashboard as a tag to make filtering
634
+ * through issues easier.
635
+ *
636
+ * @param reportCategories the report categories list which is a list of ReportCategory model
637
+ */
638
+ @ ReactMethod
639
+ public void setReportCategories (ReadableArray categoriesTitles ) {
640
+ try {
641
+ ArrayList <ReportCategory > bugCategories = new ArrayList <>();
642
+ int size = categoriesTitles != null ? categoriesTitles .size () : 0 ;
643
+ if (size == 0 ) return ;
644
+ for (int i = 0 ; i < size ; i ++) {
645
+ bugCategories .add (ReportCategory .getInstance ().withLabel (categoriesTitles .getString (i )));
646
+ }
647
+
648
+ Instabug .setReportCategories (bugCategories );
649
+ } catch (Exception e ) {
650
+ e .printStackTrace ();
651
+ }
652
+ }
653
+
620
654
private Locale getLocaleByKey (String instabugLocale ) {
621
655
String localeInLowerCase = instabugLocale .toLowerCase ();
622
656
switch (localeInLowerCase ) {
623
657
case LOCALE_ARABIC :
624
- return new Locale (InstabugLocale .ARABIC .getCode (), InstabugLocale .ARABIC .getCountry ());
658
+ return new Locale (InstabugLocale .ARABIC .getCode (), InstabugLocale .ARABIC
659
+ .getCountry ());
625
660
case LOCALE_ENGLISH :
626
- return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH .getCountry ());
661
+ return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH
662
+ .getCountry ());
627
663
case LOCALE_CZECH :
628
- return new Locale (InstabugLocale .CZECH .getCode (), InstabugLocale .CZECH .getCountry ());
664
+ return new Locale (InstabugLocale .CZECH .getCode (), InstabugLocale .CZECH .getCountry
665
+ ());
629
666
case LOCALE_FRENCH :
630
- return new Locale (InstabugLocale .FRENCH .getCode (), InstabugLocale .FRENCH .getCountry ());
667
+ return new Locale (InstabugLocale .FRENCH .getCode (), InstabugLocale .FRENCH
668
+ .getCountry ());
631
669
case LOCALE_GERMAN :
632
- return new Locale (InstabugLocale .GERMAN .getCode (), InstabugLocale .GERMAN .getCountry ());
670
+ return new Locale (InstabugLocale .GERMAN .getCode (), InstabugLocale .GERMAN
671
+ .getCountry ());
633
672
case LOCALE_ITALIAN :
634
- return new Locale (InstabugLocale .ITALIAN .getCode (), InstabugLocale .ITALIAN .getCountry ());
673
+ return new Locale (InstabugLocale .ITALIAN .getCode (), InstabugLocale .ITALIAN
674
+ .getCountry ());
635
675
case LOCALE_JAPANESE :
636
- return new Locale (InstabugLocale .JAPANESE .getCode (), InstabugLocale .JAPANESE .getCountry ());
676
+ return new Locale (InstabugLocale .JAPANESE .getCode (), InstabugLocale .JAPANESE
677
+ .getCountry ());
637
678
case LOCALE_POLISH :
638
- return new Locale (InstabugLocale .POLISH .getCode (), InstabugLocale .POLISH .getCountry ());
679
+ return new Locale (InstabugLocale .POLISH .getCode (), InstabugLocale .POLISH
680
+ .getCountry ());
639
681
case LOCALE_RUSSIAN :
640
- return new Locale (InstabugLocale .RUSSIAN .getCode (), InstabugLocale .RUSSIAN .getCountry ());
682
+ return new Locale (InstabugLocale .RUSSIAN .getCode (), InstabugLocale .RUSSIAN
683
+ .getCountry ());
641
684
case LOCALE_SPANISH :
642
- return new Locale (InstabugLocale .SPANISH .getCode (), InstabugLocale .SPANISH .getCountry ());
685
+ return new Locale (InstabugLocale .SPANISH .getCode (), InstabugLocale .SPANISH
686
+ .getCountry ());
643
687
case LOCALE_SWEDISH :
644
- return new Locale (InstabugLocale .SWEDISH .getCode (), InstabugLocale .SWEDISH .getCountry ());
688
+ return new Locale (InstabugLocale .SWEDISH .getCode (), InstabugLocale .SWEDISH
689
+ .getCountry ());
645
690
case LOCALE_TURKISH :
646
- return new Locale (InstabugLocale .TURKISH .getCode (), InstabugLocale .TURKISH .getCountry ());
691
+ return new Locale (InstabugLocale .TURKISH .getCode (), InstabugLocale .TURKISH
692
+ .getCountry ());
647
693
case LOCALE_PORTUGUESE_BRAZIL :
648
- return new Locale (InstabugLocale .PORTUGUESE_BRAZIL .getCode (), InstabugLocale .PORTUGUESE_BRAZIL .getCountry ());
694
+ return new Locale (InstabugLocale .PORTUGUESE_BRAZIL .getCode (), InstabugLocale
695
+ .PORTUGUESE_BRAZIL .getCountry ());
649
696
case LOCALE_CHINESE_SIMPLIFIED :
650
- return new Locale (InstabugLocale .SIMPLIFIED_CHINESE .getCode (), InstabugLocale .SIMPLIFIED_CHINESE .getCountry ());
697
+ return new Locale (InstabugLocale .SIMPLIFIED_CHINESE .getCode (), InstabugLocale
698
+ .SIMPLIFIED_CHINESE .getCountry ());
651
699
case LOCALE_CHINESE_TRADITIONAL :
652
- return new Locale (InstabugLocale .TRADITIONAL_CHINESE .getCode (), InstabugLocale .TRADITIONAL_CHINESE .getCountry ());
700
+ return new Locale (InstabugLocale .TRADITIONAL_CHINESE .getCode (), InstabugLocale
701
+ .TRADITIONAL_CHINESE .getCountry ());
653
702
case LOCALE_KOREAN :
654
- return new Locale (InstabugLocale .KOREAN .getCode (), InstabugLocale .KOREAN .getCountry ());
703
+ return new Locale (InstabugLocale .KOREAN .getCode (), InstabugLocale .KOREAN
704
+ .getCountry ());
655
705
default :
656
- return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH .getCountry ());
706
+ return new Locale (InstabugLocale .ENGLISH .getCode (), InstabugLocale .ENGLISH
707
+ .getCountry ());
657
708
}
658
709
}
659
710
0 commit comments