Skip to content

Commit 43a96f8

Browse files
authored
Merge pull request #13 from Instabug/feature/new_public_apis
Feature/new public apis
2 parents 1be7ddd + df16b25 commit 43a96f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2329
-581
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android {
2121

2222
dependencies {
2323
compile 'com.facebook.react:react-native:0.20.+'
24-
compile ('com.instabug.library:instabug:4.15.2'){
24+
compile ('com.instabug.library:instabug:8.0.1'){
2525
exclude group: 'com.android.support:appcompat-v7'
2626
}
2727
}

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

Lines changed: 469 additions & 103 deletions
Large diffs are not rendered by default.

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

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,108 @@
77
import com.facebook.react.bridge.NativeModule;
88
import com.facebook.react.bridge.ReactApplicationContext;
99
import com.facebook.react.uimanager.ViewManager;
10+
import com.instabug.bug.BugReporting;
1011
import com.instabug.library.Feature;
1112
import com.instabug.library.Instabug;
1213
import com.instabug.library.InstabugColorTheme;
1314
import com.instabug.library.invocation.InstabugInvocationEvent;
1415
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
1516
import com.instabug.library.visualusersteps.State;
1617
import android.graphics.Color;
18+
import android.util.Log;
1719

1820
import java.util.ArrayList;
21+
import java.util.Arrays;
1922
import java.util.Collections;
2023
import java.util.List;
2124

2225
public class RNInstabugReactnativePackage implements ReactPackage {
2326

27+
private static final String TAG = RNInstabugReactnativePackage.class.getSimpleName();
28+
2429
private Application androidApplication;
2530
private String mAndroidApplicationToken;
2631
private Instabug mInstabug;
2732
private Instabug.Builder mBuilder;
28-
private InstabugInvocationEvent invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON;
33+
private ArrayList<InstabugInvocationEvent> invocationEvents = new ArrayList<>();
2934
private InstabugColorTheme instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight;
3035

3136
public RNInstabugReactnativePackage(String androidApplicationToken, Application androidApplication,
32-
String invocationEventValue, String primaryColor,
37+
String[] invocationEventValues, String primaryColor,
3338
InstabugFloatingButtonEdge floatingButtonEdge, int offset) {
3439
this.androidApplication = androidApplication;
3540
this.mAndroidApplicationToken = androidApplicationToken;
3641

3742
//setting invocation event
38-
if (invocationEventValue.equals("button")) {
39-
this.invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON;
40-
} else if (invocationEventValue.equals("swipe")) {
41-
this.invocationEvent = InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT;
42-
43-
} else if (invocationEventValue.equals("shake")) {
44-
this.invocationEvent = InstabugInvocationEvent.SHAKE;
45-
46-
} else if (invocationEventValue.equals("screenshot")) {
47-
this.invocationEvent = InstabugInvocationEvent.SCREENSHOT_GESTURE;
48-
49-
} else if (invocationEventValue.equals("none")) {
50-
this.invocationEvent = InstabugInvocationEvent.NONE;
51-
52-
} else {
53-
this.invocationEvent = InstabugInvocationEvent.SHAKE;
54-
}
55-
43+
this.parseInvocationEvent(invocationEventValues);
5644

5745
mInstabug = new Instabug.Builder(this.androidApplication, this.mAndroidApplicationToken)
58-
.setInvocationEvent(this.invocationEvent)
46+
.setInvocationEvents(this.invocationEvents.toArray(new InstabugInvocationEvent[0]))
5947
.setCrashReportingState(Feature.State.ENABLED)
6048
.setReproStepsState(State.DISABLED)
6149
.build();
6250

6351
Instabug.setPrimaryColor(Color.parseColor(primaryColor));
64-
Instabug.setFloatingButtonEdge(floatingButtonEdge);
65-
Instabug.setFloatingButtonOffsetFromTop(offset);
52+
BugReporting.setFloatingButtonEdge(floatingButtonEdge);
53+
BugReporting.setFloatingButtonOffset(offset);
6654

6755
}
6856

6957
public RNInstabugReactnativePackage(String androidApplicationToken, Application androidApplication,
70-
String invocationEventValue, String primaryColor) {
71-
new RNInstabugReactnativePackage(androidApplicationToken,androidApplication,invocationEventValue,primaryColor,
58+
String[] invocationEventValues, String primaryColor) {
59+
new RNInstabugReactnativePackage(androidApplicationToken,androidApplication,invocationEventValues,primaryColor,
7260
InstabugFloatingButtonEdge.LEFT,250);
7361
}
7462

63+
private void parseInvocationEvent(String[] invocationEventValues) {
64+
65+
for (int i = 0; i < invocationEventValues.length; i++) {
66+
if (invocationEventValues[i].equals("button")) {
67+
this.invocationEvents.add(InstabugInvocationEvent.FLOATING_BUTTON);
68+
} else if (invocationEventValues[i].equals("swipe")) {
69+
this.invocationEvents.add(InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT);
70+
71+
} else if (invocationEventValues[i].equals("shake")) {
72+
this.invocationEvents.add(InstabugInvocationEvent.SHAKE);
73+
74+
} else if (invocationEventValues[i].equals("screenshot")) {
75+
this.invocationEvents.add(InstabugInvocationEvent.SCREENSHOT_GESTURE);
76+
77+
} else if (invocationEventValues[i].equals("none")) {
78+
this.invocationEvents.add(InstabugInvocationEvent.NONE);
79+
}
80+
}
81+
82+
if (invocationEvents.isEmpty()) {
83+
invocationEvents.add(InstabugInvocationEvent.SHAKE);
84+
}
85+
}
86+
87+
@Override
88+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
89+
List<NativeModule> modules = new ArrayList<>();
90+
modules.add(new RNInstabugReactnativeModule(reactContext, this.androidApplication, this.mInstabug));
91+
return modules;
92+
}
93+
94+
public List<Class<? extends JavaScriptModule>> createJSModules() {
95+
return Collections.emptyList();
96+
}
97+
98+
@Override
99+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
100+
return Collections.emptyList();
101+
}
102+
103+
75104
public static class Builder {
76105
//FloatingButtonEdge
77106
private final String FLOATING_BUTTON_EDGE_RIGHT = "right";
78107
private final String FLOATING_BUTTON_EDGE_LEFT = "left";
79108

80109
String androidApplicationToken;
81110
Application application;
82-
String invocationEvent;
111+
String[] invocationEvents;
83112
String primaryColor;
84113
InstabugFloatingButtonEdge floatingButtonEdge;
85114
int offset;
@@ -89,8 +118,8 @@ public Builder(String androidApplicationToken, Application application) {
89118
this.application = application;
90119
}
91120

92-
public Builder setInvocationEvent(String invocationEvent) {
93-
this.invocationEvent = invocationEvent;
121+
public Builder setInvocationEvent(String... invocationEvents) {
122+
this.invocationEvents = invocationEvents;
94123
return this;
95124
}
96125

@@ -110,7 +139,7 @@ public Builder setFloatingButtonOffsetFromTop(int offset) {
110139
}
111140

112141
public RNInstabugReactnativePackage build() {
113-
return new RNInstabugReactnativePackage(androidApplicationToken,application,invocationEvent,primaryColor,floatingButtonEdge,offset);
142+
return new RNInstabugReactnativePackage(androidApplicationToken,application,invocationEvents,primaryColor,floatingButtonEdge,offset);
114143
}
115144

116145
private InstabugFloatingButtonEdge getFloatingButtonEdge(String floatingButtonEdgeValue) {
@@ -130,20 +159,4 @@ private InstabugFloatingButtonEdge getFloatingButtonEdge(String floatingButtonEd
130159
}
131160
}
132161

133-
@Override
134-
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
135-
List<NativeModule> modules = new ArrayList<>();
136-
modules.add(new RNInstabugReactnativeModule(reactContext, this.androidApplication, this.mInstabug));
137-
return modules;
138-
}
139-
140-
public List<Class<? extends JavaScriptModule>> createJSModules() {
141-
return Collections.emptyList();
142-
}
143-
144-
@Override
145-
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
146-
return Collections.emptyList();
147-
}
148-
149162
}

0 commit comments

Comments
 (0)