Przeglądaj źródła

android: introduce JitsiMeetConferenceOptions

Co-authored-by: Saúl Ibarra Corretgé <saghul@jitsi.org>
master
paweldomas 6 lat temu
rodzic
commit
5b3e8a9b5e

+ 38
- 8
android/app/src/main/java/org/jitsi/meet/MainActivity.java Wyświetl plik

@@ -27,21 +27,25 @@ import android.support.v4.app.FragmentActivity;
27 27
 import android.view.KeyEvent;
28 28
 
29 29
 import org.jitsi.meet.sdk.JitsiMeet;
30
-import org.jitsi.meet.sdk.JitsiMeetFragment;
31 30
 import org.jitsi.meet.sdk.JitsiMeetActivityInterface;
32 31
 import org.jitsi.meet.sdk.JitsiMeetActivityDelegate;
32
+import org.jitsi.meet.sdk.JitsiMeetFragment;
33
+import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
33 34
 
34 35
 import com.crashlytics.android.Crashlytics;
35 36
 import com.facebook.react.modules.core.PermissionListener;
36 37
 import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
37 38
 import io.fabric.sdk.android.Fabric;
38 39
 
40
+import java.net.MalformedURLException;
41
+import java.net.URL;
42
+
39 43
 /**
40
- * The one and only {@link Activity} that the Jitsi Meet app needs. The
44
+ * The one and only {@link FragmentActivity} that the Jitsi Meet app needs. The
41 45
  * {@code Activity} is launched in {@code singleTask} mode, so it will be
42 46
  * created upon application initialization and there will be a single instance
43 47
  * of it. Further attempts at launching the application once it was already
44
- * launched will result in {@link Activity#onNewIntent(Intent)} being called.
48
+ * launched will result in {@link FragmentActivity#onNewIntent(Intent)} being called.
45 49
  */
46 50
 public class MainActivity extends FragmentActivity implements JitsiMeetActivityInterface {
47 51
     /**
@@ -51,14 +55,40 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
51 55
     private static final int OVERLAY_PERMISSION_REQUEST_CODE
52 56
         = (int) (Math.random() * Short.MAX_VALUE);
53 57
 
58
+    private static final String TAG = "MainActivity";
59
+
54 60
     private JitsiMeetFragment getFragment() {
55 61
         return (JitsiMeetFragment) getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
56 62
     }
57 63
 
64
+    private @Nullable URL buildURL(String urlStr) {
65
+        try {
66
+            return new URL(urlStr);
67
+        } catch (MalformedURLException e) {
68
+            return null;
69
+        }
70
+    }
71
+
58 72
     private void initialize() {
59
-        JitsiMeetFragment fragment = getFragment();
60
-        fragment.setWelcomePageEnabled(true);
61
-        fragment.getJitsiView().join(getIntentUrl(getIntent()));
73
+        // Set default options
74
+        JitsiMeetConferenceOptions defaultOptions
75
+            = new JitsiMeetConferenceOptions.Builder()
76
+                .setWelcomePageEnabled(true)
77
+                .setServerURL(buildURL("https://meet.jit.si"))
78
+                .build();
79
+        JitsiMeet.setDefaultConferenceOptions(defaultOptions);
80
+
81
+        // Join the room specified by the URL the app was launched with.
82
+        // Joining without the room option displays the welcome page.
83
+        join(getIntentUrl(getIntent()));
84
+    }
85
+
86
+    private void join(@Nullable String url) {
87
+        JitsiMeetConferenceOptions options
88
+            = new JitsiMeetConferenceOptions.Builder()
89
+                .setRoom(url)
90
+                .build();
91
+        getFragment().getJitsiView().join(options);
62 92
     }
63 93
 
64 94
     private @Nullable String getIntentUrl(Intent intent) {
@@ -113,7 +143,7 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
113 143
         String url;
114 144
 
115 145
         if ((url = getIntentUrl(intent)) != null) {
116
-            getFragment().getJitsiView().join(url);
146
+            join(url);
117 147
             return;
118 148
         }
119 149
 
@@ -145,7 +175,7 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
145 175
                     }
146 176
 
147 177
                     if (dynamicLink != null) {
148
-                        getFragment().getJitsiView().join(dynamicLink.toString());
178
+                        join(dynamicLink.toString());
149 179
                     }
150 180
                 });
151 181
         }

+ 20
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeet.java Wyświetl plik

@@ -16,9 +16,29 @@
16 16
  */
17 17
 package org.jitsi.meet.sdk;
18 18
 
19
+import android.os.Bundle;
20
+
19 21
 import com.facebook.react.ReactInstanceManager;
20 22
 
21 23
 public class JitsiMeet {
24
+    private static JitsiMeetConferenceOptions defaultConferenceOptions;
25
+
26
+    public static JitsiMeetConferenceOptions getDefaultConferenceOptions() {
27
+        return defaultConferenceOptions;
28
+    }
29
+
30
+    static Bundle getDefaultProps() {
31
+        if (defaultConferenceOptions != null) {
32
+            return defaultConferenceOptions.asProps();
33
+        }
34
+
35
+        return new Bundle();
36
+    }
37
+
38
+    public static void setDefaultConferenceOptions(JitsiMeetConferenceOptions options) {
39
+        defaultConferenceOptions = options;
40
+    }
41
+
22 42
     public static void showDevOptions() {
23 43
         ReactInstanceManager reactInstanceManager
24 44
             = ReactInstanceManagerHolder.getReactInstanceManager();

+ 169
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java Wyświetl plik

@@ -0,0 +1,169 @@
1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package org.jitsi.meet.sdk;
18
+
19
+import android.os.Bundle;
20
+
21
+import java.net.URL;
22
+
23
+
24
+public class JitsiMeetConferenceOptions {
25
+    private URL serverURL;
26
+    private String room;
27
+    private String token;
28
+
29
+    private Bundle colorScheme;
30
+
31
+    private Boolean audioMuted;
32
+    private Boolean audioOnly;
33
+    private Boolean videoMuted;
34
+
35
+    private Boolean welcomePageEnabled;
36
+
37
+    public static class Builder {
38
+        private URL serverURL;
39
+        private String room;
40
+        private String token;
41
+
42
+        private Bundle colorScheme;
43
+
44
+        private Boolean audioMuted;
45
+        private Boolean audioOnly;
46
+        private Boolean videoMuted;
47
+
48
+        private Boolean welcomePageEnabled;
49
+
50
+        public Builder() {
51
+        }
52
+
53
+        public Builder setServerURL(URL url) {
54
+            this.serverURL = url;
55
+
56
+            return this;
57
+        }
58
+
59
+        public Builder setRoom(String room) {
60
+            this.room = room;
61
+
62
+            return this;
63
+        }
64
+
65
+        public Builder setToken(String token) {
66
+            this.token = token;
67
+
68
+            return this;
69
+        }
70
+
71
+        public Builder setColorScheme(Bundle colorScheme) {
72
+            this.colorScheme = colorScheme;
73
+
74
+            return this;
75
+        }
76
+
77
+        public Builder setAudioMuted(boolean muted) {
78
+            this.audioMuted = muted;
79
+
80
+            return this;
81
+        }
82
+
83
+        public Builder setAudioOnly(boolean audioOnly) {
84
+            this.audioOnly = audioOnly;
85
+
86
+            return this;
87
+        }
88
+
89
+        public Builder setVideoMuted(boolean videoMuted) {
90
+            this.videoMuted = videoMuted;
91
+
92
+            return this;
93
+        }
94
+
95
+        public Builder setWelcomePageEnabled(boolean enabled) {
96
+            this.welcomePageEnabled = enabled;
97
+
98
+            return this;
99
+        }
100
+
101
+        public JitsiMeetConferenceOptions build() {
102
+            JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions();
103
+
104
+            options.serverURL = this.serverURL;
105
+            options.room = this.room;
106
+            options.token = this.token;
107
+            options.colorScheme = this.colorScheme;
108
+            options.audioMuted = this.audioMuted;
109
+            options.audioOnly = this.audioOnly;
110
+            options.videoMuted = this.videoMuted;
111
+            options.welcomePageEnabled = this.welcomePageEnabled;
112
+
113
+            return options;
114
+        }
115
+    }
116
+
117
+    private JitsiMeetConferenceOptions() {
118
+    }
119
+
120
+    Bundle asProps() {
121
+        Bundle props = new Bundle();
122
+
123
+        if (colorScheme != null) {
124
+            props.putBundle("colorScheme", colorScheme);
125
+        }
126
+
127
+        if (welcomePageEnabled != null) {
128
+            props.putBoolean("welcomePageEnabled", welcomePageEnabled);
129
+        }
130
+
131
+        // TODO: get rid of this.
132
+        props.putBoolean("pictureInPictureEnabled", true);
133
+
134
+        Bundle config = new Bundle();
135
+
136
+        if (audioMuted != null) {
137
+            config.putBoolean("startWithAudioMuted", audioMuted);
138
+        }
139
+        if (audioOnly != null) {
140
+            config.putBoolean("startAudioOnly", audioOnly);
141
+        }
142
+        if (videoMuted != null) {
143
+            config.putBoolean("startWithVideoMuted", videoMuted);
144
+        }
145
+
146
+        Bundle urlProps = new Bundle();
147
+
148
+        // The room is fully qualified
149
+        if (room != null && room.contains("://")) {
150
+            urlProps.putString("url", room);
151
+        } else {
152
+            if (serverURL != null) {
153
+                urlProps.putString("serverURL", serverURL.toString());
154
+            }
155
+            if (room != null) {
156
+                urlProps.putString("room", room);
157
+            }
158
+        }
159
+
160
+        if (token != null) {
161
+            urlProps.putString("jwt", token);
162
+        }
163
+
164
+        urlProps.putBundle("config", config);
165
+        props.putBundle("url", urlProps);
166
+
167
+        return props;
168
+    }
169
+}

+ 4
- 125
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetFragment.java Wyświetl plik

@@ -41,95 +41,23 @@ import java.net.URL;
41 41
  */
42 42
 public class JitsiMeetFragment extends Fragment {
43 43
 
44
-    /**
45
-     * A color scheme object to override the default color is the SDK.
46
-     */
47
-    private Bundle colorScheme;
48
-
49
-    /**
50
-     * The default base {@code URL} used to join a conference when a partial URL
51
-     * (e.g. a room name only) is specified. The value is used only while
52
-     * {@link #view} equals {@code null}.
53
-     */
54
-    private URL defaultURL;
55
-
56 44
     /**
57 45
      * Instance of the {@link JitsiMeetView} which this activity will display.
58 46
      */
59 47
     private JitsiMeetView view;
60 48
 
61
-    /**
62
-     * Whether Picture-in-Picture is enabled. The value is used only while
63
-     * {@link #view} equals {@code null}.
64
-     */
65
-    private Boolean pictureInPictureEnabled;
66
-
67
-    /**
68
-     * Whether the Welcome page is enabled. The value is used only while
69
-     * {@link #view} equals {@code null}.
70
-     */
71
-    private boolean welcomePageEnabled;
72
-
73
-    /**
74
-     *
75
-     * @see JitsiMeetView#getDefaultURL()
76
-     */
77
-    public URL getDefaultURL() {
78
-        return view == null ? defaultURL : view.getDefaultURL();
79
-    }
80
-
81 49
     @Nullable
82 50
     @Override
83
-    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
84
-        this.view = initializeView();
85
-
86
-        return this.view;
87
-    }
88
-
89
-    /**
90
-     * Initializes a new {@link JitsiMeetView} instance.
91
-     *
92
-     * @return a new {@code JitsiMeetView} instance.
93
-     */
94
-    protected JitsiMeetView initializeView() {
95
-        JitsiMeetView view = new JitsiMeetView(getActivity());
96
-
97
-        // XXX Before calling JitsiMeetView#loadURL, make sure to call whatever
98
-        // is documented to need such an order in order to take effect:
99
-        view.setColorScheme(colorScheme);
100
-        view.setDefaultURL(defaultURL);
101
-        if (pictureInPictureEnabled != null) {
102
-            view.setPictureInPictureEnabled(
103
-                pictureInPictureEnabled.booleanValue());
104
-        }
105
-        view.setWelcomePageEnabled(welcomePageEnabled);
106
-
107
-        return view;
51
+    public View onCreateView(@NonNull LayoutInflater inflater,
52
+                             @Nullable ViewGroup container,
53
+                             @Nullable Bundle savedInstanceState) {
54
+        return this.view = new JitsiMeetView(getActivity());
108 55
     }
109 56
 
110 57
     public JitsiMeetView getJitsiView() {
111 58
         return view;
112 59
     }
113 60
 
114
-    /**
115
-     *
116
-     * @see JitsiMeetView#isPictureInPictureEnabled()
117
-     */
118
-    public boolean isPictureInPictureEnabled() {
119
-        return
120
-            view == null
121
-                ? pictureInPictureEnabled
122
-                : view.isPictureInPictureEnabled();
123
-    }
124
-
125
-    /**
126
-     *
127
-     * @see JitsiMeetView#isWelcomePageEnabled()
128
-     */
129
-    public boolean isWelcomePageEnabled() {
130
-        return view == null ? welcomePageEnabled : view.isWelcomePageEnabled();
131
-    }
132
-
133 61
     @Override
134 62
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
135 63
         JitsiMeetActivityDelegate.onActivityResult(
@@ -181,53 +109,4 @@ public class JitsiMeetFragment extends Fragment {
181 109
             view.enterPictureInPicture();
182 110
         }
183 111
     }
184
-
185
-    /**
186
-     *
187
-     * @see JitsiMeetView#setColorScheme(Bundle)
188
-     */
189
-    public void setColorScheme(Bundle colorScheme) {
190
-        if (view == null) {
191
-            this.colorScheme = colorScheme;
192
-        } else {
193
-            view.setColorScheme(colorScheme);
194
-        }
195
-    }
196
-
197
-    /**
198
-     *
199
-     * @see JitsiMeetView#setDefaultURL(URL)
200
-     */
201
-    public void setDefaultURL(URL defaultURL) {
202
-        if (view == null) {
203
-            this.defaultURL = defaultURL;
204
-        } else {
205
-            view.setDefaultURL(defaultURL);
206
-        }
207
-    }
208
-
209
-    /**
210
-     *
211
-     * @see JitsiMeetView#setPictureInPictureEnabled(boolean)
212
-     */
213
-    public void setPictureInPictureEnabled(boolean pictureInPictureEnabled) {
214
-        if (view == null) {
215
-            this.pictureInPictureEnabled
216
-                = Boolean.valueOf(pictureInPictureEnabled);
217
-        } else {
218
-            view.setPictureInPictureEnabled(pictureInPictureEnabled);
219
-        }
220
-    }
221
-
222
-    /**
223
-     *
224
-     * @see JitsiMeetView#setWelcomePageEnabled(boolean)
225
-     */
226
-    public void setWelcomePageEnabled(boolean welcomePageEnabled) {
227
-        if (view == null) {
228
-            this.welcomePageEnabled = welcomePageEnabled;
229
-        } else {
230
-            view.setWelcomePageEnabled(welcomePageEnabled);
231
-        }
232
-    }
233 112
 }

+ 61
- 207
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java Wyświetl plik

@@ -26,11 +26,10 @@ import android.util.Log;
26 26
 import com.facebook.react.bridge.ReadableMap;
27 27
 
28 28
 import java.lang.reflect.Method;
29
-import java.net.URL;
30 29
 import java.util.Map;
31 30
 
32
-public class JitsiMeetView
33
-    extends BaseReactView<JitsiMeetViewListener> {
31
+
32
+public class JitsiMeetView extends BaseReactView<JitsiMeetViewListener> {
34 33
 
35 34
     /**
36 35
      * The {@code Method}s of {@code JitsiMeetViewListener} by event name i.e.
@@ -45,25 +44,6 @@ public class JitsiMeetView
45 44
      */
46 45
     private static final String TAG = JitsiMeetView.class.getSimpleName();
47 46
 
48
-    /**
49
-     * A color scheme object to override the default color is the SDK.
50
-     */
51
-    private Bundle colorScheme;
52
-
53
-    /**
54
-     * The default base {@code URL} used to join a conference when a partial URL
55
-     * (e.g. a room name only) is specified to {@link #loadURLString(String)} or
56
-     * {@link #loadURLObject(Bundle)}.
57
-     */
58
-    private URL defaultURL;
59
-
60
-    /**
61
-     * Whether Picture-in-Picture is enabled. If {@code null}, defaults to
62
-     * {@code true} iff the Android platform supports Picture-in-Picture
63
-     * natively.
64
-     */
65
-    private Boolean pictureInPictureEnabled;
66
-
67 47
     /**
68 48
      * The URL of the current conference.
69 49
      */
@@ -71,10 +51,45 @@ public class JitsiMeetView
71 51
     // fine to have this field volatile without additional synchronization.
72 52
     private volatile String url;
73 53
 
74
-    /**
75
-     * Whether the Welcome page is enabled.
76
-     */
77
-    private boolean welcomePageEnabled;
54
+    private static Bundle mergeProps(@Nullable Bundle a, @Nullable Bundle b) {
55
+        Bundle result = new Bundle();
56
+
57
+        if (a == null) {
58
+            if (b != null) {
59
+                result.putAll(b);
60
+            }
61
+
62
+            return result;
63
+        }
64
+
65
+        if (b == null) {
66
+            result.putAll(a);
67
+
68
+            return result;
69
+        }
70
+
71
+        // Start by putting all of a in the result.
72
+        result.putAll(a);
73
+
74
+        // Iterate over each key in b and override if appropriate.
75
+        for (String key : b.keySet()) {
76
+            Object bValue = b.get(key);
77
+            Object aValue = a.get(key);
78
+            String valueType = bValue.getClass().getSimpleName();
79
+
80
+            if (valueType.contentEquals("Boolean")) {
81
+                result.putBoolean(key, (Boolean)bValue);
82
+            } else if (valueType.contentEquals("String")) {
83
+                result.putString(key, (String)bValue);
84
+            } else if (valueType.contentEquals("Bundle")) {
85
+                result.putBundle(key, mergeProps((Bundle)aValue, (Bundle)bValue));
86
+            }
87
+
88
+            // TODO: handle string arrays when the need arises.
89
+        }
90
+
91
+        return result;
92
+    }
78 93
 
79 94
     public JitsiMeetView(@NonNull Context context) {
80 95
         super(context);
@@ -96,134 +111,31 @@ public class JitsiMeetView
96 111
      * page.
97 112
      */
98 113
     public void enterPictureInPicture() {
99
-        if (isPictureInPictureEnabled() && getURL() != null) {
100
-            PictureInPictureModule pipModule
101
-                = ReactInstanceManagerHolder.getNativeModule(
114
+        PictureInPictureModule pipModule
115
+            = ReactInstanceManagerHolder.getNativeModule(
102 116
                 PictureInPictureModule.class);
103
-
104
-            if (pipModule != null) {
105
-                try {
106
-                    pipModule.enterPictureInPicture();
107
-                } catch (RuntimeException re) {
108
-                    Log.e(TAG, "onUserLeaveHint: failed to enter PiP mode", re);
109
-                }
117
+        if (pipModule != null
118
+                && PictureInPictureModule.isPictureInPictureSupported()
119
+                && this.url != null) {
120
+            try {
121
+                pipModule.enterPictureInPicture();
122
+            } catch (RuntimeException re) {
123
+                Log.e(TAG, "failed to enter PiP mode", re);
110 124
             }
111 125
         }
112 126
     }
113 127
 
114
-    /**
115
-     * Gets the color scheme used in the SDK.
116
-     *
117
-     * @return The color scheme map.
118
-     */
119
-    public Bundle getColorScheme() {
120
-        return colorScheme;
121
-    }
122
-
123
-    /**
124
-     * Gets the default base {@code URL} used to join a conference when a
125
-     * partial URL (e.g. a room name only) is specified to
126
-     * {@link #loadURLString(String)} or {@link #loadURLObject(Bundle)}. If not
127
-     * set or if set to {@code null}, the default built in JavaScript is used:
128
-     * https://meet.jit.si
129
-     *
130
-     * @return The default base {@code URL} or {@code null}.
131
-     */
132
-    public URL getDefaultURL() {
133
-        return defaultURL;
134
-    }
135
-
136
-    /**
137
-     * Gets the URL of the current conference.
138
-     *
139
-     * XXX The method is meant for internal purposes only at the time of this
140
-     * writing because there is no equivalent API on iOS.
141
-     *
142
-     * @return the URL {@code String} of the current conference if any;
143
-     * otherwise, {@code null}.
144
-     */
145
-    String getURL() {
146
-        return url;
147
-    }
148
-
149
-    /**
150
-     * Gets whether Picture-in-Picture is enabled. Picture-in-Picture is
151
-     * natively supported on Android API >= 26 (Oreo), so it should not be
152
-     * enabled on older platform versions.
153
-     *
154
-     * @return If Picture-in-Picture is enabled, {@code true}; {@code false},
155
-     * otherwise.
156
-     */
157
-    public boolean isPictureInPictureEnabled() {
158
-        return
159
-            PictureInPictureModule.isPictureInPictureSupported()
160
-                && (pictureInPictureEnabled == null
161
-                    || pictureInPictureEnabled);
162
-    }
163
-
164
-    /**
165
-     * Gets whether the Welcome page is enabled. If {@code true}, the Welcome
166
-     * page is rendered when this {@code JitsiMeetView} is not at a URL
167
-     * identifying a Jitsi Meet conference/room.
168
-     *
169
-     * @return {@code true} if the Welcome page is enabled; otherwise,
170
-     * {@code false}.
171
-     */
172
-    public boolean isWelcomePageEnabled() {
173
-        return welcomePageEnabled;
174
-    }
175
-
176
-    public void join(@Nullable String url) {
177
-        Bundle urlObject;
178
-
179
-        if (url == null) {
180
-            urlObject = null;
181
-        } else {
182
-            urlObject = new Bundle();
183
-            urlObject.putString("url", url);
184
-        }
185
-        loadURL(urlObject);
128
+    public void join(@Nullable JitsiMeetConferenceOptions options) {
129
+        setProps(options != null ? options.asProps() : new Bundle());
186 130
     }
187 131
 
188 132
     public void leave() {
189
-        loadURL(null);
133
+        setProps(new Bundle());
190 134
     }
191 135
 
192
-    /**
193
-     * Loads a specific URL which may identify a conference to join. The URL is
194
-     * specified in the form of a {@link Bundle} of properties which (1)
195
-     * internally are sufficient to construct a URL {@code String} while (2)
196
-     * abstracting the specifics of constructing the URL away from API
197
-     * clients/consumers. If the specified URL is {@code null} and the Welcome
198
-     * page is enabled, the Welcome page is displayed instead.
199
-     *
200
-     * @param urlObject The URL to load which may identify a conference to join.
201
-     */
202
-    private void loadURL(@Nullable Bundle urlObject) {
203
-        Bundle props = new Bundle();
204
-
205
-        // color scheme
206
-        if (colorScheme != null) {
207
-            props.putBundle("colorScheme", colorScheme);
208
-        }
209
-
210
-        // defaultURL
211
-        if (defaultURL != null) {
212
-            props.putString("defaultURL", defaultURL.toString());
213
-        }
214
-
215
-        // pictureInPictureEnabled
216
-        props.putBoolean(
217
-            "pictureInPictureEnabled",
218
-            isPictureInPictureEnabled());
219
-
220
-        // url
221
-        if (urlObject != null) {
222
-            props.putBundle("url", urlObject);
223
-        }
224
-
225
-        // welcomePageEnabled
226
-        props.putBoolean("welcomePageEnabled", welcomePageEnabled);
136
+    private void setProps(@NonNull Bundle newProps) {
137
+        // Merge the default options with the newly provided ones.
138
+        Bundle props = mergeProps(JitsiMeet.getDefaultProps(), newProps);
227 139
 
228 140
         // XXX The method loadURLObject: is supposed to be imperative i.e.
229 141
         // a second invocation with one and the same URL is expected to join
@@ -248,18 +160,18 @@ public class JitsiMeetView
248 160
      * by/associated with the specified {@code eventName}.
249 161
      */
250 162
     private void maybeSetViewURL(String eventName, ReadableMap eventData) {
163
+        String url = eventData.getString("url");
164
+
251 165
         switch(eventName) {
252 166
         case "CONFERENCE_WILL_JOIN":
253
-            setURL(eventData.getString("url"));
167
+            this.url = url;
254 168
             break;
255 169
 
256 170
         case "CONFERENCE_FAILED":
257 171
         case "CONFERENCE_WILL_LEAVE":
258 172
         case "LOAD_CONFIG_ERROR":
259
-            String url = eventData.getString("url");
260
-
261
-            if (url != null && url.equals(getURL())) {
262
-                setURL(null);
173
+            if (url != null && url.equals(this.url)) {
174
+                this.url = null;
263 175
             }
264 176
             break;
265 177
         }
@@ -283,62 +195,4 @@ public class JitsiMeetView
283 195
 
284 196
         onExternalAPIEvent(LISTENER_METHODS, name, data);
285 197
     }
286
-
287
-    /**
288
-     * Sets the color scheme to override the default colors of the SDK.
289
-     *
290
-     * @param colorScheme The color scheme map.
291
-     */
292
-    public void setColorScheme(Bundle colorScheme) {
293
-        this.colorScheme = colorScheme;
294
-    }
295
-
296
-    /**
297
-     * Sets the default base {@code URL} used to join a conference when a
298
-     * partial URL (e.g. a room name only) is specified to
299
-     * {@link #loadURLString(String)} or {@link #loadURLObject(Bundle)}. Must be
300
-     * called before {@link #loadURL(URL)} for it to take effect.
301
-     *
302
-     * @param defaultURL The {@code URL} to be set as the default base URL.
303
-     * @see #getDefaultURL()
304
-     */
305
-    public void setDefaultURL(URL defaultURL) {
306
-        this.defaultURL = defaultURL;
307
-    }
308
-
309
-    /**
310
-     * Sets whether Picture-in-Picture is enabled. Because Picture-in-Picture is
311
-     * natively supported only since certain platform versions, specifying
312
-     * {@code true} will have no effect on unsupported platform versions.
313
-     *
314
-     * @param pictureInPictureEnabled To enable Picture-in-Picture,
315
-     * {@code true}; otherwise, {@code false}.
316
-     */
317
-    public void setPictureInPictureEnabled(boolean pictureInPictureEnabled) {
318
-        this.pictureInPictureEnabled = pictureInPictureEnabled;
319
-    }
320
-
321
-    /**
322
-     * Sets the URL of the current conference.
323
-     *
324
-     * XXX The method is meant for internal purposes only. It does not
325
-     * {@code loadURL}, it merely remembers the specified URL.
326
-     *
327
-     * @param url the URL {@code String} which to be set as the URL of the
328
-     * current conference.
329
-     */
330
-    void setURL(String url) {
331
-        this.url = url;
332
-    }
333
-
334
-    /**
335
-     * Sets whether the Welcome page is enabled. Must be called before
336
-     * {@link #loadURL(URL)} for it to take effect.
337
-     *
338
-     * @param welcomePageEnabled {@code true} to enable the Welcome page;
339
-     * otherwise, {@code false}.
340
-     */
341
-    public void setWelcomePageEnabled(boolean welcomePageEnabled) {
342
-        this.welcomePageEnabled = welcomePageEnabled;
343
-    }
344 198
 }

Ładowanie…
Anuluj
Zapisz