From 72c666c5593622896fb7ef399ef45f76bc7d82ec Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Tue, 27 Feb 2018 18:30:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20setExtendedBugReportMode=20API=20fo?= =?UTF-8?q?r=20Android?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNInstabugReactnativeModule.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index b237317..862d48d 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -21,6 +21,7 @@ import com.facebook.react.bridge.Callback; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.instabug.library.Feature; import com.instabug.library.Instabug; +import com.instabug.library.extendedbugreport.ExtendedBugReport; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.invocation.InstabugInvocationMode; @@ -87,6 +88,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { private final String BOTTOM_RIGHT = "bottomRight"; private final String BOTTOM_LEFT = "bottomLeft"; + //Instabug extended bug report modes + private final String EXTENDED_BUG_REPORT_REQUIRED_FIELDS = "enabledWithRequiredFields"; + private final String EXTENDED_BUG_REPORT_OPTIONAL_FIELDS = "enabledWithOptionalFields"; + private final String EXTENDED_BUG_REPORT_DISABLED = "disabled"; + //Theme colors private final String COLOR_THEME_LIGHT = "light"; private final String COLOR_THEME_DARK = "dark"; @@ -205,6 +211,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } + + /** * Dismisses all visible Instabug views */ @@ -279,6 +287,33 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Sets whether the extended bug report mode should be disabled, + * enabled with required fields, or enabled with optional fields. + * + * @param extendedBugReportMode + */ + @ReactMethod + public void setExtendedBugReportMode(String extendedBugReportMode) { + try { + switch(extendedBugReportMode) { + case EXTENDED_BUG_REPORT_REQUIRED_FIELDS: + Instabug.setExtendedBugReportState(ExtendedBugReport.State.ENABLED_WITH_REQUIRED_FIELDS); + break; + case EXTENDED_BUG_REPORT_OPTIONAL_FIELDS: + Instabug.setExtendedBugReportState(ExtendedBugReport.State.ENABLED_WITH_OPTIONAL_FIELDS); + break; + case EXTENDED_BUG_REPORT_DISABLED: + Instabug.setExtendedBugReportState(ExtendedBugReport.State.DISABLED); + break; + default: + Instabug.setExtendedBugReportState(ExtendedBugReport.State.DISABLED); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + @ReactMethod public void setViewHierarchyEnabled(boolean enabled) { try { @@ -1435,6 +1470,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { constants.put("bottomRight", BOTTOM_RIGHT); constants.put("bottomLeft", BOTTOM_LEFT); + constants.put("enabledWithRequiredFields", EXTENDED_BUG_REPORT_REQUIRED_FIELDS); + constants.put("enabledWithOptionalFields", EXTENDED_BUG_REPORT_OPTIONAL_FIELDS); + constants.put("disabled", EXTENDED_BUG_REPORT_DISABLED); + constants.put("shakeHint", SHAKE_HINT); constants.put("swipeHint", SWIPE_HINT); constants.put("invalidEmailMessage", INVALID_EMAIL_MESSAGE);