Просмотр исходного кода

android: update SDK documentation

master
Saúl Ibarra Corretgé 6 лет назад
Родитель
Сommit
a7018970ca

+ 44
- 86
android/README.md Просмотреть файл

33
 }
33
 }
34
 ```
34
 ```
35
 
35
 
36
-Also, enable 32bit mode for react-native, since react-native only supports 32bit apps. (If you have a 64bit device, it will not run unless this setting it set)
36
+Also, enable 32bit mode for react-native, since the react-native version we currently depend on only supports 32bit apps. (If you have a 64bit device, it will not run unless this setting it set).
37
 
37
 
38
 ```gradle
38
 ```gradle
39
 android {
39
 android {
167
 package org.jitsi.example;
167
 package org.jitsi.example;
168
 
168
 
169
 import android.os.Bundle;
169
 import android.os.Bundle;
170
-import android.support.v7.app.AppCompatActivity;
170
+import android.support.v4.app.FragmentActivity;
171
 
171
 
172
 import org.jitsi.meet.sdk.JitsiMeetView;
172
 import org.jitsi.meet.sdk.JitsiMeetView;
173
 import org.jitsi.meet.sdk.ReactActivityLifecycleCallbacks;
173
 import org.jitsi.meet.sdk.ReactActivityLifecycleCallbacks;
174
 
174
 
175
 // Example
175
 // Example
176
 //
176
 //
177
-public class MainActivity extends AppCompatActivity {
177
+public class MainActivity extends FragmentActivity implements JitsiMeetActivityInterface {
178
     private JitsiMeetView view;
178
     private JitsiMeetView view;
179
 
179
 
180
     @Override
180
     @Override
182
             int requestCode,
182
             int requestCode,
183
             int resultCode,
183
             int resultCode,
184
             Intent data) {
184
             Intent data) {
185
-        ReactActivityLifecycleCallbacks.onActivityResult(
185
+        JitsiMeetActivityDelegate.onActivityResult(
186
                 this, requestCode, resultCode, data);
186
                 this, requestCode, resultCode, data);
187
     }
187
     }
188
 
188
 
189
     @Override
189
     @Override
190
     public void onBackPressed() {
190
     public void onBackPressed() {
191
-        ReactActivityLifecycleCallbacks.onBackPressed();
191
+        JitsiMeetActivityDelegate.onBackPressed();
192
     }
192
     }
193
 
193
 
194
     @Override
194
     @Override
196
         super.onCreate(savedInstanceState);
196
         super.onCreate(savedInstanceState);
197
 
197
 
198
         view = new JitsiMeetView(this);
198
         view = new JitsiMeetView(this);
199
-        view.loadURL(null);
199
+        JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder()
200
+            .setRoom("https://meet.jit.si/test123")
201
+            .build();
202
+        view.join(options);
200
 
203
 
201
         setContentView(view);
204
         setContentView(view);
202
     }
205
     }
208
         view.dispose();
211
         view.dispose();
209
         view = null;
212
         view = null;
210
 
213
 
211
-        ReactActivityLifecycleCallbacks.onHostDestroy(this);
214
+        JitsiMeetActivityDelegate.onHostDestroy(this);
212
     }
215
     }
213
 
216
 
214
     @Override
217
     @Override
215
     public void onNewIntent(Intent intent) {
218
     public void onNewIntent(Intent intent) {
216
-        ReactActivityLifecycleCallbacks.onNewIntent(intent);
219
+        JitsiMeetActivityDelegate.onNewIntent(intent);
217
     }
220
     }
218
 
221
 
219
     @Override
222
     @Override
221
             final int requestCode,
224
             final int requestCode,
222
             final String[] permissions,
225
             final String[] permissions,
223
             final int[] grantResults) {
226
             final int[] grantResults) {
224
-        ReactActivityLifecycleCallbacks.onRequestPermissionsResult(requestCode, permissions, grantResults);
227
+        JitsiMeetActivityDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
225
     }
228
     }
226
 
229
 
227
     @Override
230
     @Override
228
     protected void onResume() {
231
     protected void onResume() {
229
         super.onResume();
232
         super.onResume();
230
 
233
 
231
-        ReactActivityLifecycleCallbacks.onHostResume(this);
234
+        JitsiMeetActivityDelegate.onHostResume(this);
232
     }
235
     }
233
 
236
 
234
     @Override
237
     @Override
235
     protected void onStop() {
238
     protected void onStop() {
236
         super.onStop();
239
         super.onStop();
237
 
240
 
238
-        ReactActivityLifecycleCallbacks.onHostPause(this);
241
+        JitsiMeetActivityDelegate.onHostPause(this);
239
     }
242
     }
240
 }
243
 }
241
 ```
244
 ```
262
 
265
 
263
 ### JitsiMeetActivity
266
 ### JitsiMeetActivity
264
 
267
 
265
-This class encapsulates a high level API in the form of an Android `Activity`
266
-which displays a single `JitsiMeetView`.
268
+This class encapsulates a high level API in the form of an Android `FragmentActivity`
269
+which displays a single `JitsiMeetView`. You can pass a URL as a `ACTION_VIEW`
270
+on the Intent when starting it and it will join the conference, and will be
271
+automatically terminated (finish() will be called on the activity) when the
272
+conference ends or fails.
267
 
273
 
268
 ### JitsiMeetView
274
 ### JitsiMeetView
269
 
275
 
270
 The `JitsiMeetView` class is the core of Jitsi Meet SDK. It's designed to
276
 The `JitsiMeetView` class is the core of Jitsi Meet SDK. It's designed to
271
 display a Jitsi Meet conference (or a welcome page).
277
 display a Jitsi Meet conference (or a welcome page).
272
 
278
 
279
+#### join(options)
280
+
281
+Joins the conference specified by the given `JitsiMeetConferenceOptions`.
282
+
283
+#### leave()
284
+
285
+Leaves the currently active conference. If the welcome page is enabled it will
286
+go back to it, otherwise a black window will be shown.
287
+
273
 #### dispose()
288
 #### dispose()
274
 
289
 
275
 Releases all resources associated with this view. This method MUST be called
290
 Releases all resources associated with this view. This method MUST be called
276
 when the Activity holding this view is going to be destroyed, usually in the
291
 when the Activity holding this view is going to be destroyed, usually in the
277
 `onDestroy()` method.
292
 `onDestroy()` method.
278
 
293
 
279
-#### getDefaultURL()
280
-
281
-Returns the default base URL used to join a conference when a partial URL (e.g.
282
-a room name only) is specified to `loadURLString`/`loadURLObject`. If not set or
283
-if set to `null`, the default built in JavaScript is used: https://meet.jit.si.
284
-
285
 #### getListener()
294
 #### getListener()
286
 
295
 
287
 Returns the `JitsiMeetViewListener` instance attached to the view.
296
 Returns the `JitsiMeetViewListener` instance attached to the view.
288
 
297
 
289
-#### isPictureInPictureEnabled()
290
-
291
-Returns `true` if Picture-in-Picture is enabled; `false`, otherwise. If not
292
-explicitly set (by a preceding `setPictureInPictureEnabled` call), defaults to
293
-`true` if the platform supports Picture-in-Picture natively; `false`, otherwise.
294
-
295
-#### isWelcomePageEnabled()
296
-
297
-Returns true if the Welcome page is enabled; otherwise, false. If false, a black
298
-empty view will be rendered when not in a conference. Defaults to false.
299
-
300
-#### loadURL(URL)
301
-
302
-Loads a specific URL which may identify a conference to join. If the specified
303
-URL is null and the Welcome page is enabled, the Welcome page is displayed
304
-instead.
305
-
306
-#### loadURLString(String)
307
-
308
-Loads a specific URL which may identify a conference to join. If the specified
309
-URL is null and the Welcome page is enabled, the Welcome page is displayed
310
-instead.
311
-
312
-#### loadURLObject(Bundle)
313
-
314
-Loads a specific URL which may identify a conference to join. The URL is
315
-specified in the form of a Bundle of properties which (1) internally are
316
-sufficient to construct a URL (string) while (2) abstracting the specifics of
317
-constructing the URL away from API clients/consumers. If the specified URL is
318
-null and the Welcome page is enabled, the Welcome page is displayed instead.
319
-
320
-Example:
321
-
322
-```java
323
-Bundle config = new Bundle();
324
-config.putBoolean("startWithAudioMuted", true);
325
-config.putBoolean("startWithVideoMuted", false);
326
-Bundle urlObject = new Bundle();
327
-urlObject.putBundle("config", config);
328
-urlObject.putString("url", "https://meet.jit.si/Test123");
329
-view.loadURLObject(urlObject);
330
-```
331
-
332
-#### setDefaultURL(URL)
333
-
334
-Sets the default URL. See `getDefaultURL` for more information.
335
-
336
-NOTE: Must be called before (if at all) `loadURL`/`loadURLString` for it to take
337
-effect.
338
-
339
 #### setListener(listener)
298
 #### setListener(listener)
340
 
299
 
341
 Sets the given listener (class implementing the `JitsiMeetViewListener`
300
 Sets the given listener (class implementing the `JitsiMeetViewListener`
342
 interface) on the view.
301
 interface) on the view.
343
 
302
 
344
-#### setPictureInPictureEnabled(boolean)
303
+### JitsiMeetConferenceOptions
345
 
304
 
346
-Sets whether Picture-in-Picture is enabled. If not set, Jitsi Meet SDK
347
-automatically enables/disables Picture-in-Picture based on native platform
348
-support.
305
+This object encapsulates all the options that can be tweaked when joining
306
+a conference.
349
 
307
 
350
-NOTE: Must be called (if at all) before `loadURL`/`loadURLString` for it to take
351
-effect.
352
-
353
-#### setWelcomePageEnabled(boolean)
308
+Example:
354
 
309
 
355
-Sets whether the Welcome page is enabled. See `isWelcomePageEnabled` for more
356
-information.
310
+```java
311
+JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder()
312
+    .setServerURL(new URL("https://meet.jit.si"))
313
+    .setRoom("test123")
314
+    .setAudioMuted(false)
315
+    .setVideoMuted(false)
316
+    .setAudioOnly(false)
317
+    .setWelcomePageEnabled(false)
318
+    .build();
319
+```
357
 
320
 
358
-NOTE: Must be called (if at all) before `loadURL`/`loadURLString` for it to take
359
-effect.
321
+See the `JitsiMeetConferenceOptions` implementation for all available options.
360
 
322
 
361
-### ReactActivityLifecycleCallbacks
323
+### JitsiMeetActivityDelegate
362
 
324
 
363
 This class handles the interaction between `JitsiMeetView` and its enclosing
325
 This class handles the interaction between `JitsiMeetView` and its enclosing
364
 `Activity`. Generally this shouldn't be consumed by users, because they'd be
326
 `Activity`. Generally this shouldn't be consumed by users, because they'd be
470
 Picture-in-Picture style scenario, in a rectangle too small to accommodate its
432
 Picture-in-Picture style scenario, in a rectangle too small to accommodate its
471
 "full" UI.
433
 "full" UI.
472
 
434
 
473
-Jitsi Meet SDK automatically enables (unless explicitly disabled by a
474
-`setPictureInPictureEnabled(false)` call) Android's native Picture-in-Picture
475
-mode iff the platform is supported i.e. Android >= Oreo.
476
-
477
 ## Dropbox integration
435
 ## Dropbox integration
478
 
436
 
479
 To setup the Dropbox integration, follow these steps:
437
 To setup the Dropbox integration, follow these steps:

+ 2
- 4
android/app/src/main/java/org/jitsi/meet/MainActivity.java Просмотреть файл

55
     private static final int OVERLAY_PERMISSION_REQUEST_CODE
55
     private static final int OVERLAY_PERMISSION_REQUEST_CODE
56
         = (int) (Math.random() * Short.MAX_VALUE);
56
         = (int) (Math.random() * Short.MAX_VALUE);
57
 
57
 
58
-    private static final String TAG = "MainActivity";
59
-
60
     private JitsiMeetFragment getFragment() {
58
     private JitsiMeetFragment getFragment() {
61
         return (JitsiMeetFragment) getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
59
         return (JitsiMeetFragment) getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
62
     }
60
     }
186
             if (canRequestOverlayPermission() && !Settings.canDrawOverlays(this)) {
184
             if (canRequestOverlayPermission() && !Settings.canDrawOverlays(this)) {
187
                 Intent intent
185
                 Intent intent
188
                     = new Intent(
186
                     = new Intent(
189
-                    Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
190
-                    Uri.parse("package:" + getPackageName()));
187
+                        Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
188
+                        Uri.parse("package:" + getPackageName()));
191
 
189
 
192
                 startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
190
                 startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
193
                 return;
191
                 return;

+ 17
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeet.java Просмотреть файл

21
 import com.facebook.react.ReactInstanceManager;
21
 import com.facebook.react.ReactInstanceManager;
22
 
22
 
23
 public class JitsiMeet {
23
 public class JitsiMeet {
24
+    /**
25
+     * Default {@link JitsiMeetConferenceOptions} which will be used for all conferences. When
26
+     * joining a conference these options will be merged with the ones passed to
27
+     * {@link JitsiMeetView} join().
28
+     */
24
     private static JitsiMeetConferenceOptions defaultConferenceOptions;
29
     private static JitsiMeetConferenceOptions defaultConferenceOptions;
25
 
30
 
26
     public static JitsiMeetConferenceOptions getDefaultConferenceOptions() {
31
     public static JitsiMeetConferenceOptions getDefaultConferenceOptions() {
27
         return defaultConferenceOptions;
32
         return defaultConferenceOptions;
28
     }
33
     }
29
 
34
 
35
+    public static void setDefaultConferenceOptions(JitsiMeetConferenceOptions options) {
36
+        defaultConferenceOptions = options;
37
+    }
38
+
39
+    /**
40
+     * Helper to get the default conference options as a {@link Bundle}.
41
+     *
42
+     * @return a {@link Bundle} with the default conference options.
43
+     */
30
     static Bundle getDefaultProps() {
44
     static Bundle getDefaultProps() {
31
         if (defaultConferenceOptions != null) {
45
         if (defaultConferenceOptions != null) {
32
             return defaultConferenceOptions.asProps();
46
             return defaultConferenceOptions.asProps();
35
         return new Bundle();
49
         return new Bundle();
36
     }
50
     }
37
 
51
 
38
-    public static void setDefaultConferenceOptions(JitsiMeetConferenceOptions options) {
39
-        defaultConferenceOptions = options;
40
-    }
41
-
52
+    /**
53
+     * Used in development mode. It displays the React Native development menu.
54
+     */
42
     public static void showDevOptions() {
55
     public static void showDevOptions() {
43
         ReactInstanceManager reactInstanceManager
56
         ReactInstanceManager reactInstanceManager
44
             = ReactInstanceManagerHolder.getReactInstanceManager();
57
             = ReactInstanceManagerHolder.getReactInstanceManager();

+ 28
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java Просмотреть файл

21
 import java.net.URL;
21
 import java.net.URL;
22
 
22
 
23
 
23
 
24
+/**
25
+ * This class represents the options when joining a Jitsi Meet conference. The user can create an
26
+ * instance by using {@link JitsiMeetConferenceOptions.Builder} and setting the desired options
27
+ * there.
28
+ *
29
+ * The resulting {@link JitsiMeetConferenceOptions} object is immutable and represents how the
30
+ * conference will be joined.
31
+ */
24
 public class JitsiMeetConferenceOptions {
32
 public class JitsiMeetConferenceOptions {
33
+    /**
34
+     * Server where the conference should take place.
35
+     */
25
     private URL serverURL;
36
     private URL serverURL;
37
+    /**
38
+     * Room name.
39
+     */
26
     private String room;
40
     private String room;
41
+    /**
42
+     * JWT token used for authentication.
43
+     */
27
     private String token;
44
     private String token;
28
 
45
 
46
+    /**
47
+     * Color scheme override, see: https://github.com/jitsi/jitsi-meet/blob/dbedee5e22e5dcf9c92db96ef5bb3c9982fc526d/react/features/base/color-scheme/defaultScheme.js
48
+     */
29
     private Bundle colorScheme;
49
     private Bundle colorScheme;
30
 
50
 
51
+    /**
52
+     * Set to {@code true} to join the conference with audio / video muted or to start in audio
53
+     * only mode respectively.
54
+     */
31
     private Boolean audioMuted;
55
     private Boolean audioMuted;
32
     private Boolean audioOnly;
56
     private Boolean audioOnly;
33
     private Boolean videoMuted;
57
     private Boolean videoMuted;
34
 
58
 
59
+    /**
60
+     * Set to {@code true} to enable the welcome page. Typically SDK users won't need this enabled
61
+     * since the host application decides which meeting to join.
62
+     */
35
     private Boolean welcomePageEnabled;
63
     private Boolean welcomePageEnabled;
36
 
64
 
37
     public static class Builder {
65
     public static class Builder {

+ 5
- 5
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetFragment.java Просмотреть файл

29
 import java.net.URL;
29
 import java.net.URL;
30
 
30
 
31
 /**
31
 /**
32
- * Base Activity for applications integrating Jitsi Meet at a higher level. It
32
+ * Base {@link Fragment} for applications integrating Jitsi Meet at a higher level. It
33
  * contains all the required wiring between the {@code JitsiMeetView} and
33
  * contains all the required wiring between the {@code JitsiMeetView} and
34
- * the Activity lifecycle methods already implemented.
34
+ * the Fragment lifecycle methods already implemented.
35
  *
35
  *
36
- * In this activity we use a single {@code JitsiMeetView} instance. This
36
+ * In this fragment we use a single {@code JitsiMeetView} instance. This
37
  * instance gives us access to a view which displays the welcome page and the
37
  * instance gives us access to a view which displays the welcome page and the
38
- * conference itself. All lifetime methods associated with this Activity are
38
+ * conference itself. All lifecycle methods associated with this Fragment are
39
  * hooked to the React Native subsystem via proxy calls through the
39
  * hooked to the React Native subsystem via proxy calls through the
40
- * {@code JitsiMeetView} static methods.
40
+ * {@code JitsiMeetActivityDelegate} static methods.
41
  */
41
  */
42
 public class JitsiMeetFragment extends Fragment {
42
 public class JitsiMeetFragment extends Fragment {
43
 
43
 

+ 22
- 3
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java Просмотреть файл

51
     // fine to have this field volatile without additional synchronization.
51
     // fine to have this field volatile without additional synchronization.
52
     private volatile String url;
52
     private volatile String url;
53
 
53
 
54
+    /**
55
+     * Helper method to recursively merge 2 {@link Bundle} objects representing React Native props.
56
+     *
57
+     * @param a - The first {@link Bundle}.
58
+     * @param b - The second {@link Bundle}.
59
+     * @return The merged {@link Bundle} object.
60
+     */
54
     private static Bundle mergeProps(@Nullable Bundle a, @Nullable Bundle b) {
61
     private static Bundle mergeProps(@Nullable Bundle a, @Nullable Bundle b) {
55
         Bundle result = new Bundle();
62
         Bundle result = new Bundle();
56
 
63
 
125
         }
132
         }
126
     }
133
     }
127
 
134
 
135
+    /**
136
+     * Joins the conference specified by the given {@link JitsiMeetConferenceOptions}.
137
+     * @param options - Description of what conference must be joined and what options will be used
138
+     *                when doing so.
139
+     */
128
     public void join(@Nullable JitsiMeetConferenceOptions options) {
140
     public void join(@Nullable JitsiMeetConferenceOptions options) {
129
         setProps(options != null ? options.asProps() : new Bundle());
141
         setProps(options != null ? options.asProps() : new Bundle());
130
     }
142
     }
131
 
143
 
144
+    /**
145
+     * Leaves the currently active conference.
146
+     */
132
     public void leave() {
147
     public void leave() {
133
         setProps(new Bundle());
148
         setProps(new Bundle());
134
     }
149
     }
135
 
150
 
151
+    /**
152
+     * Helper method to set the React Native props.
153
+     * @param newProps - New props to be set on the React Native view.
154
+     */
136
     private void setProps(@NonNull Bundle newProps) {
155
     private void setProps(@NonNull Bundle newProps) {
137
         // Merge the default options with the newly provided ones.
156
         // Merge the default options with the newly provided ones.
138
         Bundle props = mergeProps(JitsiMeet.getDefaultProps(), newProps);
157
         Bundle props = mergeProps(JitsiMeet.getDefaultProps(), newProps);
139
 
158
 
140
-        // XXX The method loadURLObject: is supposed to be imperative i.e.
159
+        // XXX The setProps() method is supposed to be imperative i.e.
141
         // a second invocation with one and the same URL is expected to join
160
         // a second invocation with one and the same URL is expected to join
142
         // the respective conference again if the first invocation was followed
161
         // the respective conference again if the first invocation was followed
143
         // by leaving the conference. However, React and, respectively,
162
         // by leaving the conference. However, React and, respectively,
144
         // appProperties/initialProperties are declarative expressions i.e. one
163
         // appProperties/initialProperties are declarative expressions i.e. one
145
         // and the same URL will not trigger an automatic re-render in the
164
         // and the same URL will not trigger an automatic re-render in the
146
         // JavaScript source code. The workaround implemented bellow introduces
165
         // JavaScript source code. The workaround implemented bellow introduces
147
-        // imperativeness in React Component props by defining a unique value
148
-        // per loadURLObject: invocation.
166
+        // "imperativeness" in React Component props by defining a unique value
167
+        // per setProps() invocation.
149
         props.putLong("timestamp", System.currentTimeMillis());
168
         props.putLong("timestamp", System.currentTimeMillis());
150
 
169
 
151
         createReactRootView("App", props);
170
         createReactRootView("App", props);

Загрузка…
Отмена
Сохранить