|
@@ -20,34 +20,31 @@ package org.jitsi.meet;
|
20
|
20
|
import android.content.Intent;
|
21
|
21
|
import android.net.Uri;
|
22
|
22
|
import android.os.Build;
|
23
|
|
-import android.os.Bundle;
|
24
|
23
|
import android.provider.Settings;
|
25
|
24
|
import android.support.annotation.Nullable;
|
26
|
|
-import android.support.v4.app.FragmentActivity;
|
|
25
|
+import android.util.Log;
|
27
|
26
|
import android.view.KeyEvent;
|
28
|
27
|
|
29
|
28
|
import org.jitsi.meet.sdk.JitsiMeet;
|
30
|
|
-import org.jitsi.meet.sdk.JitsiMeetActivityInterface;
|
31
|
|
-import org.jitsi.meet.sdk.JitsiMeetActivityDelegate;
|
32
|
|
-import org.jitsi.meet.sdk.JitsiMeetFragment;
|
|
29
|
+import org.jitsi.meet.sdk.JitsiMeetActivity;
|
33
|
30
|
import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
|
34
|
31
|
|
35
|
32
|
import com.crashlytics.android.Crashlytics;
|
36
|
|
-import com.facebook.react.modules.core.PermissionListener;
|
37
|
33
|
import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
|
38
|
34
|
import io.fabric.sdk.android.Fabric;
|
39
|
35
|
|
40
|
36
|
import java.net.MalformedURLException;
|
41
|
37
|
import java.net.URL;
|
|
38
|
+import java.util.Map;
|
42
|
39
|
|
43
|
40
|
/**
|
44
|
|
- * The one and only {@link FragmentActivity} that the Jitsi Meet app needs. The
|
|
41
|
+ * The one and only Activity that the Jitsi Meet app needs. The
|
45
|
42
|
* {@code Activity} is launched in {@code singleTask} mode, so it will be
|
46
|
43
|
* created upon application initialization and there will be a single instance
|
47
|
44
|
* of it. Further attempts at launching the application once it was already
|
48
|
|
- * launched will result in {@link FragmentActivity#onNewIntent(Intent)} being called.
|
|
45
|
+ * launched will result in {@link MainActivity#onNewIntent(Intent)} being called.
|
49
|
46
|
*/
|
50
|
|
-public class MainActivity extends FragmentActivity implements JitsiMeetActivityInterface {
|
|
47
|
+public class MainActivity extends JitsiMeetActivity {
|
51
|
48
|
/**
|
52
|
49
|
* The request code identifying requests for the permission to draw on top
|
53
|
50
|
* of other apps. The value must be 16-bit and is arbitrarily chosen here.
|
|
@@ -55,19 +52,49 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
|
55
|
52
|
private static final int OVERLAY_PERMISSION_REQUEST_CODE
|
56
|
53
|
= (int) (Math.random() * Short.MAX_VALUE);
|
57
|
54
|
|
58
|
|
- private JitsiMeetFragment getFragment() {
|
59
|
|
- return (JitsiMeetFragment) getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
|
60
|
|
- }
|
|
55
|
+ // JitsiMeetActivity overrides
|
|
56
|
+ //
|
61
|
57
|
|
62
|
|
- private @Nullable URL buildURL(String urlStr) {
|
63
|
|
- try {
|
64
|
|
- return new URL(urlStr);
|
65
|
|
- } catch (MalformedURLException e) {
|
66
|
|
- return null;
|
|
58
|
+ @Override
|
|
59
|
+ protected boolean extraInitialize() {
|
|
60
|
+ // Setup Crashlytics and Firebase Dynamic Links
|
|
61
|
+ if (BuildConfig.GOOGLE_SERVICES_ENABLED) {
|
|
62
|
+ Fabric.with(this, new Crashlytics());
|
|
63
|
+
|
|
64
|
+ FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
|
|
65
|
+ .addOnSuccessListener(this, pendingDynamicLinkData -> {
|
|
66
|
+ Uri dynamicLink = null;
|
|
67
|
+
|
|
68
|
+ if (pendingDynamicLinkData != null) {
|
|
69
|
+ dynamicLink = pendingDynamicLinkData.getLink();
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ if (dynamicLink != null) {
|
|
73
|
+ join(dynamicLink.toString());
|
|
74
|
+ }
|
|
75
|
+ });
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ // In Debug builds React needs permission to write over other apps in
|
|
79
|
+ // order to display the warning and error overlays.
|
|
80
|
+ if (BuildConfig.DEBUG) {
|
|
81
|
+ if (canRequestOverlayPermission() && !Settings.canDrawOverlays(this)) {
|
|
82
|
+ Intent intent
|
|
83
|
+ = new Intent(
|
|
84
|
+ Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
85
|
+ Uri.parse("package:" + getPackageName()));
|
|
86
|
+
|
|
87
|
+ startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
|
|
88
|
+
|
|
89
|
+ return true;
|
|
90
|
+ }
|
67
|
91
|
}
|
|
92
|
+
|
|
93
|
+ return false;
|
68
|
94
|
}
|
69
|
95
|
|
70
|
|
- private void initialize() {
|
|
96
|
+ @Override
|
|
97
|
+ protected void initialize() {
|
71
|
98
|
// Set default options
|
72
|
99
|
JitsiMeetConferenceOptions defaultOptions
|
73
|
100
|
= new JitsiMeetConferenceOptions.Builder()
|
|
@@ -76,36 +103,27 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
|
76
|
103
|
.build();
|
77
|
104
|
JitsiMeet.setDefaultConferenceOptions(defaultOptions);
|
78
|
105
|
|
79
|
|
- // Join the room specified by the URL the app was launched with.
|
80
|
|
- // Joining without the room option displays the welcome page.
|
81
|
|
- join(getIntentUrl(getIntent()));
|
|
106
|
+ super.initialize();
|
82
|
107
|
}
|
83
|
108
|
|
84
|
|
- private void join(@Nullable String url) {
|
85
|
|
- JitsiMeetConferenceOptions options
|
86
|
|
- = new JitsiMeetConferenceOptions.Builder()
|
87
|
|
- .setRoom(url)
|
88
|
|
- .build();
|
89
|
|
- getFragment().getJitsiView().join(options);
|
|
109
|
+ @Override
|
|
110
|
+ public void onConferenceFailed(Map<String, Object> data) {
|
|
111
|
+ Log.d(TAG, "Conference failed: " + data);
|
90
|
112
|
}
|
91
|
113
|
|
92
|
|
- private @Nullable String getIntentUrl(Intent intent) {
|
93
|
|
- Uri uri;
|
94
|
|
-
|
95
|
|
- if (Intent.ACTION_VIEW.equals(intent.getAction())
|
96
|
|
- && (uri = intent.getData()) != null) {
|
97
|
|
- return uri.toString();
|
98
|
|
- }
|
99
|
|
-
|
100
|
|
- return null;
|
|
114
|
+ @Override
|
|
115
|
+ public void onConferenceLeft(Map<String, Object> data) {
|
|
116
|
+ Log.d(TAG, "Conference left: " + data);
|
101
|
117
|
}
|
102
|
118
|
|
103
|
|
- private boolean canRequestOverlayPermission() {
|
104
|
|
- return
|
105
|
|
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
106
|
|
- && getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.M;
|
|
119
|
+ @Override
|
|
120
|
+ public void onLoadConfigError(Map<String, Object> data) {
|
|
121
|
+ Log.d(TAG, "Error loading config: " + data);
|
107
|
122
|
}
|
108
|
123
|
|
|
124
|
+ // Activity lifecycle method overrides
|
|
125
|
+ //
|
|
126
|
+
|
109
|
127
|
@Override
|
110
|
128
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
111
|
129
|
if (requestCode == OVERLAY_PERMISSION_REQUEST_CODE
|
|
@@ -120,11 +138,6 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
|
120
|
138
|
super.onActivityResult(requestCode, resultCode, data);
|
121
|
139
|
}
|
122
|
140
|
|
123
|
|
- @Override
|
124
|
|
- public void onBackPressed() {
|
125
|
|
- JitsiMeetActivityDelegate.onBackPressed();
|
126
|
|
- }
|
127
|
|
-
|
128
|
141
|
// ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java
|
129
|
142
|
@Override
|
130
|
143
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
|
@@ -136,68 +149,20 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
|
136
|
149
|
return super.onKeyUp(keyCode, event);
|
137
|
150
|
}
|
138
|
151
|
|
139
|
|
- @Override
|
140
|
|
- public void onNewIntent(Intent intent) {
|
141
|
|
- String url;
|
142
|
|
-
|
143
|
|
- if ((url = getIntentUrl(intent)) != null) {
|
144
|
|
- join(url);
|
145
|
|
- return;
|
146
|
|
- }
|
147
|
|
-
|
148
|
|
- JitsiMeetActivityDelegate.onNewIntent(intent);
|
149
|
|
- }
|
150
|
|
-
|
151
|
|
- @Override
|
152
|
|
- protected void onUserLeaveHint() {
|
153
|
|
- getFragment().getJitsiView().enterPictureInPicture();
|
154
|
|
- }
|
155
|
|
-
|
156
|
|
- @Override
|
157
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
158
|
|
- super.onCreate(savedInstanceState);
|
159
|
|
-
|
160
|
|
- // Set the Activity's content view.
|
161
|
|
- setContentView(R.layout.main_layout);
|
162
|
|
-
|
163
|
|
- // Setup Crashlytics and Firebase Dynamic Links
|
164
|
|
- if (BuildConfig.GOOGLE_SERVICES_ENABLED) {
|
165
|
|
- Fabric.with(this, new Crashlytics());
|
166
|
|
-
|
167
|
|
- FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
|
168
|
|
- .addOnSuccessListener(this, pendingDynamicLinkData -> {
|
169
|
|
- Uri dynamicLink = null;
|
170
|
|
-
|
171
|
|
- if (pendingDynamicLinkData != null) {
|
172
|
|
- dynamicLink = pendingDynamicLinkData.getLink();
|
173
|
|
- }
|
174
|
|
-
|
175
|
|
- if (dynamicLink != null) {
|
176
|
|
- join(dynamicLink.toString());
|
177
|
|
- }
|
178
|
|
- });
|
179
|
|
- }
|
|
152
|
+ // Helper methods
|
|
153
|
+ //
|
180
|
154
|
|
181
|
|
- // In Debug builds React needs permission to write over other apps in
|
182
|
|
- // order to display the warning and error overlays.
|
183
|
|
- if (BuildConfig.DEBUG) {
|
184
|
|
- if (canRequestOverlayPermission() && !Settings.canDrawOverlays(this)) {
|
185
|
|
- Intent intent
|
186
|
|
- = new Intent(
|
187
|
|
- Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
188
|
|
- Uri.parse("package:" + getPackageName()));
|
189
|
|
-
|
190
|
|
- startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
|
191
|
|
- return;
|
192
|
|
- }
|
|
155
|
+ private @Nullable URL buildURL(String urlStr) {
|
|
156
|
+ try {
|
|
157
|
+ return new URL(urlStr);
|
|
158
|
+ } catch (MalformedURLException e) {
|
|
159
|
+ return null;
|
193
|
160
|
}
|
194
|
|
-
|
195
|
|
- initialize();
|
196
|
161
|
}
|
197
|
162
|
|
198
|
|
- @Override
|
199
|
|
- public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
|
200
|
|
- JitsiMeetActivityDelegate.requestPermissions(this, permissions, requestCode, listener);
|
|
163
|
+ private boolean canRequestOverlayPermission() {
|
|
164
|
+ return
|
|
165
|
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
|
166
|
+ && getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.M;
|
201
|
167
|
}
|
202
|
|
-
|
203
|
168
|
}
|