|
|
@@ -18,16 +18,13 @@
|
|
18
|
18
|
package org.jitsi.meet.sdk;
|
|
19
|
19
|
|
|
20
|
20
|
import android.content.Intent;
|
|
21
|
|
-import android.net.Uri;
|
|
22
|
|
-import android.os.Build;
|
|
23
|
21
|
import android.os.Bundle;
|
|
24
|
|
-import android.provider.Settings;
|
|
|
22
|
+import android.support.annotation.NonNull;
|
|
25
|
23
|
import android.support.annotation.Nullable;
|
|
26
|
|
-import android.support.v7.app.AppCompatActivity;
|
|
27
|
|
-import android.view.KeyEvent;
|
|
28
|
|
-
|
|
29
|
|
-import com.facebook.react.ReactInstanceManager;
|
|
30
|
|
-import com.facebook.react.modules.core.PermissionListener;
|
|
|
24
|
+import android.support.v4.app.Fragment;
|
|
|
25
|
+import android.view.LayoutInflater;
|
|
|
26
|
+import android.view.View;
|
|
|
27
|
+import android.view.ViewGroup;
|
|
31
|
28
|
|
|
32
|
29
|
import java.net.URL;
|
|
33
|
30
|
|
|
|
@@ -42,15 +39,7 @@ import java.net.URL;
|
|
42
|
39
|
* hooked to the React Native subsystem via proxy calls through the
|
|
43
|
40
|
* {@code JitsiMeetView} static methods.
|
|
44
|
41
|
*/
|
|
45
|
|
-public class JitsiMeetActivity
|
|
46
|
|
- extends AppCompatActivity implements JitsiMeetActivityInterface {
|
|
47
|
|
-
|
|
48
|
|
- /**
|
|
49
|
|
- * The request code identifying requests for the permission to draw on top
|
|
50
|
|
- * of other apps. The value must be 16-bit and is arbitrarily chosen here.
|
|
51
|
|
- */
|
|
52
|
|
- private static final int OVERLAY_PERMISSION_REQUEST_CODE
|
|
53
|
|
- = (int) (Math.random() * Short.MAX_VALUE);
|
|
|
42
|
+public class JitsiMeetFragment extends Fragment {
|
|
54
|
43
|
|
|
55
|
44
|
/**
|
|
56
|
45
|
* A color scheme object to override the default color is the SDK.
|
|
|
@@ -81,14 +70,6 @@ public class JitsiMeetActivity
|
|
81
|
70
|
*/
|
|
82
|
71
|
private boolean welcomePageEnabled;
|
|
83
|
72
|
|
|
84
|
|
- private boolean canRequestOverlayPermission() {
|
|
85
|
|
- return
|
|
86
|
|
- BuildConfig.DEBUG
|
|
87
|
|
- && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
|
88
|
|
- && getApplicationInfo().targetSdkVersion
|
|
89
|
|
- >= Build.VERSION_CODES.M;
|
|
90
|
|
- }
|
|
91
|
|
-
|
|
92
|
73
|
/**
|
|
93
|
74
|
*
|
|
94
|
75
|
* @see JitsiMeetView#getDefaultURL()
|
|
|
@@ -97,22 +78,12 @@ public class JitsiMeetActivity
|
|
97
|
78
|
return view == null ? defaultURL : view.getDefaultURL();
|
|
98
|
79
|
}
|
|
99
|
80
|
|
|
100
|
|
- /**
|
|
101
|
|
- * Initializes the {@link #view} of this {@code JitsiMeetActivity} with a
|
|
102
|
|
- * new {@link JitsiMeetView} instance.
|
|
103
|
|
- */
|
|
104
|
|
- private void initializeContentView() {
|
|
105
|
|
- JitsiMeetView view = initializeView();
|
|
106
|
|
-
|
|
107
|
|
- if (view != null) {
|
|
108
|
|
- // XXX Allow extenders who override initializeView() to configure
|
|
109
|
|
- // the view before the first loadURL(). Probably works around a
|
|
110
|
|
- // problem related to ReactRootView#setAppProperties().
|
|
111
|
|
- view.loadURL(null);
|
|
|
81
|
+ @Nullable
|
|
|
82
|
+ @Override
|
|
|
83
|
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
84
|
+ this.view = initializeView();
|
|
112
|
85
|
|
|
113
|
|
- this.view = view;
|
|
114
|
|
- setContentView(this.view);
|
|
115
|
|
- }
|
|
|
86
|
+ return this.view;
|
|
116
|
87
|
}
|
|
117
|
88
|
|
|
118
|
89
|
/**
|
|
|
@@ -121,7 +92,7 @@ public class JitsiMeetActivity
|
|
121
|
92
|
* @return a new {@code JitsiMeetView} instance.
|
|
122
|
93
|
*/
|
|
123
|
94
|
protected JitsiMeetView initializeView() {
|
|
124
|
|
- JitsiMeetView view = new JitsiMeetView(this);
|
|
|
95
|
+ JitsiMeetView view = new JitsiMeetView(getActivity());
|
|
125
|
96
|
|
|
126
|
97
|
// XXX Before calling JitsiMeetView#loadURL, make sure to call whatever
|
|
127
|
98
|
// is documented to need such an order in order to take effect:
|
|
|
@@ -161,97 +132,31 @@ public class JitsiMeetActivity
|
|
161
|
132
|
*
|
|
162
|
133
|
* @param url The conference URL.
|
|
163
|
134
|
*/
|
|
164
|
|
- public void loadURL(@Nullable URL url) {
|
|
165
|
|
- view.loadURL(url);
|
|
166
|
|
- }
|
|
167
|
|
-
|
|
168
|
|
- @Override
|
|
169
|
|
- protected void onActivityResult(
|
|
170
|
|
- int requestCode,
|
|
171
|
|
- int resultCode,
|
|
172
|
|
- Intent data) {
|
|
173
|
|
- if (requestCode == OVERLAY_PERMISSION_REQUEST_CODE
|
|
174
|
|
- && canRequestOverlayPermission()) {
|
|
175
|
|
- if (Settings.canDrawOverlays(this)) {
|
|
176
|
|
- initializeContentView();
|
|
177
|
|
- }
|
|
178
|
|
-
|
|
179
|
|
- return;
|
|
180
|
|
- }
|
|
181
|
|
-
|
|
182
|
|
- ReactActivityLifecycleCallbacks.onActivityResult(
|
|
183
|
|
- this, requestCode, resultCode, data);
|
|
184
|
|
- }
|
|
185
|
|
-
|
|
186
|
|
- @Override
|
|
187
|
|
- public void onBackPressed() {
|
|
188
|
|
- ReactActivityLifecycleCallbacks.onBackPressed();
|
|
|
135
|
+ public void loadURL(@Nullable String url) {
|
|
|
136
|
+ view.loadURLString(url);
|
|
189
|
137
|
}
|
|
190
|
138
|
|
|
191
|
139
|
@Override
|
|
192
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
193
|
|
- super.onCreate(savedInstanceState);
|
|
194
|
|
-
|
|
195
|
|
- // In Debug builds React needs permission to write over other apps in
|
|
196
|
|
- // order to display the warning and error overlays.
|
|
197
|
|
- if (canRequestOverlayPermission() && !Settings.canDrawOverlays(this)) {
|
|
198
|
|
- Intent intent
|
|
199
|
|
- = new Intent(
|
|
200
|
|
- Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
201
|
|
- Uri.parse("package:" + getPackageName()));
|
|
202
|
|
-
|
|
203
|
|
- startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
|
|
204
|
|
- return;
|
|
205
|
|
- }
|
|
206
|
|
-
|
|
207
|
|
- initializeContentView();
|
|
|
140
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
141
|
+ JitsiMeetActivityDelegate.onActivityResult(
|
|
|
142
|
+ getActivity(), requestCode, resultCode, data);
|
|
208
|
143
|
}
|
|
209
|
144
|
|
|
210
|
145
|
@Override
|
|
211
|
|
- protected void onDestroy() {
|
|
212
|
|
- super.onDestroy();
|
|
213
|
|
-
|
|
|
146
|
+ public void onDestroyView() {
|
|
214
|
147
|
if (view != null) {
|
|
215
|
148
|
view.dispose();
|
|
216
|
149
|
view = null;
|
|
217
|
150
|
}
|
|
218
|
151
|
|
|
219
|
|
- ReactActivityLifecycleCallbacks.onHostDestroy(this);
|
|
220
|
|
- }
|
|
221
|
|
-
|
|
222
|
|
- // ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java
|
|
223
|
|
- @Override
|
|
224
|
|
- public boolean onKeyUp(int keyCode, KeyEvent event) {
|
|
225
|
|
- ReactInstanceManager reactInstanceManager;
|
|
226
|
|
-
|
|
227
|
|
- if (!super.onKeyUp(keyCode, event)
|
|
228
|
|
- && BuildConfig.DEBUG
|
|
229
|
|
- && (reactInstanceManager
|
|
230
|
|
- = ReactInstanceManagerHolder.getReactInstanceManager())
|
|
231
|
|
- != null
|
|
232
|
|
- && keyCode == KeyEvent.KEYCODE_MENU) {
|
|
233
|
|
- reactInstanceManager.showDevOptionsDialog();
|
|
234
|
|
- return true;
|
|
235
|
|
- }
|
|
236
|
|
- return false;
|
|
|
152
|
+ super.onDestroyView();
|
|
237
|
153
|
}
|
|
238
|
154
|
|
|
239
|
155
|
@Override
|
|
240
|
|
- public void onNewIntent(Intent intent) {
|
|
241
|
|
- // XXX At least twice we received bug reports about malfunctioning
|
|
242
|
|
- // loadURL in the Jitsi Meet SDK while the Jitsi Meet app seemed to
|
|
243
|
|
- // functioning as expected in our testing. But that was to be expected
|
|
244
|
|
- // because the app does not exercise loadURL. In order to increase the
|
|
245
|
|
- // test coverage of loadURL, channel deep linking through loadURL.
|
|
246
|
|
- Uri uri;
|
|
247
|
|
-
|
|
248
|
|
- if (Intent.ACTION_VIEW.equals(intent.getAction())
|
|
249
|
|
- && (uri = intent.getData()) != null
|
|
250
|
|
- && JitsiMeetView.loadURLStringInViews(uri.toString())) {
|
|
251
|
|
- return;
|
|
252
|
|
- }
|
|
|
156
|
+ public void onDestroy() {
|
|
|
157
|
+ super.onDestroy();
|
|
253
|
158
|
|
|
254
|
|
- ReactActivityLifecycleCallbacks.onNewIntent(intent);
|
|
|
159
|
+ JitsiMeetActivityDelegate.onHostDestroy(getActivity());
|
|
255
|
160
|
}
|
|
256
|
161
|
|
|
257
|
162
|
// https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback
|
|
|
@@ -260,39 +165,31 @@ public class JitsiMeetActivity
|
|
260
|
165
|
final int requestCode,
|
|
261
|
166
|
final String[] permissions,
|
|
262
|
167
|
final int[] grantResults) {
|
|
263
|
|
- ReactActivityLifecycleCallbacks.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
168
|
+ JitsiMeetActivityDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
264
|
169
|
}
|
|
265
|
170
|
|
|
266
|
171
|
@Override
|
|
267
|
|
- protected void onResume() {
|
|
|
172
|
+ public void onResume() {
|
|
268
|
173
|
super.onResume();
|
|
269
|
174
|
|
|
270
|
|
- ReactActivityLifecycleCallbacks.onHostResume(this);
|
|
|
175
|
+ JitsiMeetActivityDelegate.onHostResume(getActivity());
|
|
271
|
176
|
}
|
|
272
|
177
|
|
|
273
|
178
|
@Override
|
|
274
|
179
|
public void onStop() {
|
|
275
|
180
|
super.onStop();
|
|
276
|
181
|
|
|
277
|
|
- ReactActivityLifecycleCallbacks.onHostPause(this);
|
|
|
182
|
+ JitsiMeetActivityDelegate.onHostPause(getActivity());
|
|
278
|
183
|
}
|
|
279
|
184
|
|
|
280
|
|
- @Override
|
|
281
|
|
- protected void onUserLeaveHint() {
|
|
|
185
|
+ public void enterPictureInPicture() {
|
|
282
|
186
|
if (view != null) {
|
|
283
|
187
|
view.enterPictureInPicture();
|
|
284
|
188
|
}
|
|
285
|
189
|
}
|
|
286
|
190
|
|
|
287
|
191
|
/**
|
|
288
|
|
- * Implementation of the {@code PermissionAwareActivity} interface.
|
|
289
|
|
- */
|
|
290
|
|
- @Override
|
|
291
|
|
- public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
|
|
292
|
|
- ReactActivityLifecycleCallbacks.requestPermissions(this, permissions, requestCode, listener);
|
|
293
|
|
- }
|
|
294
|
|
-
|
|
295
|
|
- /**
|
|
|
192
|
+ *
|
|
296
|
193
|
* @see JitsiMeetView#setColorScheme(Bundle)
|
|
297
|
194
|
*/
|
|
298
|
195
|
public void setColorScheme(Bundle colorScheme) {
|