From 03e7314ea8804d34ff17bae90c4ecf6e1ff4cecf Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Thu, 21 Nov 2024 08:14:09 -0800 Subject: [PATCH 1/2] Android: Improve voice typing dialog accessibility --- .../voiceTyping/VoiceTypingDialog.tsx | 70 ++++++++++++++----- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx index 0effd0a3cad..ef69ce321aa 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,34 @@ const VoiceTypingDialog: React.FC = props => { return {preview}; }; - const headerAndStatus = {`${_('Voice typing...')}\n${renderContent()}`}; + const headerAndStatus = {`${_('Voice typing...')}\n${renderContent()}`}; return ( - - {headerAndStatus} - {'\n'} - {renderPreview()} - + + + + + + + + + {headerAndStatus} + + {renderPreview()} + + + + + + + ); }; From ea48f1d5123e4bd5c756d2f9c9eed6ce4f3acce1 Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Thu, 21 Nov 2024 08:30:09 -0800 Subject: [PATCH 2/2] Commenting, adjust roles --- .../components/voiceTyping/VoiceTypingDialog.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx index ef69ce321aa..e002da97c99 100644 --- a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx +++ b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx @@ -168,7 +168,6 @@ const VoiceTypingDialog: React.FC = props => { return {preview}; }; - const headerAndStatus = {`${_('Voice typing...')}\n${renderContent()}`}; return ( @@ -181,10 +180,21 @@ const VoiceTypingDialog: React.FC = props => { // Auto-focus refocusCounter={1} aria-live='polite' - role='alert' + role='heading' > - {headerAndStatus} + + {_('Voice typing...')} + + {renderContent()} {renderPreview()}