|
@@ -16,6 +16,7 @@
|
16
|
16
|
|
17
|
17
|
package org.jitsi.meet.sdk;
|
18
|
18
|
|
|
19
|
+import android.app.Activity;
|
19
|
20
|
import android.content.BroadcastReceiver;
|
20
|
21
|
import android.content.Context;
|
21
|
22
|
import android.content.Intent;
|
|
@@ -32,11 +33,16 @@ import com.facebook.react.modules.core.PermissionListener;
|
32
|
33
|
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
|
33
|
34
|
|
34
|
35
|
import java.util.HashMap;
|
35
|
|
-import android.app.Activity;
|
36
|
36
|
|
37
|
37
|
/**
|
38
|
|
- * A base activity for SDK users to embed. It uses {@link JitsiMeetFragment} to do the heavy
|
39
|
|
- * lifting and wires the remaining Activity lifecycle methods so it works out of the box.
|
|
38
|
+ * A base activity for SDK users to embed. It contains all the required wiring
|
|
39
|
+ * between the {@code JitsiMeetView} and the Activity lifecycle methods.
|
|
40
|
+ *
|
|
41
|
+ * In this activity we use a single {@code JitsiMeetView} instance. This
|
|
42
|
+ * instance gives us access to a view which displays the welcome page and the
|
|
43
|
+ * conference itself. All lifecycle methods associated with this Activity are
|
|
44
|
+ * hooked to the React Native subsystem via proxy calls through the
|
|
45
|
+ * {@code JitsiMeetActivityDelegate} static methods.
|
40
|
46
|
*/
|
41
|
47
|
public class JitsiMeetActivity extends AppCompatActivity
|
42
|
48
|
implements JitsiMeetActivityInterface {
|
|
@@ -52,6 +58,12 @@ public class JitsiMeetActivity extends AppCompatActivity
|
52
|
58
|
onBroadcastReceived(intent);
|
53
|
59
|
}
|
54
|
60
|
};
|
|
61
|
+
|
|
62
|
+ /**
|
|
63
|
+ * Instance of the {@link JitsiMeetView} which this activity will display.
|
|
64
|
+ */
|
|
65
|
+ private JitsiMeetView jitsiView;
|
|
66
|
+
|
55
|
67
|
// Helpers for starting the activity
|
56
|
68
|
//
|
57
|
69
|
|
|
@@ -79,6 +91,7 @@ public class JitsiMeetActivity extends AppCompatActivity
|
79
|
91
|
super.onCreate(savedInstanceState);
|
80
|
92
|
|
81
|
93
|
setContentView(R.layout.activity_jitsi_meet);
|
|
94
|
+ this.jitsiView = findViewById(R.id.jitsiView);
|
82
|
95
|
|
83
|
96
|
registerForBroadcastMessages();
|
84
|
97
|
|
|
@@ -87,6 +100,18 @@ public class JitsiMeetActivity extends AppCompatActivity
|
87
|
100
|
}
|
88
|
101
|
}
|
89
|
102
|
|
|
103
|
+ @Override
|
|
104
|
+ public void onResume() {
|
|
105
|
+ super.onResume();
|
|
106
|
+ JitsiMeetActivityDelegate.onHostResume(this);
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ @Override
|
|
110
|
+ public void onStop() {
|
|
111
|
+ JitsiMeetActivityDelegate.onHostPause(this);
|
|
112
|
+ super.onStop();
|
|
113
|
+ }
|
|
114
|
+
|
90
|
115
|
@Override
|
91
|
116
|
public void onDestroy() {
|
92
|
117
|
// Here we are trying to handle the following corner case: an application using the SDK
|
|
@@ -97,6 +122,9 @@ public class JitsiMeetActivity extends AppCompatActivity
|
97
|
122
|
// be operational so the external API won't be able to notify the native side that the
|
98
|
123
|
// conference terminated. Thus, try our best to clean up.
|
99
|
124
|
leave();
|
|
125
|
+
|
|
126
|
+ this.jitsiView = null;
|
|
127
|
+
|
100
|
128
|
if (AudioModeModule.useConnectionService()) {
|
101
|
129
|
ConnectionService.abortConnections();
|
102
|
130
|
}
|
|
@@ -104,6 +132,8 @@ public class JitsiMeetActivity extends AppCompatActivity
|
104
|
132
|
|
105
|
133
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver);
|
106
|
134
|
|
|
135
|
+ JitsiMeetActivityDelegate.onHostDestroy(this);
|
|
136
|
+
|
107
|
137
|
super.onDestroy();
|
108
|
138
|
}
|
109
|
139
|
|
|
@@ -118,9 +148,7 @@ public class JitsiMeetActivity extends AppCompatActivity
|
118
|
148
|
//
|
119
|
149
|
|
120
|
150
|
protected JitsiMeetView getJitsiView() {
|
121
|
|
- JitsiMeetFragment fragment
|
122
|
|
- = (JitsiMeetFragment) getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
|
123
|
|
- return fragment != null ? fragment.getJitsiView() : null;
|
|
151
|
+ return jitsiView;
|
124
|
152
|
}
|
125
|
153
|
|
126
|
154
|
public void join(@Nullable String url) {
|
|
@@ -132,20 +160,16 @@ public class JitsiMeetActivity extends AppCompatActivity
|
132
|
160
|
}
|
133
|
161
|
|
134
|
162
|
public void join(JitsiMeetConferenceOptions options) {
|
135
|
|
- JitsiMeetView view = getJitsiView();
|
136
|
|
-
|
137
|
|
- if (view != null) {
|
138
|
|
- view.join(options);
|
|
163
|
+ if (this.jitsiView != null) {
|
|
164
|
+ this.jitsiView .join(options);
|
139
|
165
|
} else {
|
140
|
166
|
JitsiMeetLogger.w("Cannot join, view is null");
|
141
|
167
|
}
|
142
|
168
|
}
|
143
|
169
|
|
144
|
170
|
public void leave() {
|
145
|
|
- JitsiMeetView view = getJitsiView();
|
146
|
|
-
|
147
|
|
- if (view != null) {
|
148
|
|
- view.leave();
|
|
171
|
+ if (this.jitsiView != null) {
|
|
172
|
+ this.jitsiView .leave();
|
149
|
173
|
} else {
|
150
|
174
|
JitsiMeetLogger.w("Cannot leave, view is null");
|
151
|
175
|
}
|
|
@@ -252,10 +276,8 @@ public class JitsiMeetActivity extends AppCompatActivity
|
252
|
276
|
|
253
|
277
|
@Override
|
254
|
278
|
protected void onUserLeaveHint() {
|
255
|
|
- JitsiMeetView view = getJitsiView();
|
256
|
|
-
|
257
|
|
- if (view != null) {
|
258
|
|
- view.enterPictureInPicture();
|
|
279
|
+ if (this.jitsiView != null) {
|
|
280
|
+ this.jitsiView .enterPictureInPicture();
|
259
|
281
|
}
|
260
|
282
|
}
|
261
|
283
|
|