setExtendedBugReportMode API for Android

This commit is contained in:
Salma ElTarzi 2018-02-27 18:30:13 +02:00
parent 08e28a808b
commit 72c666c559

View File

@ -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);