mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-13 09:20:29 +00:00
Enable profiles switch UI
This commit is contained in:
@@ -1,21 +1,32 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'profiles_feature_service.dart';
|
||||
import '../utils/voice_message_parser.dart';
|
||||
|
||||
/// Stores user-selected voice bitrate and maps it to supported codec modes.
|
||||
class VoiceBitratePreferences {
|
||||
static const String _bitrateKey = 'voice_bitrate';
|
||||
static const int defaultBitrate = 1300;
|
||||
static const List<int> supportedBitrates = [700, 1200, 1300, 1400, 1600, 2400, 3200];
|
||||
static const List<int> supportedBitrates = [
|
||||
700,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1600,
|
||||
2400,
|
||||
3200,
|
||||
];
|
||||
|
||||
static Future<int> getBitrate() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final value = prefs.getInt(_bitrateKey) ?? defaultBitrate;
|
||||
final value =
|
||||
prefs.getInt(ProfileStorageScope.scopedKey(_bitrateKey)) ??
|
||||
defaultBitrate;
|
||||
return supportedBitrates.contains(value) ? value : defaultBitrate;
|
||||
}
|
||||
|
||||
static Future<void> setBitrate(int bitrate) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt(_bitrateKey, bitrate);
|
||||
await prefs.setInt(ProfileStorageScope.scopedKey(_bitrateKey), bitrate);
|
||||
}
|
||||
|
||||
static VoicePacketMode toVoiceMode(int bitrate) {
|
||||
|
||||
Reference in New Issue
Block a user