fix(pip) make PiP disabled by default

This reverts commit c84c3c61e2c24014b43023316627f7747bbca7a6.
This commit is contained in:
Titus Moldovan 2022-06-21 08:49:46 +03:00 committed by tmoldovan8x8
parent d1c9720033
commit b428ce2dcd
6 changed files with 20 additions and 17 deletions

View File

@ -43,7 +43,7 @@ class PictureInPictureModule extends ReactContextBaseJavaModule {
private static final String TAG = NAME;
private static boolean isSupported;
private boolean isDisabled;
private boolean isEnabled;
public PictureInPictureModule(ReactApplicationContext reactContext) {
super(reactContext);
@ -84,7 +84,7 @@ class PictureInPictureModule extends ReactContextBaseJavaModule {
*/
@TargetApi(Build.VERSION_CODES.O)
public void enterPictureInPicture() {
if (isDisabled) {
if (!isEnabled) {
return;
}
@ -132,8 +132,8 @@ class PictureInPictureModule extends ReactContextBaseJavaModule {
}
@ReactMethod
public void setPictureInPictureDisabled(Boolean disabled) {
this.isDisabled = disabled;
public void setPictureInPictureEnabled(Boolean enabled) {
this.isEnabled = enabled;
}
public boolean isPictureInPictureSupported() {

View File

@ -1,6 +1,6 @@
// @flow
import { setPictureInPictureDisabled } from '../../mobile/picture-in-picture/functions';
import { setPictureInPictureEnabled } from '../../mobile/picture-in-picture/functions';
import { setAudioOnly } from '../audio-only';
import JitsiMeetJS from '../lib-jitsi-meet';
import { MiddlewareRegistry } from '../redux';
@ -41,7 +41,7 @@ function _toggleScreenSharing(enabled, store) {
}
} else {
dispatch(destroyLocalDesktopTrackIfExists());
setPictureInPictureDisabled(false);
setPictureInPictureEnabled(true);
}
}
@ -54,7 +54,7 @@ function _toggleScreenSharing(enabled, store) {
* @returns {void}
*/
function _startScreenSharing(dispatch, state) {
setPictureInPictureDisabled(true);
setPictureInPictureEnabled(false);
JitsiMeetJS.createLocalTracks({ devices: [ 'desktop' ] })
.then(tracks => {
@ -73,6 +73,6 @@ function _startScreenSharing(dispatch, state) {
.catch(error => {
console.log('ERROR creating ScreeSharing stream ', error);
setPictureInPictureDisabled(false);
setPictureInPictureEnabled(true);
});
}

View File

@ -27,6 +27,7 @@ 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';
import { Captions } from '../../../subtitles';
import { setToolboxVisible } from '../../../toolbox/actions';
import { Toolbox } from '../../../toolbox/components/native';
@ -179,6 +180,7 @@ class Conference extends AbstractConference<Props, State> {
*/
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this._onHardwareBackPress);
setPictureInPictureEnabled(true);
}
/**
@ -211,6 +213,7 @@ class Conference extends AbstractConference<Props, State> {
BackHandler.removeEventListener('hardwareBackPress', this._onHardwareBackPress);
clearTimeout(this._expandedLabelTimeout.current);
setPictureInPictureEnabled(false);
}
/**

View File

@ -7,7 +7,7 @@ import { useDispatch, useSelector } from 'react-redux';
import JitsiScreen from '../../../../base/modal/components/JitsiScreen';
import { LoadingIndicator, TintedView } from '../../../../base/react';
import { isLocalVideoTrackDesktop } from '../../../../base/tracks';
import { setPictureInPictureDisabled } from '../../../../mobile/picture-in-picture/functions';
import { setPictureInPictureEnabled } from '../../../../mobile/picture-in-picture/functions';
import { setIsCarmode } from '../../../../video-layout/actions';
import ConferenceTimer from '../../ConferenceTimer';
import { isConnecting } from '../../functions';
@ -31,12 +31,12 @@ const CarmodeTab = (): JSX.Element => {
useEffect(() => {
dispatch(setIsCarmode(true));
setPictureInPictureDisabled(true);
setPictureInPictureEnabled(false);
return () => {
dispatch(setIsCarmode(false));
if (!isSharing) {
setPictureInPictureDisabled(false);
setPictureInPictureEnabled(true);
}
};
}, []);

View File

@ -4,7 +4,7 @@ import { NativeModules } from 'react-native';
const { Dropbox } = NativeModules;
import { setPictureInPictureDisabled } from '../mobile/picture-in-picture/functions';
import { setPictureInPictureEnabled } from '../mobile/picture-in-picture/functions';
/**
* Action to authorize the Jitsi Recording app in dropbox.
@ -13,12 +13,12 @@ import { setPictureInPictureDisabled } from '../mobile/picture-in-picture/functi
* access token or rejected with an error.
*/
export async function _authorizeDropbox(): Promise<Object> {
setPictureInPictureDisabled(true);
setPictureInPictureEnabled(false);
try {
return await Dropbox.authorize();
} finally {
setPictureInPictureDisabled(false);
setPictureInPictureEnabled(true);
}
}

View File

@ -5,13 +5,13 @@ import { NativeModules } from 'react-native';
/**
* Enabled/Disables the PictureInPicture mode in PiP native module.
*
* @param {boolean} disabled - Whether the PiP mode should be disabled.
* @param {boolean} enabled - Whether the PiP mode should be enabled.
* @returns {void}
*/
export function setPictureInPictureDisabled(disabled: boolean) {
export function setPictureInPictureEnabled(enabled: boolean) {
const { PictureInPicture } = NativeModules;
if (PictureInPicture) {
PictureInPicture.setPictureInPictureDisabled(disabled);
PictureInPicture.setPictureInPictureEnabled(enabled);
}
}