From db07bd208aa68a8313fee4ff0ef239a5c599125b Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Fri, 22 Nov 2024 02:47:46 -0800 Subject: [PATCH] Android: Accessibility: Improve voice typing dialog screen reader accessibility (#11428) --- .../voiceTyping/VoiceTypingDialog.tsx | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx index 0effd0a3c..e002da97c 100644 --- a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx +++ b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { useState, useEffect, useCallback, useRef, useMemo } from 'react'; -import { Banner, ActivityIndicator, Text } from 'react-native-paper'; +import { Icon, ActivityIndicator, Text, Surface, Button } from 'react-native-paper'; import { _, languageName } from '@joplin/lib/locale'; import useAsyncEffect, { AsyncEffectEvent } from '@joplin/lib/hooks/useAsyncEffect'; import { IconSource } from 'react-native-paper/lib/typescript/components/Icon'; @@ -9,6 +9,8 @@ import whisper from '../../services/voiceTyping/whisper'; import vosk from '../../services/voiceTyping/vosk'; import { AppState } from '../../utils/types'; import { connect } from 'react-redux'; +import { View, StyleSheet } from 'react-native'; +import AccessibleView from '../accessibility/AccessibleView'; interface Props { locale: string; @@ -79,6 +81,30 @@ const useWhisper = ({ locale, provider, onSetPreview, onText }: UseVoiceTypingPr return [error, mustDownloadModel, voiceTyping]; }; +const styles = StyleSheet.create({ + container: { + marginHorizontal: 1, + width: '100%', + maxWidth: 680, + alignSelf: 'center', + }, + contentWrapper: { + flexDirection: 'row', + }, + iconWrapper: { + margin: 8, + marginTop: 16, + }, + content: { + marginTop: 16, + marginHorizontal: 8, + }, + actionContainer: { + flexDirection: 'row', + justifyContent: 'flex-end', + }, +}); + const VoiceTypingDialog: React.FC = props => { const [recorderState, setRecorderState] = useState(RecorderState.Loading); const [preview, setPreview] = useState(''); @@ -142,22 +168,44 @@ const VoiceTypingDialog: React.FC = props => { return {preview}; }; - const headerAndStatus = {`${_('Voice typing...')}\n${renderContent()}`}; return ( - - {headerAndStatus} - {'\n'} - {renderPreview()} - + + + + + + + + + + {_('Voice typing...')} + + + {renderContent()} + {renderPreview()} + + + + + + + ); };