瀏覽代碼

(react-native-sdk) Adds `CONFERENCE_FOCUSED` and `CONFERENCE_BLURRED` events to the external and RN api (#13657)

* (react-native-sdk) Adds `CONFERENCE_FOCUSED` and `CONFERENCE_BLURRED` events to the external and RN API
factor2
Ricardo Corrie 1 年之前
父節點
當前提交
1303040e17
沒有連結到貢獻者的電子郵件帳戶。

+ 8
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastEvent.java 查看文件

@@ -75,6 +75,8 @@ public class BroadcastEvent {
75 75
     }
76 76
 
77 77
     public enum Type {
78
+        CONFERENCE_BLURRED("org.jitsi.meet.CONFERENCE_BLURRED"),
79
+        CONFERENCE_FOCUSED("org.jitsi.meet.CONFERENCE_FOCUSED"),
78 80
         CONFERENCE_JOINED("org.jitsi.meet.CONFERENCE_JOINED"),
79 81
         CONFERENCE_TERMINATED("org.jitsi.meet.CONFERENCE_TERMINATED"),
80 82
         CONFERENCE_WILL_JOIN("org.jitsi.meet.CONFERENCE_WILL_JOIN"),
@@ -89,6 +91,8 @@ public class BroadcastEvent {
89 91
         VIDEO_MUTED_CHANGED("org.jitsi.meet.VIDEO_MUTED_CHANGED"),
90 92
         READY_TO_CLOSE("org.jitsi.meet.READY_TO_CLOSE");
91 93
 
94
+        private static final String CONFERENCE_BLURRED_NAME = "CONFERENCE_BLURRED";
95
+        private static final String CONFERENCE_FOCUSED_NAME = "CONFERENCE_FOCUSED";
92 96
         private static final String CONFERENCE_WILL_JOIN_NAME = "CONFERENCE_WILL_JOIN";
93 97
         private static final String CONFERENCE_JOINED_NAME = "CONFERENCE_JOINED";
94 98
         private static final String CONFERENCE_TERMINATED_NAME = "CONFERENCE_TERMINATED";
@@ -124,6 +128,10 @@ public class BroadcastEvent {
124 128
 
125 129
         private static Type buildTypeFromName(String name) {
126 130
             switch (name) {
131
+                case CONFERENCE_BLURRED_NAME:
132
+                    return CONFERENCE_BLURRED;
133
+                case CONFERENCE_FOCUSED_NAME:
134
+                    return CONFERENCE_FOCUSED;
127 135
                 case CONFERENCE_WILL_JOIN_NAME:
128 136
                     return CONFERENCE_WILL_JOIN;
129 137
                 case CONFERENCE_JOINED_NAME:

+ 4
- 0
react-native-sdk/index.tsx 查看文件

@@ -19,6 +19,8 @@ import { setAudioMuted, setVideoMuted } from './react/features/base/media/action
19 19
 
20 20
 
21 21
 interface IEventListeners {
22
+    onConferenceBlurred?: Function;
23
+    onConferenceFocused?: Function;
22 24
     onConferenceJoined?: Function;
23 25
     onConferenceLeft?: Function;
24 26
     onConferenceWillJoin?: Function;
@@ -105,6 +107,8 @@ export const JitsiMeeting = forwardRef((props: IAppProps, ref) => {
105 107
             setAppProps({
106 108
                 'flags': flags,
107 109
                 'rnSdkHandlers': {
110
+                    onConferenceBlurred: eventListeners?.onConferenceBlurred,
111
+                    onConferenceFocused: eventListeners?.onConferenceFocused,
108 112
                     onConferenceJoined: eventListeners?.onConferenceJoined,
109 113
                     onConferenceWillJoin: eventListeners?.onConferenceWillJoin,
110 114
                     onConferenceLeft: eventListeners?.onConferenceLeft,

+ 19
- 0
react/features/base/conference/actionTypes.ts 查看文件

@@ -53,6 +53,25 @@ export const CONFERENCE_JOIN_IN_PROGRESS = 'CONFERENCE_JOIN_IN_PROGRESS';
53 53
  */
54 54
 export const CONFERENCE_LEFT = 'CONFERENCE_LEFT';
55 55
 
56
+/**
57
+ * The type of (redux) action which signals that the conference is out of focus.
58
+ * For example, if the user navigates to the Chat screen.
59
+ * 
60
+ * {
61
+ *      type: CONFERENCE_BLURRED,
62
+ * }
63
+ */
64
+export const CONFERENCE_BLURRED = 'CONFERENCE_BLURRED';
65
+
66
+/**
67
+ * The type of (redux) action which signals that the conference is in focus.
68
+ * 
69
+ * {
70
+ *      type: CONFERENCE_FOCUSED,
71
+ * }
72
+ */
73
+export const CONFERENCE_FOCUSED = 'CONFERENCE_FOCUSED';
74
+
56 75
 /**
57 76
  * The type of (redux) action, which indicates conference local subject changes.
58 77
  *

+ 13
- 14
react/features/conference/components/native/Conference.tsx 查看文件

@@ -1,5 +1,5 @@
1
-import { useIsFocused } from '@react-navigation/native';
2
-import React, { useEffect } from 'react';
1
+import { useFocusEffect } from '@react-navigation/native';
2
+import React, { useCallback } from 'react';
3 3
 import {
4 4
     BackHandler,
5 5
     NativeModules,
@@ -10,10 +10,11 @@ import {
10 10
     ViewStyle
11 11
 } from 'react-native';
12 12
 import { EdgeInsets, withSafeAreaInsets } from 'react-native-safe-area-context';
13
-import { connect } from 'react-redux';
13
+import { connect, useDispatch } from 'react-redux';
14 14
 
15 15
 import { appNavigate } from '../../../app/actions';
16 16
 import { IReduxState, IStore } from '../../../app/types';
17
+import { CONFERENCE_BLURRED, CONFERENCE_FOCUSED } from '../../../base/conference/actionTypes';
17 18
 import { FULLSCREEN_ENABLED, PIP_ENABLED } from '../../../base/flags/constants';
18 19
 import { getFeatureFlag } from '../../../base/flags/functions';
19 20
 import { getParticipantCount } from '../../../base/participants/functions';
@@ -60,7 +61,6 @@ import TitleBar from './TitleBar';
60 61
 import { EXPANDED_LABEL_TIMEOUT } from './constants';
61 62
 import styles from './styles';
62 63
 
63
-
64 64
 /**
65 65
  * The type of the React {@code Component} props of {@link Conference}.
66 66
  */
@@ -608,18 +608,17 @@ function _mapStateToProps(state: IReduxState, _ownProps: any) {
608 608
 }
609 609
 
610 610
 export default withSafeAreaInsets(connect(_mapStateToProps)(props => {
611
-    const isFocused = useIsFocused();
611
+    const dispatch = useDispatch();
612 612
 
613
-    useEffect(() => {
614
-        if (isFocused) {
615
-            setPictureInPictureEnabled(true);
616
-        } else {
617
-            setPictureInPictureEnabled(false);
618
-        }
613
+    useFocusEffect(useCallback(() => {
614
+        dispatch({ type: CONFERENCE_FOCUSED });
615
+        setPictureInPictureEnabled(true);
619 616
 
620
-        // We also need to disable PiP when we are back on the WelcomePage
621
-        return () => setPictureInPictureEnabled(false);
622
-    }, [ isFocused ]);
617
+        return () => {
618
+            dispatch({ type: CONFERENCE_BLURRED });
619
+            setPictureInPictureEnabled(false);
620
+        };
621
+    }, []));
623 622
 
624 623
     return ( // @ts-ignore
625 624
         <Conference { ...props } />

+ 10
- 0
react/features/mobile/external-api/middleware.ts 查看文件

@@ -10,7 +10,9 @@ import { appNavigate } from '../../app/actions.native';
10 10
 import { IStore } from '../../app/types';
11 11
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';
12 12
 import {
13
+    CONFERENCE_BLURRED,
13 14
     CONFERENCE_FAILED,
15
+    CONFERENCE_FOCUSED,
14 16
     CONFERENCE_JOINED,
15 17
     CONFERENCE_LEFT,
16 18
     CONFERENCE_WILL_JOIN,
@@ -151,6 +153,14 @@ externalAPIEnabled && MiddlewareRegistry.register(store => next => action => {
151 153
         _registerForEndpointTextMessages(store);
152 154
         break;
153 155
 
156
+    case CONFERENCE_BLURRED:
157
+        sendEvent(store, CONFERENCE_BLURRED, {});
158
+        break;
159
+
160
+    case CONFERENCE_FOCUSED:
161
+        sendEvent(store, CONFERENCE_FOCUSED, {});
162
+        break;
163
+
154 164
     case CONNECTION_DISCONNECTED: {
155 165
         // FIXME: This is a hack. See the description in the JITSI_CONNECTION_CONFERENCE_KEY constant definition.
156 166
         // Check if this connection was attached to any conference.

+ 8
- 0
react/features/mobile/react-native-sdk/middleware.js 查看文件

@@ -1,5 +1,7 @@
1 1
 import { getAppProp } from '../../base/app/functions';
2 2
 import {
3
+    CONFERENCE_BLURRED,
4
+    CONFERENCE_FOCUSED,
3 5
     CONFERENCE_JOINED,
4 6
     CONFERENCE_LEFT,
5 7
     CONFERENCE_WILL_JOIN
@@ -23,6 +25,12 @@ const externalAPIEnabled = isExternalAPIAvailable();
23 25
     const rnSdkHandlers = getAppProp(store, 'rnSdkHandlers');
24 26
 
25 27
     switch (type) {
28
+    case CONFERENCE_BLURRED:
29
+        rnSdkHandlers?.onConferenceBlurred && rnSdkHandlers?.onConferenceBlurred();
30
+        break;
31
+    case CONFERENCE_FOCUSED:
32
+        rnSdkHandlers?.onConferenceFocused && rnSdkHandlers?.onConferenceFocused();
33
+        break;
26 34
     case CONFERENCE_JOINED:
27 35
         rnSdkHandlers?.onConferenceJoined && rnSdkHandlers?.onConferenceJoined();
28 36
         break;

Loading…
取消
儲存