1
1
package com .instabug .reactlibrary ;
2
2
3
3
import android .annotation .SuppressLint ;
4
- import android .app .Application ;
5
4
import android .graphics .Bitmap ;
6
5
import android .net .Uri ;
7
- import android .os .Handler ;
8
- import android .os .Looper ;
9
6
import android .util .Log ;
10
7
import android .view .View ;
11
8
12
9
import com .facebook .react .bridge .Arguments ;
13
10
import com .facebook .react .bridge .Promise ;
14
11
import com .facebook .react .bridge .ReactApplicationContext ;
15
- import com .facebook .react .bridge .ReactContextBaseJavaModule ;
16
12
import com .facebook .react .bridge .ReactMethod ;
17
13
import com .facebook .react .bridge .ReadableArray ;
18
- import com .facebook .react .bridge .ReadableMap ;
19
14
import com .facebook .react .bridge .WritableArray ;
20
15
import com .facebook .react .bridge .WritableNativeArray ;
21
16
import com .facebook .react .bridge .WritableMap ;
22
17
import com .facebook .react .bridge .WritableNativeMap ;
23
18
import com .facebook .react .bridge .Callback ;
24
19
25
- import com .facebook .react .modules .core .DeviceEventManagerModule ;
26
20
import com .facebook .react .uimanager .NativeViewHierarchyManager ;
27
21
import com .facebook .react .uimanager .UIBlock ;
28
22
import com .facebook .react .uimanager .UIManagerModule ;
29
23
import com .instabug .apm .APM ;
30
24
import com .instabug .bug .BugReporting ;
31
25
import com .instabug .bug .instabugdisclaimer .Internal ;
32
- import com .instabug .bug .invocation .Option ;
33
26
import com .instabug .chat .Replies ;
34
- import com .instabug .crash .CrashReporting ;
35
27
import com .instabug .featuresrequest .FeatureRequests ;
36
- import com .instabug .featuresrequest .ActionType ;
37
28
import com .instabug .library .Feature ;
38
29
import com .instabug .library .Instabug ;
39
- import com .instabug .library .InstabugState ;
40
30
import com .instabug .library .OnSdkDismissCallback ;
41
31
import com .instabug .library .Platform ;
42
32
import com .instabug .library .LogLevel ;
45
35
import com .instabug .library .invocation .InstabugInvocationEvent ;
46
36
import com .instabug .library .InstabugColorTheme ;
47
37
import com .instabug .library .invocation .OnInvokeCallback ;
48
- import com .instabug .library .invocation .util .InstabugFloatingButtonEdge ;
49
- import com .instabug .library .invocation .util .InstabugVideoRecordingButtonPosition ;
50
38
import com .instabug .library .logging .InstabugLog ;
51
39
import com .instabug .library .ui .onboarding .WelcomeMessage ;
52
40
import com .instabug .library .InstabugCustomTextPlaceHolder ;
55
43
import com .instabug .library .visualusersteps .State ;
56
44
57
45
import com .instabug .reactlibrary .utils .ArrayUtil ;
46
+ import com .instabug .reactlibrary .utils .EventEmitterModule ;
58
47
import com .instabug .reactlibrary .utils .InstabugUtil ;
59
48
import com .instabug .reactlibrary .utils .MainThreadHandler ;
60
49
import com .instabug .reactlibrary .utils .ReportUtil ;
84
73
/**
85
74
* The type Rn instabug reactnative module.
86
75
*/
87
- public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
76
+ public class RNInstabugReactnativeModule extends EventEmitterModule {
88
77
89
78
private static final String TAG = RNInstabugReactnativeModule .class .getSimpleName ();
90
79
@@ -98,15 +87,26 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
98
87
*/
99
88
public RNInstabugReactnativeModule (ReactApplicationContext reactContext ) {
100
89
super (reactContext );
101
- //init placHolders
90
+ //init placeHolders
102
91
placeHolders = new InstabugCustomTextPlaceHolder ();
103
92
}
104
93
105
94
@ Override
106
95
public String getName () {
107
96
return "Instabug" ;
108
97
}
109
-
98
+
99
+
100
+ @ ReactMethod
101
+ public void addListener (String event ) {
102
+ super .addListener (event );
103
+ }
104
+
105
+ @ ReactMethod
106
+ public void removeListeners (Integer count ) {
107
+ super .removeListeners (count );
108
+ }
109
+
110
110
/**
111
111
* Enables or disables Instabug functionality.
112
112
* @param isEnabled A boolean to enable/disable Instabug.
@@ -953,7 +953,7 @@ public void run() {
953
953
BugReporting .setOnInvokeCallback (new OnInvokeCallback () {
954
954
@ Override
955
955
public void onInvoke () {
956
- sendEvent (getReactApplicationContext (), "IBGpreInvocationHandler" , null );
956
+ sendEvent ("IBGpreInvocationHandler" , null );
957
957
}
958
958
});
959
959
} catch (java .lang .Exception exception ) {
@@ -986,7 +986,7 @@ public void onReportCreated(Report report) {
986
986
reportParam .putString ("userData" , report .getUserData ());
987
987
reportParam .putMap ("userAttributes" , convertFromHashMapToWriteableMap (report .getUserAttributes ()));
988
988
reportParam .putMap ("fileAttachments" , convertFromHashMapToWriteableMap (report .getFileAttachments ()));
989
- sendEvent (getReactApplicationContext (), "IBGpreSendingHandler" , reportParam );
989
+ sendEvent ("IBGpreSendingHandler" , reportParam );
990
990
currentReport = report ;
991
991
}
992
992
});
@@ -1159,7 +1159,7 @@ public void call(DismissType dismissType, ReportType reportType) {
1159
1159
WritableMap params = Arguments .createMap ();
1160
1160
params .putString ("dismissType" , dismissType .toString ());
1161
1161
params .putString ("reportType" , reportType .toString ());
1162
- sendEvent (getReactApplicationContext (), "IBGpostInvocationHandler" , params );
1162
+ sendEvent ("IBGpostInvocationHandler" , params );
1163
1163
}
1164
1164
});
1165
1165
} catch (java .lang .Exception exception ) {
@@ -1203,7 +1203,7 @@ public void run() {
1203
1203
Surveys .setOnShowCallback (new OnShowCallback () {
1204
1204
@ Override
1205
1205
public void onShow () {
1206
- sendEvent (getReactApplicationContext (), "IBGWillShowSurvey" , null );
1206
+ sendEvent ("IBGWillShowSurvey" , null );
1207
1207
}
1208
1208
});
1209
1209
}
@@ -1225,7 +1225,7 @@ public void run() {
1225
1225
Surveys .setOnDismissCallback (new OnDismissCallback () {
1226
1226
@ Override
1227
1227
public void onDismiss () {
1228
- sendEvent (getReactApplicationContext (), "IBGDidDismissSurvey" , null );
1228
+ sendEvent ("IBGDidDismissSurvey" , null );
1229
1229
}
1230
1230
});
1231
1231
}
@@ -1347,7 +1347,7 @@ public void run() {
1347
1347
Runnable onNewReplyReceivedRunnable = new Runnable () {
1348
1348
@ Override
1349
1349
public void run () {
1350
- sendEvent (getReactApplicationContext (), "IBGOnNewReplyReceivedCallback" , null );
1350
+ sendEvent ("IBGOnNewReplyReceivedCallback" , null );
1351
1351
}
1352
1352
};
1353
1353
Replies .setOnNewReplyReceivedCallback (onNewReplyReceivedRunnable );
@@ -1697,14 +1697,6 @@ public void run() {
1697
1697
});
1698
1698
}
1699
1699
1700
- private void sendEvent (ReactApplicationContext reactContext ,
1701
- String eventName ,
1702
- WritableMap params ) {
1703
- reactContext
1704
- .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
1705
- .emit (eventName , params );
1706
- }
1707
-
1708
1700
@ ReactMethod
1709
1701
public void addExperiments (final ReadableArray experiments ) {
1710
1702
MainThreadHandler .runOnMainThread (new Runnable () {
0 commit comments