mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(mobile): Manual asset upload (#3445)
* fix: exclude albums filter in backup provider * refactor: Separate builder methods for Top Control App Bar buttons * fix: Show download button only for Remote only assets * fix(mobile): Force Refresh duration is too low to trigger it consistently * feat(mobile): Make Buttons dynamic in Home Selection DraggableScrollableSheet * feat(mobile): Manual Asset upload * refactor(mobile): Replace _showToast with ImmichToast calls * refactor(mobile): home_page selectionAssetState handling * chore(mobile): min and initial size of DraggableScrollState increased This is to prevent the buttons in the bottom sheet getting clipped behind the 3 way navigation buttons in the default density of Android devices * feat(mobile): notifications for manual upload progress * wording --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
f1b92718d5
commit
deaf81e2a4
27 changed files with 887 additions and 163 deletions
132
mobile/lib/shared/services/local_notification.service.dart
Normal file
132
mobile/lib/shared/services/local_notification.service.dart
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
final localNotificationService = Provider((ref) => LocalNotificationService());
|
||||
|
||||
class LocalNotificationService {
|
||||
static final LocalNotificationService _instance =
|
||||
LocalNotificationService._internal();
|
||||
final FlutterLocalNotificationsPlugin _localNotificationPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
static const manualUploadNotificationID = 4;
|
||||
static const manualUploadDetailedNotificationID = 5;
|
||||
static const manualUploadChannelName = 'Manual Asset Upload';
|
||||
static const manualUploadChannelID = 'immich/manualUpload';
|
||||
static const manualUploadChannelNameDetailed = 'Manual Asset Upload Detailed';
|
||||
static const manualUploadDetailedChannelID = 'immich/manualUploadDetailed';
|
||||
|
||||
factory LocalNotificationService() => _instance;
|
||||
LocalNotificationService._internal();
|
||||
|
||||
Future<void> setup() async {
|
||||
const androidSetting = AndroidInitializationSettings('notification_icon');
|
||||
const iosSetting = DarwinInitializationSettings();
|
||||
|
||||
const initSettings =
|
||||
InitializationSettings(android: androidSetting, iOS: iosSetting);
|
||||
|
||||
await _localNotificationPlugin.initialize(initSettings);
|
||||
}
|
||||
|
||||
Future<void> _showOrUpdateNotification(
|
||||
int id,
|
||||
String channelId,
|
||||
String channelName,
|
||||
String title,
|
||||
String body, {
|
||||
bool? ongoing,
|
||||
bool? playSound,
|
||||
bool? showProgress,
|
||||
Priority? priority,
|
||||
Importance? importance,
|
||||
bool? onlyAlertOnce,
|
||||
int? maxProgress,
|
||||
int? progress,
|
||||
bool? indeterminate,
|
||||
bool? presentBadge,
|
||||
bool? presentBanner,
|
||||
bool? presentList,
|
||||
}) async {
|
||||
var androidNotificationDetails = AndroidNotificationDetails(
|
||||
channelId,
|
||||
channelName,
|
||||
ticker: title,
|
||||
playSound: playSound ?? false,
|
||||
showProgress: showProgress ?? false,
|
||||
maxProgress: maxProgress ?? 0,
|
||||
progress: progress ?? 0,
|
||||
onlyAlertOnce: onlyAlertOnce ?? false,
|
||||
indeterminate: indeterminate ?? false,
|
||||
priority: priority ?? Priority.defaultPriority,
|
||||
importance: importance ?? Importance.defaultImportance,
|
||||
ongoing: ongoing ?? false,
|
||||
);
|
||||
|
||||
var iosNotificationDetails = DarwinNotificationDetails(
|
||||
presentBadge: presentBadge ?? false,
|
||||
presentBanner: presentBanner ?? false,
|
||||
presentList: presentList ?? false,
|
||||
|
||||
);
|
||||
|
||||
final notificationDetails = NotificationDetails(
|
||||
android: androidNotificationDetails,
|
||||
iOS: iosNotificationDetails,
|
||||
);
|
||||
|
||||
await _localNotificationPlugin.show(id, title, body, notificationDetails);
|
||||
}
|
||||
|
||||
Future<void> closeNotification(int id) {
|
||||
return _localNotificationPlugin.cancel(id);
|
||||
}
|
||||
|
||||
Future<void> showOrUpdateManualUploadStatus(
|
||||
String title,
|
||||
String body, {
|
||||
bool? isDetailed,
|
||||
bool? presentBanner,
|
||||
int? maxProgress,
|
||||
int? progress,
|
||||
}) {
|
||||
var notificationlId = manualUploadNotificationID;
|
||||
var channelId = manualUploadChannelID;
|
||||
var channelName = manualUploadChannelName;
|
||||
// Separate Notification for Info/Alerts and Progress
|
||||
if (isDetailed != null && isDetailed) {
|
||||
notificationlId = manualUploadDetailedNotificationID;
|
||||
channelId = manualUploadDetailedChannelID;
|
||||
channelName = manualUploadChannelNameDetailed;
|
||||
}
|
||||
final isProgressNotification = maxProgress != null && progress != null;
|
||||
return isProgressNotification
|
||||
? _showOrUpdateNotification(
|
||||
notificationlId,
|
||||
channelId,
|
||||
channelName,
|
||||
title,
|
||||
body,
|
||||
showProgress: true,
|
||||
onlyAlertOnce: true,
|
||||
maxProgress: maxProgress,
|
||||
progress: progress,
|
||||
indeterminate: false,
|
||||
presentList: true,
|
||||
priority: Priority.low,
|
||||
importance: Importance.low,
|
||||
presentBadge: true,
|
||||
ongoing: true,
|
||||
)
|
||||
: _showOrUpdateNotification(
|
||||
notificationlId,
|
||||
channelId,
|
||||
channelName,
|
||||
title,
|
||||
body,
|
||||
presentList: true,
|
||||
presentBadge: true,
|
||||
presentBanner: presentBanner,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue