fix(recordings): open last file on android
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../modelos/alarma_musical.dart';
|
||||
@@ -64,9 +65,15 @@ class ServicioAlarmasAndroid {
|
||||
Future<void> programar(AlarmaMusical alarma) async {
|
||||
final proxima = alarma.proximaEjecucion;
|
||||
if (proxima == null || !alarma.activa) {
|
||||
debugPrint(
|
||||
'[PluriWave][alarmas] cancelar por inactiva/sin proxima id=${alarma.id} activa=${alarma.activa} proxima=$proxima',
|
||||
);
|
||||
await cancelar(alarma.id);
|
||||
return;
|
||||
}
|
||||
debugPrint(
|
||||
'[PluriWave][alarmas] programar id=${alarma.id} nombre=${alarma.nombre} proxima=${proxima.toIso8601String()} preaviso=${proxima.subtract(const Duration(minutes: 30)).toIso8601String()}',
|
||||
);
|
||||
await _channel.invokeMethod<void>('scheduleAlarm', {
|
||||
'id': alarma.id,
|
||||
'title': alarma.nombre,
|
||||
@@ -77,16 +84,21 @@ class ServicioAlarmasAndroid {
|
||||
}
|
||||
|
||||
Future<void> cancelar(String alarmaId) =>
|
||||
_channel.invokeMethod<void>('cancelAlarm', {'id': alarmaId});
|
||||
_logAndInvokeVoid('cancelAlarm', {'id': alarmaId});
|
||||
|
||||
Future<void> ocultarNotificacionAlarma(String alarmaId) => _channel
|
||||
.invokeMethod<void>('dismissAlarmNotification', {'id': alarmaId});
|
||||
Future<void> ocultarNotificacionAlarma(String alarmaId) =>
|
||||
_logAndInvokeVoid('dismissAlarmNotification', {'id': alarmaId});
|
||||
|
||||
Future<DiagnosticoAlarmasAndroid> diagnostico() async {
|
||||
debugPrint('[PluriWave][alarmas] diagnostico android');
|
||||
final raw = await _channel.invokeMethod<Map<Object?, Object?>>(
|
||||
'diagnostics',
|
||||
);
|
||||
return DiagnosticoAlarmasAndroid.fromMap(raw ?? const {});
|
||||
final diag = DiagnosticoAlarmasAndroid.fromMap(raw ?? const {});
|
||||
debugPrint(
|
||||
'[PluriWave][alarmas] diagnostico exactas=${diag.puedeProgramarExactas} notificaciones=${diag.notificacionesPermitidas} sdk=${diag.versionSdk} fabricante=${diag.fabricante}',
|
||||
);
|
||||
return diag;
|
||||
}
|
||||
|
||||
Future<EventoAlarmaAndroid?> obtenerEventoInicial() async {
|
||||
@@ -95,9 +107,17 @@ class ServicioAlarmasAndroid {
|
||||
);
|
||||
if (raw == null || raw.isEmpty) return null;
|
||||
final evento = EventoAlarmaAndroid.fromMap(raw);
|
||||
debugPrint(
|
||||
'[PluriWave][alarmas] evento inicial id=${evento.alarmaId} accion=${evento.accion}',
|
||||
);
|
||||
return evento.alarmaId.isEmpty ? null : evento;
|
||||
}
|
||||
|
||||
Future<void> _logAndInvokeVoid(String method, Map<String, Object?> args) {
|
||||
debugPrint('[PluriWave][alarmas] $method $args');
|
||||
return _channel.invokeMethod<void>(method, args);
|
||||
}
|
||||
|
||||
static void _instalarHandler(MethodChannel channel) {
|
||||
if (_handlerInstalado) return;
|
||||
_handlerInstalado = true;
|
||||
@@ -107,6 +127,9 @@ class ServicioAlarmasAndroid {
|
||||
if (args is Map) {
|
||||
final evento = EventoAlarmaAndroid.fromMap(args);
|
||||
if (evento.alarmaId.isNotEmpty) {
|
||||
debugPrint(
|
||||
'[PluriWave][alarmas] evento nativo id=${evento.alarmaId} accion=${evento.accion}',
|
||||
);
|
||||
_eventosController.add(evento);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user