Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
jitsi-meet/react/features/mobile/proximity/middleware.js

34 lines
1.3 KiB

import { NativeModules } from 'react-native';
import { getCurrentConference } from '../../base/conference';
import { StateListenerRegistry } from '../../base/redux';
/**
* State listener which enables / disables the proximity sensor based on the
* current conference state. If the proximity sensor is enabled, it will dim
* the screen and disable touch controls when an object is nearby. The
* functionality is enabled when the current audio device is the earpiece.
*/
StateListenerRegistry.register(
/* selector */ state => {
const { devices } = state['features/mobile/audio-mode'];
const selectedDevice = devices.filter(d => d.selected)[0];
const conference = getCurrentConference(state);
return Boolean(conference && selectedDevice?.type === 'EARPIECE');
},
/* listener */ proximityEnabled => _setProximityEnabled(proximityEnabled)
);
/**
* Enables / disables the proximity sensor. If the proximity sensor is enabled,
* it will dim the screen and disable touch controls when an object is nearby.
*
* @param {boolean} enabled - True to enable the proximity sensor or false to
* disable it.
* @private
* @returns {void}
*/
function _setProximityEnabled(enabled) {
NativeModules.Proximity.setEnabled(Boolean(enabled));
}