Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Merge main and preserve device picker integration

r4khul383caad0f5ee
diff --cc mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart
index cf84d87c63,e19a124b14..a460343a4b
--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart
@@@ -12,7 -16,7 +12,8 @@@ import "package:photos/services/collect
import "package:photos/services/filter/db_filters.dart";
import "package:photos/ui/actions/collection/collection_file_actions.dart";
import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
+ import "package:photos/ui/components/bottom_action_bar/action_bar_widget.dart";
+import "package:photos/ui/device_picker/device_picker_page.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
import "package:photos/ui/viewer/gallery/state/boundary_reporter_mixin.dart";
import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";
@@@ -174,12 -217,89 +212,16 @@@ class _AddPhotosPhotoWidgetState extend
}
Future<void> _onPickFromDeviceClicked(BuildContext context) async {
- try {
- final assetPickerTextDelegate = await _getAssetPickerTextDelegate();
- if (!context.mounted) return;
- final List<AssetEntity>? result = await AssetPicker.pickAssets(
- context,
- pickerConfig: AssetPickerConfig(
- keepScrollOffset: true,
- maxAssets: maxPickAssetLimit,
- textDelegate: assetPickerTextDelegate,
- gridCount: 6,
- pageSize: 120,
- ),
- );
- if (result != null && result.isNotEmpty) {
- final ca = CollectionActions(CollectionsService.instance);
- if (!context.mounted) return;
- await ca.addToCollection(
+ final result = await showDevicePicker(context);
+ if (!context.mounted || result == null || result.isEmpty) return;
- final added = await CollectionActions(
- CollectionsService.instance,
- ).addToCollection(context, collection.id, false, picketAssets: result);
++ final added = await CollectionActions(CollectionsService.instance)
++ .addToCollection(
+ context,
+ widget.collection.id,
+ false,
+ picketAssets: result,
+ );
- if (!context.mounted) return;
- Navigator.of(context).pop();
- }
- } catch (e) {
- if (e is StateError) {
- final PermissionState ps = await permissionService
- .requestPhotoMangerPermissions();
- if (ps != PermissionState.authorized && ps != PermissionState.limited) {
- if (!context.mounted) return;
- await showChoiceDialog(
- context,
- title: context.strings.grantPermission,
- body: context.strings.pleaseGrantPermissions,
- firstButtonLabel: context.strings.ok,
- secondButtonLabel: context.strings.cancel,
- firstButtonOnTap: () async {
- await PhotoManager.openSetting();
- },
- );
- } else {
- if (!context.mounted) return;
- await showErrorDialog(
- context,
- context.strings.oops,
- context.strings.somethingWentWrong + (kDebugMode ? "\n$e" : ""),
- );
- }
- }
- }
- }
-
- // AssetPicker's fallback is Chinese. Unsupported locales use its English
- // delegate.
- Future<AssetPickerTextDelegate> _getAssetPickerTextDelegate() async {
- final Locale locale = (await getLocale())!;
- switch (locale.languageCode.toLowerCase()) {
- case "en":
- return const EnglishAssetPickerTextDelegate();
- case "he":
- return const HebrewAssetPickerTextDelegate();
- case "de":
- return const GermanAssetPickerTextDelegate();
- case "ru":
- return const RussianAssetPickerTextDelegate();
- case "ja":
- return const JapaneseAssetPickerTextDelegate();
- case "ar":
- return const ArabicAssetPickerTextDelegate();
- case "fr":
- return const FrenchAssetPickerTextDelegate();
- case "vi":
- return const VietnameseAssetPickerTextDelegate();
- case "tr":
- return const TurkishAssetPickerTextDelegate();
- case "ko":
- return const KoreanAssetPickerTextDelegate();
- case "zh":
- return const AssetPickerTextDelegate();
- default:
- return const EnglishAssetPickerTextDelegate();
- }
+ if (context.mounted && added) Navigator.of(context).pop();
}
}