14
14
import com .instabug .library .invocation .util .InstabugFloatingButtonEdge ;
15
15
import com .instabug .library .visualusersteps .State ;
16
16
import android .graphics .Color ;
17
+ import android .util .Log ;
17
18
18
19
import java .util .ArrayList ;
20
+ import java .util .Arrays ;
19
21
import java .util .Collections ;
20
22
import java .util .List ;
21
23
22
24
public class RNInstabugReactnativePackage implements ReactPackage {
23
25
26
+ private static final String TAG = RNInstabugReactnativePackage .class .getSimpleName ();
27
+
24
28
private Application androidApplication ;
25
29
private String mAndroidApplicationToken ;
26
30
private Instabug mInstabug ;
27
31
private Instabug .Builder mBuilder ;
28
- private InstabugInvocationEvent invocationEvent = InstabugInvocationEvent . FLOATING_BUTTON ;
32
+ private ArrayList < InstabugInvocationEvent > invocationEvents = new ArrayList <>() ;
29
33
private InstabugColorTheme instabugColorTheme = InstabugColorTheme .InstabugColorThemeLight ;
30
34
31
35
public RNInstabugReactnativePackage (String androidApplicationToken , Application androidApplication ,
32
- String invocationEventValue , String primaryColor ,
36
+ String [] invocationEventValues , String primaryColor ,
33
37
InstabugFloatingButtonEdge floatingButtonEdge , int offset ) {
34
38
this .androidApplication = androidApplication ;
35
39
this .mAndroidApplicationToken = androidApplicationToken ;
36
40
37
- //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
- }
41
+ Log .d (TAG , "ARRAY: " + Arrays .toString (invocationEventValues ));
55
42
43
+ //setting invocation event
44
+ this .parseInvocationEvent (invocationEventValues );
56
45
57
46
mInstabug = new Instabug .Builder (this .androidApplication , this .mAndroidApplicationToken )
58
- .setInvocationEvent (this .invocationEvent )
47
+ .setInvocationEvents (this .invocationEvents . toArray ( new InstabugInvocationEvent [ 0 ]) )
59
48
.setCrashReportingState (Feature .State .ENABLED )
60
49
.setReproStepsState (State .DISABLED )
61
50
.build ();
@@ -67,19 +56,60 @@ public RNInstabugReactnativePackage(String androidApplicationToken, Application
67
56
}
68
57
69
58
public RNInstabugReactnativePackage (String androidApplicationToken , Application androidApplication ,
70
- String invocationEventValue , String primaryColor ) {
71
- new RNInstabugReactnativePackage (androidApplicationToken ,androidApplication ,invocationEventValue ,primaryColor ,
59
+ String [] invocationEventValues , String primaryColor ) {
60
+ new RNInstabugReactnativePackage (androidApplicationToken ,androidApplication ,invocationEventValues ,primaryColor ,
72
61
InstabugFloatingButtonEdge .LEFT ,250 );
73
62
}
74
63
64
+ private void parseInvocationEvent (String [] invocationEventValues ) {
65
+
66
+ for (int i = 0 ; i < invocationEventValues .length ; i ++) {
67
+ if (invocationEventValues [i ].equals ("button" )) {
68
+ this .invocationEvents .add (InstabugInvocationEvent .FLOATING_BUTTON );
69
+ } else if (invocationEventValues [i ].equals ("swipe" )) {
70
+ this .invocationEvents .add (InstabugInvocationEvent .TWO_FINGER_SWIPE_LEFT );
71
+
72
+ } else if (invocationEventValues [i ].equals ("shake" )) {
73
+ this .invocationEvents .add (InstabugInvocationEvent .SHAKE );
74
+
75
+ } else if (invocationEventValues [i ].equals ("screenshot" )) {
76
+ this .invocationEvents .add (InstabugInvocationEvent .SCREENSHOT_GESTURE );
77
+
78
+ } else if (invocationEventValues [i ].equals ("none" )) {
79
+ this .invocationEvents .add (InstabugInvocationEvent .NONE );
80
+ }
81
+ }
82
+
83
+ if (invocationEvents .isEmpty ()) {
84
+ invocationEvents .add (InstabugInvocationEvent .SHAKE );
85
+ }
86
+ }
87
+
88
+ @ Override
89
+ public List <NativeModule > createNativeModules (ReactApplicationContext reactContext ) {
90
+ List <NativeModule > modules = new ArrayList <>();
91
+ modules .add (new RNInstabugReactnativeModule (reactContext , this .androidApplication , this .mInstabug ));
92
+ return modules ;
93
+ }
94
+
95
+ public List <Class <? extends JavaScriptModule >> createJSModules () {
96
+ return Collections .emptyList ();
97
+ }
98
+
99
+ @ Override
100
+ public List <ViewManager > createViewManagers (ReactApplicationContext reactContext ) {
101
+ return Collections .emptyList ();
102
+ }
103
+
104
+
75
105
public static class Builder {
76
106
//FloatingButtonEdge
77
107
private final String FLOATING_BUTTON_EDGE_RIGHT = "right" ;
78
108
private final String FLOATING_BUTTON_EDGE_LEFT = "left" ;
79
109
80
110
String androidApplicationToken ;
81
111
Application application ;
82
- String invocationEvent ;
112
+ String [] invocationEvents ;
83
113
String primaryColor ;
84
114
InstabugFloatingButtonEdge floatingButtonEdge ;
85
115
int offset ;
@@ -89,8 +119,8 @@ public Builder(String androidApplicationToken, Application application) {
89
119
this .application = application ;
90
120
}
91
121
92
- public Builder setInvocationEvent (String invocationEvent ) {
93
- this .invocationEvent = invocationEvent ;
122
+ public Builder setInvocationEvent (String ... invocationEvents ) {
123
+ this .invocationEvents = invocationEvents ;
94
124
return this ;
95
125
}
96
126
@@ -110,7 +140,7 @@ public Builder setFloatingButtonOffsetFromTop(int offset) {
110
140
}
111
141
112
142
public RNInstabugReactnativePackage build () {
113
- return new RNInstabugReactnativePackage (androidApplicationToken ,application ,invocationEvent ,primaryColor ,floatingButtonEdge ,offset );
143
+ return new RNInstabugReactnativePackage (androidApplicationToken ,application ,invocationEvents ,primaryColor ,floatingButtonEdge ,offset );
114
144
}
115
145
116
146
private InstabugFloatingButtonEdge getFloatingButtonEdge (String floatingButtonEdgeValue ) {
@@ -130,20 +160,4 @@ private InstabugFloatingButtonEdge getFloatingButtonEdge(String floatingButtonEd
130
160
}
131
161
}
132
162
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
-
149
163
}
0 commit comments