mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
chore: Add App Store screenshots
Refs:
This commit is contained in:
@@ -12,6 +12,9 @@ class NotificationService {
|
||||
factory NotificationService() => _instance;
|
||||
NotificationService._internal();
|
||||
|
||||
static const bool _skipPermissionRequests = bool.fromEnvironment(
|
||||
'MESHCORE_SCREENSHOTS',
|
||||
);
|
||||
final FlutterLocalNotificationsPlugin _notificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
static const String _prefMessagesEnabled = 'notifications_messages_enabled';
|
||||
@@ -90,9 +93,9 @@ class NotificationService {
|
||||
|
||||
// iOS initialization settings
|
||||
final darwinSettings = DarwinInitializationSettings(
|
||||
requestAlertPermission: true,
|
||||
requestBadgePermission: true,
|
||||
requestSoundPermission: true,
|
||||
requestAlertPermission: !_skipPermissionRequests,
|
||||
requestBadgePermission: !_skipPermissionRequests,
|
||||
requestSoundPermission: !_skipPermissionRequests,
|
||||
);
|
||||
|
||||
// Combined initialization settings
|
||||
@@ -114,7 +117,11 @@ class NotificationService {
|
||||
}
|
||||
|
||||
// Request permissions
|
||||
await _requestPermissions();
|
||||
if (_skipPermissionRequests) {
|
||||
_permissionGranted = true;
|
||||
} else {
|
||||
await _requestPermissions();
|
||||
}
|
||||
await _loadPreferences();
|
||||
|
||||
// Create notification channels (Android)
|
||||
@@ -327,6 +334,8 @@ class NotificationService {
|
||||
String? notes,
|
||||
AppLocalizations? localizations,
|
||||
}) async {
|
||||
if (_skipPermissionRequests) return;
|
||||
|
||||
if (!_isInitialized) {
|
||||
debugPrint(
|
||||
'⚠️ [NotificationService] Not initialized, skipping notification',
|
||||
@@ -509,6 +518,8 @@ class NotificationService {
|
||||
String? channelName,
|
||||
AppLocalizations? localizations,
|
||||
}) async {
|
||||
if (_skipPermissionRequests) return;
|
||||
|
||||
if (!_isInitialized) {
|
||||
debugPrint(
|
||||
'⚠️ [NotificationService] Not initialized, skipping notification',
|
||||
@@ -672,6 +683,8 @@ class NotificationService {
|
||||
required String downloadUrl,
|
||||
AppLocalizations? localizations,
|
||||
}) async {
|
||||
if (_skipPermissionRequests) return;
|
||||
|
||||
if (!_isInitialized) {
|
||||
debugPrint(
|
||||
'⚠️ [NotificationService] Not initialized, skipping notification',
|
||||
@@ -772,6 +785,8 @@ class NotificationService {
|
||||
required double batteryPercent,
|
||||
required bool isCurrentDevice,
|
||||
}) async {
|
||||
if (_skipPermissionRequests) return false;
|
||||
|
||||
if (!_isInitialized) {
|
||||
debugPrint(
|
||||
'⚠️ [NotificationService] Not initialized, skipping notification',
|
||||
@@ -863,6 +878,8 @@ class NotificationService {
|
||||
required String contactKey,
|
||||
String? contactName,
|
||||
}) async {
|
||||
if (_skipPermissionRequests) return false;
|
||||
|
||||
if (!_isInitialized) return false;
|
||||
if (!_permissionGranted) return false;
|
||||
if (!_discoveryNotificationsEnabled) return false;
|
||||
|
||||
@@ -11,6 +11,7 @@ class VoicePlayerService {
|
||||
final AudioPlayer _player = AudioPlayer();
|
||||
final StreamController<void> _events = StreamController<void>.broadcast();
|
||||
bool _isPlaying = false;
|
||||
bool _isDisposed = false;
|
||||
Duration _position = Duration.zero;
|
||||
Duration _duration = Duration.zero;
|
||||
Timer? _fallbackTicker;
|
||||
@@ -30,22 +31,22 @@ class VoicePlayerService {
|
||||
} else {
|
||||
_stopFallbackTicker();
|
||||
}
|
||||
_events.add(null);
|
||||
_emit();
|
||||
});
|
||||
_player.onLog.listen((msg) => debugPrint('🔊 [VoicePlayer] log: $msg'));
|
||||
_player.onPositionChanged.listen((position) {
|
||||
_position = position;
|
||||
_events.add(null);
|
||||
_emit();
|
||||
});
|
||||
_player.onDurationChanged.listen((duration) {
|
||||
_duration = duration;
|
||||
_events.add(null);
|
||||
_emit();
|
||||
});
|
||||
_player.onPlayerComplete.listen((_) {
|
||||
_isPlaying = false;
|
||||
_position = _duration;
|
||||
_stopFallbackTicker();
|
||||
_events.add(null);
|
||||
_emit();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ class VoicePlayerService {
|
||||
milliseconds: (pcmSamples.length * 1000) ~/ sampleRateHz,
|
||||
);
|
||||
_playbackStartedAt = DateTime.now();
|
||||
_events.add(null);
|
||||
_emit();
|
||||
|
||||
final wavBytes = _buildWav(pcmSamples, sampleRate: sampleRateHz);
|
||||
final tmpDir = await getTemporaryDirectory();
|
||||
@@ -70,14 +71,14 @@ class VoicePlayerService {
|
||||
try {
|
||||
_isPlaying = true;
|
||||
_startFallbackTicker();
|
||||
_events.add(null);
|
||||
_emit();
|
||||
await _player.play(DeviceFileSource(file.path));
|
||||
debugPrint('🔊 [VoicePlayer] play() returned (audio playing)');
|
||||
} catch (e, st) {
|
||||
debugPrint('❌ [VoicePlayer] play() error: $e\n$st');
|
||||
_isPlaying = false;
|
||||
_stopFallbackTicker();
|
||||
_events.add(null);
|
||||
_emit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,15 +89,22 @@ class VoicePlayerService {
|
||||
_position = Duration.zero;
|
||||
_playbackStartedAt = null;
|
||||
_stopFallbackTicker();
|
||||
_events.add(null);
|
||||
_emit();
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_isDisposed = true;
|
||||
_stopFallbackTicker();
|
||||
_events.close();
|
||||
_player.dispose();
|
||||
}
|
||||
|
||||
void _emit() {
|
||||
if (!_isDisposed) {
|
||||
_events.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
void _startFallbackTicker() {
|
||||
if (_fallbackTicker != null) return;
|
||||
_fallbackTicker = Timer.periodic(const Duration(milliseconds: 100), (_) {
|
||||
@@ -107,7 +115,7 @@ class VoicePlayerService {
|
||||
final clamped = elapsed > _duration ? _duration : elapsed;
|
||||
if (clamped > _position) {
|
||||
_position = clamped;
|
||||
_events.add(null);
|
||||
_emit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user