Pārlūkot izejas kodu

[RN] Increase the coverage of JitsiMeetViewListener

JitsiMeetViewListener is an integral part of the public API of Jitsi
Meet SDK for Android. Utilize it in the Debug configuration of the Jitsi
Meet app for Android in order to increase (1) awareness of API breakages
and (2) API coverage.

The same goes for JitsiMeetViewDelegate in Jitsi Meet SDK and app for
iOS.
master
Lyubo Marinov 7 gadus atpakaļ
vecāks
revīzija
4dc78ce458

+ 79
- 0
android/app/src/main/java/org/jitsi/meet/MainActivity.java Parādīt failu

@@ -17,8 +17,13 @@
17 17
 package org.jitsi.meet;
18 18
 
19 19
 import android.os.Bundle;
20
+import android.util.Log;
20 21
 
21 22
 import org.jitsi.meet.sdk.JitsiMeetActivity;
23
+import org.jitsi.meet.sdk.JitsiMeetView;
24
+import org.jitsi.meet.sdk.JitsiMeetViewListener;
25
+
26
+import java.util.Map;
22 27
 
23 28
 /**
24 29
  * The one and only {@link Activity} that the Jitsi Meet app needs. The
@@ -33,6 +38,80 @@ import org.jitsi.meet.sdk.JitsiMeetActivity;
33 38
  * {@code react-native run-android}.
34 39
  */
35 40
 public class MainActivity extends JitsiMeetActivity {
41
+    /**
42
+     * {@inheritDoc}
43
+     */
44
+    protected JitsiMeetView initializeView() {
45
+        JitsiMeetView view = super.initializeView();
46
+
47
+        // XXX In order to increase (1) awareness of API breakages and (2) API
48
+        // coverage, utilize JitsiMeetViewListener in the Debug configuration of
49
+        // the app.
50
+        if (BuildConfig.DEBUG && view != null) {
51
+            view.setListener(new JitsiMeetViewListener() {
52
+                private void on(String name, Map<String, Object> data) {
53
+                    // Log with the tag "ReactNative" in order to have the log
54
+                    // visible in react-native log-android as well.
55
+                    Log.d(
56
+                        "ReactNative",
57
+                        JitsiMeetViewListener.class.getSimpleName() + " "
58
+                            + name + " "
59
+                            + data);
60
+                }
61
+
62
+                /**
63
+                 * {@inheritDoc}
64
+                 */
65
+                @Override
66
+                public void onConferenceFailed(Map<String, Object> data) {
67
+                    on("CONFERENCE_FAILED", data);
68
+                }
69
+
70
+                /**
71
+                 * {@inheritDoc}
72
+                 */
73
+                @Override
74
+                public void onConferenceJoined(Map<String, Object> data) {
75
+                    on("CONFERENCE_JOINED", data);
76
+                }
77
+
78
+                /**
79
+                 * {@inheritDoc}
80
+                 */
81
+                @Override
82
+                public void onConferenceLeft(Map<String, Object> data) {
83
+                    on("CONFERENCE_LEFT", data);
84
+                }
85
+
86
+                /**
87
+                 * {@inheritDoc}
88
+                 */
89
+                @Override
90
+                public void onConferenceWillJoin(Map<String, Object> data) {
91
+                    on("CONFERENCE_WILL_JOIN", data);
92
+                }
93
+
94
+                /**
95
+                 * {@inheritDoc}
96
+                 */
97
+                @Override
98
+                public void onConferenceWillLeave(Map<String, Object> data) {
99
+                    on("CONFERENCE_WILL_LEAVE", data);
100
+                }
101
+
102
+                /**
103
+                 * {@inheritDoc}
104
+                 */
105
+                @Override
106
+                public void onLoadConfigError(Map<String, Object> data) {
107
+                    on("LOAD_CONFIG_ERROR", data);
108
+                }
109
+            });
110
+        }
111
+
112
+        return view;
113
+    }
114
+
36 115
     /**
37 116
      * {@inheritDoc}
38 117
      */

+ 19
- 5
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java Parādīt failu

@@ -76,8 +76,22 @@ public class JitsiMeetActivity extends AppCompatActivity {
76 76
      * Initializes the {@link #view} of this {@code JitsiMeetActivity} with a
77 77
      * new {@link JitsiMeetView} instance.
78 78
      */
79
-    private void initializeView() {
80
-        view = new JitsiMeetView(this);
79
+    private void initializeContentView() {
80
+        JitsiMeetView view = initializeView();
81
+
82
+        if (view != null) {
83
+            this.view = view;
84
+            setContentView(this.view);
85
+        }
86
+    }
87
+
88
+    /**
89
+     * Initializes a new {@link JitsiMeetView} instance.
90
+     *
91
+     * @return a new {@code JitsiMeetView} instance.
92
+     */
93
+    protected JitsiMeetView initializeView() {
94
+        JitsiMeetView view = new JitsiMeetView(this);
81 95
 
82 96
         // In order to have the desired effect
83 97
         // JitsiMeetView#setWelcomePageEnabled(boolean) must be invoked before
@@ -85,7 +99,7 @@ public class JitsiMeetActivity extends AppCompatActivity {
85 99
         view.setWelcomePageEnabled(welcomePageEnabled);
86 100
         view.loadURL(null);
87 101
 
88
-        setContentView(view);
102
+        return view;
89 103
     }
90 104
 
91 105
     /**
@@ -109,7 +123,7 @@ public class JitsiMeetActivity extends AppCompatActivity {
109 123
         if (requestCode == OVERLAY_PERMISSION_REQUEST_CODE
110 124
                 && canRequestOverlayPermission()) {
111 125
             if (Settings.canDrawOverlays(this)) {
112
-                initializeView();
126
+                initializeContentView();
113 127
             }
114 128
         }
115 129
     }
@@ -144,7 +158,7 @@ public class JitsiMeetActivity extends AppCompatActivity {
144 158
             return;
145 159
         }
146 160
 
147
-        initializeView();
161
+        initializeContentView();
148 162
     }
149 163
 
150 164
     /**

+ 34
- 0
ios/app/src/ViewController.m Parādīt failu

@@ -40,4 +40,38 @@
40 40
     [view loadURL:nil];
41 41
 }
42 42
 
43
+#if DEBUG
44
+
45
+void _onJitsiMeetViewDelegateEvent(NSString *name, NSDictionary *data) {
46
+    NSLog(
47
+        @"[%s:%d] JitsiMeetViewDelegate %@ %@",
48
+        __FILE__, __LINE__, name, data);
49
+}
50
+
51
+- (void)conferenceFailed:(NSDictionary *)data {
52
+    _onJitsiMeetViewDelegateEvent(@"CONFERENCE_FAILED", data);
53
+}
54
+
55
+- (void)conferenceJoined:(NSDictionary *)data {
56
+    _onJitsiMeetViewDelegateEvent(@"CONFERENCE_JOINED", data);
57
+}
58
+
59
+- (void)conferenceLeft:(NSDictionary *)data {
60
+    _onJitsiMeetViewDelegateEvent(@"CONFERENCE_LEFT", data);
61
+}
62
+
63
+- (void)conferenceWillJoin:(NSDictionary *)data {
64
+    _onJitsiMeetViewDelegateEvent(@"CONFERENCE_WILL_JOIN", data);
65
+}
66
+
67
+- (void)conferenceWillLeave:(NSDictionary *)data {
68
+    _onJitsiMeetViewDelegateEvent(@"CONFERENCE_WILL_LEAVE", data);
69
+}
70
+
71
+- (void)loadConfigError:(NSDictionary *)data {
72
+    _onJitsiMeetViewDelegateEvent(@"LOAD_CONFIG_ERROR", data);
73
+}
74
+
75
+#endif
76
+
43 77
 @end

Notiek ielāde…
Atcelt
Saglabāt