Skip to content

Commit f1f4b8a

Browse files
committed
✨ Add setVideoRecordingFloatingButtonPosition for Android
1 parent d34da32 commit f1f4b8a

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

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

Lines changed: 47 additions & 2 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
@@ -1211,6 +1232,26 @@ private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
12111232
}
12121233
}
12131234

1235+
private InstabugVideoRecordingButtonCorner getVideoRecordingButtonCorner(String cornerValue) {
1236+
InstabugVideoRecordingButtonCorner corner = InstabugVideoRecordingButtonCorner.BOTTOM_RIGHT;
1237+
try {
1238+
if (cornerValue.equals(BOTTOM_RIGHT)) {
1239+
corner = InstabugVideoRecordingButtonCorner.BOTTOM_RIGHT;
1240+
} else if (cornerValue.equals(BOTTOM_LEFT)) {
1241+
corner = InstabugVideoRecordingButtonCorner.BOTTOM_LEFT;
1242+
} else if (cornerValue.equals(TOP_LEFT)) {
1243+
corner = InstabugVideoRecordingButtonCorner.TOP_LEFT;
1244+
} else if (cornerValue.equals(TOP_RIGHT)) {
1245+
corner = InstabugVideoRecordingButtonCorner.TOP_RIGHT;
1246+
}
1247+
1248+
return corner;
1249+
} catch (Exception e) {
1250+
e.printStackTrace();
1251+
return corner;
1252+
}
1253+
}
1254+
12141255
private Locale getLocaleByKey(String instabugLocale) {
12151256
String localeInLowerCase = instabugLocale.toLowerCase();
12161257
switch (localeInLowerCase) {
@@ -1275,7 +1316,7 @@ private void sendEvent(ReactApplicationContext reactContext,
12751316
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
12761317
.emit(eventName, params);
12771318
}
1278-
1319+
12791320
@Override
12801321
public Map<String, Object> getConstants() {
12811322
final Map<String, Object> constants = new HashMap<>();
@@ -1313,6 +1354,11 @@ public Map<String, Object> getConstants() {
13131354
constants.put("localeSwedish", LOCALE_SWEDISH);
13141355
constants.put("localeTurkish", LOCALE_TURKISH);
13151356

1357+
constants.put("topRight", TOP_RIGHT);
1358+
constants.put("topLeft", TOP_LEFT);
1359+
constants.put("bottomRight", BOTTOM_RIGHT);
1360+
constants.put("bottomLeft", BOTTOM_LEFT);
1361+
13161362
constants.put("shakeHint", SHAKE_HINT);
13171363
constants.put("swipeHint", SWIPE_HINT);
13181364
constants.put("invalidEmailMessage", INVALID_EMAIL_MESSAGE);
@@ -1340,4 +1386,3 @@ public Map<String, Object> getConstants() {
13401386
return constants;
13411387
}
13421388
}
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)