🤝 Merge pull request #103 from Instabug/feature/add_video_button_api

 Add setVideoRecordingFloatingButtonPosition for Android
This commit is contained in:
salmatarzi 2017-12-20 14:41:09 +02:00 committed by GitHub
commit 8a062e2dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 7 deletions

View File

@ -24,6 +24,7 @@ import com.instabug.library.internal.module.InstabugLocale;
import com.instabug.library.invocation.InstabugInvocationEvent;
import com.instabug.library.invocation.InstabugInvocationMode;
import com.instabug.library.InstabugColorTheme;
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonCorner;
import com.instabug.library.logging.InstabugLog;
import com.instabug.library.bugreporting.model.ReportCategory;
import com.instabug.library.InstabugCustomTextPlaceHolder;
@ -79,6 +80,12 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
private final String LOCALE_SWEDISH = "swedish";
private final String LOCALE_TURKISH = "turkish";
//Instabug Button Corner
private final String TOP_RIGHT = "topRight";
private final String TOP_LEFT = "topLeft";
private final String BOTTOM_RIGHT = "bottomRight";
private final String BOTTOM_LEFT = "bottomLeft";
//Theme colors
private final String COLOR_THEME_LIGHT = "light";
private final String COLOR_THEME_DARK = "dark";
@ -240,6 +247,20 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
}
}
/**
* Sets the default corner at which the video recording floating button will be shown
*
* @param corner corner to stick the video recording floating button to
*/
@ReactMethod
public void setVideoRecordingFloatingButtonPosition(String corner) {
try {
mInstabug.setVideoRecordingFloatingButtonCorner(getVideoRecordingButtonCorner(corner));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* The file at filePath will be uploaded along upcoming reports with the name
* fileNameWithExtension
@ -527,11 +548,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
invocationEvent = InstabugInvocationEvent.NONE;
}
return invocationEvent;
} catch (Exception e) {
e.printStackTrace();
return invocationEvent;
}
return invocationEvent;
}
/**
@ -1211,6 +1231,25 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
}
}
private InstabugVideoRecordingButtonCorner getVideoRecordingButtonCorner(String cornerValue) {
InstabugVideoRecordingButtonCorner corner = InstabugVideoRecordingButtonCorner.BOTTOM_RIGHT;
try {
if (cornerValue.equals(BOTTOM_RIGHT)) {
corner = InstabugVideoRecordingButtonCorner.BOTTOM_RIGHT;
} else if (cornerValue.equals(BOTTOM_LEFT)) {
corner = InstabugVideoRecordingButtonCorner.BOTTOM_LEFT;
} else if (cornerValue.equals(TOP_LEFT)) {
corner = InstabugVideoRecordingButtonCorner.TOP_LEFT;
} else if (cornerValue.equals(TOP_RIGHT)) {
corner = InstabugVideoRecordingButtonCorner.TOP_RIGHT;
}
} catch (Exception e) {
e.printStackTrace();
}
return corner;
}
private Locale getLocaleByKey(String instabugLocale) {
String localeInLowerCase = instabugLocale.toLowerCase();
switch (localeInLowerCase) {
@ -1275,7 +1314,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
@ -1313,6 +1352,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
constants.put("localeSwedish", LOCALE_SWEDISH);
constants.put("localeTurkish", LOCALE_TURKISH);
constants.put("topRight", TOP_RIGHT);
constants.put("topLeft", TOP_LEFT);
constants.put("bottomRight", BOTTOM_RIGHT);
constants.put("bottomLeft", BOTTOM_LEFT);
constants.put("shakeHint", SHAKE_HINT);
constants.put("swipeHint", SWIPE_HINT);
constants.put("invalidEmailMessage", INVALID_EMAIL_MESSAGE);
@ -1340,4 +1384,3 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
return constants;
}
}

View File

@ -809,9 +809,7 @@ module.exports = {
* @param position is of type IBGPosition `topLeft` to show on the top left of screen , or `bottomRight` to show on the bottom right of scrren.
*/
setVideoRecordingFloatingButtonPosition: function(position) {
if(Platform.OS === 'ios') {
Instabug.setVideoRecordingFloatingButtonPosition(position);
}
Instabug.setVideoRecordingFloatingButtonPosition(position);
},
/**