refactor: voice_*-Prefs hinter VoicePrefs-Fassade in settings_prefs (M2 storage-Leitplanke, gleiche Keys/Semantik)
This commit is contained in:
@@ -90,6 +90,56 @@ final privacyReadReceiptsProvider =
|
||||
final privacyTypingProvider =
|
||||
StateNotifierProvider<BoolPref, bool>((ref) => BoolPref('privacy_typing', true));
|
||||
|
||||
// ── Voice preferences ────────────────────────────────────────────────────────
|
||||
// Geschrieben von der Settings-Voice-Sektion, gelesen von den Call-Modulen
|
||||
// (call_signaling, voice_channel). Die historischen voice_*-Keys bleiben
|
||||
// unverändert, damit bestehende Nutzer-Einstellungen erhalten bleiben.
|
||||
|
||||
class VoicePrefs {
|
||||
VoicePrefs._();
|
||||
|
||||
static const _kMic = 'voice_mic_device';
|
||||
static const _kSpeaker = 'voice_speaker_device';
|
||||
static const _kCamera = 'voice_camera_device';
|
||||
static const _kOutputVolume = 'voice_output_volume';
|
||||
|
||||
static Future<double> loadOutputVolume() async {
|
||||
final p = await SharedPreferences.getInstance();
|
||||
return p.getDouble(_kOutputVolume) ?? 1.0;
|
||||
}
|
||||
|
||||
static Future<void> saveOutputVolume(double v) async {
|
||||
final p = await SharedPreferences.getInstance();
|
||||
await p.setDouble(_kOutputVolume, v);
|
||||
}
|
||||
|
||||
/// Gewählte Geräte-IDs; null = kein Pref gesetzt (System-Standard nutzen).
|
||||
static Future<({String? mic, String? speaker, String? camera})>
|
||||
loadDevices() async {
|
||||
final p = await SharedPreferences.getInstance();
|
||||
return (
|
||||
mic: p.getString(_kMic),
|
||||
speaker: p.getString(_kSpeaker),
|
||||
camera: p.getString(_kCamera),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> saveMic(String? deviceId) => _saveDevice(_kMic, deviceId);
|
||||
static Future<void> saveSpeaker(String? deviceId) =>
|
||||
_saveDevice(_kSpeaker, deviceId);
|
||||
static Future<void> saveCamera(String? deviceId) =>
|
||||
_saveDevice(_kCamera, deviceId);
|
||||
|
||||
static Future<void> _saveDevice(String key, String? deviceId) async {
|
||||
final p = await SharedPreferences.getInstance();
|
||||
if (deviceId == null || deviceId.isEmpty) {
|
||||
await p.remove(key);
|
||||
} else {
|
||||
await p.setString(key, deviceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Theme persistence helpers ────────────────────────────────────────────────
|
||||
|
||||
Future<void> saveThemePrefs({
|
||||
|
||||
Reference in New Issue
Block a user