10
10
import com .instabug .library .Instabug ;
11
11
import com .instabug .library .InstabugColorTheme ;
12
12
import com .instabug .library .invocation .InstabugInvocationEvent ;
13
+ import com .instabug .library .invocation .util .InstabugFloatingButtonEdge ;
13
14
import android .graphics .Color ;
14
15
15
16
import java .util .ArrayList ;
@@ -26,7 +27,8 @@ public class RNInstabugReactnativePackage implements ReactPackage {
26
27
private InstabugColorTheme instabugColorTheme = InstabugColorTheme .InstabugColorThemeLight ;
27
28
28
29
public RNInstabugReactnativePackage (String androidApplicationToken , Application androidApplication ,
29
- String invocationEventValue , String primaryColor ) {
30
+ String invocationEventValue , String primaryColor ,
31
+ InstabugFloatingButtonEdge floatingButtonEdge , int offset ) {
30
32
this .androidApplication = androidApplication ;
31
33
this .mAndroidApplicationToken = androidApplicationToken ;
32
34
@@ -55,9 +57,69 @@ public RNInstabugReactnativePackage(String androidApplicationToken, Application
55
57
.build ();
56
58
57
59
Instabug .setPrimaryColor (Color .parseColor (primaryColor ));
60
+ Instabug .setFloatingButtonEdge (floatingButtonEdge );
61
+ Instabug .setFloatingButtonOffsetFromTop (offset );
58
62
59
63
}
60
64
65
+ public static class Builder {
66
+ //FloatingButtonEdge
67
+ private final String FLOATING_BUTTON_EDGE_RIGHT = "right" ;
68
+ private final String FLOATING_BUTTON_EDGE_LEFT = "left" ;
69
+
70
+ String androidApplicationToken ;
71
+ Application application ;
72
+ String invocationEvent ;
73
+ String primaryColor ;
74
+ InstabugFloatingButtonEdge floatingButtonEdge ;
75
+ int offset ;
76
+
77
+ public Builder (String androidApplicationToken , Application application ) {
78
+ this .androidApplicationToken = androidApplicationToken ;
79
+ this .application = application ;
80
+ }
81
+
82
+ public Builder setInvocationEvent (String invocationEvent ) {
83
+ this .invocationEvent = invocationEvent ;
84
+ return this ;
85
+ }
86
+
87
+ public Builder setPrimaryColor (String primaryColor ) {
88
+ this .primaryColor = primaryColor ;
89
+ return this ;
90
+ }
91
+
92
+ public Builder setFloatingEdge (String floatingEdge ) {
93
+ this .floatingButtonEdge = getFloatingButtonEdge (floatingEdge );
94
+ return this ;
95
+ }
96
+
97
+ public Builder setFloatingButtonOffsetFromTop (int offset ) {
98
+ this .offset = offset ;
99
+ return this ;
100
+ }
101
+
102
+ public RNInstabugReactnativePackage build () {
103
+ return new RNInstabugReactnativePackage (androidApplicationToken ,application ,invocationEvent ,primaryColor ,floatingButtonEdge ,offset );
104
+ }
105
+
106
+ private InstabugFloatingButtonEdge getFloatingButtonEdge (String floatingButtonEdgeValue ) {
107
+ InstabugFloatingButtonEdge floatingButtonEdge = InstabugFloatingButtonEdge .RIGHT ;
108
+ try {
109
+ if (floatingButtonEdgeValue .equals (FLOATING_BUTTON_EDGE_LEFT )) {
110
+ floatingButtonEdge = InstabugFloatingButtonEdge .LEFT ;
111
+ } else if (floatingButtonEdgeValue .equals (FLOATING_BUTTON_EDGE_RIGHT )) {
112
+ floatingButtonEdge = InstabugFloatingButtonEdge .RIGHT ;
113
+ }
114
+ return floatingButtonEdge ;
115
+
116
+ } catch (Exception e ) {
117
+ e .printStackTrace ();
118
+ return floatingButtonEdge ;
119
+ }
120
+ }
121
+ }
122
+
61
123
@ Override
62
124
public List <NativeModule > createNativeModules (ReactApplicationContext reactContext ) {
63
125
List <NativeModule > modules = new ArrayList <>();
0 commit comments