13
13
import com .instabug .library .internal .module .InstabugLocale ;
14
14
import com .instabug .library .invocation .InstabugInvocationEvent ;
15
15
import com .instabug .library .invocation .InstabugInvocationMode ;
16
+ import com .instabug .library .InstabugColorTheme ;
16
17
import com .instabug .library .logging .InstabugLog ;
17
18
import com .instabug .library .bugreporting .model .ReportCategory ;
18
19
@@ -56,6 +57,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
56
57
private final String LOCALE_SWEDISH = "swedish" ;
57
58
private final String LOCALE_TURKISH = "turkish" ;
58
59
60
+ //Theme colors
61
+ private final String COLOR_THEME_LIGHT = "light" ;
62
+ private final String COLOR_THEME_DARK = "dark" ;
63
+
59
64
private Application androidApplication ;
60
65
private Instabug mInstabug ;
61
66
private InstabugInvocationEvent invocationEvent ;
@@ -627,6 +632,25 @@ public void clearAllUserAttributes() {
627
632
}
628
633
}
629
634
635
+ /**
636
+ * Sets InstabugSDK theme color.
637
+ *
638
+ * @param theme which is a constant String "light" or "dark"
639
+ */
640
+ @ ReactMethod
641
+ public void setColorTheme (String theme ) {
642
+ try {
643
+ if (theme .equals (COLOR_THEME_LIGHT )) {
644
+ mInstabug .setTheme (InstabugColorTheme .InstabugColorThemeLight );
645
+
646
+ } else if (theme .equals (COLOR_THEME_DARK )) {
647
+ mInstabug .setTheme (InstabugColorTheme .InstabugColorThemeDark );
648
+ }
649
+ } catch (Exception e ) {
650
+ e .printStackTrace ();
651
+ }
652
+ }
653
+
630
654
/**
631
655
* Allows you to show a predefined set of categories for users to choose
632
656
* from when reporting a bug or sending feedback. Selected category
@@ -642,7 +666,8 @@ public void setReportCategories(ReadableArray categoriesTitles) {
642
666
int size = categoriesTitles != null ? categoriesTitles .size () : 0 ;
643
667
if (size == 0 ) return ;
644
668
for (int i = 0 ; i < size ; i ++) {
645
- bugCategories .add (ReportCategory .getInstance ().withLabel (categoriesTitles .getString (i )));
669
+ bugCategories .add (ReportCategory .getInstance ().withLabel (categoriesTitles
670
+ .getString (i )));
646
671
}
647
672
648
673
Instabug .setReportCategories (bugCategories );
@@ -717,6 +742,9 @@ public Map<String, Object> getConstants() {
717
742
constants .put ("invocationEventTwoFingersSwipe" , INVOCATION_EVENT_TWO_FINGERS_SWIPE );
718
743
constants .put ("invocationEventFloatingButton" , INVOCATION_EVENT_FLOATING_BUTTON );
719
744
745
+ constants .put ("colorThemeLight" , COLOR_THEME_LIGHT );
746
+ constants .put ("colorThemeDark" , COLOR_THEME_DARK );
747
+
720
748
constants .put ("invocationModeNewBug" , INVOCATION_MODE_NEW_BUG );
721
749
constants .put ("invocationModeNewFeedback" , INVOCATION_MODE_NEW_FEEDBACK );
722
750
constants .put ("invocationModeNewChat" , INVOCATION_MODE_NEW_CHAT );
0 commit comments