16
16
import com .instabug .library .InstabugColorTheme ;
17
17
import com .instabug .library .logging .InstabugLog ;
18
18
import com .instabug .library .bugreporting .model .ReportCategory ;
19
+ import com .instabug .library .InstabugCustomTextPlaceHolder ;
19
20
20
21
import java .util .ArrayList ;
21
22
import java .util .HashMap ;
@@ -61,9 +62,52 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
61
62
private final String COLOR_THEME_LIGHT = "light" ;
62
63
private final String COLOR_THEME_DARK = "dark" ;
63
64
65
+ edgeSwipeStartHint :Instabug .edgeSwipeStartHint ,
66
+
67
+ startAlertText :Instabug .startAlertText ,
68
+
69
+
70
+ microphonePermissionAlertSettingsButtonText :Instabug
71
+ .microphonePermissionAlertSettingsButtonText ,
72
+
73
+ conversationsHeaderTitle :Instabug .conversationsHeaderTitle ,
74
+
75
+ screenshotHeaderTitle :Instabug .screenshotHeaderTitle ,
76
+
77
+ //CustomTextPlaceHolders
78
+ private final String SHAKE_HINT = "shakeHint" ;
79
+ private final String SWIPE_HINT = "swipeHint" ;
80
+ private final String INVALID_EMAIL_MESSAGE = "invalidEmailMessage" ;
81
+ private final String INVALID_COMMENT_MESSAGE = "invalidCommentMessage" ;
82
+ private final String EMAIL_FIELD_HINT = "emailFieldHint" ;
83
+ private final String COMMENT_FIELD_HINT_FOR_BUG_REPORT = "commentFieldHintForBugReport" ;
84
+ private final String COMMENT_FIELD_HINT_FOR_FEEDBACK = "commentFieldHintForFeedback" ;
85
+
86
+ private final String INVOCATION_HEADER = "invocationHeader" ;
87
+ private final String START_CHATS = "talkToUs" ;
88
+ private final String REPORT_BUG = "reportBug" ;
89
+ private final String REPORT_FEEDBACK = "reportFeedback" ;
90
+
91
+ private final String CONVERSATIONS_LIST_TITLE = "conversationsHeaderTitle" ;
92
+
93
+ private final String ADD_VOICE_MESSAGE = "addVoiceMessage" ;
94
+ private final String ADD_IMAGE_FROM_GALLERY = "addImageFromGallery" ;
95
+ private final String ADD_EXTRA_SCREENSHOT = "addExtraScreenshot" ;
96
+ private final String ADD_VIDEO = "addVideoMessage" ;
97
+
98
+ private final String AUDIO_RECORDING_PERMISSION_DENIED =
99
+ "audioRecordingPermissionDeniedMessage" ;
100
+
101
+ private final String VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD = "recordingMessageToHoldText" ;
102
+ private final String VOICE_MESSAGE_RELEASE_TO_ATTACH = "recordingMessageToReleaseText" ;
103
+
104
+ private final String REPORT_SUCCESSFULLY_SENT = "thankYouText" ;
105
+ private final String VIDEO_PLAYER_TITLE = "video" ;
106
+
64
107
private Application androidApplication ;
65
108
private Instabug mInstabug ;
66
109
private InstabugInvocationEvent invocationEvent ;
110
+ private InstabugCustomTextPlaceHolder placeHolders ;
67
111
68
112
/**
69
113
* Instantiates a new Rn instabug reactnative module.
@@ -88,6 +132,9 @@ public void startWithToken(String androidToken, String invocationEvent) {
88
132
.setIntroMessageEnabled (false )
89
133
.setInvocationEvent (getInvocationEventById (invocationEvent ))
90
134
.build ();
135
+ //init placHolders
136
+ placeHolders = new InstabugCustomTextPlaceHolder ();
137
+
91
138
}
92
139
93
140
/**
@@ -701,7 +748,11 @@ public void setReportCategories(ReadableArray categoriesTitles) {
701
748
*/
702
749
@ ReactMethod
703
750
public void setEmailFieldRequired (boolean isEmailFieldRequired ) {
704
- mInstabug .setEmailFieldRequired (isEmailFieldRequired );
751
+ try {
752
+ mInstabug .setEmailFieldRequired (isEmailFieldRequired );
753
+ } catch (java .lang .Exception exception ) {
754
+ exception .printStackTrace ();
755
+ }
705
756
}
706
757
707
758
/**
@@ -713,7 +764,80 @@ public void setEmailFieldRequired(boolean isEmailFieldRequired) {
713
764
*/
714
765
@ ReactMethod
715
766
public void setCommentFieldRequired (boolean isCommentFieldRequired ) {
716
- mInstabug .setCommentFieldRequired (isCommentFieldRequired );
767
+ try {
768
+ mInstabug .setCommentFieldRequired (isCommentFieldRequired );
769
+ } catch (java .lang .Exception exception ) {
770
+ exception .printStackTrace ();
771
+ }
772
+ }
773
+
774
+ /**
775
+ * Overrides any of the strings shown in the SDK with custom ones.
776
+ * Allows you to customize any of the strings shown to users in the SDK.
777
+ *
778
+ * @param {string} string String value to override the default one.
779
+ * @param {strings} key Key of string to override.
780
+ */
781
+ @ ReactMethod
782
+ public void setStringToKey (String string , String key ) {
783
+ try {
784
+ placeHolders .set (getStringToKeyConstant (key ), string );
785
+ Instabug .setCustomTextPlaceHolders (placeHolders );
786
+ } catch (java .lang .Exception exception ) {
787
+ exception .printStackTrace ();
788
+ }
789
+ }
790
+
791
+ private String getStringToKeyConstant (String key ) {
792
+ String keyInLowerCase = key .toLowerCase ();
793
+ switch (localeInLowerCase ) {
794
+ case SHAKE_HINT :
795
+ return InstabugCustomTextPlaceHolder .Key .SHAKE_HINT ;
796
+ case SWIPE_HINT :
797
+ return InstabugCustomTextPlaceHolder .Key .SWIPE_HINT ;
798
+ case INVALID_EMAIL_MESSAGE :
799
+ return InstabugCustomTextPlaceHolder .Key .INVALID_EMAIL_MESSAGE ;
800
+ case INVALID_COMMENT_MESSAGE :
801
+ return InstabugCustomTextPlaceHolder .Key .INVALID_COMMENT_MESSAGE ;
802
+ case EMAIL_FIELD_HINT :
803
+ return InstabugCustomTextPlaceHolder .Key .EMAIL_FIELD_HINT ;
804
+ case COMMENT_FIELD_HINT_FOR_BUG_REPORT :
805
+ return InstabugCustomTextPlaceHolder .Key .COMMENT_FIELD_HINT_FOR_BUG_REPORT ;
806
+ case COMMENT_FIELD_HINT_FOR_FEEDBACK :
807
+ return InstabugCustomTextPlaceHolder .Key .COMMENT_FIELD_HINT_FOR_FEEDBACK ;
808
+ case INVOCATION_HEADER :
809
+ return InstabugCustomTextPlaceHolder .Key .INVOCATION_HEADER ;
810
+ case START_CHATS :
811
+ return InstabugCustomTextPlaceHolder .Key .START_CHATS ;
812
+ case REPORT_BUG :
813
+ return InstabugCustomTextPlaceHolder .Key .REPORT_BUG ;
814
+ case REPORT_FEEDBACK :
815
+ return InstabugCustomTextPlaceHolder .Key .REPORT_FEEDBACK ;
816
+ case CONVERSATIONS_LIST_TITLE :
817
+ return InstabugCustomTextPlaceHolder .Key .CONVERSATIONS_LIST_TITLE ;
818
+ case ADD_VOICE_MESSAGE :
819
+ return InstabugCustomTextPlaceHolder .Key .ADD_VOICE_MESSAGE ;
820
+ case ADD_IMAGE_FROM_GALLERY :
821
+ return InstabugCustomTextPlaceHolder .Key .ADD_IMAGE_FROM_GALLERY ;
822
+ case ADD_EXTRA_SCREENSHOT :
823
+ return InstabugCustomTextPlaceHolder .Key .ADD_EXTRA_SCREENSHOT ;
824
+ case ADD_VIDEO :
825
+ return InstabugCustomTextPlaceHolder .Key .ADD_VIDEO ;
826
+ case AUDIO_RECORDING_PERMISSION_DENIED :
827
+ return InstabugCustomTextPlaceHolder .Key .AUDIO_RECORDING_PERMISSION_DENIED ;
828
+ case VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD :
829
+ return InstabugCustomTextPlaceHolder .Key .VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD ;
830
+ case VOICE_MESSAGE_RELEASE_TO_ATTACH :
831
+ return InstabugCustomTextPlaceHolder .Key .VOICE_MESSAGE_RELEASE_TO_ATTACH ;
832
+ case CONVERSATION_TEXT_FIELD_HINT :
833
+ return InstabugCustomTextPlaceHolder .Key .CONVERSATION_TEXT_FIELD_HINT ;
834
+ case REPORT_SUCCESSFULLY_SENT :
835
+ return InstabugCustomTextPlaceHolder .Key .REPORT_SUCCESSFULLY_SENT ;
836
+ case VIDEO_PLAYER_TITLE :
837
+ return InstabugCustomTextPlaceHolder .Key .VIDEO_PLAYER_TITLE ;
838
+ default :
839
+ return null ;
840
+ }
717
841
}
718
842
719
843
private Locale getLocaleByKey (String instabugLocale ) {
@@ -807,6 +931,7 @@ public Map<String, Object> getConstants() {
807
931
constants .put ("localeSwedish" , LOCALE_SWEDISH );
808
932
constants .put ("localeTurkish" , LOCALE_TURKISH );
809
933
934
+
810
935
return constants ;
811
936
}
812
937
}
0 commit comments