fix(devices): cache platform device names, dedupe placeholder ids, purge collided EQ entries
Dart half of bt-device-identity. EstadoEcualizador now caches each device's platform-reported name in memory so the settings screen shows the device's own Bluetooth name instead of its raw id when no custom rename exists, and skips auto-creating preset entries for the composite-placeholder sentinel. Enabling multi-device EQ triggers the Bluetooth permission request through the new channel contract. A flag-guarded one-time migration purges only entries keyed by the exact literal placeholder id from the three per-device preference maps, since those collided entries cannot be attributed to a device. Work unit 2/2 of bt-device-identity (Dart state + migration).
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
@@ -698,7 +699,8 @@ class _SeccionEcualizadorAvanzado extends StatelessWidget {
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap:
|
||||
() => eq.cambiarMultiDeviceEnabled(!multiDeviceEnabled),
|
||||
() =>
|
||||
_alternarMultiDevice(eq, !multiDeviceEnabled),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -718,7 +720,7 @@ class _SeccionEcualizadorAvanzado extends StatelessWidget {
|
||||
Switch.adaptive(
|
||||
value: multiDeviceEnabled,
|
||||
onChanged:
|
||||
(habilitado) => eq.cambiarMultiDeviceEnabled(habilitado),
|
||||
(habilitado) => _alternarMultiDevice(eq, habilitado),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -749,6 +751,17 @@ class _SeccionEcualizadorAvanzado extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Toggles the multi-device EQ feature and, when turning it ON, requests
|
||||
/// `BLUETOOTH_CONNECT` at this point-of-intent (bt-device-identity ADR-1)
|
||||
/// so BT devices report their real MAC instead of the OS placeholder.
|
||||
/// Fire-and-forget: neither call blocks the toggle UI on its result.
|
||||
void _alternarMultiDevice(EstadoEcualizador eq, bool habilitado) {
|
||||
unawaited(eq.cambiarMultiDeviceEnabled(habilitado));
|
||||
if (habilitado) {
|
||||
unawaited(eq.solicitarPermisoBluetooth());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A single device row in the known-devices list.
|
||||
@@ -766,7 +779,7 @@ class _FilaDispositivo extends StatelessWidget {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final eq = context.watch<EstadoEcualizador>();
|
||||
final isActive = eq.dispositivoActualId == deviceId;
|
||||
final displayName = eq.nombreVisible(deviceId, '');
|
||||
final displayName = eq.nombreVisible(deviceId, eq.nombrePlataforma(deviceId));
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
@@ -843,7 +856,10 @@ class _DialogoEdicionDispositivoState
|
||||
void initState() {
|
||||
super.initState();
|
||||
final eq = context.read<EstadoEcualizador>();
|
||||
final displayName = eq.nombreVisible(widget.deviceId, '');
|
||||
final displayName = eq.nombreVisible(
|
||||
widget.deviceId,
|
||||
eq.nombrePlataforma(widget.deviceId),
|
||||
);
|
||||
_nombreCtrl = TextEditingController(text: displayName);
|
||||
_presetActual = widget.preset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user