Skip to content

Commit 8a062e2

Browse files
authored
🤝 Merge pull request #103 from Instabug/feature/add_video_button_api
✨ Add setVideoRecordingFloatingButtonPosition for Android
2 parents d34da32 + 983d0d8 commit 8a062e2

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.instabug.library.invocation.InstabugInvocationEvent;
2525
import com.instabug.library.invocation.InstabugInvocationMode;
2626
import com.instabug.library.InstabugColorTheme;
27+
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonCorner;
2728
import com.instabug.library.logging.InstabugLog;
2829
import com.instabug.library.bugreporting.model.ReportCategory;
2930
import com.instabug.library.InstabugCustomTextPlaceHolder;
@@ -79,6 +80,12 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
7980
private final String LOCALE_SWEDISH = "swedish";
8081
private final String LOCALE_TURKISH = "turkish";
8182

83+
//Instabug Button Corner
84+
private final String TOP_RIGHT = "topRight";
85+
private final String TOP_LEFT = "topLeft";
86+
private final String BOTTOM_RIGHT = "bottomRight";
87+
private final String BOTTOM_LEFT = "bottomLeft";
88+
8289
//Theme colors
8390
private final String COLOR_THEME_LIGHT = "light";
8491
private final String COLOR_THEME_DARK = "dark";
@@ -240,6 +247,20 @@ public void changeLocale(String instabugLocale) {
240247
}
241248
}
242249

250+
/**
251+
* Sets the default corner at which the video recording floating button will be shown
252+
*
253+
* @param corner corner to stick the video recording floating button to
254+
*/
255+
@ReactMethod
256+
public void setVideoRecordingFloatingButtonPosition(String corner) {
257+
try {
258+
mInstabug.setVideoRecordingFloatingButtonCorner(getVideoRecordingButtonCorner(corner));
259+
} catch (Exception e) {
260+
e.printStackTrace();
261+
}
262+
}
263+
243264
/**
244265
* The file at filePath will be uploaded along upcoming reports with the name
245266
* fileNameWithExtension
@@ -527,11 +548,10 @@ private InstabugInvocationEvent getInvocationEventById(String invocationEventVal
527548
invocationEvent = InstabugInvocationEvent.NONE;
528549
}
529550

530-
return invocationEvent;
531551
} catch (Exception e) {
532552
e.printStackTrace();
533-
return invocationEvent;
534553
}
554+
return invocationEvent;
535555
}
536556

537557
/**
@@ -1211,6 +1231,25 @@ private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
12111231
}
12121232
}
12131233

1234+
private InstabugVideoRecordingButtonCorner getVideoRecordingButtonCorner(String cornerValue) {
1235+
InstabugVideoRecordingButtonCorner corner = InstabugVideoRecordingButtonCorner.BOTTOM_RIGHT;
1236+
try {
1237+
if (cornerValue.equals(BOTTOM_RIGHT)) {
1238+
corner = InstabugVideoRecordingButtonCorner.BOTTOM_RIGHT;
1239+
} else if (cornerValue.equals(BOTTOM_LEFT)) {
1240+
corner = InstabugVideoRecordingButtonCorner.BOTTOM_LEFT;
1241+
} else if (cornerValue.equals(TOP_LEFT)) {
1242+
corner = InstabugVideoRecordingButtonCorner.TOP_LEFT;
1243+
} else if (cornerValue.equals(TOP_RIGHT)) {
1244+
corner = InstabugVideoRecordingButtonCorner.TOP_RIGHT;
1245+
}
1246+
1247+
} catch (Exception e) {
1248+
e.printStackTrace();
1249+
}
1250+
return corner;
1251+
}
1252+
12141253
private Locale getLocaleByKey(String instabugLocale) {
12151254
String localeInLowerCase = instabugLocale.toLowerCase();
12161255
switch (localeInLowerCase) {
@@ -1275,7 +1314,7 @@ private void sendEvent(ReactApplicationContext reactContext,
12751314
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
12761315
.emit(eventName, params);
12771316
}
1278-
1317+
12791318
@Override
12801319
public Map<String, Object> getConstants() {
12811320
final Map<String, Object> constants = new HashMap<>();
@@ -1313,6 +1352,11 @@ public Map<String, Object> getConstants() {
13131352
constants.put("localeSwedish", LOCALE_SWEDISH);
13141353
constants.put("localeTurkish", LOCALE_TURKISH);
13151354

1355+
constants.put("topRight", TOP_RIGHT);
1356+
constants.put("topLeft", TOP_LEFT);
1357+
constants.put("bottomRight", BOTTOM_RIGHT);
1358+
constants.put("bottomLeft", BOTTOM_LEFT);
1359+
13161360
constants.put("shakeHint", SHAKE_HINT);
13171361
constants.put("swipeHint", SWIPE_HINT);
13181362
constants.put("invalidEmailMessage", INVALID_EMAIL_MESSAGE);
@@ -1340,4 +1384,3 @@ public Map<String, Object> getConstants() {
13401384
return constants;
13411385
}
13421386
}
1343-

index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,7 @@ module.exports = {
809809
* @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.
810810
*/
811811
setVideoRecordingFloatingButtonPosition: function(position) {
812-
if(Platform.OS === 'ios') {
813-
Instabug.setVideoRecordingFloatingButtonPosition(position);
814-
}
812+
Instabug.setVideoRecordingFloatingButtonPosition(position);
815813
},
816814

817815
/**

0 commit comments

Comments
 (0)