Skip to content

Commit 2a4ee33

Browse files
feat(mobile): choose the microphone order for voice input (pingdotgg#17896)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 61eb4af commit 2a4ee33

14 files changed

Lines changed: 737 additions & 66 deletions

‎apps/mobile/src/Stack.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import {
102102
import { ScheduledTaskEditorProvider } from "./features/settings/scheduled-task-editor";
103103
import { SettingsKeyboardRouteScreen } from "./features/settings/SettingsKeyboardRouteScreen";
104104
import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
105+
import { SettingsMicrophoneRouteScreen } from "./features/settings/SettingsMicrophoneRouteScreen";
105106
import {
106107
SettingsOpenSourceLicenseRouteScreen,
107108
SettingsOpenSourceLicensesRouteScreen,
@@ -310,6 +311,13 @@ const SettingsContentStack = createV5SheetStackNavigator({
310311
title: "Keyboard",
311312
},
312313
}),
314+
SettingsMicrophone: createNativeStackScreen({
315+
screen: SettingsMicrophoneRouteScreen,
316+
linking: "microphone",
317+
options: {
318+
title: "Microphone",
319+
},
320+
}),
313321
SettingsFollowUp: createNativeStackScreen({
314322
screen: SettingsFollowUpRouteScreen,
315323
linking: "follow-ups",

‎apps/mobile/src/components/AppSymbol.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import IconBolt from "@tabler/icons-react-native/IconBolt";
2828
import IconBox from "@tabler/icons-react-native/IconBox";
2929
import IconBrain from "@tabler/icons-react-native/IconBrain";
3030
import IconCamera from "@tabler/icons-react-native/IconCamera";
31+
import IconCar from "@tabler/icons-react-native/IconCar";
3132
import IconChartBar from "@tabler/icons-react-native/IconChartBar";
3233
import IconCheck from "@tabler/icons-react-native/IconCheck";
3334
import IconCloud from "@tabler/icons-react-native/IconCloud";
@@ -58,6 +59,7 @@ import IconFilter from "@tabler/icons-react-native/IconFilter";
5859
import IconFilterFilled from "@tabler/icons-react-native/IconFilterFilled";
5960
import IconFolder from "@tabler/icons-react-native/IconFolder";
6061
import IconFolderOpen from "@tabler/icons-react-native/IconFolderOpen";
62+
import IconHeadphones from "@tabler/icons-react-native/IconHeadphones";
6163
import IconFolderPlus from "@tabler/icons-react-native/IconFolderPlus";
6264
import IconGitBranch from "@tabler/icons-react-native/IconGitBranch";
6365
import IconGitMerge from "@tabler/icons-react-native/IconGitMerge";
@@ -83,6 +85,7 @@ import IconMoon from "@tabler/icons-react-native/IconMoon";
8385
import IconNetwork from "@tabler/icons-react-native/IconNetwork";
8486
import IconPalette from "@tabler/icons-react-native/IconPalette";
8587
import IconPencil from "@tabler/icons-react-native/IconPencil";
88+
import IconPlug from "@tabler/icons-react-native/IconPlug";
8689
import IconPhoto from "@tabler/icons-react-native/IconPhoto";
8790
import IconPin from "@tabler/icons-react-native/IconPin";
8891
import IconPinnedOff from "@tabler/icons-react-native/IconPinnedOff";
@@ -146,7 +149,9 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
146149
"bolt.circle": IconBolt,
147150
"bolt.horizontal.circle": IconBolt,
148151
brain: IconBrain,
152+
"cable.connector": IconPlug,
149153
camera: IconCamera,
154+
car: IconCar,
150155
"chart.bar.xaxis": IconChartBar,
151156
checkmark: IconCheck,
152157
"checkmark.circle": IconCircleCheck,
@@ -178,9 +183,11 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
178183
gearshape: IconSettings,
179184
globe: IconWorld,
180185
hammer: IconHammer,
186+
headphones: IconHeadphones,
181187
house: IconHome,
182188
"info.circle": IconInfoCircle,
183189
internaldrive: IconDatabase,
190+
iphone: IconDeviceMobile,
184191
keyboard: IconKeyboard,
185192
laptopcomputer: IconDeviceLaptop,
186193
link: IconLink,

‎apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx‎

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import { type EnvironmentId, sessionGrantsScope } from "@t3tools/contracts";
1313
import { AUTH_SCOPE_OPTIONS } from "@t3tools/shared/authScopeOptions";
1414
import { AsyncResult } from "effect/reactivity";
1515
import * as Option from "effect/Option";
16-
import { useEffect, useMemo, useRef, useState } from "react";
16+
import { useState } from "react";
1717
import { Alert, Platform, Pressable, View } from "react-native";
18-
import { Gesture, GestureDetector } from "react-native-gesture-handler";
1918
import Reanimated, { ReduceMotion, useAnimatedStyle, withTiming } from "react-native-reanimated";
2019

2120
import { type AppSymbolName, SymbolView } from "../../components/AppSymbol";
@@ -27,6 +26,7 @@ import { environmentSession } from "../../state/session";
2726
import { useAtomCommand } from "../../state/use-atom-command";
2827
import { connectionTone } from "../connection/connectionTone";
2928
import { SettingsActionRow } from "./components/SettingsActionRow";
29+
import { SettingsDragHandle } from "./components/SettingsDragHandle";
3030
import { SettingsSection } from "./components/SettingsSection";
3131

3232
const ICON_SIZE = Platform.OS === "android" ? 24 : 22;
@@ -324,7 +324,7 @@ function RouteRow(props: {
324324
</View>
325325
</View>
326326
{props.editing ? (
327-
<DragHandle
327+
<SettingsDragHandle
328328
title={label}
329329
canMoveUp={props.position > 1}
330330
canMoveDown={props.position < props.count}
@@ -337,62 +337,3 @@ function RouteRow(props: {
337337
</Reanimated.View>
338338
);
339339
}
340-
341-
/** Pan recognition wins over the settings scroll view only inside the handle. */
342-
function DragHandle(props: {
343-
readonly title: string;
344-
readonly canMoveUp: boolean;
345-
readonly canMoveDown: boolean;
346-
readonly onStart: () => void;
347-
readonly onMove: (translation: number) => void;
348-
readonly onEnd: (translation: number, cancelled: boolean) => void;
349-
readonly onStep: (direction: "up" | "down") => void;
350-
}) {
351-
const latest = useRef(props);
352-
useEffect(() => {
353-
latest.current = props;
354-
});
355-
const translation = useRef(0);
356-
const gesture = useMemo(
357-
() =>
358-
Gesture.Pan()
359-
.minDistance(0)
360-
.shouldCancelWhenOutside(false)
361-
.runOnJS(true)
362-
.onStart(() => {
363-
translation.current = 0;
364-
latest.current.onStart();
365-
})
366-
.onUpdate((event) => {
367-
translation.current = event.translationY;
368-
latest.current.onMove(event.translationY);
369-
})
370-
.onFinalize((_, success) => latest.current.onEnd(translation.current, !success)),
371-
[],
372-
);
373-
return (
374-
<GestureDetector gesture={gesture}>
375-
<View
376-
collapsable={false}
377-
accessible
378-
accessibilityRole="adjustable"
379-
accessibilityLabel={`Reorder ${props.title}`}
380-
accessibilityActions={[
381-
...(props.canMoveUp ? [{ name: "decrement", label: "Move up" }] : []),
382-
...(props.canMoveDown ? [{ name: "increment", label: "Move down" }] : []),
383-
]}
384-
onAccessibilityAction={({ nativeEvent }) => {
385-
if (nativeEvent.actionName === "decrement" && props.canMoveUp) props.onStep("up");
386-
if (nativeEvent.actionName === "increment" && props.canMoveDown) props.onStep("down");
387-
}}
388-
style={{ width: 48, alignSelf: "stretch", alignItems: "center", justifyContent: "center" }}
389-
>
390-
<SymbolView
391-
name="line.3.horizontal"
392-
size={20}
393-
tintColorClassName="accent-foreground-muted"
394-
/>
395-
</View>
396-
</GestureDetector>
397-
);
398-
}

0 commit comments

Comments
 (0)