Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(toolbox): use custom buttons inside toolbox (#15506)

Calinteodor95a6001a6f0e
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java
index 05b262eb43..3e8de65710 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java
@@ -271,8 +271,8 @@ public class JitsiMeetActivity extends AppCompatActivity
// JitsiMeetLogger.i("Transcription chunk received: " + extraData);
// }
-// protected void onCustomOverflowMenuButtonPressed(HashMap<String, Object> extraData) {
-// JitsiMeetLogger.i("Custom overflow menu button pressed: " + extraData);
+// protected void onCustomButtonPressed(HashMap<String, Object> extraData) {
+// JitsiMeetLogger.i("Custom button pressed: " + extraData);
// }
// Activity lifecycle methods
@@ -361,8 +361,8 @@ public class JitsiMeetActivity extends AppCompatActivity
// case TRANSCRIPTION_CHUNK_RECEIVED:
// onTranscriptionChunkReceived(event.getData());
// break;
-// case CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED:
-// onCustomOverflowMenuButtonPressed(event.getData());
+// case CUSTOM_BUTTON_PRESSED:
+// onCustomButtonPressed(event.getData());
// break;
}
}
diff --git a/ios/app/src/AppDelegate.m b/ios/app/src/AppDelegate.m
index cc19d55071..d2903206db 100644
--- a/ios/app/src/AppDelegate.m
+++ b/ios/app/src/AppDelegate.m
@@ -34,6 +34,10 @@
jitsiMeet.universalLinkDomains = @[@"meet.jit.si", @"alpha.jitsi.net", @"beta.meet.jit.si"];
jitsiMeet.defaultConferenceOptions = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
+
+ // For testing configOverrides a room needs to be set
+ // builder.room = @"test0988test";
+
[builder setFeatureFlag:@"welcomepage.enabled" withBoolean:YES];
[builder setFeatureFlag:@"ios.screensharing.enabled" withBoolean:YES];
[builder setFeatureFlag:@"ios.recording.enabled" withBoolean:YES];
diff --git a/ios/app/src/ViewController.m b/ios/app/src/ViewController.m
index a169c17d3c..f443e51801 100644
--- a/ios/app/src/ViewController.m
+++ b/ios/app/src/ViewController.m
@@ -88,8 +88,8 @@
[self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_WILL_JOIN" withData:data];
}
-// - (void)customOverflowMenuButtonPressed:(NSDictionary *)data {
-// [self _onJitsiMeetViewDelegateEvent:@"CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED" withData:data];
+// - (void)customButtonPressed:(NSDictionary *)data {
+// [self _onJitsiMeetViewDelegateEvent:@"CUSTOM_BUTTON_PRESSED" withData:data];
// }
#if 0
diff --git a/ios/sdk/src/JitsiMeet.m b/ios/sdk/src/JitsiMeet.m
index db993fada8..c7dcbf6b95 100644
--- a/ios/sdk/src/JitsiMeet.m
+++ b/ios/sdk/src/JitsiMeet.m
@@ -231,6 +231,9 @@
}
- (void)setDefaultConferenceOptions:(JitsiMeetConferenceOptions *)defaultConferenceOptions {
+
+ // For testing configOverrides a room needs to be set,
+ // thus the following check needs to be commented out
if (defaultConferenceOptions != nil && defaultConferenceOptions.room != nil) {
@throw [NSException exceptionWithName:@"RuntimeError"
reason:@"'room' must be null in the default conference options"
diff --git a/ios/sdk/src/JitsiMeetViewDelegate.h b/ios/sdk/src/JitsiMeetViewDelegate.h
index 56f388eaeb..85a1e177d7 100644
--- a/ios/sdk/src/JitsiMeetViewDelegate.h
+++ b/ios/sdk/src/JitsiMeetViewDelegate.h
@@ -128,6 +128,6 @@
*
* The `data` dictionary contains a `id`, `text` key.
*/
-- (void)customOverflowMenuButtonPressed:(NSDictionary *)data;
+- (void)customButtonPressed:(NSDictionary *)data;
@end
diff --git a/react/features/base/config/configWhitelist.ts b/react/features/base/config/configWhitelist.ts
index 6a1d49a767..2154342821 100644
--- a/react/features/base/config/configWhitelist.ts
+++ b/react/features/base/config/configWhitelist.ts
@@ -77,6 +77,7 @@ export default [
'channelLastN',
'connectionIndicators',
'constraints',
+ 'customToolbarButtons',
'deeplinking.disabled',
'deeplinking.desktop.enabled',
'defaultLocalDisplayName',
diff --git a/react/features/mobile/external-api/middleware.ts b/react/features/mobile/external-api/middleware.ts
index ccc7381cab..a5203bc774 100644
--- a/react/features/mobile/external-api/middleware.ts
+++ b/react/features/mobile/external-api/middleware.ts
@@ -52,7 +52,7 @@ import { ITrack } from '../../base/tracks/types';
import { CLOSE_CHAT, OPEN_CHAT } from '../../chat/actionTypes';
import { closeChat, openChat, sendMessage, setPrivateMessageRecipient } from '../../chat/actions.native';
import { setRequestingSubtitles } from '../../subtitles/actions.any';
-import { CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED } from '../../toolbox/actionTypes';
+import { CUSTOM_BUTTON_PRESSED } from '../../toolbox/actionTypes';
import { muteLocal } from '../../video-menu/actions.native';
import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture/actionTypes';
// @ts-ignore
@@ -186,12 +186,12 @@ externalAPIEnabled && MiddlewareRegistry.register(store => next => action => {
break;
}
- case CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED: {
+ case CUSTOM_BUTTON_PRESSED: {
const { id, text } = action;
sendEvent(
store,
- CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED,
+ CUSTOM_BUTTON_PRESSED,
{
id,
text
diff --git a/react/features/toolbox/actionTypes.ts b/react/features/toolbox/actionTypes.ts
index 7803a1169e..91374fecb6 100644
--- a/react/features/toolbox/actionTypes.ts
+++ b/react/features/toolbox/actionTypes.ts
@@ -8,15 +8,15 @@
export const CLEAR_TOOLBOX_TIMEOUT = 'CLEAR_TOOLBOX_TIMEOUT';
/**
- * The type of (redux) action which signals that a custom button from the overflow menu was pressed.
+ * The type of (redux) action which signals that a custom button was pressed.
*
* @returns {{
- * type: CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED,
+ * type: CUSTOM_BUTTON_PRESSED,
* id: string,
* text: string
* }}
*/
-export const CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED = 'CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED';
+export const CUSTOM_BUTTON_PRESSED = 'CUSTOM_BUTTON_PRESSED';
/**
* The type of (redux) action which updates whether the conference is or is not
diff --git a/react/features/toolbox/actions.native.ts b/react/features/toolbox/actions.native.ts
index 568d9320c2..9d0c7d5556 100644
--- a/react/features/toolbox/actions.native.ts
+++ b/react/features/toolbox/actions.native.ts
@@ -1,4 +1,4 @@
-import { CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED } from './actionTypes';
+import { CUSTOM_BUTTON_PRESSED } from './actionTypes';
export * from './actions.any';
@@ -26,19 +26,19 @@ export function setOverflowMenuVisible(_visible: boolean): any {
}
/**
- * Creates a (redux) action which that a custom overflow menu button was pressed.
+ * Creates a (redux) action which that a custom button was pressed.
*
* @param {string} id - The id for the custom button.
* @param {string} text - The label for the custom button.
* @returns {{
- * type: CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED,
+ * type: CUSTOM_BUTTON_PRESSED,
* id: string,
* text: string
* }}
*/
-export function customOverflowMenuButtonPressed(id: string, text: string) {
+export function customButtonPressed(id: string, text: string) {
return {
- type: CUSTOM_OVERFLOW_MENU_BUTTON_PRESSED,
+ type: CUSTOM_BUTTON_PRESSED,
id,
text
};
diff --git a/react/features/toolbox/components/native/CustomOptionButton.tsx b/react/features/toolbox/components/native/CustomOptionButton.tsx
index 988fe28ede..f586095f34 100644
--- a/react/features/toolbox/components/native/CustomOptionButton.tsx
+++ b/react/features/toolbox/components/native/CustomOptionButton.tsx
@@ -13,7 +13,7 @@ interface IProps extends AbstractButtonProps {
backgroundColor?: string;
icon: any;
id?: string;
- text: string;
+ text?: string;
}
/**
@@ -56,7 +56,7 @@ class CustomOptionButton extends AbstractButton<IProps> {
return iconComponent;
};
- label = this.text;
+ label = this.text || '';
}
export default translate(connect()(CustomOptionButton));
diff --git a/react/features/toolbox/components/native/OverflowMenu.tsx b/react/features/toolbox/components/native/OverflowMenu.tsx
index 8ef428f351..a10ba90d20 100644
--- a/react/features/toolbox/components/native/OverflowMenu.tsx
+++ b/react/features/toolbox/components/native/OverflowMenu.tsx
@@ -25,7 +25,7 @@ import ClosedCaptionButton from '../../../subtitles/components/native/ClosedCapt
import TileViewButton from '../../../video-layout/components/TileViewButton';
import styles from '../../../video-menu/components/native/styles';
import WhiteboardButton from '../../../whiteboard/components/native/WhiteboardButton';
-import { customOverflowMenuButtonPressed } from '../../actions.native';
+import { customButtonPressed } from '../../actions.native';
import { getMovableButtons } from '../../functions.native';
import AudioOnlyButton from './AudioOnlyButton';
@@ -234,7 +234,7 @@ class OverflowMenu extends PureComponent<IProps, IState> {
backgroundColor = { backgroundColor }
/* eslint-disable react/jsx-no-bind */
handleClick = { () =>
- dispatch(customOverflowMenuButtonPressed(id, text))
+ dispatch(customButtonPressed(id, text))
}
icon = { icon }
key = { id }
diff --git a/react/features/toolbox/components/native/Toolbox.tsx b/react/features/toolbox/components/native/Toolbox.tsx
index c752d69bc0..6b2b873b33 100644
--- a/react/features/toolbox/components/native/Toolbox.tsx
+++ b/react/features/toolbox/components/native/Toolbox.tsx
@@ -3,7 +3,7 @@ import { View, ViewStyle } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { connect } from 'react-redux';
-import { IReduxState } from '../../../app/types';
+import { IReduxState, IStore } from '../../../app/types';
import ColorSchemeRegistry from '../../../base/color-scheme/ColorSchemeRegistry';
import Platform from '../../../base/react/Platform.native';
import ChatButton from '../../../chat/components/native/ChatButton';
@@ -11,10 +11,12 @@ import ReactionsMenuButton from '../../../reactions/components/native/ReactionsM
import { shouldDisplayReactionsButtons } from '../../../reactions/functions.any';
import TileViewButton from '../../../video-layout/components/TileViewButton';
import { iAmVisitor } from '../../../visitors/functions';
+import { customButtonPressed } from '../../actions.native';
import { getMovableButtons, isToolboxVisible } from '../../functions.native';
import HangupButton from '../HangupButton';
import AudioMuteButton from './AudioMuteButton';
+import CustomOptionButton from './CustomOptionButton';
import HangupMenuButton from './HangupMenuButton';
import OverflowMenuButton from './OverflowMenuButton';
import RaiseHandButton from './RaiseHandButton';
@@ -22,11 +24,17 @@ import ScreenSharingButton from './ScreenSharingButton';
import VideoMuteButton from './VideoMuteButton';
import styles from './styles';
+
/**
* The type of {@link Toolbox}'s React {@code Component} props.
*/
interface IProps {
+ /**
+ * Custom Toolbar buttons.
+ */
+ _customToolbarButtons?: Array<{ backgroundColor?: string; icon: string; id: string; text: string; }>;
+
/**
* Whether the end conference feature is supported.
*/
@@ -56,6 +64,11 @@ interface IProps {
* The width of the screen.
*/
_width: number;
+
+ /**
+ * Redux store dispatch method.
+ */
+ dispatch: IStore['dispatch'];
}
/**
@@ -65,7 +78,16 @@ interface IProps {
* @returns {React$Element}
*/
function Toolbox(props: IProps) {
- const { _endConferenceSupported, _shouldDisplayReactionsButtons, _styles, _visible, _iAmVisitor, _width } = props;
+ const {
+ _customToolbarButtons,
+ _endConferenceSupported,
+ _iAmVisitor,
+ _shouldDisplayReactionsButtons,
+ _styles,
+ _visible,
+ _width,
+ dispatch
+ } = props;
if (!_visible) {
return null;
@@ -89,6 +111,28 @@ function Toolbox(props: IProps) {
style.justifyContent = 'center';
}
+ const renderCustomToolboxButtons = () => {
+ if (!_customToolbarButtons?.length) {
+ return;
+ }
+
+ return (
+ <>
+ {
+ _customToolbarButtons.map(({ backgroundColor, id, text, icon }) => (
+ <CustomOptionButton
+ backgroundColor = { backgroundColor }
+
+ /* eslint-disable react/jsx-no-bind */
+ handleClick = { () => dispatch(customButtonPressed(id, text)) }
+ icon = { icon }
+ key = { id } />
+ ))
+ }
+ </>
+ );
+ };
+
return (
<View
style = { styles.toolboxContainer as ViewStyle }>
@@ -99,37 +143,38 @@ function Toolbox(props: IProps) {
edges = { [ bottomEdge && 'bottom' ].filter(Boolean) }
pointerEvents = 'box-none'
style = { style as ViewStyle }>
- {!_iAmVisitor && <AudioMuteButton
- styles = { buttonStylesBorderless }
- toggledStyles = { toggledButtonStyles } />
- }
- {!_iAmVisitor && <VideoMuteButton
- styles = { buttonStylesBorderless }
- toggledStyles = { toggledButtonStyles } />
- }
- {additionalButtons.has('chat')
- && <ChatButton
- styles = { buttonStylesBorderless }
- toggledStyles = { backgroundToggledStyle } />
- }
- {!_iAmVisitor && additionalButtons.has('screensharing')
- && <ScreenSharingButton styles = { buttonStylesBorderless } />}
- {additionalButtons.has('raisehand') && (_shouldDisplayReactionsButtons
- ? <ReactionsMenuButton
- styles = { buttonStylesBorderless }
- toggledStyles = { backgroundToggledStyle } />
- : <RaiseHandButton
- styles = { buttonStylesBorderless }
- toggledStyles = { backgroundToggledStyle } />)}
- {additionalButtons.has('tileview') && <TileViewButton styles = { buttonStylesBorderless } />}
- {!_iAmVisitor && <OverflowMenuButton
- styles = { buttonStylesBorderless }
- toggledStyles = { toggledButtonStyles } />
- }
- { _endConferenceSupported
- ? <HangupMenuButton />
- : <HangupButton
- styles = { hangupButtonStyles } />
+ {
+ _customToolbarButtons
+ ? renderCustomToolboxButtons()
+ : <>
+ {!_iAmVisitor && <AudioMuteButton
+ styles = { buttonStylesBorderless }
+ toggledStyles = { toggledButtonStyles } />}
+ {!_iAmVisitor && <VideoMuteButton
+ styles = { buttonStylesBorderless }
+ toggledStyles = { toggledButtonStyles } />}
+ {additionalButtons.has('chat')
+ && <ChatButton
+ styles = { buttonStylesBorderless }
+ toggledStyles = { backgroundToggledStyle } />}
+ {!_iAmVisitor && additionalButtons.has('screensharing')
+ && <ScreenSharingButton styles = { buttonStylesBorderless } />}
+ {additionalButtons.has('raisehand') && (_shouldDisplayReactionsButtons
+ ? <ReactionsMenuButton
+ styles = { buttonStylesBorderless }
+ toggledStyles = { backgroundToggledStyle } />
+ : <RaiseHandButton
+ styles = { buttonStylesBorderless }
+ toggledStyles = { backgroundToggledStyle } />)}
+ {additionalButtons.has('tileview')
+ && <TileViewButton styles = { buttonStylesBorderless } />}
+ {!_iAmVisitor && <OverflowMenuButton
+ styles = { buttonStylesBorderless }
+ toggledStyles = { toggledButtonStyles } />}
+ { _endConferenceSupported
+ ? <HangupMenuButton />
+ : <HangupButton styles = { hangupButtonStyles } />}
+ </>
}
</SafeAreaView>
</View>
@@ -150,6 +195,7 @@ function _mapStateToProps(state: IReduxState) {
const endConferenceSupported = conference?.isEndConferenceSupported();
return {
+ _customToolbarButtons: state['features/base/config']?.customToolbarButtons,
_endConferenceSupported: Boolean(endConferenceSupported),
_styles: ColorSchemeRegistry.get(state, 'Toolbox'),
_visible: isToolboxVisible(state),
diff --git a/react/features/toolbox/components/native/styles.ts b/react/features/toolbox/components/native/styles.ts
index 962d515d75..e56f398b17 100644
--- a/react/features/toolbox/components/native/styles.ts
+++ b/react/features/toolbox/components/native/styles.ts
@@ -99,8 +99,9 @@ const styles = {
backgroundColor: BaseTheme.palette.uiBackground,
flexDirection: 'column',
maxWidth: 580,
- marginLeft: 'auto',
- marginRight: 'auto',
+ marginHorizontal: 'auto',
+ marginVertical: BaseTheme.spacing[0],
+ paddingHorizontal: BaseTheme.spacing[1],
width: '100%'
},