浏览代码

[RN] Consistency in Jitsi Meet SDK for Android

master
Lyubo Marinov 8 年前
父节点
当前提交
90466183d6

+ 48
- 47
android/README.md 查看文件

@@ -1,24 +1,38 @@
1
-# Jitsi Meet for Android
1
+# Jitsi Meet SDK for Android
2 2
 
3
-This directory contains the source code for Jitsi Meet for Android (the
4
-application) and the Jitsi Meet SDK for Android.
3
+This directory contains the source code of the Jitsi Meet app and the Jitsi Meet
4
+SDK for Android.
5 5
 
6 6
 ## Jitsi Meet SDK
7 7
 
8
-Jitsi Meet SDK is an Android library which embodies the Jitsi Meet experience,
9
-gift-wrapped so other applications can use it. Example use:
8
+Jitsi Meet SDK is an Android library which embodies the whole Jitsi Meet
9
+experience and makes it reusable by third-party apps.
10
+
11
+To get started, extends your `android.app.Activity` from
12
+`org.jitsi.meet.sdk.JitsiMeetActivity`:
10 13
 
11 14
 ```java
12 15
 package org.jitsi.example;
13 16
 
14
-import android.support.v7.app.AppCompatActivity;
15
-import android.os.Bundle;
17
+import org.jitsi.meet.sdk.JitsiMeetActivity;
18
+
19
+public class MainActivity extends JitsiMeetActivity {
20
+}
21
+```
16 22
 
17
-import org.jitsi.meet.sdk.*;
23
+Alternatively, you can use the `org.jitsi.meet.sdk.JitsiMeetView` class which
24
+extends `android.view.View`:
18 25
 
26
+```java
27
+package org.jitsi.example;
19 28
 
20
-public class CustomActivity extends AppCompatActivity {
21
-    private JitsiMeetView jitsiMeetView;
29
+import android.os.Bundle;
30
+import android.support.v7.app.AppCompatActivity;
31
+
32
+import org.jitsi.meet.sdk.JitsiMeetView;
33
+
34
+public class MainActivity extends AppCompatActivity {
35
+    private JitsiMeetView view;
22 36
 
23 37
     @Override
24 38
     public void onBackPressed() {
@@ -32,56 +46,44 @@ public class CustomActivity extends AppCompatActivity {
32 46
     protected void onCreate(Bundle savedInstanceState) {
33 47
         super.onCreate(savedInstanceState);
34 48
 
35
-        jitsiMeetView = new JitsiMeetView(this);
36
-        jitsiMeetView.loadURL(null);
49
+        view = new JitsiMeetView(this);
50
+        view.loadURL(null);
37 51
 
38
-        setContentView(jitsiMeetView);
39
-    }
40
-
41
-    @Override
42
-    public void onNewIntent(Intent intent) {
43
-        JitsiMeetView.onNewIntent(intent);
52
+        setContentView(view);
44 53
     }
45 54
 
46 55
     @Override
47 56
     protected void onDestroy() {
48 57
         super.onDestroy();
58
+
49 59
         JitsiMeetView.onHostDestroy(this);
50 60
     }
51 61
 
62
+    @Override
63
+    public void onNewIntent(Intent intent) {
64
+        JitsiMeetView.onNewIntent(intent);
65
+    }
66
+
52 67
     @Override
53 68
     protected void onPause() {
54 69
         super.onPause();
70
+
55 71
         JitsiMeetView.onHostPause(this);
56 72
     }
57 73
 
58 74
     @Override
59 75
     protected void onResume() {
60 76
         super.onResume();
77
+
61 78
         JitsiMeetView.onHostResume(this);
62 79
     }
63
-
64
-}
65
-```
66
-
67
-Alternatively, you can use the `JitsiMeetBaseActivity` class, which already has
68
-all activity lifecycle methods hooked up:
69
-
70
-```java
71
-package org.jitsi.example;
72
-
73
-import org.jitsi.meet.sdk.*;
74
-
75
-
76
-public class MainActivity extends JitsiMeetBaseActivity {
77 80
 }
78
-
79 81
 ```
80 82
 
81
-### JitsiMeetBaseActivity
83
+### JitsiMeetActivity
82 84
 
83
-This class encapsulates a high level API in the form of an Android activity
84
-which displays a single `JitsiMeetView` views.
85
+This class encapsulates a high level API in the form of an Android `Activity`
86
+which displays a single `JitsiMeetView`.
85 87
 
86 88
 #### loadURL(url)
87 89
 
@@ -91,7 +93,7 @@ See JitsiMeetView.loadURL.
91 93
 ### JitsiMeetView
92 94
 
93 95
 The `JitsiMeetView` class is the core of Jitsi Meet SDK. It's designed to
94
-display a Jitsi Meet conference view (or a welcome page).
96
+display a Jitsi Meet conference (or a welcome page).
95 97
 
96 98
 #### getListener()
97 99
 
@@ -99,8 +101,8 @@ Returns the `JitsiMeetView.Listener` instance attached to the view.
99 101
 
100 102
 #### loadURL(url)
101 103
 
102
-Loads the given URL and joins the conference which is being pointed to. If null,
103
-it will load the welcome page.
104
+Loads the given URL and joins the room. If `null` is specified, the welcome page
105
+is displayed instead.
104 106
 
105 107
 #### setListener(listener)
106 108
 
@@ -110,8 +112,8 @@ interface) on the view.
110 112
 #### onBackPressed()
111 113
 
112 114
 Helper method which should be called from the activity's `onBackPressed` method.
113
-If this function returns `true` it means the action was handled and thus no
114
-extra processing is required, otherwise the application should call the parent's
115
+If this function returns `true`, it means the action was handled and thus no
116
+extra processing is required; otherwise the app should call the parent's
115 117
 `onBackPressed` method.
116 118
 
117 119
 This is a static method.
@@ -136,16 +138,16 @@ This is a static method.
136 138
 
137 139
 #### onNewIntent(intent)
138 140
 
139
-Helper method for integrating the *deep linking* functionality. If your
140
-application's activity is launched in "singleTask" mode this method should
141
-be called from the activity's `onNewIntent` method.
141
+Helper method for integrating the *deep linking* functionality. If your app's
142
+activity is launched in "singleTask" mode this method should be called from the
143
+activity's `onNewIntent` method.
142 144
 
143 145
 This is a static method.
144 146
 
145 147
 #### Listener
146 148
 
147
-JitsiMeetView.Listener provides an interface applications can implement in order
148
-to get notified about the state of the Jitsi Meet conference.
149
+JitsiMeetView.Listener provides an interface apps can implement in order to get
150
+notified about the state of the Jitsi Meet conference.
149 151
 
150 152
 ##### onConferenceFailed
151 153
 
@@ -178,4 +180,3 @@ The `data` HashMap contains a "url" key with the conference URL.
178 180
 Called before a conference is left.
179 181
 
180 182
 The `data` HashMap contains a "url" key with the conference URL.
181
-

+ 0
- 1
android/app/build.gradle 查看文件

@@ -1,6 +1,5 @@
1 1
 apply plugin: 'com.android.application'
2 2
 
3
-
4 3
 android {
5 4
     compileSdkVersion rootProject.ext.compileSdkVersion
6 5
     buildToolsVersion rootProject.ext.buildToolsVersion

+ 11
- 10
android/app/src/main/java/org/jitsi/meet/MainActivity.java 查看文件

@@ -16,18 +16,19 @@
16 16
 
17 17
 package org.jitsi.meet;
18 18
 
19
-import org.jitsi.meet.sdk.JitsiMeetBaseActivity;
20
-
19
+import org.jitsi.meet.sdk.JitsiMeetActivity;
21 20
 
22 21
 /**
23
- * The one and only Activity that Jitsi Meet (the app) needs. The activity is launched in
24
- * "singleTask" mode, so it will be created upon application initialization and there will be
25
- * a single instance of it. Further attempts at launching the application once it was already
26
- * launched will result in <tt>onNewIntent</tt> being called.
22
+ * The one and only {@link Activity} that the Jitsi Meet app needs. The
23
+ * {@code Activity} is launched in {@code singleTask} mode, so it will be
24
+ * created upon application initialization and there will be a single instance
25
+ * of it. Further attempts at launching the application once it was already
26
+ * launched will result in {@link Activity#onNewIntent(Intent)} being called.
27 27
  *
28
- * This Activity inherits from JitsiMeetBaseActivity without adding anything to it. It merely exists to
29
- * keep the React Native CLI working, since it always tries to launch an activity called
30
- * "MainActivity" when doing "react-native run-android".
28
+ * This {@code Activity} extends {@link JitsiMeetActivity} without adding
29
+ * anything to it. It exists to merely keep the React Native CLI working, since
30
+ * the latter always tries to launch an {@code Activity} named
31
+ * {@code MainActivity} when doing {@code react-native run-android}.
31 32
  */
32
-public class MainActivity extends JitsiMeetBaseActivity {
33
+public class MainActivity extends JitsiMeetActivity {
33 34
 }

+ 5
- 3
android/build.gradle 查看文件

@@ -1,4 +1,5 @@
1
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
1
+// Top-level build file where you can add configuration options common to all
2
+// sub-projects/modules.
2 3
 
3 4
 buildscript {
4 5
     repositories {
@@ -8,7 +9,7 @@ buildscript {
8 9
         classpath 'com.android.tools.build:gradle:2.2.3'
9 10
 
10 11
         // NOTE: Do not place your application dependencies here; they belong
11
-        // in the individual module build.gradle files
12
+        // in the individual module build.gradle files.
12 13
     }
13 14
 }
14 15
 
@@ -17,7 +18,8 @@ allprojects {
17 18
         mavenLocal()
18 19
         jcenter()
19 20
         maven {
20
-            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21
+            // All of React Native (JS, Obj-C sources, Android binaries) is
22
+            // installed from npm.
21 23
             url "$rootDir/../node_modules/react-native/android"
22 24
         }
23 25
     }

+ 16
- 8
android/sdk/build.gradle 查看文件

@@ -47,7 +47,7 @@ gradle.projectsEvaluated {
47 47
         def buildNameCapitalized = "${buildType.name.capitalize()}"
48 48
         def bundlePath = "${buildDir}/intermediates/bundles/${buildType.name}"
49 49
 
50
-        // Bundle fonts in react-native-vector-icons
50
+        // Bundle fonts in react-native-vector-icons.
51 51
         //
52 52
 
53 53
         def currentFontTask = tasks.create(name: "${buildType.name}CopyFonts", type: Copy) {
@@ -63,35 +63,43 @@ gradle.projectsEvaluated {
63 63
         runBefore("processUniversal${buildNameCapitalized}Resources", currentFontTask)
64 64
         runBefore("process${buildNameCapitalized}Resources", currentFontTask)
65 65
 
66
-        // Bundle JavaScript and React resources
66
+        // Bundle JavaScript and React resources.
67 67
         // (adapted from react-native/react.gradle)
68 68
         //
69 69
 
70
-        // React js bundle directories
70
+        // React JS bundle directories
71 71
         def jsBundleDir = file("${bundlePath}/assets")
72 72
         def resourcesDir = file("${bundlePath}/res/merged")
73 73
         def jsBundleFile = file("${jsBundleDir}/index.android.bundle")
74 74
 
75
-        // Bundle task name for variant
75
+        // Bundle task name for variant.
76 76
         def bundleJsAndAssetsTaskName = "bundle${buildNameCapitalized}JsAndAssets"
77 77
 
78 78
         def currentBundleTask = tasks.create(
79 79
                 name: bundleJsAndAssetsTaskName,
80 80
                 type: Exec) {
81 81
 
82
-            // Set up inputs and outputs so gradle can cache the result
82
+            // Set up inputs and outputs so gradle can cache the result.
83 83
             def reactRoot = file("${projectDir}/../../")
84 84
             inputs.files fileTree(dir: reactRoot, excludes: ["android/**", "ios/**"])
85 85
             outputs.dir jsBundleDir
86 86
             outputs.dir resourcesDir
87 87
 
88
-            // Set up the call to the react-native cli
88
+            // Set up the call to the react-native cli.
89 89
             workingDir reactRoot
90 90
 
91 91
             // Create JS bundle
92 92
             def devEnabled = !buildNameCapitalized.toLowerCase().contains("release")
93
-            commandLine("node", "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}",
94
-                    "--reset-cache", "--entry-file", "index.android.js", "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir)
93
+            commandLine(
94
+                "node",
95
+                "node_modules/react-native/local-cli/cli.js",
96
+                "bundle",
97
+                "--assets-dest", resourcesDir,
98
+                "--bundle-output", jsBundleFile,
99
+                "--dev", "${devEnabled}",
100
+                "--entry-file", "index.android.js",
101
+                "--platform", "android",
102
+                "--reset-cache")
95 103
 
96 104
             // TODO: disable task in Debug mode?
97 105
         }

android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetBaseActivity.java → android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java 查看文件

@@ -26,53 +26,57 @@ import android.os.Bundle;
26 26
 
27 27
 import java.net.URL;
28 28
 
29
-
30 29
 /**
31
- * Base Activity for applications integrating Jitsi Meet at a higher level. It contains all the
32
- * required wiring between the <tt>JKConferenceView</tt> and the Activity lifecycle methods already
33
- * implemented.
30
+ * Base Activity for applications integrating Jitsi Meet at a higher level. It
31
+ * contains all the required wiring between the <tt>JKConferenceView</tt> and
32
+ * the Activity lifecycle methods already implemented.
34 33
  *
35
- * In this activity we use a single <tt>JKConferenceView</tt> instance. This instance gives us
36
- * access to a view which displays the welcome page and the conference itself. All lifetime methods
37
- * associated with this Activity are hooked to the React Native subsystem via proxy calls through
38
- * the <tt>JKConferenceView</tt> static methods.
34
+ * In this activity we use a single <tt>JKConferenceView</tt> instance. This
35
+ * instance gives us access to a view which displays the welcome page and the
36
+ * conference itself. All lifetime methods associated with this Activity are
37
+ * hooked to the React Native subsystem via proxy calls through the
38
+ * <tt>JKConferenceView</tt> static methods.
39 39
  */
40
-public class JitsiMeetBaseActivity extends AppCompatActivity {
40
+public class JitsiMeetActivity extends AppCompatActivity {
41 41
     /**
42
-     * Instance of the {@JitsiMeetView} which this activity will display.
42
+     * Code for identifying the permission to draw on top of other apps. The
43
+     * number is chosen arbitrarily and used to correlate the intent with its
44
+     * result.
43 45
      */
44
-    private JitsiMeetView jitsiMeetView;
46
+    public static final int OVERLAY_PERMISSION_REQ_CODE = 4242;
45 47
 
46 48
     /**
47
-     * Code for identifying the permission to draw on top of other apps. The number is chosen
48
-     * arbitrarily and used to correlate the intent with its result.
49
+     * Instance of the {@JitsiMeetView} which this activity will display.
49 50
      */
50
-    public static final int OVERLAY_PERMISSION_REQ_CODE = 4242;
51
+    private JitsiMeetView view;
51 52
 
52 53
     /**
53
-     * Loads the given URL and displays the conference. If the specified URL is null, the welcome
54
-     * page is displayed instead.
54
+     * Loads the given URL and displays the conference. If the specified URL is
55
+     * null, the welcome page is displayed instead.
55 56
      *
56 57
      * @param url - The conference URL.
57 58
      */
58 59
     public void loadURL(@Nullable URL url) {
59
-        jitsiMeetView.loadURL(url);
60
+        view.loadURL(url);
60 61
     }
61 62
 
62 63
     /**
63 64
      * {@inheritDoc}
64 65
      */
65 66
     @Override
66
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
67
+    protected void onActivityResult(
68
+            int requestCode,
69
+            int resultCode,
70
+            Intent data) {
67 71
         if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
68 72
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
69 73
                 if (!Settings.canDrawOverlays(this)) {
70
-                    // Permission not granted...
74
+                    // Permission not granted.
71 75
                     return;
72 76
                 }
73 77
             }
74 78
 
75
-            setContentView(jitsiMeetView);
79
+            setContentView(view);
76 80
         }
77 81
     }
78 82
 
@@ -94,41 +98,42 @@ public class JitsiMeetBaseActivity extends AppCompatActivity {
94 98
     protected void onCreate(Bundle savedInstanceState) {
95 99
         super.onCreate(savedInstanceState);
96 100
 
97
-        jitsiMeetView = new JitsiMeetView(this);
98
-        jitsiMeetView.loadURL(null);
99
-
100
-        /**
101
-         * In debug mode React needs permission to write over other apps in order to display the
102
-         * warning and error overlays.
103
-         */
104
-        if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
105
-            !Settings.canDrawOverlays(this)) {
101
+        view = new JitsiMeetView(this);
102
+        view.loadURL(null);
106 103
 
104
+        // In debug mode React needs permission to write over other apps in
105
+        // order to display the warning and error overlays.
106
+        if (BuildConfig.DEBUG
107
+                && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
108
+                && !Settings.canDrawOverlays(this)) {
107 109
             Intent intent
108
-                = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
109
-                Uri.parse("package:" + getPackageName()));
110
+                = new Intent(
111
+                        Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
112
+                        Uri.parse("package:" + getPackageName()));
113
+
110 114
             startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
111 115
             return;
112 116
         }
113 117
 
114
-        setContentView(jitsiMeetView);
118
+        setContentView(view);
115 119
     }
116 120
 
117 121
     /**
118 122
      * {@inheritDoc}
119 123
      */
120 124
     @Override
121
-    public void onNewIntent(Intent intent) {
122
-        JitsiMeetView.onNewIntent(intent);
125
+    protected void onDestroy() {
126
+        super.onDestroy();
127
+
128
+        JitsiMeetView.onHostDestroy(this);
123 129
     }
124 130
 
125 131
     /**
126 132
      * {@inheritDoc}
127 133
      */
128 134
     @Override
129
-    protected void onDestroy() {
130
-        super.onDestroy();
131
-        JitsiMeetView.onHostDestroy(this);
135
+    public void onNewIntent(Intent intent) {
136
+        JitsiMeetView.onNewIntent(intent);
132 137
     }
133 138
 
134 139
     /**
@@ -137,6 +142,7 @@ public class JitsiMeetBaseActivity extends AppCompatActivity {
137 142
     @Override
138 143
     protected void onPause() {
139 144
         super.onPause();
145
+
140 146
         JitsiMeetView.onHostPause(this);
141 147
     }
142 148
 
@@ -146,7 +152,7 @@ public class JitsiMeetBaseActivity extends AppCompatActivity {
146 152
     @Override
147 153
     protected void onResume() {
148 154
         super.onResume();
155
+
149 156
         JitsiMeetView.onHostResume(this);
150 157
     }
151
-
152 158
 }

+ 79
- 66
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java 查看文件

@@ -32,56 +32,58 @@ import com.facebook.react.common.LifecycleState;
32 32
 import java.net.URL;
33 33
 import java.util.HashMap;
34 34
 
35
-
36 35
 public class JitsiMeetView extends FrameLayout {
37 36
     /**
38
-     * Background color used by this view and the React Native root view.
37
+     * Background color used by {@code JitsiMeetView} and the React Native root
38
+     * view.
39 39
      */
40 40
     private static final int BACKGROUND_COLOR = 0xFF111111;
41 41
 
42 42
     /**
43
-     * {@JitsiMeetView.Listener} instance for reporting events occurring in Jitsi Meet.
43
+     * Reference to the single instance of this class we currently allow. It's
44
+     * currently used for fetching the instance from the listener's callbacks.
45
+     *
46
+     * TODO: lift this limitation.
44 47
      */
45
-    private JitsiMeetView.Listener listener;
48
+    private static JitsiMeetView instance;
46 49
 
47 50
     /**
48
-     * Reference to the single instance of this class we currently allow. It's currently used for
49
-     * fetching the instance from the listener's callbacks.
50
-     *
51
-     * TODO: lift this limitation.
51
+     * React Native bridge. The instance manager allows embedding applications
52
+     * to create multiple root views off the same JavaScript bundle.
52 53
      */
53
-    private static JitsiMeetView mInstance;
54
+    private static ReactInstanceManager reactInstanceManager;
54 55
 
55 56
     /**
56
-     * React Native bridge. The instance manager allows embedding applications to create multiple
57
-     * root views off the same JavaScript bundle.
57
+     * {@JitsiMeetView.Listener} instance for reporting events occurring in
58
+     * Jitsi Meet.
58 59
      */
59
-    private static ReactInstanceManager mReactInstanceManager;
60
+    private JitsiMeetView.Listener listener;
60 61
 
61 62
     /**
62 63
      * React Native root view.
63 64
      */
64
-    private ReactRootView mReactRootView;
65
+    private ReactRootView reactRootView;
65 66
 
66 67
     public JitsiMeetView(@NonNull Context context) {
67 68
         super(context);
68 69
 
69
-        if (mInstance != null) {
70
-            throw new RuntimeException("Only a single instance is currently allowed");
70
+        if (instance != null) {
71
+            throw new RuntimeException(
72
+                    "Only a single instance is currently allowed");
71 73
         }
72 74
 
73 75
         /*
74
-         * TODO: Only allow a single instance for now. All React Native modules are
75
-         * kinda singletons so global state would be broken since we have a single
76
-         * bridge. Once we have that sorted out multiple instances of JitsiMeetView
77
-         * will be allowed.
76
+         * TODO: Only allow a single instance for now. All React Native modules
77
+         * are kinda singletons so global state would be broken since we have a
78
+         * single bridge. Once we have that sorted out multiple instances of
79
+         * JitsiMeetView will be allowed.
78 80
          */
79
-        mInstance = this;
81
+        instance = this;
80 82
 
81 83
         setBackgroundColor(BACKGROUND_COLOR);
82 84
 
83
-        if (mReactInstanceManager == null) {
84
-            initReactInstanceManager(((Activity)context).getApplication());
85
+        if (reactInstanceManager == null) {
86
+            initReactInstanceManager(((Activity) context).getApplication());
85 87
         }
86 88
     }
87 89
 
@@ -91,7 +93,7 @@ public class JitsiMeetView extends FrameLayout {
91 93
      * @returns The {@JitsiMeetView} instance.
92 94
      */
93 95
     public static JitsiMeetView getInstance() {
94
-        return mInstance;
96
+        return instance;
95 97
     }
96 98
 
97 99
     /**
@@ -104,14 +106,15 @@ public class JitsiMeetView extends FrameLayout {
104 106
     }
105 107
 
106 108
     /**
107
-     * Internal method to initialize the React Native instance manager. We create a single instance
108
-     * in order to load the JavaScript bundle a single time. All <tt>ReactRootView</tt> instances
109
-     * will be tied to the one and only <tt>ReactInstanceManager</tt>.
109
+     * Internal method to initialize the React Native instance manager. We
110
+     * create a single instance in order to load the JavaScript bundle a single
111
+     * time. All <tt>ReactRootView</tt> instances will be tied to the one and
112
+     * only <tt>ReactInstanceManager</tt>.
110 113
      *
111 114
      * @param application - <tt>Application</tt> instance which is running.
112 115
      */
113 116
     private static void initReactInstanceManager(Application application) {
114
-        mReactInstanceManager = ReactInstanceManager.builder()
117
+        reactInstanceManager = ReactInstanceManager.builder()
115 118
             .setApplication(application)
116 119
             .setBundleAssetName("index.android.bundle")
117 120
             .setJSMainModuleName("index.android")
@@ -130,8 +133,8 @@ public class JitsiMeetView extends FrameLayout {
130 133
     }
131 134
 
132 135
     /**
133
-     * Loads the given URL and displays the conference. If the specified URL is null, the welcome
134
-     * page is displayed instead.
136
+     * Loads the given URL and displays the conference. If the specified URL is
137
+     * null, the welcome page is displayed instead.
135 138
      *
136 139
      * @param url - The conference URL.
137 140
      */
@@ -142,17 +145,18 @@ public class JitsiMeetView extends FrameLayout {
142 145
             props.putString("url", url.toString());
143 146
         }
144 147
 
145
-        // TODO: ReactRootView#setAppProperties is only available on React Native 0.45, so destroy
146
-        // the current root view and create a new one.
147
-        if (mReactRootView != null) {
148
-            removeView(mReactRootView);
149
-            mReactRootView = null;
148
+        // TODO: ReactRootView#setAppProperties is only available on React
149
+        // Native 0.45, so destroy the current root view and create a new one.
150
+        if (reactRootView != null) {
151
+            removeView(reactRootView);
152
+            reactRootView = null;
150 153
         }
151 154
 
152
-        mReactRootView = new ReactRootView(getContext());
153
-        mReactRootView.startReactApplication(mReactInstanceManager, "App", props);
154
-        mReactRootView.setBackgroundColor(BACKGROUND_COLOR);
155
-        addView(mReactRootView);
155
+        reactRootView = new ReactRootView(getContext());
156
+        reactRootView
157
+            .startReactApplication(reactInstanceManager, "App", props);
158
+        reactRootView.setBackgroundColor(BACKGROUND_COLOR);
159
+        addView(reactRootView);
156 160
     }
157 161
 
158 162
     /**
@@ -165,15 +169,17 @@ public class JitsiMeetView extends FrameLayout {
165 169
     }
166 170
 
167 171
     /**
168
-     * Activity lifecycle method which should be called from <tt>Activity.onBackPressed</tt> so
169
-     * we can do the required internal processing.
172
+     * Activity lifecycle method which should be called from
173
+     * <tt>Activity.onBackPressed</tt> so we can do the required internal
174
+     * processing.
170 175
      *
171
-     * @return - true if the back-press was processed, false otherwise. In case false is returned
172
-     * the application should call the parent's implementation.
176
+     * @return - true if the back-press was processed, false otherwise. In case
177
+     * false is returned the application should call the parent's
178
+     * implementation.
173 179
      */
174 180
     public static boolean onBackPressed() {
175
-        if (mReactInstanceManager != null) {
176
-            mReactInstanceManager.onBackPressed();
181
+        if (reactInstanceManager != null) {
182
+            reactInstanceManager.onBackPressed();
177 183
             return true;
178 184
         } else {
179 185
             return false;
@@ -181,52 +187,54 @@ public class JitsiMeetView extends FrameLayout {
181 187
     }
182 188
 
183 189
     /**
184
-     * Activity lifecycle method which should be called from <tt>Activity.onDestroy</tt> so
185
-     * we can do the required internal processing.
190
+     * Activity lifecycle method which should be called from
191
+     * <tt>Activity.onDestroy</tt> so we can do the required internal
192
+     * processing.
186 193
      *
187 194
      * @param activity - <tt>Activity</tt> being destroyed.
188 195
      */
189 196
     public static void onHostDestroy(Activity activity) {
190
-        if (mReactInstanceManager != null) {
191
-            mReactInstanceManager.onHostDestroy(activity);
197
+        if (reactInstanceManager != null) {
198
+            reactInstanceManager.onHostDestroy(activity);
192 199
         }
193 200
     }
194 201
 
195 202
     /**
196
-     * Activity lifecycle method which should be called from <tt>Activity.onPause</tt> so
197
-     * we can do the required internal processing.
203
+     * Activity lifecycle method which should be called from
204
+     * <tt>Activity.onPause</tt> so we can do the required internal processing.
198 205
      *
199 206
      * @param activity - <tt>Activity</tt> being paused.
200 207
      */
201 208
     public static void onHostPause(Activity activity) {
202
-        if (mReactInstanceManager != null) {
203
-            mReactInstanceManager.onHostPause(activity);
209
+        if (reactInstanceManager != null) {
210
+            reactInstanceManager.onHostPause(activity);
204 211
         }
205 212
     }
206 213
 
207 214
     /**
208
-     * Activity lifecycle method which should be called from <tt>Activity.onResume</tt> so
209
-     * we can do the required internal processing.
215
+     * Activity lifecycle method which should be called from
216
+     * <tt>Activity.onResume</tt> so we can do the required internal processing.
210 217
      *
211 218
      * @param activity - <tt>Activity</tt> being resumed.
212 219
      */
213 220
     public static void onHostResume(Activity activity) {
214
-        if (mReactInstanceManager != null) {
215
-            mReactInstanceManager.onHostResume(activity, null);
221
+        if (reactInstanceManager != null) {
222
+            reactInstanceManager.onHostResume(activity, null);
216 223
         }
217 224
     }
218 225
 
219 226
     /**
220
-     * Activity lifecycle method which should be called from <tt>Activity.onNewIntent</tt> so
221
-     * we can do the required internal processing. Note that this is only needed if the activity's
222
-     * "launchMode" was set to "singleTask". This is required for deep linking to work once the
223
-     * application is already running.
227
+     * Activity lifecycle method which should be called from
228
+     * <tt>Activity.onNewIntent</tt> so we can do the required internal
229
+     * processing. Note that this is only needed if the activity's "launchMode"
230
+     * was set to "singleTask". This is required for deep linking to work once
231
+     * the application is already running.
224 232
      *
225 233
      * @param intent - <tt>Intent</tt> instance which was received.
226 234
      */
227 235
     public static void onNewIntent(Intent intent) {
228
-        if (mReactInstanceManager != null) {
229
-            mReactInstanceManager.onNewIntent(intent);
236
+        if (reactInstanceManager != null) {
237
+            reactInstanceManager.onNewIntent(intent);
230 238
         }
231 239
     }
232 240
 
@@ -235,33 +243,38 @@ public class JitsiMeetView extends FrameLayout {
235 243
      */
236 244
     public interface Listener {
237 245
         /**
238
-         * Called when joining a conference fails or an ongoing conference is interrupted due to a
239
-         * failure.
240
-         * @param data - HashMap with an "error" key describing the problem, and a "url" key with
241
-         *             the conference URL.
246
+         * Called when joining a conference fails or an ongoing conference is
247
+         * interrupted due to a failure.
248
+         *
249
+         * @param data - HashMap with an "error" key describing the problem, and
250
+         * a "url" key with the conference URL.
242 251
          */
243 252
         void onConferenceFailed(HashMap<String, Object> data);
244 253
 
245 254
         /**
246 255
          * Called when a conference was joined.
256
+         *
247 257
          * @param data - HashMap with a "url" key with the conference URL.
248 258
          */
249 259
         void onConferenceJoined(HashMap<String, Object> data);
250 260
 
251 261
         /**
252 262
          * Called when the conference was left, typically after hanging up.
263
+         *
253 264
          * @param data - HashMap with a "url" key with the conference URL.
254 265
          */
255 266
         void onConferenceLeft(HashMap<String, Object> data);
256 267
 
257 268
         /**
258 269
          * Called before the conference is joined.
270
+         *
259 271
          * @param data - HashMap with a "url" key with the conference URL.
260 272
          */
261 273
         void onConferenceWillJoin(HashMap<String, Object> data);
262 274
 
263 275
         /**
264 276
          * Called before the conference is left.
277
+         *
265 278
          * @param data - HashMap with a "url" key with the conference URL.
266 279
          */
267 280
         void onConferenceWillLeave(HashMap<String, Object> data);

+ 5
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java 查看文件

@@ -25,7 +25,6 @@ import org.jitsi.meet.sdk.JitsiMeetView;
25 25
 
26 26
 import java.util.HashMap;
27 27
 
28
-
29 28
 /**
30 29
  * Module implementing a simple API to enable a proximity sensor-controlled
31 30
  * wake lock. When the lock is held, if the proximity sensor detects a nearby
@@ -61,20 +60,22 @@ public class ExternalAPIModule extends ReactContextBaseJavaModule {
61 60
 
62 61
     /**
63 62
      * Dispatches an event that occurred on JavaScript to the view's listener.
63
+     *
64 64
      * @param name - Event name.
65 65
      * @param data - Ancillary data for the event.
66 66
      */
67 67
     @ReactMethod
68 68
     public void sendEvent(final String name, ReadableMap data) {
69 69
         JitsiMeetView view = JitsiMeetView.getInstance();
70
-        JitsiMeetView.Listener listener = view != null ? view.getListener() : null;
70
+        JitsiMeetView.Listener listener
71
+            = view != null ? view.getListener() : null;
71 72
 
72 73
         if (listener == null) {
73 74
             return;
74 75
         }
75 76
 
76
-        // TODO: Sigh, converting a ReadableMap to a HashMap is not supported until React Native
77
-        // 0.46.
77
+        // TODO: Sigh, converting a ReadableMap to a HashMap is not supported
78
+        // until React Native 0.46.
78 79
         final HashMap<String, Object> dataMap = new HashMap<>();
79 80
 
80 81
         try {

+ 2
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIPackage.java 查看文件

@@ -45,7 +45,7 @@ public class ExternalAPIPackage implements ReactPackage {
45 45
      */
46 46
     @Override
47 47
     public List<NativeModule> createNativeModules(
48
-        ReactApplicationContext reactContext) {
48
+            ReactApplicationContext reactContext) {
49 49
         List<NativeModule> modules = new ArrayList<>();
50 50
 
51 51
         modules.add(new ExternalAPIModule(reactContext));
@@ -58,7 +58,7 @@ public class ExternalAPIPackage implements ReactPackage {
58 58
      */
59 59
     @Override
60 60
     public List<ViewManager> createViewManagers(
61
-        ReactApplicationContext reactContext) {
61
+            ReactApplicationContext reactContext) {
62 62
         return Collections.emptyList();
63 63
     }
64 64
 }

+ 0
- 1
ios/README.md 查看文件

@@ -108,4 +108,3 @@ The `data` dictionary contains a "url" key with the conference URL.
108 108
 Called before a conference is left.
109 109
 
110 110
 The `data` dictionary contains a "url" key with the conference URL.
111
-

+ 10
- 16
ios/sdk/src/ExternalAPI.m 查看文件

@@ -18,7 +18,6 @@
18 18
 
19 19
 #import "JitsiMeetView.h"
20 20
 
21
-
22 21
 @interface ExternalAPI : NSObject<RCTBridgeModule>
23 22
 @end
24 23
 
@@ -40,25 +39,20 @@ RCT_EXPORT_METHOD(sendEvent:(NSString*)name data:(NSDictionary *) data) {
40 39
         return;
41 40
     }
42 41
 
43
-    if ([name isEqualToString:@"CONFERENCE_FAILED"] &&
44
-        [delegate respondsToSelector:@selector(conferenceFailed:)]) {
45
-
42
+    if ([name isEqualToString:@"CONFERENCE_FAILED"]
43
+            && [delegate respondsToSelector:@selector(conferenceFailed:)]) {
46 44
         [delegate conferenceFailed:data];
47
-    } else if ([name isEqualToString:@"CONFERENCE_JOINED"] &&
48
-               [delegate respondsToSelector:@selector(conferenceJoined:)]) {
49
-
45
+    } else if ([name isEqualToString:@"CONFERENCE_JOINED"]
46
+            && [delegate respondsToSelector:@selector(conferenceJoined:)]) {
50 47
         [delegate conferenceJoined:data];
51
-    } else if ([name isEqualToString:@"CONFERENCE_LEFT"] &&
52
-               [delegate respondsToSelector:@selector(conferenceLeft:)]) {
53
-
48
+    } else if ([name isEqualToString:@"CONFERENCE_LEFT"]
49
+            && [delegate respondsToSelector:@selector(conferenceLeft:)]) {
54 50
         [delegate conferenceLeft:data];
55
-    } else if ([name isEqualToString:@"CONFERENCE_WILL_JOIN"] &&
56
-               [delegate respondsToSelector:@selector(conferenceWillJoin:)]) {
57
-
51
+    } else if ([name isEqualToString:@"CONFERENCE_WILL_JOIN"]
52
+            && [delegate respondsToSelector:@selector(conferenceWillJoin:)]) {
58 53
         [delegate conferenceWillJoin:data];
59
-    } else if ([name isEqualToString:@"CONFERENCE_WILL_LEAVE"] &&
60
-               [delegate respondsToSelector:@selector(conferenceWillLeave:)]) {
61
-
54
+    } else if ([name isEqualToString:@"CONFERENCE_WILL_LEAVE"]
55
+            && [delegate respondsToSelector:@selector(conferenceWillLeave:)]) {
62 56
         [delegate conferenceWillLeave:data];
63 57
     }
64 58
 }

+ 1
- 1
ios/sdk/src/JitsiMeetView.h 查看文件

@@ -32,7 +32,7 @@
32 32
   sourceApplication:(NSString *)sourceApplication
33 33
          annotation:(id)annotation;
34 34
 
35
-+ (instancetype) getInstance;
35
++ (instancetype)getInstance;
36 36
 
37 37
 - (void)loadURL:(nullable NSURL *)url;
38 38
 

正在加载...
取消
保存