diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java index 5c7d5cd776..22406d3297 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java @@ -270,11 +270,6 @@ public class JitsiMeetConferenceOptions implements Parcelable { Bundle asProps() { Bundle props = new Bundle(); - // Android always has the PiP flag set by default. - if (!featureFlags.containsKey("pip.enabled")) { - featureFlags.putBoolean("pip.enabled", true); - } - props.putBundle("flags", featureFlags); Bundle urlProps = new Bundle(); diff --git a/react/features/conference/components/native/Conference.tsx b/react/features/conference/components/native/Conference.tsx index 37d08207e5..628a4eb3cd 100644 --- a/react/features/conference/components/native/Conference.tsx +++ b/react/features/conference/components/native/Conference.tsx @@ -15,7 +15,7 @@ import { connect, useDispatch } from 'react-redux'; import { appNavigate } from '../../../app/actions.native'; import { IReduxState, IStore } from '../../../app/types'; import { CONFERENCE_BLURRED, CONFERENCE_FOCUSED } from '../../../base/conference/actionTypes'; -import { FULLSCREEN_ENABLED, PIP_ENABLED } from '../../../base/flags/constants'; +import { FULLSCREEN_ENABLED } from '../../../base/flags/constants'; import { getFeatureFlag } from '../../../base/flags/functions'; import Container from '../../../base/react/components/native/Container'; import LoadingIndicator from '../../../base/react/components/native/LoadingIndicator'; @@ -38,7 +38,7 @@ import LargeVideo from '../../../large-video/components/LargeVideo.native'; import { getIsLobbyVisible } from '../../../lobby/functions'; import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef'; import { screen } from '../../../mobile/navigation/routes'; -import { setPictureInPictureEnabled } from '../../../mobile/picture-in-picture/functions'; +import { isPipEnabled, setPictureInPictureEnabled } from '../../../mobile/picture-in-picture/functions'; import Captions from '../../../subtitles/components/native/Captions'; import { setToolboxVisible } from '../../../toolbox/actions.native'; import Toolbox from '../../../toolbox/components/native/Toolbox'; @@ -579,7 +579,7 @@ function _mapStateToProps(state: IReduxState, _ownProps: any) { _fullscreenEnabled: getFeatureFlag(state, FULLSCREEN_ENABLED, true), _isParticipantsPaneOpen: isOpen, _largeVideoParticipantId: state['features/large-video'].participantId, - _pictureInPictureEnabled: getFeatureFlag(state, PIP_ENABLED), + _pictureInPictureEnabled: isPipEnabled(state), _reducedUI: reducedUI, _showLobby: getIsLobbyVisible(state), _startCarMode: startCarMode, diff --git a/react/features/mobile/picture-in-picture/actions.ts b/react/features/mobile/picture-in-picture/actions.ts index f3a0061d87..4b27aff531 100644 --- a/react/features/mobile/picture-in-picture/actions.ts +++ b/react/features/mobile/picture-in-picture/actions.ts @@ -1,11 +1,10 @@ import { NativeModules } from 'react-native'; import { IStore } from '../../app/types'; -import { PIP_ENABLED } from '../../base/flags/constants'; -import { getFeatureFlag } from '../../base/flags/functions'; import Platform from '../../base/react/Platform.native'; import { ENTER_PICTURE_IN_PICTURE } from './actionTypes'; +import { isPipEnabled } from './functions'; import logger from './logger'; /** @@ -23,7 +22,7 @@ export function enterPictureInPicture() { // XXX At the time of this writing this action can only be dispatched by // the button which is on the conference view, which means that it's // fine to enter PiP mode. - if (getFeatureFlag(getState, PIP_ENABLED)) { + if (isPipEnabled(getState())) { const { PictureInPicture } = NativeModules; const p = Platform.OS === 'android' diff --git a/react/features/mobile/picture-in-picture/components/PictureInPictureButton.ts b/react/features/mobile/picture-in-picture/components/PictureInPictureButton.ts index 6296ffec96..a59eea589f 100644 --- a/react/features/mobile/picture-in-picture/components/PictureInPictureButton.ts +++ b/react/features/mobile/picture-in-picture/components/PictureInPictureButton.ts @@ -1,14 +1,14 @@ -import { NativeModules, Platform } from 'react-native'; import { connect } from 'react-redux'; import { IReduxState } from '../../../app/types'; -import { PIP_ENABLED, PIP_WHILE_SCREEN_SHARING_ENABLED } from '../../../base/flags/constants'; +import { PIP_WHILE_SCREEN_SHARING_ENABLED } from '../../../base/flags/constants'; import { getFeatureFlag } from '../../../base/flags/functions'; import { translate } from '../../../base/i18n/functions'; import { IconArrowDown } from '../../../base/icons/svg'; import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton'; import { isLocalVideoTrackDesktop } from '../../../base/tracks/functions.native'; import { enterPictureInPicture } from '../actions'; +import { isPipEnabled } from '../functions'; interface IProps extends AbstractButtonProps { @@ -58,15 +58,9 @@ class PictureInPictureButton extends AbstractButton { * }} */ function _mapStateToProps(state: IReduxState) { - const pipEnabled = Boolean(getFeatureFlag(state, PIP_ENABLED)); + const pipEnabled = isPipEnabled(state); const pipWhileScreenSharingEnabled = getFeatureFlag(state, PIP_WHILE_SCREEN_SHARING_ENABLED, false); - - let enabled = pipEnabled && (!isLocalVideoTrackDesktop(state) || pipWhileScreenSharingEnabled); - - // Override flag for Android, since it might be unsupported. - if (Platform.OS === 'android' && !NativeModules.PictureInPicture.SUPPORTED) { - enabled = false; - } + const enabled = pipEnabled && (!isLocalVideoTrackDesktop(state) || pipWhileScreenSharingEnabled); return { _enabled: enabled diff --git a/react/features/mobile/picture-in-picture/functions.ts b/react/features/mobile/picture-in-picture/functions.ts index d3f95ebda0..43848f0cab 100644 --- a/react/features/mobile/picture-in-picture/functions.ts +++ b/react/features/mobile/picture-in-picture/functions.ts @@ -1,4 +1,25 @@ -import { NativeModules } from 'react-native'; +import { NativeModules, Platform } from 'react-native'; + +import { IReduxState } from '../../app/types'; +import { PIP_ENABLED } from '../../base/flags/constants'; +import { getFeatureFlag } from '../../base/flags/functions'; + +/** + * Checks whether Picture-in-Picture is enabled. + * + * @param {Object} state - The Redux state. + * @returns {boolean} Whether PiP is enabled or not. + */ +export function isPipEnabled(state: IReduxState) { + let enabled = getFeatureFlag(state, PIP_ENABLED); + + // Override flag for Android, since it might be unsupported. + if (Platform.OS === 'android' && (typeof enabled === 'undefined' || enabled)) { + enabled = NativeModules.PictureInPicture.SUPPORTED; + } + + return Boolean(enabled); +} /** * Enabled/Disables the PictureInPicture mode in PiP native module.