Switch to wechat asset picker
This commit is contained in:
parent
9c5bdac42e
commit
3edee600e6
9 changed files with 42 additions and 186 deletions
|
@ -94,8 +94,6 @@ PODS:
|
|||
- GoogleUtilities/Logger
|
||||
- image_editor_common (1.0.0):
|
||||
- Flutter
|
||||
- image_picker_ios (0.0.1):
|
||||
- Flutter
|
||||
- in_app_purchase_storekit (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
|
@ -200,7 +198,6 @@ DEPENDENCIES:
|
|||
- flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`)
|
||||
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
|
||||
- image_editor_common (from `.symlinks/plugins/image_editor_common/ios`)
|
||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||
- in_app_purchase_storekit (from `.symlinks/plugins/in_app_purchase_storekit/darwin`)
|
||||
- integration_test (from `.symlinks/plugins/integration_test/ios`)
|
||||
- local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`)
|
||||
|
@ -281,8 +278,6 @@ EXTERNAL SOURCES:
|
|||
:path: ".symlinks/plugins/fluttertoast/ios"
|
||||
image_editor_common:
|
||||
:path: ".symlinks/plugins/image_editor_common/ios"
|
||||
image_picker_ios:
|
||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||
in_app_purchase_storekit:
|
||||
:path: ".symlinks/plugins/in_app_purchase_storekit/darwin"
|
||||
integration_test:
|
||||
|
@ -354,7 +349,6 @@ SPEC CHECKSUMS:
|
|||
GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2
|
||||
GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084
|
||||
image_editor_common: d6f6644ae4a6de80481e89fe6d0a8c49e30b4b43
|
||||
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
|
||||
in_app_purchase_storekit: 4fb7ee9e824b1f09107fbfbbce8c4b276366dc43
|
||||
integration_test: 13825b8a9334a850581300559b8839134b124670
|
||||
libwebp: 33dc822fbbf4503668d09f7885bbfedc76c45e96
|
||||
|
|
|
@ -289,7 +289,6 @@
|
|||
"${BUILT_PRODUCTS_DIR}/flutter_sodium/flutter_sodium.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/image_editor_common/image_editor_common.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/in_app_purchase_storekit/in_app_purchase_storekit.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework",
|
||||
|
@ -347,7 +346,6 @@
|
|||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_sodium.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_editor_common.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/in_app_purchase_storekit.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
|
|
|
@ -346,15 +346,15 @@ class CollectionsService {
|
|||
Future<List<Collection>> getCollectionForOnEnteSection() async {
|
||||
final AlbumSortKey sortKey = LocalSettings.instance.albumSortKey();
|
||||
final List<Collection> collections =
|
||||
CollectionsService.instance.getCollectionsForUI();
|
||||
CollectionsService.instance.getCollectionsForUI();
|
||||
final bool hasFavorites = FavoritesService.instance.hasFavorites();
|
||||
late Map<int, int> collectionIDToNewestPhotoTime;
|
||||
if (sortKey == AlbumSortKey.newestPhoto) {
|
||||
collectionIDToNewestPhotoTime =
|
||||
await CollectionsService.instance.getCollectionIDToNewestFileTime();
|
||||
await CollectionsService.instance.getCollectionIDToNewestFileTime();
|
||||
}
|
||||
collections.sort(
|
||||
(first, second) {
|
||||
(first, second) {
|
||||
if (sortKey == AlbumSortKey.albumName) {
|
||||
return compareAsciiLowerCaseNatural(
|
||||
first.displayName,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import "package:image_picker/image_picker.dart";
|
||||
import "package:photo_manager/photo_manager.dart";
|
||||
import "package:photos/core/configuration.dart";
|
||||
import "package:photos/core/event_bus.dart";
|
||||
import "package:photos/db/files_db.dart";
|
||||
|
@ -83,7 +83,7 @@ extension CollectionFileActions on CollectionActions {
|
|||
bool showProgressDialog, {
|
||||
List<File>? selectedFiles,
|
||||
List<SharedMediaFile>? sharedFiles,
|
||||
List<XFile>? pickedFiles,
|
||||
List<AssetEntity>? picketAssets,
|
||||
}) async {
|
||||
ProgressDialog? dialog = showProgressDialog
|
||||
? createProgressDialog(
|
||||
|
@ -104,10 +104,10 @@ extension CollectionFileActions on CollectionActions {
|
|||
collectionID,
|
||||
),
|
||||
);
|
||||
} else if (pickedFiles != null) {
|
||||
} else if (picketAssets != null) {
|
||||
filesPendingUpload.addAll(
|
||||
await convertPickedFiles(
|
||||
pickedFiles,
|
||||
await convertPicketAssets(
|
||||
picketAssets,
|
||||
collectionID,
|
||||
),
|
||||
);
|
||||
|
@ -159,6 +159,9 @@ extension CollectionFileActions on CollectionActions {
|
|||
files.add(uploadedFile);
|
||||
}
|
||||
} else {
|
||||
for(final file in filesPendingUpload) {
|
||||
file.collectionID = collectionID;
|
||||
}
|
||||
// filesPendingUpload might be getting ignored during auto-upload
|
||||
// because the user deleted these files from ente in the past.
|
||||
await IgnoredFilesService.instance
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import "dart:math";
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:image_picker/image_picker.dart";
|
||||
import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
|
||||
import "package:photos/core/configuration.dart";
|
||||
import "package:photos/db/files_db.dart";
|
||||
|
@ -19,6 +18,7 @@ import "package:photos/ui/components/buttons/button_widget.dart";
|
|||
import "package:photos/ui/components/models/button_type.dart";
|
||||
import "package:photos/ui/components/title_bar_title_widget.dart";
|
||||
import "package:photos/ui/viewer/gallery/gallery.dart";
|
||||
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
||||
|
||||
Future<dynamic> showAddPhotosSheet(
|
||||
BuildContext context,
|
||||
|
@ -167,16 +167,8 @@ class AddPhotosPhotoWidget extends StatelessWidget {
|
|||
buttonAction: ButtonAction.second,
|
||||
labelText: S.of(context).addFromDevice,
|
||||
onTap: () async {
|
||||
final ImagePicker picker = ImagePicker();
|
||||
final pickedFiles =
|
||||
await picker.pickMultipleMedia();
|
||||
if (pickedFiles.isNotEmpty) {
|
||||
for (XFile f in pickedFiles) {
|
||||
// print XFile f details
|
||||
debugPrint(f.name);
|
||||
debugPrint(f.path);
|
||||
debugPrint(f.mimeType);
|
||||
}
|
||||
final List<AssetEntity>? result = await AssetPicker.pickAssets(context);
|
||||
if(result != null && result.isNotEmpty) {
|
||||
final ca = CollectionActions(
|
||||
CollectionsService.instance,
|
||||
);
|
||||
|
@ -184,7 +176,7 @@ class AddPhotosPhotoWidget extends StatelessWidget {
|
|||
context,
|
||||
collection.id,
|
||||
false,
|
||||
pickedFiles: pickedFiles,
|
||||
picketAssets: result,
|
||||
);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
|
|
|
@ -34,6 +34,7 @@ class MediaUploadData {
|
|||
final FileHashData? hashData;
|
||||
final int? height;
|
||||
final int? width;
|
||||
|
||||
// For android motion photos, the startIndex is the index of the first frame
|
||||
// For iOS, this value will be always null.
|
||||
final int? motionPhotoStartIndex;
|
||||
|
|
|
@ -2,9 +2,9 @@ import 'dart:async';
|
|||
import 'dart:io' as dartio;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import "package:image_picker/image_picker.dart";
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart';
|
||||
import "package:photo_manager/photo_manager.dart";
|
||||
import 'package:photos/core/configuration.dart';
|
||||
import 'package:photos/core/constants.dart';
|
||||
import 'package:photos/models/file.dart';
|
||||
|
@ -149,62 +149,13 @@ Future<List<File>> convertIncomingSharedMediaToFile(
|
|||
return localFiles;
|
||||
}
|
||||
|
||||
Future<List<File>> convertPickedFiles(
|
||||
List<XFile> pickedFiles,
|
||||
Future<List<File>> convertPicketAssets(
|
||||
List<AssetEntity> pickedAssets,
|
||||
int collectionID,
|
||||
) async {
|
||||
final List<File> localFiles = [];
|
||||
for (var media in pickedFiles) {
|
||||
FileType? enteTypeType;
|
||||
final String mimeType = (media.mimeType ?? '').toLowerCase();
|
||||
if (mimeType.contains('image')) {
|
||||
enteTypeType = FileType.image;
|
||||
} else if (mimeType.contains('video')) {
|
||||
enteTypeType = FileType.video;
|
||||
} else {
|
||||
final extenName = extension(media.path ?? '').toLowerCase().replaceFirst(
|
||||
'.',
|
||||
'',
|
||||
);
|
||||
if (_imageExtension.contains(extenName)) {
|
||||
enteTypeType = FileType.image;
|
||||
} else if (_videoExtension.contains(extenName)) {
|
||||
enteTypeType = FileType.video;
|
||||
} else {
|
||||
_logger.warning(
|
||||
"ignore file type ${media.mimeType}, extn $extenName path: ${media.path}",
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
final enteFile = File();
|
||||
// fileName: img_x.jpg
|
||||
enteFile.title = basename(media.path);
|
||||
var ioFile = dartio.File(media.path);
|
||||
ioFile = ioFile.renameSync(
|
||||
Configuration.instance.getSharedMediaDirectory() + "/" + enteFile.title!,
|
||||
);
|
||||
enteFile.localID = sharedMediaIdentifier + enteFile.title!;
|
||||
enteFile.collectionID = collectionID;
|
||||
enteFile.fileType = enteTypeType;
|
||||
if (enteFile.fileType == FileType.image) {
|
||||
final exifTime = await getCreationTimeFromEXIF(ioFile, null);
|
||||
if (exifTime != null) {
|
||||
enteFile.creationTime = exifTime.microsecondsSinceEpoch;
|
||||
}
|
||||
} else if (enteFile.fileType == FileType.video) {
|
||||
// enteFile.duration = (media.duration ?? 0) ~/ 1000;
|
||||
}
|
||||
if (enteFile.creationTime == null || enteFile.creationTime == 0) {
|
||||
final parsedDateTime =
|
||||
parseDateTimeFromFileNameV2(basenameWithoutExtension(media.path));
|
||||
if (parsedDateTime != null) {
|
||||
enteFile.creationTime = parsedDateTime.microsecondsSinceEpoch;
|
||||
} else {
|
||||
enteFile.creationTime = DateTime.now().microsecondsSinceEpoch;
|
||||
}
|
||||
}
|
||||
enteFile.modificationTime = enteFile.creationTime;
|
||||
for (var asset in pickedAssets) {
|
||||
final enteFile = await File.fromAsset('', asset);
|
||||
localFiles.add(enteFile);
|
||||
}
|
||||
return localFiles;
|
||||
|
|
116
pubspec.lock
116
pubspec.lock
|
@ -523,38 +523,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
file_selector_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_linux
|
||||
sha256: "770eb1ab057b5ae4326d1c24cc57710758b9a46026349d021d6311bd27580046"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.2"
|
||||
file_selector_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_macos
|
||||
sha256: "7a6f1ae6107265664f3f7f89a66074882c4d506aef1441c9af313c1f7e6f41ce"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3"
|
||||
file_selector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_platform_interface
|
||||
sha256: "412705a646a0ae90f33f37acfae6a0f7cbc02222d6cd34e479421c3e74d3853c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
file_selector_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_windows
|
||||
sha256: "1372760c6b389842b77156203308940558a2817360154084368608413835fc26"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3"
|
||||
firebase_core:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -1009,70 +977,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
image_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image_picker
|
||||
sha256: b9603755b35253ccfad4be0762bb74d5e8bf9ff75edebf0ac3beec24fac1c5b5
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
image_picker_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: d2bab152deb2547ea6f53d82ebca9b7e77386bb706e5789e815d37e08ea475bb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.7+3"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_for_web
|
||||
sha256: "869fe8a64771b7afbc99fc433a5f7be2fea4d1cb3d7c11a48b6b579eb9c797f0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
image_picker_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_ios
|
||||
sha256: b3e2f21feb28b24dd73a35d7ad6e83f568337c70afab5eabac876e23803f264b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.8"
|
||||
image_picker_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_linux
|
||||
sha256: "02cbc21fe1706b97942b575966e5fbbeaac535e76deef70d3a242e4afb857831"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
image_picker_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_macos
|
||||
sha256: cee2aa86c56780c13af2c77b5f2f72973464db204569e1ba2dd744459a065af4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
image_picker_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_platform_interface
|
||||
sha256: "7c7b96bb9413a9c28229e717e6fd1e3edd1cc5569c1778fcca060ecf729b65ee"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.8.0"
|
||||
image_picker_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_windows
|
||||
sha256: c3066601ea42113922232c7b7b3330a2d86f029f685bba99d82c30e799914952
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
in_app_purchase:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -2147,10 +2051,10 @@ packages:
|
|||
description:
|
||||
path: "packages/video_player/video_player"
|
||||
ref: android_video_roation_fix
|
||||
resolved-ref: a9be78ffe97b9335bcf865c72dae1ba361dad77f
|
||||
resolved-ref: "0acef25ca43206e02a0758b51d5fd176e3d8c6b8"
|
||||
url: "https://github.com/ente-io/packages.git"
|
||||
source: git
|
||||
version: "2.6.1"
|
||||
version: "2.7.0"
|
||||
video_player_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -2163,18 +2067,18 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: video_player_avfoundation
|
||||
sha256: "4c274e439f349a0ee5cb3c42978393ede173a443b98f50de6ffe6900eaa19216"
|
||||
sha256: f5f5b7fe8c865be8a57fe80c2dca130772e1db775b7af4e5c5aa1905069cfc6c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.6"
|
||||
version: "2.4.9"
|
||||
video_player_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: video_player_platform_interface
|
||||
sha256: a8c4dcae2a7a6e7cc1d7f9808294d968eca1993af34a98e95b9bdfa959bec684
|
||||
sha256: "1ca9acd7a0fb15fb1a990cb554e6f004465c6f37c99d2285766f08a4b2802988"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
version: "6.2.0"
|
||||
video_player_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -2263,6 +2167,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
wechat_assets_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: wechat_assets_picker
|
||||
sha256: "18a9ac99281ed033fc3bfd2cf7d39f2ef4b76a7601eafcf4c9de09392c65c713"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.6.3"
|
||||
widgets_to_image:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -78,7 +78,6 @@ dependencies:
|
|||
http: ^0.13.4
|
||||
image: ^3.0.2
|
||||
image_editor: ^1.3.0
|
||||
image_picker: ^1.0.0
|
||||
in_app_purchase: ^3.0.7
|
||||
intl: ^0.18.0
|
||||
json_annotation: ^4.8.0
|
||||
|
@ -137,11 +136,12 @@ dependencies:
|
|||
git:
|
||||
url: https://github.com/ente-io/packages.git
|
||||
ref: android_video_roation_fix
|
||||
path: packages/video_player/video_player/
|
||||
path: packages/video_player/video_player/p
|
||||
video_thumbnail: ^0.5.3
|
||||
visibility_detector: ^0.3.3
|
||||
wakelock_plus: ^1.1.1
|
||||
wallpaper_manager_flutter: ^0.0.2
|
||||
wechat_assets_picker: ^8.6.3
|
||||
widgets_to_image: ^0.0.2
|
||||
|
||||
dependency_overrides:
|
||||
|
@ -149,6 +149,11 @@ dependency_overrides:
|
|||
# but we need ffi: ^2.0.1 for newer packages. The original tfite_flutter_helper
|
||||
#
|
||||
ffi: ^2.0.1
|
||||
video_player:
|
||||
git:
|
||||
url: https://github.com/ente-io/packages.git
|
||||
ref: android_video_roation_fix
|
||||
path: packages/video_player/video_player/
|
||||
|
||||
flutter_intl:
|
||||
enabled: true
|
||||
|
|
Loading…
Add table
Reference in a new issue