diff options
author | Anuj Solanki <anuj603362@gmail.com> | 2024-10-17 22:12:56 +0530 |
---|---|---|
committer | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2024-10-22 11:49:11 +0000 |
commit | f8b39a2902e73422259965e724a44c56f49ce103 (patch) | |
tree | 3e95c7f307a57615780a5ba652e90c3a5f5ad377 | |
parent | 3f1370ada560d824e1cf2258e7c475a32b750e95 (diff) |
Make Voice Assistant Toggle Conditional
- Removed the Voice Assistant toggle button from the settings page
when agl-offline-voice-agent feature is not enabled.
Bug-AGL: SPEC-5265
Change-Id: I65aa011cffe90663106a0d8e4fab021972f51e87
Signed-off-by: Anuj Solanki <anuj603362@gmail.com>
-rw-r--r-- | lib/core/constants/constants.dart | 1 | ||||
-rw-r--r-- | lib/data/data_providers/app_config_provider.dart | 18 | ||||
-rw-r--r-- | lib/data/data_providers/voice_agent_client.dart | 2 | ||||
-rw-r--r-- | lib/presentation/screens/settings/widgets/settings_content.dart | 1 |
4 files changed, 18 insertions, 4 deletions
diff --git a/lib/core/constants/constants.dart b/lib/core/constants/constants.dart index edee874..7bb8e75 100644 --- a/lib/core/constants/constants.dart +++ b/lib/core/constants/constants.dart @@ -9,6 +9,7 @@ final GlobalKey<ScaffoldState> homeScaffoldKey = GlobalKey(); const debugDisplay = bool.fromEnvironment('DEBUG_DISPLAY'); const disableBkgAnimationDefault = bool.fromEnvironment('DISABLE_BKG_ANIMATION'); const randomHybridAnimationDefault = bool.fromEnvironment('RANDOM_HYBRID_ANIMATION'); +const enableVoiceAssistantDefault = bool.fromEnvironment('ENABLE_VOICE_ASSISTANT'); diff --git a/lib/data/data_providers/app_config_provider.dart b/lib/data/data_providers/app_config_provider.dart index 9e187a9..4052164 100644 --- a/lib/data/data_providers/app_config_provider.dart +++ b/lib/data/data_providers/app_config_provider.dart @@ -112,6 +112,7 @@ class AppConfig { final StorageConfig storageConfig; final MpdConfig mpdConfig; final VoiceAgentConfig voiceAgentConfig; + final bool enableVoiceAssistant; static String configFilePath = '/etc/xdg/AGL/ics-homescreen.yaml'; @@ -123,7 +124,8 @@ class AppConfig { required this.radioConfig, required this.storageConfig, required this.mpdConfig, - required this.voiceAgentConfig}); + required this.voiceAgentConfig, + required this.enableVoiceAssistant}); static KuksaConfig parseKuksaConfig(YamlMap kuksaMap) { try { @@ -324,6 +326,14 @@ final appConfigProvider = Provider((ref) { voiceAgentConfig = VoiceAgentConfig.defaultConfig(); } + bool enableVoiceAssistant = enableVoiceAssistantDefault; + if (yamlMap.containsKey('enable-voice-assistant')) { + var value = yamlMap['enable-voice-assistant']; + if (value is bool) { + enableVoiceAssistant = value; + } + } + bool disableBkgAnimation = disableBkgAnimationDefault; if (yamlMap.containsKey('disable-bg-animation')) { var value = yamlMap['disable-bg-animation']; @@ -356,7 +366,8 @@ final appConfigProvider = Provider((ref) { radioConfig: radioConfig, storageConfig: storageConfig, mpdConfig: mpdConfig, - voiceAgentConfig: voiceAgentConfig); + voiceAgentConfig: voiceAgentConfig, + enableVoiceAssistant: enableVoiceAssistant); } catch (_) { return AppConfig( disableBkgAnimation: false, @@ -366,6 +377,7 @@ final appConfigProvider = Provider((ref) { radioConfig: RadioConfig.defaultConfig(), storageConfig: StorageConfig.defaultConfig(), mpdConfig: MpdConfig.defaultConfig(), - voiceAgentConfig: VoiceAgentConfig.defaultConfig()); + voiceAgentConfig: VoiceAgentConfig.defaultConfig(), + enableVoiceAssistant: false); } }); diff --git a/lib/data/data_providers/voice_agent_client.dart b/lib/data/data_providers/voice_agent_client.dart index 295e138..903a5d0 100644 --- a/lib/data/data_providers/voice_agent_client.dart +++ b/lib/data/data_providers/voice_agent_client.dart @@ -13,6 +13,7 @@ class VoiceAgentClient { VoiceAgentClient({required this.config,required this.ref}) { // Initialize the client channel without connecting immediately + debugPrint("Connecting to Voice Assistant at ${config.hostname}:${config.port}"); String host = config.hostname; int port = config.port; _channel = ClientChannel( @@ -22,7 +23,6 @@ class VoiceAgentClient { credentials: ChannelCredentials.insecure(), ), ); - debugPrint("Connecting to Voice Assistant"); _client = VoiceAgentServiceClient(_channel); } diff --git a/lib/presentation/screens/settings/widgets/settings_content.dart b/lib/presentation/screens/settings/widgets/settings_content.dart index 458677c..b43c07b 100644 --- a/lib/presentation/screens/settings/widgets/settings_content.dart +++ b/lib/presentation/screens/settings/widgets/settings_content.dart @@ -56,6 +56,7 @@ class Settings extends ConsumerWidget { voidCallback: () { ref.read(appProvider.notifier).update(AppState.audioSettings); }), + if(ref.watch(appConfigProvider).enableVoiceAssistant) VoiceAssistantSettingsTile( icon: Icons.keyboard_voice_outlined, title: "Voice Assistant", |