fix(auto): preserve phone-chosen station order in Android Auto folders
Android Auto's Favoritos/Todas/Mis emisoras folders always re-sorted by a hardcoded quality criterion in ConstructorArbolAuto.hijos/hijosGrupo, discarding whatever order the caller passed in. EstadoRadio now pushes already-ordered snapshots (listaFavoritosManual for Favoritos, and the ordenListas-sorted populares/emisorasCustom getters for Todas/Mis emisoras, re-pushed immediately on cambiarOrdenListas), and hijos/ hijosGrupo stop re-sorting so that order survives into the car.
This commit is contained in:
@@ -394,7 +394,14 @@ class EstadoRadio extends ChangeNotifier {
|
||||
_cargandoPopulares = false;
|
||||
// Design "live snapshot the source prefers": Android Auto's `Todas`
|
||||
// folder mirrors the same populares list the phone just loaded.
|
||||
_fuenteAuto?.actualizarSnapshot(todas: _populares);
|
||||
//
|
||||
// Fix `android-auto-orden`: pushes the SORTED [populares] getter, not
|
||||
// the raw [_populares] field — the same [_ordenListas] setting the
|
||||
// phone's own discovery lists (e.g. Buscar's `tendencias`) already
|
||||
// sort by must also govern this folder's order, not the API's raw
|
||||
// arrival order. `navegacion_auto.dart`'s `hijos()` no longer
|
||||
// re-sorts, so whatever order arrives here IS what the driver sees.
|
||||
_fuenteAuto?.actualizarSnapshot(todas: populares);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -402,7 +409,13 @@ class EstadoRadio extends ChangeNotifier {
|
||||
Future<void> cargarFavoritos() async {
|
||||
_listaFavoritos = await favoritos.obtenerTodos();
|
||||
await _normalizarEmisoraPreferida();
|
||||
_fuenteAuto?.actualizarSnapshot(favoritos: _listaFavoritos);
|
||||
// Fix `android-auto-orden`: pushes the documented manual-order accessor
|
||||
// explicitly. [listaFavoritosManual] is backed by the same list as
|
||||
// [_listaFavoritos] today (obtenerTodos() already returns the persisted
|
||||
// manual order), but naming the intent here — "the exact order the
|
||||
// Favoritos screen shows and reorders" — keeps this call from silently
|
||||
// drifting onto a re-sorted list in a future refactor.
|
||||
_fuenteAuto?.actualizarSnapshot(favoritos: listaFavoritosManual);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -520,6 +533,16 @@ class EstadoRadio extends ChangeNotifier {
|
||||
await prefs.setString(_keyOrdenListas, orden.name);
|
||||
// Search owns its own listeners (S4-R3) but sorts with this preference.
|
||||
busqueda.notificarCambioOrden();
|
||||
// Fix `android-auto-orden`: Todas/Mis emisoras' Android Auto order is
|
||||
// derived from this same setting (see cargarPopulares/
|
||||
// _cargarEmisorasCustom above) — without an immediate re-push, a live
|
||||
// car session would keep showing the OLD order until the next full
|
||||
// reload instead of updating right away, same as the phone does via
|
||||
// this method's own memoized getters.
|
||||
_fuenteAuto?.actualizarSnapshot(
|
||||
todas: populares,
|
||||
misEmisoras: emisorasCustom,
|
||||
);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -659,7 +682,9 @@ class EstadoRadio extends ChangeNotifier {
|
||||
detalle: 'resolucion de ruta',
|
||||
razon: e.toString(),
|
||||
);
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: _emisorasCustom);
|
||||
// Fix `android-auto-orden`: pushes the SORTED [emisorasCustom] getter
|
||||
// (see the doc on this method's other 3 identical call sites below).
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: emisorasCustom);
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
@@ -685,7 +710,8 @@ class EstadoRadio extends ChangeNotifier {
|
||||
razon: e.toString(),
|
||||
);
|
||||
}
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: _emisorasCustom);
|
||||
// Fix `android-auto-orden`: sorted getter, not the raw field.
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: emisorasCustom);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -701,7 +727,8 @@ class EstadoRadio extends ChangeNotifier {
|
||||
if (!await archivo.exists()) {
|
||||
_emisorasCustom = [];
|
||||
_customDegradado = false;
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: _emisorasCustom);
|
||||
// Fix `android-auto-orden`: sorted getter, not the raw field.
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: emisorasCustom);
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
@@ -714,7 +741,8 @@ class EstadoRadio extends ChangeNotifier {
|
||||
detalle: archivo.path,
|
||||
razon: e.toString(),
|
||||
);
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: _emisorasCustom);
|
||||
// Fix `android-auto-orden`: sorted getter, not the raw field.
|
||||
_fuenteAuto?.actualizarSnapshot(misEmisoras: emisorasCustom);
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user