2021-03-05 15:33:53 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-08-17 10:42:29 +00:00
|
|
|
import {
|
|
|
|
ANDROID_SCREENSHARING_ENABLED,
|
|
|
|
getFeatureFlag
|
|
|
|
} from '../../../base/flags';
|
2021-03-05 15:33:53 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconScreenshare } from '../../../base/icons';
|
2021-03-05 15:33:53 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { isLocalVideoTrackDesktop, toggleScreensharing } from '../../../base/tracks';
|
2021-03-05 15:33:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link ScreenSharingAndroidButton}.
|
|
|
|
*/
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
2021-05-26 08:43:24 +00:00
|
|
|
/**
|
|
|
|
* True if the button needs to be disabled.
|
|
|
|
*/
|
|
|
|
_disabled: boolean,
|
|
|
|
|
2021-03-05 15:33:53 +00:00
|
|
|
/**
|
|
|
|
* Whether video is currently muted or not.
|
|
|
|
*/
|
|
|
|
_screensharing: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An implementation of a button for toggling screen sharing.
|
|
|
|
*/
|
|
|
|
class ScreenSharingAndroidButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.shareYourScreen';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconScreenshare;
|
2021-03-05 15:33:53 +00:00
|
|
|
label = 'toolbar.startScreenSharing';
|
|
|
|
toggledLabel = 'toolbar.stopScreenSharing';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2021-04-22 12:24:17 +00:00
|
|
|
const enable = !this._isToggled();
|
|
|
|
|
|
|
|
this.props.dispatch(toggleScreensharing(enable));
|
2021-03-05 15:33:53 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 08:43:24 +00:00
|
|
|
/**
|
|
|
|
* Returns a boolean value indicating if this button is disabled or not.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isDisabled() {
|
|
|
|
return this.props._disabled;
|
|
|
|
}
|
|
|
|
|
2021-03-05 15:33:53 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._screensharing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
|
|
|
* {@code ToggleCameraButton} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _screensharing: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object {
|
2021-08-17 10:42:29 +00:00
|
|
|
const enabled = getFeatureFlag(state, ANDROID_SCREENSHARING_ENABLED, true);
|
|
|
|
|
2021-03-05 15:33:53 +00:00
|
|
|
return {
|
2021-08-17 10:42:29 +00:00
|
|
|
_screensharing: isLocalVideoTrackDesktop(state),
|
|
|
|
visible: enabled
|
2021-03-05 15:33:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(ScreenSharingAndroidButton));
|