瀏覽代碼

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

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

19
 
19
 
20
 
20
 
21
 interface IEventListeners {
21
 interface IEventListeners {
22
+    onConferenceBlurred?: Function;
23
+    onConferenceFocused?: Function;
22
     onConferenceJoined?: Function;
24
     onConferenceJoined?: Function;
23
     onConferenceLeft?: Function;
25
     onConferenceLeft?: Function;
24
     onConferenceWillJoin?: Function;
26
     onConferenceWillJoin?: Function;
105
             setAppProps({
107
             setAppProps({
106
                 'flags': flags,
108
                 'flags': flags,
107
                 'rnSdkHandlers': {
109
                 'rnSdkHandlers': {
110
+                    onConferenceBlurred: eventListeners?.onConferenceBlurred,
111
+                    onConferenceFocused: eventListeners?.onConferenceFocused,
108
                     onConferenceJoined: eventListeners?.onConferenceJoined,
112
                     onConferenceJoined: eventListeners?.onConferenceJoined,
109
                     onConferenceWillJoin: eventListeners?.onConferenceWillJoin,
113
                     onConferenceWillJoin: eventListeners?.onConferenceWillJoin,
110
                     onConferenceLeft: eventListeners?.onConferenceLeft,
114
                     onConferenceLeft: eventListeners?.onConferenceLeft,

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

53
  */
53
  */
54
 export const CONFERENCE_LEFT = 'CONFERENCE_LEFT';
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
  * The type of (redux) action, which indicates conference local subject changes.
76
  * The type of (redux) action, which indicates conference local subject changes.
58
  *
77
  *

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

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
 import {
3
 import {
4
     BackHandler,
4
     BackHandler,
5
     NativeModules,
5
     NativeModules,
10
     ViewStyle
10
     ViewStyle
11
 } from 'react-native';
11
 } from 'react-native';
12
 import { EdgeInsets, withSafeAreaInsets } from 'react-native-safe-area-context';
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
 import { appNavigate } from '../../../app/actions';
15
 import { appNavigate } from '../../../app/actions';
16
 import { IReduxState, IStore } from '../../../app/types';
16
 import { IReduxState, IStore } from '../../../app/types';
17
+import { CONFERENCE_BLURRED, CONFERENCE_FOCUSED } from '../../../base/conference/actionTypes';
17
 import { FULLSCREEN_ENABLED, PIP_ENABLED } from '../../../base/flags/constants';
18
 import { FULLSCREEN_ENABLED, PIP_ENABLED } from '../../../base/flags/constants';
18
 import { getFeatureFlag } from '../../../base/flags/functions';
19
 import { getFeatureFlag } from '../../../base/flags/functions';
19
 import { getParticipantCount } from '../../../base/participants/functions';
20
 import { getParticipantCount } from '../../../base/participants/functions';
60
 import { EXPANDED_LABEL_TIMEOUT } from './constants';
61
 import { EXPANDED_LABEL_TIMEOUT } from './constants';
61
 import styles from './styles';
62
 import styles from './styles';
62
 
63
 
63
-
64
 /**
64
 /**
65
  * The type of the React {@code Component} props of {@link Conference}.
65
  * The type of the React {@code Component} props of {@link Conference}.
66
  */
66
  */
608
 }
608
 }
609
 
609
 
610
 export default withSafeAreaInsets(connect(_mapStateToProps)(props => {
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
     return ( // @ts-ignore
623
     return ( // @ts-ignore
625
         <Conference { ...props } />
624
         <Conference { ...props } />

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

10
 import { IStore } from '../../app/types';
10
 import { IStore } from '../../app/types';
11
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';
11
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';
12
 import {
12
 import {
13
+    CONFERENCE_BLURRED,
13
     CONFERENCE_FAILED,
14
     CONFERENCE_FAILED,
15
+    CONFERENCE_FOCUSED,
14
     CONFERENCE_JOINED,
16
     CONFERENCE_JOINED,
15
     CONFERENCE_LEFT,
17
     CONFERENCE_LEFT,
16
     CONFERENCE_WILL_JOIN,
18
     CONFERENCE_WILL_JOIN,
151
         _registerForEndpointTextMessages(store);
153
         _registerForEndpointTextMessages(store);
152
         break;
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
     case CONNECTION_DISCONNECTED: {
164
     case CONNECTION_DISCONNECTED: {
155
         // FIXME: This is a hack. See the description in the JITSI_CONNECTION_CONFERENCE_KEY constant definition.
165
         // FIXME: This is a hack. See the description in the JITSI_CONNECTION_CONFERENCE_KEY constant definition.
156
         // Check if this connection was attached to any conference.
166
         // Check if this connection was attached to any conference.

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

1
 import { getAppProp } from '../../base/app/functions';
1
 import { getAppProp } from '../../base/app/functions';
2
 import {
2
 import {
3
+    CONFERENCE_BLURRED,
4
+    CONFERENCE_FOCUSED,
3
     CONFERENCE_JOINED,
5
     CONFERENCE_JOINED,
4
     CONFERENCE_LEFT,
6
     CONFERENCE_LEFT,
5
     CONFERENCE_WILL_JOIN
7
     CONFERENCE_WILL_JOIN
23
     const rnSdkHandlers = getAppProp(store, 'rnSdkHandlers');
25
     const rnSdkHandlers = getAppProp(store, 'rnSdkHandlers');
24
 
26
 
25
     switch (type) {
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
     case CONFERENCE_JOINED:
34
     case CONFERENCE_JOINED:
27
         rnSdkHandlers?.onConferenceJoined && rnSdkHandlers?.onConferenceJoined();
35
         rnSdkHandlers?.onConferenceJoined && rnSdkHandlers?.onConferenceJoined();
28
         break;
36
         break;

Loading…
取消
儲存