diff --git a/android/app/src/main/java/org/jitsi/meet/MainActivity.java b/android/app/src/main/java/org/jitsi/meet/MainActivity.java index ba13956cf..f284f992e 100644 --- a/android/app/src/main/java/org/jitsi/meet/MainActivity.java +++ b/android/app/src/main/java/org/jitsi/meet/MainActivity.java @@ -17,8 +17,13 @@ package org.jitsi.meet; import android.os.Bundle; +import android.util.Log; import org.jitsi.meet.sdk.JitsiMeetActivity; +import org.jitsi.meet.sdk.JitsiMeetView; +import org.jitsi.meet.sdk.JitsiMeetViewListener; + +import java.util.Map; /** * The one and only {@link Activity} that the Jitsi Meet app needs. The @@ -33,6 +38,80 @@ import org.jitsi.meet.sdk.JitsiMeetActivity; * {@code react-native run-android}. */ public class MainActivity extends JitsiMeetActivity { + /** + * {@inheritDoc} + */ + protected JitsiMeetView initializeView() { + JitsiMeetView view = super.initializeView(); + + // XXX In order to increase (1) awareness of API breakages and (2) API + // coverage, utilize JitsiMeetViewListener in the Debug configuration of + // the app. + if (BuildConfig.DEBUG && view != null) { + view.setListener(new JitsiMeetViewListener() { + private void on(String name, Map data) { + // Log with the tag "ReactNative" in order to have the log + // visible in react-native log-android as well. + Log.d( + "ReactNative", + JitsiMeetViewListener.class.getSimpleName() + " " + + name + " " + + data); + } + + /** + * {@inheritDoc} + */ + @Override + public void onConferenceFailed(Map data) { + on("CONFERENCE_FAILED", data); + } + + /** + * {@inheritDoc} + */ + @Override + public void onConferenceJoined(Map data) { + on("CONFERENCE_JOINED", data); + } + + /** + * {@inheritDoc} + */ + @Override + public void onConferenceLeft(Map data) { + on("CONFERENCE_LEFT", data); + } + + /** + * {@inheritDoc} + */ + @Override + public void onConferenceWillJoin(Map data) { + on("CONFERENCE_WILL_JOIN", data); + } + + /** + * {@inheritDoc} + */ + @Override + public void onConferenceWillLeave(Map data) { + on("CONFERENCE_WILL_LEAVE", data); + } + + /** + * {@inheritDoc} + */ + @Override + public void onLoadConfigError(Map data) { + on("LOAD_CONFIG_ERROR", data); + } + }); + } + + return view; + } + /** * {@inheritDoc} */ diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java index 87cf26a84..c102e5df7 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java @@ -76,8 +76,22 @@ public class JitsiMeetActivity extends AppCompatActivity { * Initializes the {@link #view} of this {@code JitsiMeetActivity} with a * new {@link JitsiMeetView} instance. */ - private void initializeView() { - view = new JitsiMeetView(this); + private void initializeContentView() { + JitsiMeetView view = initializeView(); + + if (view != null) { + this.view = view; + setContentView(this.view); + } + } + + /** + * Initializes a new {@link JitsiMeetView} instance. + * + * @return a new {@code JitsiMeetView} instance. + */ + protected JitsiMeetView initializeView() { + JitsiMeetView view = new JitsiMeetView(this); // In order to have the desired effect // JitsiMeetView#setWelcomePageEnabled(boolean) must be invoked before @@ -85,7 +99,7 @@ public class JitsiMeetActivity extends AppCompatActivity { view.setWelcomePageEnabled(welcomePageEnabled); view.loadURL(null); - setContentView(view); + return view; } /** @@ -109,7 +123,7 @@ public class JitsiMeetActivity extends AppCompatActivity { if (requestCode == OVERLAY_PERMISSION_REQUEST_CODE && canRequestOverlayPermission()) { if (Settings.canDrawOverlays(this)) { - initializeView(); + initializeContentView(); } } } @@ -144,7 +158,7 @@ public class JitsiMeetActivity extends AppCompatActivity { return; } - initializeView(); + initializeContentView(); } /** diff --git a/ios/app/src/ViewController.m b/ios/app/src/ViewController.m index dd610296a..406e39c36 100644 --- a/ios/app/src/ViewController.m +++ b/ios/app/src/ViewController.m @@ -40,4 +40,38 @@ [view loadURL:nil]; } +#if DEBUG + +void _onJitsiMeetViewDelegateEvent(NSString *name, NSDictionary *data) { + NSLog( + @"[%s:%d] JitsiMeetViewDelegate %@ %@", + __FILE__, __LINE__, name, data); +} + +- (void)conferenceFailed:(NSDictionary *)data { + _onJitsiMeetViewDelegateEvent(@"CONFERENCE_FAILED", data); +} + +- (void)conferenceJoined:(NSDictionary *)data { + _onJitsiMeetViewDelegateEvent(@"CONFERENCE_JOINED", data); +} + +- (void)conferenceLeft:(NSDictionary *)data { + _onJitsiMeetViewDelegateEvent(@"CONFERENCE_LEFT", data); +} + +- (void)conferenceWillJoin:(NSDictionary *)data { + _onJitsiMeetViewDelegateEvent(@"CONFERENCE_WILL_JOIN", data); +} + +- (void)conferenceWillLeave:(NSDictionary *)data { + _onJitsiMeetViewDelegateEvent(@"CONFERENCE_WILL_LEAVE", data); +} + +- (void)loadConfigError:(NSDictionary *)data { + _onJitsiMeetViewDelegateEvent(@"LOAD_CONFIG_ERROR", data); +} + +#endif + @end