소스 검색

android: update SDK documentation

master
Saúl Ibarra Corretgé 6 년 전
부모
커밋
a7018970ca

+ 44
- 86
android/README.md 파일 보기

@@ -33,7 +33,7 @@ dependencies {
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 38
 ```gradle
39 39
 android {
@@ -167,14 +167,14 @@ View is strongly recommended.
167 167
 package org.jitsi.example;
168 168
 
169 169
 import android.os.Bundle;
170
-import android.support.v7.app.AppCompatActivity;
170
+import android.support.v4.app.FragmentActivity;
171 171
 
172 172
 import org.jitsi.meet.sdk.JitsiMeetView;
173 173
 import org.jitsi.meet.sdk.ReactActivityLifecycleCallbacks;
174 174
 
175 175
 // Example
176 176
 //
177
-public class MainActivity extends AppCompatActivity {
177
+public class MainActivity extends FragmentActivity implements JitsiMeetActivityInterface {
178 178
     private JitsiMeetView view;
179 179
 
180 180
     @Override
@@ -182,13 +182,13 @@ public class MainActivity extends AppCompatActivity {
182 182
             int requestCode,
183 183
             int resultCode,
184 184
             Intent data) {
185
-        ReactActivityLifecycleCallbacks.onActivityResult(
185
+        JitsiMeetActivityDelegate.onActivityResult(
186 186
                 this, requestCode, resultCode, data);
187 187
     }
188 188
 
189 189
     @Override
190 190
     public void onBackPressed() {
191
-        ReactActivityLifecycleCallbacks.onBackPressed();
191
+        JitsiMeetActivityDelegate.onBackPressed();
192 192
     }
193 193
 
194 194
     @Override
@@ -196,7 +196,10 @@ public class MainActivity extends AppCompatActivity {
196 196
         super.onCreate(savedInstanceState);
197 197
 
198 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 204
         setContentView(view);
202 205
     }
@@ -208,12 +211,12 @@ public class MainActivity extends AppCompatActivity {
208 211
         view.dispose();
209 212
         view = null;
210 213
 
211
-        ReactActivityLifecycleCallbacks.onHostDestroy(this);
214
+        JitsiMeetActivityDelegate.onHostDestroy(this);
212 215
     }
213 216
 
214 217
     @Override
215 218
     public void onNewIntent(Intent intent) {
216
-        ReactActivityLifecycleCallbacks.onNewIntent(intent);
219
+        JitsiMeetActivityDelegate.onNewIntent(intent);
217 220
     }
218 221
 
219 222
     @Override
@@ -221,21 +224,21 @@ public class MainActivity extends AppCompatActivity {
221 224
             final int requestCode,
222 225
             final String[] permissions,
223 226
             final int[] grantResults) {
224
-        ReactActivityLifecycleCallbacks.onRequestPermissionsResult(requestCode, permissions, grantResults);
227
+        JitsiMeetActivityDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
225 228
     }
226 229
 
227 230
     @Override
228 231
     protected void onResume() {
229 232
         super.onResume();
230 233
 
231
-        ReactActivityLifecycleCallbacks.onHostResume(this);
234
+        JitsiMeetActivityDelegate.onHostResume(this);
232 235
     }
233 236
 
234 237
     @Override
235 238
     protected void onStop() {
236 239
         super.onStop();
237 240
 
238
-        ReactActivityLifecycleCallbacks.onHostPause(this);
241
+        JitsiMeetActivityDelegate.onHostPause(this);
239 242
     }
240 243
 }
241 244
 ```
@@ -262,103 +265,62 @@ implementation("com.github.bumptech.glide:annotations:${glideVersion}") {
262 265
 
263 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 274
 ### JitsiMeetView
269 275
 
270 276
 The `JitsiMeetView` class is the core of Jitsi Meet SDK. It's designed to
271 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 288
 #### dispose()
274 289
 
275 290
 Releases all resources associated with this view. This method MUST be called
276 291
 when the Activity holding this view is going to be destroyed, usually in the
277 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 294
 #### getListener()
286 295
 
287 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 298
 #### setListener(listener)
340 299
 
341 300
 Sets the given listener (class implementing the `JitsiMeetViewListener`
342 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 325
 This class handles the interaction between `JitsiMeetView` and its enclosing
364 326
 `Activity`. Generally this shouldn't be consumed by users, because they'd be
@@ -470,10 +432,6 @@ rules file: https://github.com/jitsi/jitsi-meet/blob/master/android/app/proguard
470 432
 Picture-in-Picture style scenario, in a rectangle too small to accommodate its
471 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 435
 ## Dropbox integration
478 436
 
479 437
 To setup the Dropbox integration, follow these steps:

+ 2
- 4
android/app/src/main/java/org/jitsi/meet/MainActivity.java 파일 보기

@@ -55,8 +55,6 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
55 55
     private static final int OVERLAY_PERMISSION_REQUEST_CODE
56 56
         = (int) (Math.random() * Short.MAX_VALUE);
57 57
 
58
-    private static final String TAG = "MainActivity";
59
-
60 58
     private JitsiMeetFragment getFragment() {
61 59
         return (JitsiMeetFragment) getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
62 60
     }
@@ -186,8 +184,8 @@ public class MainActivity extends FragmentActivity implements JitsiMeetActivityI
186 184
             if (canRequestOverlayPermission() && !Settings.canDrawOverlays(this)) {
187 185
                 Intent intent
188 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 190
                 startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
193 191
                 return;

+ 17
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeet.java 파일 보기

@@ -21,12 +21,26 @@ import android.os.Bundle;
21 21
 import com.facebook.react.ReactInstanceManager;
22 22
 
23 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 29
     private static JitsiMeetConferenceOptions defaultConferenceOptions;
25 30
 
26 31
     public static JitsiMeetConferenceOptions getDefaultConferenceOptions() {
27 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 44
     static Bundle getDefaultProps() {
31 45
         if (defaultConferenceOptions != null) {
32 46
             return defaultConferenceOptions.asProps();
@@ -35,10 +49,9 @@ public class JitsiMeet {
35 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 55
     public static void showDevOptions() {
43 56
         ReactInstanceManager reactInstanceManager
44 57
             = ReactInstanceManagerHolder.getReactInstanceManager();

+ 28
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java 파일 보기

@@ -21,17 +21,45 @@ import android.os.Bundle;
21 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 32
 public class JitsiMeetConferenceOptions {
33
+    /**
34
+     * Server where the conference should take place.
35
+     */
25 36
     private URL serverURL;
37
+    /**
38
+     * Room name.
39
+     */
26 40
     private String room;
41
+    /**
42
+     * JWT token used for authentication.
43
+     */
27 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 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 55
     private Boolean audioMuted;
32 56
     private Boolean audioOnly;
33 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 63
     private Boolean welcomePageEnabled;
36 64
 
37 65
     public static class Builder {

+ 5
- 5
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetFragment.java 파일 보기

@@ -29,15 +29,15 @@ import android.view.ViewGroup;
29 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 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 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 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 42
 public class JitsiMeetFragment extends Fragment {
43 43
 

+ 22
- 3
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java 파일 보기

@@ -51,6 +51,13 @@ public class JitsiMeetView extends BaseReactView<JitsiMeetViewListener> {
51 51
     // fine to have this field volatile without additional synchronization.
52 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 61
     private static Bundle mergeProps(@Nullable Bundle a, @Nullable Bundle b) {
55 62
         Bundle result = new Bundle();
56 63
 
@@ -125,27 +132,39 @@ public class JitsiMeetView extends BaseReactView<JitsiMeetViewListener> {
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 140
     public void join(@Nullable JitsiMeetConferenceOptions options) {
129 141
         setProps(options != null ? options.asProps() : new Bundle());
130 142
     }
131 143
 
144
+    /**
145
+     * Leaves the currently active conference.
146
+     */
132 147
     public void leave() {
133 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 155
     private void setProps(@NonNull Bundle newProps) {
137 156
         // Merge the default options with the newly provided ones.
138 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 160
         // a second invocation with one and the same URL is expected to join
142 161
         // the respective conference again if the first invocation was followed
143 162
         // by leaving the conference. However, React and, respectively,
144 163
         // appProperties/initialProperties are declarative expressions i.e. one
145 164
         // and the same URL will not trigger an automatic re-render in the
146 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 168
         props.putLong("timestamp", System.currentTimeMillis());
150 169
 
151 170
         createReactRootView("App", props);

Loading…
취소
저장