Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(audio-translation): React Native UI (ducking, language selector, indicators)
Jaya Allamsetty63e649aee47d
diff --git a/react/features/audio-translation/components/native/AudioTranslationButton.tsx b/react/features/audio-translation/components/native/AudioTranslationButton.tsxnew file mode 100644index 0000000000..8b30ec5420--- /dev/null+++ b/react/features/audio-translation/components/native/AudioTranslationButton.tsx@@ -0,0 +1,61 @@+import { connect } from 'react-redux';++import { IReduxState } from '../../../app/types';+import { translate } from '../../../base/i18n/functions';+import { IconTranslate } from '../../../base/icons/svg';+import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';+import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';+import { screen } from '../../../mobile/navigation/routes';+import { isAudioTranslationAvailable } from '../../functions';++interface IProps extends AbstractButtonProps {++ /**+ * The target language remote audio is currently translated into, or null.+ */+ _language: string | null;+}++/**+ * An overflow-menu button that opens the AI audio-translation language selector screen.+ */+class AudioTranslationButton extends AbstractButton<IProps> {+ override accessibilityLabel = 'toolbar.accessibilityLabel.audioTranslation';+ override icon = IconTranslate;+ override label = 'toolbar.audioTranslation';++ /**+ * Handles clicking the button by opening the language selector screen.+ *+ * @override+ * @returns {void}+ */+ override _handleClick() {+ navigate(screen.conference.audioTranslation, { participantId: undefined });+ }++ /**+ * Indicates whether this button is in the toggled (translation-on) state.+ *+ * @override+ * @returns {boolean}+ */+ override _isToggled() {+ return Boolean(this.props._language);+ }+}++/**+ * Maps (parts of) the redux state to the button's props.+ *+ * @param {IReduxState} state - The redux state.+ * @returns {Object}+ */+function _mapStateToProps(state: IReduxState) {+ return {+ _language: state['features/audio-translation'].language,+ visible: isAudioTranslationAvailable(state)+ };+}++export default translate(connect(_mapStateToProps)(AudioTranslationButton));diff --git a/react/features/audio-translation/components/native/AudioTranslationDialog.tsx b/react/features/audio-translation/components/native/AudioTranslationDialog.tsxnew file mode 100644index 0000000000..3749cc66ea--- /dev/null+++ b/react/features/audio-translation/components/native/AudioTranslationDialog.tsx@@ -0,0 +1,75 @@+import React, { useCallback } from 'react';+import { WithTranslation } from 'react-i18next';+import { ScrollView, StyleProp, ViewStyle } from 'react-native';+import { useDispatch, useSelector } from 'react-redux';++import { IReduxState } from '../../../app/types';+import { translate } from '../../../base/i18n/functions';+import JitsiScreen from '../../../base/modal/components/JitsiScreen';+import { goBack } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';+import { setAudioTranslationLanguage, setParticipantAudioTranslationLanguage } from '../../actions';+import { SUPPORTED_TRANSLATION_LANGUAGES } from '../../constants';++import AudioTranslationLanguageItem from './AudioTranslationLanguageItem';+import styles from './styles';++interface IProps extends WithTranslation {++ /**+ * Navigation route; params.participantId scopes the selector to one participant.+ */+ route?: { params?: { participantId?: string; }; };+}++/**+ * A screen for selecting the AI audio-translation target language (or off).+ *+ * @param {IProps} props - The component's props.+ * @returns {ReactElement}+ */+const AudioTranslationDialog = ({ route, t }: IProps) => {+ const participantId = route?.params?.participantId;+ const dispatch = useDispatch();+ const defaultLanguage = useSelector((state: IReduxState) => state['features/audio-translation'].language);+ const participantLanguages+ = useSelector((state: IReduxState) => state['features/audio-translation'].participantLanguages);++ // Highlight the effective language for the target: the per-participant override if one is set, else the+ // default. (For the conference-wide screen there is no participantId, so this is just the default.)+ const language = participantId && participantId in participantLanguages+ ? participantLanguages[participantId]+ : defaultLanguage;++ const onSelect = useCallback((code: string | null) => {+ if (participantId) {+ dispatch(setParticipantAudioTranslationLanguage(participantId, code));+ } else {+ dispatch(setAudioTranslationLanguage(code));+ }+ goBack();+ }, [ dispatch, participantId ]);++ return (+ <JitsiScreen style = { styles.container }>+ <ScrollView+ bounces = { false }+ style = { styles.itemsContainer as StyleProp<ViewStyle> }>+ <AudioTranslationLanguageItem+ code = { null }+ label = { t('toolbar.audioTranslationOff') }+ onSelect = { onSelect }+ selected = { !language } />+ { SUPPORTED_TRANSLATION_LANGUAGES.map(({ code, label }) => (+ <AudioTranslationLanguageItem+ code = { code }+ key = { code }+ label = { label }+ onSelect = { onSelect }+ selected = { language === code } />+ )) }+ </ScrollView>+ </JitsiScreen>+ );+};++export default translate(AudioTranslationDialog);diff --git a/react/features/audio-translation/components/native/AudioTranslationLanguageItem.tsx b/react/features/audio-translation/components/native/AudioTranslationLanguageItem.tsxnew file mode 100644index 0000000000..75d8262f50--- /dev/null+++ b/react/features/audio-translation/components/native/AudioTranslationLanguageItem.tsx@@ -0,0 +1,60 @@+import React, { useCallback } from 'react';+import { StyleProp, TouchableHighlight, View, ViewStyle } from 'react-native';+import { Text } from 'react-native-paper';++import Icon from '../../../base/icons/components/Icon';+import { IconCheck } from '../../../base/icons/svg';++import styles from './styles';++interface IProps {++ /**+ * The language code this item selects, or null for the "off" item.+ */+ code: string | null;++ /**+ * The label shown for the item.+ */+ label: string;++ /**+ * Invoked with the item's code when the item is pressed.+ */+ onSelect: (code: string | null) => void;++ /**+ * Whether this item is the current selection.+ */+ selected: boolean;+}++/**+ * A row in the native audio-translation language selector.+ *+ * @param {IProps} props - The component's props.+ * @returns {ReactElement}+ */+const AudioTranslationLanguageItem = ({ code, label, onSelect, selected }: IProps) => {+ const onPress = useCallback(() => onSelect(code), [ code, onSelect ]);++ return (+ <View style = { styles.languageItemWrapper as StyleProp<ViewStyle> }>+ <View style = { styles.iconWrapper as StyleProp<ViewStyle> }>+ { selected && <Icon+ size = { 20 }+ src = { IconCheck } /> }+ </View>+ <TouchableHighlight+ onPress = { onPress }+ underlayColor = { 'transparent' }>+ <Text style = { [ styles.languageItemText, selected && styles.selectedLanguageItemText ] }>+ { label }+ </Text>+ </TouchableHighlight>+ </View>+ );+};++export default AudioTranslationLanguageItem;diff --git a/react/features/audio-translation/components/native/TranslationExpandedLabel.ts b/react/features/audio-translation/components/native/TranslationExpandedLabel.tsnew file mode 100644index 0000000000..5ba6d3dacd--- /dev/null+++ b/react/features/audio-translation/components/native/TranslationExpandedLabel.ts@@ -0,0 +1,23 @@+import { WithTranslation } from 'react-i18next';++import { translate } from '../../../base/i18n/functions';+import ExpandedLabel, { IProps as AbstractProps } from '../../../base/label/components/native/ExpandedLabel';++type Props = AbstractProps & WithTranslation;++/**+ * A tooltip-like expanded label explaining the meaning of the audio-translation conference label.+ */+class TranslationExpandedLabel extends ExpandedLabel<Props> {++ /**+ * Returns the label specific text of this {@code ExpandedLabel}.+ *+ * @returns {string}+ */+ _getLabel() {+ return this.props.t('audioTranslation.labelTooltip');+ }+}++export default translate(TranslationExpandedLabel);diff --git a/react/features/audio-translation/components/native/TranslationLabel.tsx b/react/features/audio-translation/components/native/TranslationLabel.tsxnew file mode 100644index 0000000000..c1341c26bd--- /dev/null+++ b/react/features/audio-translation/components/native/TranslationLabel.tsx@@ -0,0 +1,37 @@+import React from 'react';+import { useSelector } from 'react-redux';++import { IconTranslate } from '../../../base/icons/svg';+import Label from '../../../base/label/components/native/Label';+import BaseTheme from '../../../base/ui/components/BaseTheme.native';+import { isAudioTranslationActiveInMeeting, isAudioTranslationAvailable } from '../../functions';++const styles = {+ translationLabel: {+ alignItems: 'center',+ backgroundColor: BaseTheme.palette.action01,+ borderRadius: BaseTheme.shape.borderRadius,+ flexDirection: 'row',+ marginBottom: BaseTheme.spacing[0],+ marginLeft: BaseTheme.spacing[0]+ }+};++/**+ * Conference-header label shown while audio translation is active in the meeting.+ *+ * @returns {ReactElement|null}+ */+const TranslationLabel = () => {+ const available = useSelector(isAudioTranslationAvailable);+ const active = useSelector(isAudioTranslationActiveInMeeting);++ return available && active ? (+ <Label+ icon = { IconTranslate }+ iconColor = { BaseTheme.palette.icon01 }+ style = { styles.translationLabel } />+ ) : null;+};++export default TranslationLabel;diff --git a/react/features/audio-translation/components/native/styles.ts b/react/features/audio-translation/components/native/styles.tsnew file mode 100644index 0000000000..85209a5905--- /dev/null+++ b/react/features/audio-translation/components/native/styles.ts@@ -0,0 +1,37 @@+import BaseTheme from '../../../base/ui/components/BaseTheme.native';++/**+ * The styles of the native audio-translation components.+ */+export default {+ container: {+ backgroundColor: BaseTheme.palette.ui01,+ flex: 1+ },++ iconWrapper: {+ width: 32+ },++ itemsContainer: {+ marginHorizontal: BaseTheme.spacing[4],+ marginVertical: BaseTheme.spacing[4]+ },++ languageItemText: {+ ...BaseTheme.typography.bodyShortRegularLarge,+ color: BaseTheme.palette.text01,+ marginLeft: BaseTheme.spacing[2],+ marginVertical: BaseTheme.spacing[2]+ },++ languageItemWrapper: {+ alignItems: 'center',+ display: 'flex',+ flexDirection: 'row'+ },++ selectedLanguageItemText: {+ ...BaseTheme.typography.bodyShortBoldLarge+ }+};diff --git a/react/features/audio-translation/functions.ts b/react/features/audio-translation/functions.tsindex 52e215e94a..5f2443e063 100644--- a/react/features/audio-translation/functions.ts+++ b/react/features/audio-translation/functions.ts@@ -1,10 +1,12 @@import { IReduxState } from '../app/types';+import { AUDIO_TRANSLATION_ENABLED } from '../base/flags/constants';+import { getFeatureFlag } from '../base/flags/functions';import { MEET_FEATURES } from '../base/jwt/constants';import { isJwtFeatureEnabled } from '../base/jwt/functions';import { isLocalParticipantModerator } from '../base/participants/functions';import { ITrack } from '../base/tracks/types';-import { TranslationTreatment } from './constants';+import { DUCKED_ORIGINAL_VOLUME, TranslationTreatment } from './constants';/*** Whether audio translation is enabled for the room. Driven by the {@code audioTranslation} RoomMetadata flag,@@ -118,13 +120,16 @@ export function canManageAudioTranslation(state: IReduxState): boolean {* @returns {boolean}*/export function isAudioTranslationAvailable(state: IReduxState): boolean {+ // SDK embedder kill switch; defaults true, so web (no flags state) is unaffected.+ if (!getFeatureFlag(state, AUDIO_TRANSLATION_ENABLED, true)) {+ return false;+ }+if (!state['features/base/config'].audioTranslation?.enabled) {return false;}- // A deployment can hide the feature for a room via the audioTranslationAvailable RoomMetadata flag- // (e.g. when the translation backend is not provisioned for it). Absent, or any value other than an- // explicit false, means available. Applies even to those who could otherwise manage it.+ // Per-room availability via RoomMetadata; only an explicit false hides it.if (state['features/base/conference'].metadata?.audioTranslationAvailable === false) {return false;}@@ -169,3 +174,64 @@ export function getTranslatedSourceNames(state: IReduxState): Set<string> {return translated;}++/**+ * The per-participant override language if set, else the conference-wide default.+ *+ * @param {IReduxState} state - The redux state.+ * @param {string} [participantId] - The speaker's participant id.+ * @returns {string | null} The target language, or null.+ */+export function getEffectiveTranslationLanguage(state: IReduxState, participantId?: string): string | null {+ const { language, participantLanguages } = state['features/audio-translation'];++ return participantId && participantId in participantLanguages+ ? participantLanguages[participantId]+ : language;+}++/**+ * Whether to duck a speaker's original: a language is set and its translated counterpart is present.+ *+ * @param {IReduxState} state - The redux state.+ * @param {string} [sourceName] - The original audio source name.+ * @param {string} [participantId] - The speaker's participant id.+ * @returns {boolean}+ */+export function shouldDuckOriginalAudio(state: IReduxState, sourceName?: string, participantId?: string): boolean {+ const language = getEffectiveTranslationLanguage(state, participantId);++ if (!language || typeof sourceName !== 'string' || sourceName.endsWith(`.${language}`)) {+ return false;+ }++ return getTranslatedSourceNames(state).has(`${sourceName}.${language}`);+}++/**+ * The ducked volume (0..1) from config.audioTranslation.duckedVolume; invalid values fall back to default.+ *+ * @param {IReduxState} state - The redux state.+ * @returns {number}+ */+export function getDuckedVolume(state: IReduxState): number {+ const configured = state['features/base/config'].audioTranslation?.duckedVolume;++ return typeof configured === 'number' && configured >= 0 && configured <= 1+ ? configured+ : DUCKED_ORIGINAL_VOLUME;+}++/**+ * The ducked volume, capped at the user's chosen volume so ducking never makes a quieted speaker louder.+ *+ * @param {IReduxState} state - The redux state.+ * @param {string} [participantId] - The speaker's participant id.+ * @returns {number}+ */+export function getDuckedVolumeForParticipant(state: IReduxState, participantId?: string): number {+ const duckedVolume = getDuckedVolume(state);+ const userVolume = participantId ? state['features/filmstrip'].participantsVolume[participantId] : undefined;++ return typeof userVolume === 'number' ? Math.min(userVolume, duckedVolume) : duckedVolume;+}diff --git a/react/features/audio-translation/middleware.ts b/react/features/audio-translation/middleware.any.tssimilarity index 100%rename from react/features/audio-translation/middleware.tsrename to react/features/audio-translation/middleware.any.tsdiff --git a/react/features/audio-translation/middleware.native.ts b/react/features/audio-translation/middleware.native.tsnew file mode 100644index 0000000000..c01916b9b0--- /dev/null+++ b/react/features/audio-translation/middleware.native.ts@@ -0,0 +1,83 @@+import { IStore } from '../app/types';+import { MEDIA_TYPE } from '../base/media/constants';+import StateListenerRegistry from '../base/redux/StateListenerRegistry';++import { DEFAULT_ORIGINAL_VOLUME } from './constants';+import { getDuckedVolumeForParticipant, shouldDuckOriginalAudio } from './functions';+import logger from './logger';++import './middleware.any';++// Playout gain last applied per track id; untouched tracks are left to the volume slider.+const appliedVolumes = new Map<string, number>();++/**+ * Ducks original remote audio via _setVolume (native has no per-track audio elements), restoring the+ * user/full volume afterwards.+ *+ * @param {IStore} store - The redux store.+ * @param {boolean} reassertDucked - Re-apply the duck after a slider move overwrote the gain.+ * @returns {void}+ */+function _applyDucking({ getState }: IStore, reassertDucked = false): void {+ const state = getState();+ const { participantsVolume } = state['features/filmstrip'];+ const currentIds = new Set<string>();++ for (const track of state['features/base/tracks']) {+ if (track.local || track.mediaType !== MEDIA_TYPE.AUDIO) {+ continue;+ }++ const webrtcTrack = track.jitsiTrack?.getTrack?.();+ const trackId: string | undefined = webrtcTrack?.id;++ if (!webrtcTrack || typeof webrtcTrack._setVolume !== 'function' || !trackId) {+ continue;+ }+ currentIds.add(trackId);++ const sourceName: string | undefined = track.jitsiTrack?.getSourceName?.();+ const ducked = shouldDuckOriginalAudio(state, sourceName, track.participantId);+ const userVolume = track.participantId ? participantsVolume[track.participantId] : undefined;+ const target = ducked+ ? getDuckedVolumeForParticipant(state, track.participantId)+ : typeof userVolume === 'number' ? userVolume : DEFAULT_ORIGINAL_VOLUME;+ const applied = appliedVolumes.get(trackId);++ if ((!ducked && applied === undefined)+ || (applied === target && !(ducked && reassertDucked))) {+ continue;+ }++ try {+ webrtcTrack._setVolume(target);+ appliedVolumes.set(trackId, target);+ } catch (error) {+ logger.warn(`Failed to set playout volume for track ${trackId}`, error);+ }+ }++ for (const id of Array.from(appliedVolumes.keys())) {+ if (!currentIds.has(id)) {+ appliedVolumes.delete(id);+ }+ }+}++StateListenerRegistry.register(+ state => state['features/base/tracks'],+ (_, store) => _applyDucking(store));++StateListenerRegistry.register(+ state => state['features/audio-translation'].language,+ (_, store) => _applyDucking(store));++StateListenerRegistry.register(+ state => state['features/audio-translation'].participantLanguages,+ (_, store) => _applyDucking(store));++// A slider move writes the gain directly, so re-assert the duck over it.+StateListenerRegistry.register(+ state => state['features/filmstrip'].participantsVolume,+ (_, store) => _applyDucking(store, true));diff --git a/react/features/audio-translation/middleware.web.ts b/react/features/audio-translation/middleware.web.tsnew file mode 100644index 0000000000..fefd329e8a--- /dev/null+++ b/react/features/audio-translation/middleware.web.ts@@ -0,0 +1 @@+import './middleware.any';diff --git a/react/features/base/flags/constants.ts b/react/features/base/flags/constants.tsindex c6abc476bb..ca9c6efa9a 100644--- a/react/features/base/flags/constants.ts+++ b/react/features/base/flags/constants.ts@@ -29,6 +29,12 @@ export const AUDIO_MUTE_BUTTON_ENABLED = 'audio-mute.enabled';*/export const AUDIO_ONLY_BUTTON_ENABLED = 'audio-only.enabled';+/**+ * Flag indicating if the audio-translation feature should be enabled.+ * Default: enabled (true).+ */+export const AUDIO_TRANSLATION_ENABLED = 'audio-translation.enabled';+/*** Flag indicating that the Breakout Rooms button in the overflow menu is enabled.* Default: enabled (true).diff --git a/react/features/base/media/components/web/AudioTrack.tsx b/react/features/base/media/components/web/AudioTrack.tsxindex 42c6a54114..256ce5d683 100644--- a/react/features/base/media/components/web/AudioTrack.tsx+++ b/react/features/base/media/components/web/AudioTrack.tsx@@ -4,8 +4,9 @@ import { connect } from 'react-redux';import { createAudioPlayErrorEvent, createAudioPlaySuccessEvent } from '../../../../analytics/AnalyticsEvents';import { sendAnalytics } from '../../../../analytics/functions';import { IReduxState } from '../../../../app/types';-import { DEFAULT_ORIGINAL_VOLUME, DUCKED_ORIGINAL_VOLUME } from '../../../../audio-translation/constants';-import { getTranslatedSourceNames } from '../../../../audio-translation/functions';+import { DEFAULT_ORIGINAL_VOLUME } from '../../../../audio-translation/constants';+import { getDuckedVolumeForParticipant, shouldDuckOriginalAudio }+ from '../../../../audio-translation/functions';import { browser } from '../../../lib-jitsi-meet';import { ITrack } from '../../../tracks/types';import logger from '../../logger';@@ -358,47 +359,19 @@ class AudioTrack extends Component<IProps> {*/function _mapStateToProps(state: IReduxState, ownProps: any) {const { participantsVolume } = state['features/filmstrip'];- const { language: defaultLanguage, participantLanguages } = state['features/audio-translation'];- const { audioTranslation: audioTranslationConfig } = state['features/base/config'];- const audioTranslationEnabled = audioTranslationConfig?.enabled;-- // The volume a speaker's original is ducked to while its translation plays; overridable via config, so- // validate it — a value outside 0..1 (or a non-number from configOverwrite/URL) would throw a- // DOMException when assigned to HTMLMediaElement.volume. Fall back to the default when invalid.- const configuredDuckedVolume = audioTranslationConfig?.duckedVolume;- const duckedVolume = typeof configuredDuckedVolume === 'number'- && configuredDuckedVolume >= 0 && configuredDuckedVolume <= 1- ? configuredDuckedVolume- : DUCKED_ORIGINAL_VOLUME;+ const audioTranslationConfigured = Boolean(state['features/base/config'].audioTranslation);let _volume: number | boolean | undefined = participantsVolume[ownProps.participantId];- // Effective translation language for this speaker: the per-participant override if one is set (which- // may be null to disable), otherwise the conference-wide default. Turning translation off — globally- // or for this participant — clears this, so the original un-ducks (this selector re-runs on change).- const participantId: string | undefined = ownProps.participantId;- const effectiveLanguage = participantId && participantId in participantLanguages- ? participantLanguages[participantId]- : defaultLanguage;-- // Duck a speaker's original only while its translated counterpart ({source}.{language}) is present.+ // Driven by actual translated-audio presence, not isAudioTranslationAvailable: ducking follows the+ // media, and must not un-duck mid-playback on a permission/flag change.const sourceName: string | undefined = ownProps.audioTrack?.jitsiTrack?.getSourceName?.();+ const ducked = shouldDuckOriginalAudio(state, sourceName, ownProps.participantId);- let ducked = false;-- if (effectiveLanguage && typeof sourceName === 'string' && !sourceName.endsWith(`.${effectiveLanguage}`)) {- const translatedSourceName = `${sourceName}.${effectiveLanguage}`;-- if (getTranslatedSourceNames(state).has(translatedSourceName)) {- _volume = duckedVolume;- ducked = true;- }- }-- // When the feature is enabled, a track may have been ducked to a non-default volume. Once it is no longer- // ducked and has no explicit per-participant volume, restore full volume — otherwise the audio element keeps- // the previously-applied ducked level, since AudioTrack only writes numeric volumes (undefined is ignored).- if (!ducked && audioTranslationEnabled && _volume === undefined) {+ if (ducked) {+ _volume = getDuckedVolumeForParticipant(state, ownProps.participantId);+ } else if (audioTranslationConfigured && _volume === undefined) {+ // Restore full volume after ducking (config presence, not enabled, so a mid-call disable un-ducks)._volume = DEFAULT_ORIGINAL_VOLUME;}diff --git a/react/features/conference/components/native/AlwaysOnLabels.tsx b/react/features/conference/components/native/AlwaysOnLabels.tsxindex 780efc4b0f..45d5b8696e 100644--- a/react/features/conference/components/native/AlwaysOnLabels.tsx+++ b/react/features/conference/components/native/AlwaysOnLabels.tsx@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';import { TouchableOpacity } from 'react-native';import { useDispatch, useSelector } from 'react-redux';+import TranslationLabel from '../../../audio-translation/components/native/TranslationLabel';import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';import { openHighlightDialog } from '../../../recording/actions.native';import HighlightButton from '../../../recording/components/Recording/native/HighlightButton';@@ -12,6 +13,7 @@ import VisitorsCountLabel from '../../../visitors/components/native/VisitorsCounimport RaisedHandsCountLabel from './RaisedHandsCountLabel';import {+ LABEL_ID_AUDIO_TRANSLATION,LABEL_ID_RAISED_HANDS_COUNT,LABEL_ID_RECORDING,LABEL_ID_STREAMING,@@ -64,6 +66,11 @@ const AlwaysOnLabels = ({ createOnPress }: IProps) => {onPress = { createOnPress(LABEL_ID_RAISED_HANDS_COUNT) } ><RaisedHandsCountLabel /></TouchableOpacity>+ <TouchableOpacity+ hitSlop = { LabelHitSlop }+ onPress = { createOnPress(LABEL_ID_AUDIO_TRANSLATION) } >+ <TranslationLabel />+ </TouchableOpacity><TouchableOpacityhitSlop = { LabelHitSlop }onPress = { createOnPress(LABEL_ID_VISITORS_COUNT) } >diff --git a/react/features/conference/components/native/constants.ts b/react/features/conference/components/native/constants.tsindex 6cebc06d67..b181a324ac 100644--- a/react/features/conference/components/native/constants.ts+++ b/react/features/conference/components/native/constants.ts@@ -1,5 +1,6 @@import React from 'react';+import TranslationExpandedLabel from '../../../audio-translation/components/native/TranslationExpandedLabel';import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';import RecordingExpandedLabel from '../../../recording/components/native/RecordingExpandedLabel';import TranscribingExpandedLabel from '../../../recording/components/native/TranscribingExpandedLabel';@@ -27,6 +28,7 @@ export const LABEL_ID_TRANSCRIBING = 'transcribing';export const LABEL_ID_INSECURE_ROOM_NAME = 'insecure-room-name';export const LABEL_ID_RAISED_HANDS_COUNT = 'raised-hands-count';export const LABEL_ID_VISITORS_COUNT = 'visitors-count';+export const LABEL_ID_AUDIO_TRANSLATION = 'audio-translation';interface IExpandedLabel {alwaysOn?: boolean;@@ -68,5 +70,9 @@ export const EXPANDED_LABELS: {[LABEL_ID_RAISED_HANDS_COUNT]: {component: RaisedHandsCountExpandedLabel,alwaysOn: true+ },+ [LABEL_ID_AUDIO_TRANSLATION]: {+ component: TranslationExpandedLabel,+ alwaysOn: true}};diff --git a/react/features/filmstrip/components/native/Thumbnail.tsx b/react/features/filmstrip/components/native/Thumbnail.tsxindex da59295b49..9ed4dc63b3 100644--- a/react/features/filmstrip/components/native/Thumbnail.tsx+++ b/react/features/filmstrip/components/native/Thumbnail.tsx@@ -3,6 +3,8 @@ import { Image, ImageStyle, View, ViewStyle } from 'react-native';import { connect } from 'react-redux';import { IReduxState, IStore } from '../../../app/types';+import { TranslationTreatment } from '../../../audio-translation/constants';+import { getTranslationTreatment, isAudioTranslationAvailable } from '../../../audio-translation/functions';import { MEDIA_TYPE, VIDEO_TYPE } from '../../../base/media/constants';import { pinParticipant } from '../../../base/participants/actions';import ParticipantView from '../../../base/participants/components/ParticipantView.native';@@ -41,6 +43,7 @@ import ModeratorIndicator from './ModeratorIndicator';import PinnedIndicator from './PinnedIndicator';import RaisedHandIndicator from './RaisedHandIndicator';import ScreenShareIndicator from './ScreenShareIndicator';+import TranslationIndicator from './TranslationIndicator';import styles, { AVATAR_SIZE } from './styles';@@ -114,6 +117,11 @@ interface IProps {_shouldDisplayTileView: boolean;+ /**+ * The audio-translation treatment to render for this participant (NONE renders no indicator).+ */+ _translationTreatment: TranslationTreatment;+/*** The video track that will be displayed in the thumbnail.*/@@ -220,6 +228,7 @@ class Thumbnail extends PureComponent<IProps> {_participantId: participantId,_pinned,_renderModeratorIndicator: renderModeratorIndicator,+ _translationTreatment: translationTreatment,_shouldDisplayTileView,renderDisplayName,tileView@@ -230,7 +239,8 @@ class Thumbnail extends PureComponent<IProps> {if (_shouldDisplayTileView) {bottomIndicatorsContainerStyle = styles.bottomIndicatorsContainer;- } else if (audioMuted || renderModeratorIndicator) {+ } else if (audioMuted || renderModeratorIndicator+ || translationTreatment !== TranslationTreatment.NONE) {bottomIndicatorsContainerStyle = styles.bottomIndicatorsContainer;} else {bottomIndicatorsContainerStyle = null;@@ -254,6 +264,8 @@ class Thumbnail extends PureComponent<IProps> {<Containerstyle = { bottomIndicatorsContainerStyle as StyleType }>{ audioMuted && !_isVirtualScreenshare && <AudioMutedIndicator /> }+ { translationTreatment !== TranslationTreatment.NONE+ && <TranslationIndicator treatment = { translationTreatment } /> }{ !tileView && _pinned && <PinnedIndicator />}{ renderModeratorIndicator && !_isVirtualScreenshare && <ModeratorIndicator />}{ !tileView && (isScreenShare || _isVirtualScreenshare) && <ScreenShareIndicator /> }@@ -354,6 +366,10 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {const _isEveryoneModerator = isEveryoneModerator(state);const renderModeratorIndicator = tileView && !_isEveryoneModerator&& participant?.role === PARTICIPANT_ROLE.MODERATOR;+ const translationTreatment = !participant?.local && !isScreenShareParticipant(participant)+ && isAudioTranslationAvailable(state)+ ? getTranslationTreatment(state, id ?? '')+ : TranslationTreatment.NONE;const { gifUrl: gifSrc } = getGifForParticipant(state, id ?? '');const mode = getGifDisplayMode(state);@@ -370,6 +386,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {_raisedHand: hasRaisedHand(participant),_renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,_renderModeratorIndicator: renderModeratorIndicator,+ _translationTreatment: translationTreatment,_shouldDisplayTileView: shouldDisplayTileView(state),_videoTrack: videoTrack};diff --git a/react/features/filmstrip/components/native/TranslationIndicator.tsx b/react/features/filmstrip/components/native/TranslationIndicator.tsxnew file mode 100644index 0000000000..68a8c6c913--- /dev/null+++ b/react/features/filmstrip/components/native/TranslationIndicator.tsx@@ -0,0 +1,42 @@+import React from 'react';+import { StyleProp, View, ViewStyle } from 'react-native';++import { TranslationTreatment } from '../../../audio-translation/constants';+import { IconTranslate } from '../../../base/icons/svg';+import BaseIndicator from '../../../base/react/components/native/BaseIndicator';+import BaseTheme from '../../../base/ui/components/BaseTheme.native';++import styles from './styles';++interface IProps {++ /**+ * Which of the three treatments to render.+ */+ treatment: TranslationTreatment;+}++/**+ * Thumbnail badge for a participant's translation status: outlined (enabled), filled (receiving), dot (both).+ *+ * @param {IProps} props - The component's props.+ * @returns {ReactElement}+ */+const TranslationIndicator = ({ treatment }: IProps) => {+ const outlined = treatment === TranslationTreatment.ENABLED;++ return (+ <View+ style = { (outlined+ ? styles.translationIndicatorOutlined+ : styles.translationIndicatorFilled) as StyleProp<ViewStyle> }>+ <BaseIndicator+ icon = { IconTranslate }+ iconStyle = { outlined ? { color: BaseTheme.palette.action01 } : {} } />+ { treatment === TranslationTreatment.BOTH+ && <View style = { styles.translationIndicatorDot as StyleProp<ViewStyle> } /> }+ </View>+ );+};++export default TranslationIndicator;diff --git a/react/features/filmstrip/components/native/styles.ts b/react/features/filmstrip/components/native/styles.tsindex f69be1809e..f2e9748cd7 100644--- a/react/features/filmstrip/components/native/styles.ts+++ b/react/features/filmstrip/components/native/styles.ts@@ -178,5 +178,28 @@ export default {thumbnailGif: {flexGrow: 1,resizeMode: 'contain'+ },++ translationIndicatorDot: {+ backgroundColor: BaseTheme.palette.icon01,+ borderColor: BaseTheme.palette.uiBackground,+ borderRadius: 3,+ borderWidth: 1,+ height: 6,+ position: 'absolute',+ right: -1,+ top: -1,+ width: 6+ },++ translationIndicatorFilled: {+ backgroundColor: BaseTheme.palette.action01,+ borderRadius: 4+ },++ translationIndicatorOutlined: {+ borderColor: BaseTheme.palette.action01,+ borderRadius: 4,+ borderWidth: 1}};diff --git a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsxindex 2138fb4fb7..972571bc83 100644--- a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx+++ b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx@@ -6,6 +6,8 @@ import React from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';+import AudioTranslationDialog+ from '../../../../../audio-translation/components/native/AudioTranslationDialog';import BreakoutRooms// @ts-ignorefrom '../../../../../breakout-rooms/components/native/BreakoutRooms';@@ -48,6 +50,7 @@ import Whiteboard from '../../../../../whiteboard/components/native/Whiteboard';// @ts-ignoreimport { screen } from '../../../routes';import {+ audioTranslationScreenOptions,breakoutRoomsScreenOptions,carmodeScreenOptions,chatScreenOptions,@@ -222,6 +225,13 @@ const ConferenceNavigationContainer = () => {...subtitlesScreenOptions,title: t('transcribing.subtitles')}} />+ <ConferenceStack.Screen+ component = { AudioTranslationDialog }+ name = { screen.conference.audioTranslation }+ options = {{+ ...audioTranslationScreenOptions,+ title: t('toolbar.audioTranslation')+ }} /><ConferenceStack.Screencomponent = { BreakoutRooms }name = { screen.conference.breakoutRooms }diff --git a/react/features/mobile/navigation/routes.ts b/react/features/mobile/navigation/routes.tsindex 7418d3cfb7..5ea0e8bd80 100644--- a/react/features/mobile/navigation/routes.ts+++ b/react/features/mobile/navigation/routes.ts@@ -1,5 +1,6 @@export const screen = {conference: {+ audioTranslation: 'Audio Translation',breakoutRooms: 'Breakout Rooms',carmode: 'Car Mode',chat: 'Chat',diff --git a/react/features/mobile/navigation/screenOptions.ts b/react/features/mobile/navigation/screenOptions.tsindex 93e91e87fd..f51c897589 100644--- a/react/features/mobile/navigation/screenOptions.ts+++ b/react/features/mobile/navigation/screenOptions.ts@@ -144,6 +144,11 @@ export const securityScreenOptions = presentationScreenOptions;*/export const recordingScreenOptions = presentationScreenOptions;+/**+ * Screen options for the audio-translation language selector modal.+ */+export const audioTranslationScreenOptions = presentationScreenOptions;+/*** Screen options for subtitles modal.*/diff --git a/react/features/toolbox/components/native/OverflowMenu.tsx b/react/features/toolbox/components/native/OverflowMenu.tsxindex 6677519d41..c4d6d8b021 100644--- a/react/features/toolbox/components/native/OverflowMenu.tsx+++ b/react/features/toolbox/components/native/OverflowMenu.tsx@@ -4,6 +4,7 @@ import { Divider } from 'react-native-paper';import { connect, useSelector } from 'react-redux';import { IReduxState, IStore } from '../../../app/types';+import AudioTranslationButton from '../../../audio-translation/components/native/AudioTranslationButton';import { hideSheet } from '../../../base/dialog/actions';import BottomSheet from '../../../base/dialog/components/native/BottomSheet';import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';@@ -173,6 +174,7 @@ class OverflowMenu extends PureComponent<IProps, IState> {{/* @ts-ignore */}<Divider style = { styles.divider as ViewStyle } /><ClosedCaptionButton { ...buttonProps } />+ <AudioTranslationButton { ...buttonProps } /><SharedDocumentButton { ...buttonProps } /><SettingsButton { ...buttonProps } /></BottomSheet>diff --git a/react/features/video-menu/components/native/RemoteVideoMenu.tsx b/react/features/video-menu/components/native/RemoteVideoMenu.tsxindex c51d25343f..3047801640 100644--- a/react/features/video-menu/components/native/RemoteVideoMenu.tsx+++ b/react/features/video-menu/components/native/RemoteVideoMenu.tsx@@ -35,6 +35,7 @@ import MuteEveryoneElseButton from './MuteEveryoneElseButton';import MuteVideoButton from './MuteVideoButton';import PinButton from './PinButton';import SendToBreakoutRoom from './SendToBreakoutRoom';+import TranslateParticipantButton from './TranslateParticipantButton';import VolumeSlider from './VolumeSlider';import styles from './styles';@@ -194,6 +195,7 @@ class RemoteVideoMenu extends PureComponent<IProps> {{ _showDemote && <DemoteToVisitorButton { ...buttonProps } /> }{ _enablePrivateChat && <PrivateMessageButton { ...buttonProps } /> }<ConnectionStatusButton { ...connectionStatusButtonProps } />+ <TranslateParticipantButton { ...buttonProps } />{_moderator && _rooms.length > 1 && <>{/* @ts-ignore */}<Divider style = { styles.divider as ViewStyle } />diff --git a/react/features/video-menu/components/native/TranslateParticipantButton.tsx b/react/features/video-menu/components/native/TranslateParticipantButton.tsxnew file mode 100644index 0000000000..76bd4651f6--- /dev/null+++ b/react/features/video-menu/components/native/TranslateParticipantButton.tsx@@ -0,0 +1,50 @@+import { connect } from 'react-redux';++import { IReduxState } from '../../../app/types';+import { isAudioTranslationAvailable } from '../../../audio-translation/functions';+import { translate } from '../../../base/i18n/functions';+import { IconTranslate } from '../../../base/icons/svg';+import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';+import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';+import { screen } from '../../../mobile/navigation/routes';++interface IProps extends AbstractButtonProps {++ /**+ * The id of the participant the language selector targets.+ */+ participantID: string;+}++/**+ * Remote-menu button opening the translation language selector for that participant.+ */+class TranslateParticipantButton extends AbstractButton<IProps> {+ override accessibilityLabel = 'toolbar.accessibilityLabel.audioTranslation';+ override icon = IconTranslate;+ override label = 'toolbar.audioTranslation';++ /**+ * Opens the language selector screen scoped to the participant.+ *+ * @override+ * @returns {void}+ */+ override _handleClick() {+ navigate(screen.conference.audioTranslation, { participantId: this.props.participantID });+ }+}++/**+ * Maps (parts of) the redux state to the button's props.+ *+ * @param {IReduxState} state - The redux state.+ * @returns {Object}+ */+function _mapStateToProps(state: IReduxState) {+ return {+ visible: isAudioTranslationAvailable(state)+ };+}++export default translate(connect(_mapStateToProps)(TranslateParticipantButton));