Only allow voice if enabled

This commit is contained in:
JHubi1 2024-06-18 17:02:18 +02:00
parent 1b9225fdb8
commit 09fda2b004
No known key found for this signature in database
GPG Key ID: 7BF82570CBBBD050
3 changed files with 42 additions and 23 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -118,6 +118,9 @@ class _AppState extends State<App> {
if ((await Permission.bluetoothConnect.isGranted) && if ((await Permission.bluetoothConnect.isGranted) &&
(await Permission.microphone.isGranted)) { (await Permission.microphone.isGranted)) {
voiceSupported = await speech.initialize(); voiceSupported = await speech.initialize();
} else {
prefs!.setBool("voiceModeEnabled", false);
voiceSupported = false;
} }
SharedPreferences.setPrefix("ollama."); SharedPreferences.setPrefix("ollama.");
@ -1225,28 +1228,44 @@ class _MainAppState extends State<MainApp> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
SizedBox( (prefs?.getBool(
width: double.infinity, "voiceModeEnabled") ??
child: OutlinedButton.icon( false)
onPressed: () async { ? SizedBox(
selectionHaptic(); width: double.infinity,
Navigator.of(context) child:
.pop(); OutlinedButton.icon(
setMainState = setState; onPressed:
settingsOpen = true; () async {
logoVisible = false; selectionHaptic();
Navigator.of(context).push( Navigator.of(
MaterialPageRoute( context)
builder: .pop();
(context) => setMainState =
const ScreenVoice())); setState;
}, settingsOpen =
icon: const Icon(Icons true;
.headphones_rounded), logoVisible =
label: Text(AppLocalizations false;
.of(context)! Navigator.of(
.settingsTitleVoice))), context)
const SizedBox(height: 8), .push(MaterialPageRoute(
builder:
(context) =>
const ScreenVoice()));
},
icon: const Icon(Icons
.headphones_rounded),
label: Text(
AppLocalizations.of(
context)!
.settingsTitleVoice)))
: const SizedBox.shrink(),
(prefs?.getBool(
"voiceModeEnabled") ??
false)
? const SizedBox(height: 8)
: const SizedBox.shrink(),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: OutlinedButton.icon( child: OutlinedButton.icon(

View File

@ -86,7 +86,7 @@ class _ScreenSettingsAboutState extends State<ScreenSettingsAbout> {
// const SizedBox(height: 16), // const SizedBox(height: 16),
button( button(
AppLocalizations.of(context)! AppLocalizations.of(context)!
.settingsVersion(currentVersion ?? "0.0.1"), .settingsVersion(currentVersion ?? ""),
Icons.verified_rounded, Icons.verified_rounded,
null), null),
(updateStatus == "notAvailable") (updateStatus == "notAvailable")