-
-
Notifications
You must be signed in to change notification settings - Fork 348
feat(voice): add Flutter UI and platform channel for voice profile se… #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Arunodoy18
wants to merge
1
commit into
AOSSIE-Org:master
Choose a base branch
from
Arunodoy18:feat/684-voice-profile-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 63 additions & 1 deletion
64
android/app/src/main/kotlin/com/resonate/resonate/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,68 @@ | ||
| package com.resonate.resonate | ||
|
|
||
| import android.util.Log | ||
| import io.flutter.embedding.android.FlutterActivity | ||
| import io.flutter.embedding.engine.FlutterEngine | ||
| import io.flutter.plugin.common.MethodChannel | ||
|
|
||
| class MainActivity: FlutterActivity() { | ||
| class MainActivity : FlutterActivity() { | ||
|
|
||
| private val channelName = "voice_control_channel" | ||
|
|
||
| override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
| super.configureFlutterEngine(flutterEngine) | ||
|
|
||
| MethodChannel( | ||
| flutterEngine.dartExecutor.binaryMessenger, | ||
| channelName | ||
| ).setMethodCallHandler { call, result -> | ||
| when (call.method) { | ||
| "setVoiceProfile" -> { | ||
| val selectedVoice = call.argument<String>("selectedVoice") | ||
| if (selectedVoice != null) { | ||
| applyVoiceProfile(selectedVoice) | ||
| result.success(null) | ||
| } else { | ||
| result.error( | ||
| "INVALID_ARGUMENT", | ||
| "selectedVoice must not be null", | ||
| null | ||
| ) | ||
| } | ||
| } | ||
| "setPreviewEnabled" -> { | ||
| val isPreviewEnabled = call.argument<Boolean>("isPreviewEnabled") | ||
| if (isPreviewEnabled != null) { | ||
| setVoicePreviewEnabled(isPreviewEnabled) | ||
| result.success(null) | ||
| } else { | ||
| result.error( | ||
| "INVALID_ARGUMENT", | ||
| "isPreviewEnabled must not be null", | ||
| null | ||
| ) | ||
| } | ||
| } | ||
| else -> result.notImplemented() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Apply the selected voice profile in the native audio processing layer. | ||
| * Replace the log statement with real DSP / audio-engine calls. | ||
| */ | ||
| private fun applyVoiceProfile(profile: String) { | ||
| // TODO: forward to native audio engine | ||
| Log.d("VoiceControl", "Voice profile set: $profile") | ||
| } | ||
|
|
||
| /** | ||
| * Start or stop audio preview in the native audio processing layer. | ||
| * Replace the log statement with real DSP / audio-engine calls. | ||
| */ | ||
| private fun setVoicePreviewEnabled(enabled: Boolean) { | ||
| // TODO: forward to native audio engine | ||
| Log.d("VoiceControl", "Preview enabled: $enabled") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import 'package:get/get.dart'; | ||
| import '../services/voice_control_service.dart'; | ||
|
|
||
| class VoiceProfileController extends GetxController { | ||
| /// Available predefined voice profiles. | ||
| final List<String> voiceProfiles = const [ | ||
| 'Default', | ||
| 'Deep', | ||
| 'Soft', | ||
| 'Energetic', | ||
| 'Calm', | ||
| ]; | ||
|
|
||
| /// Currently selected voice profile. | ||
| var selectedVoice = 'Default'.obs; | ||
|
|
||
| /// Whether preview playback is active. | ||
| var isPreviewEnabled = false.obs; | ||
|
|
||
| @override | ||
| void onInit() { | ||
| super.onInit(); | ||
| // Notify native layer of the initial defaults. | ||
| _sendVoiceProfile(); | ||
| _sendPreviewState(); | ||
| } | ||
|
Arunodoy18 marked this conversation as resolved.
|
||
|
|
||
| /// Called when the user picks a different voice profile. | ||
| Future<void> onVoiceProfileChanged(String? voice) async { | ||
| if (voice == null || voice == selectedVoice.value) return; | ||
| selectedVoice.value = voice; | ||
| await _sendVoiceProfile(); | ||
| } | ||
|
|
||
| /// Called when the user toggles the preview switch. | ||
| Future<void> onPreviewToggled(bool value) async { | ||
| isPreviewEnabled.value = value; | ||
| await _sendPreviewState(); | ||
| } | ||
|
Arunodoy18 marked this conversation as resolved.
|
||
|
|
||
| // ─── private helpers ─────────────────────────────────────────────────────── | ||
|
|
||
| Future<void> _sendVoiceProfile() async { | ||
| await VoiceControlService.setVoiceProfile(selectedVoice.value); | ||
| } | ||
|
|
||
| Future<void> _sendPreviewState() async { | ||
| await VoiceControlService.setPreviewEnabled(isPreviewEnabled.value); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import 'package:flutter/services.dart'; | ||
|
|
||
| /// Lightweight signal-only bridge to native audio processing. | ||
| /// Flutter sends voice profile selection and preview toggle states; | ||
| /// all audio work is performed on the native side. | ||
| class VoiceControlService { | ||
| static const _channel = MethodChannel('voice_control_channel'); | ||
|
|
||
| /// Sends the selected voice profile name to native code. | ||
| /// [selectedVoice] – identifier of the chosen voice profile. | ||
| static Future<void> setVoiceProfile(String selectedVoice) async { | ||
| await _channel.invokeMethod('setVoiceProfile', { | ||
| 'selectedVoice': selectedVoice, | ||
| }); | ||
| } | ||
|
|
||
| /// Notifies native code to enable or disable preview playback. | ||
| /// [isPreviewEnabled] – whether preview mode is active. | ||
| static Future<void> setPreviewEnabled(bool isPreviewEnabled) async { | ||
| await _channel.invokeMethod('setPreviewEnabled', { | ||
| 'isPreviewEnabled': isPreviewEnabled, | ||
| }); | ||
| } | ||
|
Arunodoy18 marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:get/get.dart'; | ||
| import 'package:resonate/utils/ui_sizes.dart'; | ||
| import '../../controllers/voice_profile_controller.dart'; | ||
|
|
||
| class VoiceProfileScreen extends StatelessWidget { | ||
| VoiceProfileScreen({super.key}); | ||
|
|
||
| final VoiceProfileController controller = | ||
| Get.put(VoiceProfileController()); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final colorScheme = Theme.of(context).colorScheme; | ||
|
|
||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: const Text('Voice Profile'), | ||
| backgroundColor: colorScheme.surface, | ||
| foregroundColor: colorScheme.onSurface, | ||
| elevation: 0, | ||
| ), | ||
| backgroundColor: colorScheme.surface, | ||
| body: SafeArea( | ||
| child: ListView( | ||
| padding: EdgeInsets.symmetric( | ||
| horizontal: UiSizes.width_20, | ||
| vertical: UiSizes.height_20, | ||
| ), | ||
| children: [ | ||
| // ── Section: Voice Profile Selection ──────────────────────────── | ||
| Text( | ||
| 'Select Voice Profile', | ||
| style: Theme.of(context).textTheme.titleMedium?.copyWith( | ||
| color: colorScheme.onSurface, | ||
| fontWeight: FontWeight.w600, | ||
| ), | ||
| ), | ||
| SizedBox(height: UiSizes.height_12), | ||
| _VoiceProfileDropdown(controller: controller), | ||
| SizedBox(height: UiSizes.height_30), | ||
|
|
||
| // ── Section: Preview Toggle ────────────────────────────────────── | ||
| _PreviewToggleTile(controller: controller), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // ─── Voice Profile Dropdown ─────────────────────────────────────────────────── | ||
|
|
||
| class _VoiceProfileDropdown extends StatelessWidget { | ||
| const _VoiceProfileDropdown({required this.controller}); | ||
|
|
||
| final VoiceProfileController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final colorScheme = Theme.of(context).colorScheme; | ||
|
|
||
| return Obx( | ||
| () => DropdownButtonFormField<String>( | ||
| value: controller.selectedVoice.value, | ||
| decoration: InputDecoration( | ||
| labelText: 'Voice Profile', | ||
| border: OutlineInputBorder( | ||
| borderRadius: BorderRadius.circular(12), | ||
| ), | ||
| prefixIcon: Icon( | ||
| Icons.record_voice_over_outlined, | ||
| color: colorScheme.primary, | ||
| ), | ||
| ), | ||
| items: controller.voiceProfiles | ||
| .map( | ||
| (profile) => DropdownMenuItem<String>( | ||
| value: profile, | ||
| child: Text(profile), | ||
| ), | ||
| ) | ||
| .toList(), | ||
| onChanged: controller.onVoiceProfileChanged, | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // ─── Preview Toggle Tile ────────────────────────────────────────────────────── | ||
|
|
||
| class _PreviewToggleTile extends StatelessWidget { | ||
| const _PreviewToggleTile({required this.controller}); | ||
|
|
||
| final VoiceProfileController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final colorScheme = Theme.of(context).colorScheme; | ||
|
|
||
| return Container( | ||
| decoration: BoxDecoration( | ||
| border: Border.all(color: colorScheme.outline), | ||
| borderRadius: BorderRadius.circular(12), | ||
| ), | ||
| child: Obx( | ||
| () => SwitchListTile( | ||
| title: const Text('Preview Mode'), | ||
| subtitle: Text( | ||
| controller.isPreviewEnabled.value ? 'On' : 'Off', | ||
| style: TextStyle(color: colorScheme.onSurfaceVariant), | ||
| ), | ||
| secondary: Icon( | ||
| Icons.headphones_outlined, | ||
| color: colorScheme.primary, | ||
| ), | ||
| value: controller.isPreviewEnabled.value, | ||
| onChanged: controller.onPreviewToggled, | ||
| activeColor: colorScheme.primary, | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.