diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e7046d210..8d84abb91 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,6 +1,8 @@ PODS: - background_fetch (1.2.1): - Flutter + - battery_info (0.0.1): + - Flutter - connectivity_plus (0.0.1): - Flutter - ReachabilitySwift @@ -213,6 +215,7 @@ PODS: DEPENDENCIES: - background_fetch (from `.symlinks/plugins/background_fetch/ios`) + - battery_info (from `.symlinks/plugins/battery_info/ios`) - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - file_saver (from `.symlinks/plugins/file_saver/ios`) @@ -286,6 +289,8 @@ SPEC REPOS: EXTERNAL SOURCES: background_fetch: :path: ".symlinks/plugins/background_fetch/ios" + battery_info: + :path: ".symlinks/plugins/battery_info/ios" connectivity_plus: :path: ".symlinks/plugins/connectivity_plus/ios" device_info_plus: @@ -377,6 +382,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: background_fetch: 896944864b038d2837fc750d470e9841e1e6a363 + battery_info: 09f5c9ee65394f2291c8c6227bedff345b8a730c connectivity_plus: 53efb943fc2882c8512d84c45707bcabc4c36076 device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea file_saver: 503e386464dbe118f630e17b4c2e1190fa0cf808 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index ea4cd3588..6813056ec 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -276,6 +276,7 @@ "${BUILT_PRODUCTS_DIR}/SentryPrivate/SentryPrivate.framework", "${BUILT_PRODUCTS_DIR}/Toast/Toast.framework", "${BUILT_PRODUCTS_DIR}/background_fetch/background_fetch.framework", + "${BUILT_PRODUCTS_DIR}/battery_info/battery_info.framework", "${BUILT_PRODUCTS_DIR}/connectivity_plus/connectivity_plus.framework", "${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework", "${BUILT_PRODUCTS_DIR}/file_saver/file_saver.framework", @@ -357,6 +358,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SentryPrivate.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Toast.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/background_fetch.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/battery_info.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity_plus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_saver.framework", diff --git a/lib/ui/payment/subscription.dart b/lib/ui/payment/subscription.dart index 0327c3ab5..067a3ae10 100644 --- a/lib/ui/payment/subscription.dart +++ b/lib/ui/payment/subscription.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import 'package:photos/core/configuration.dart'; import 'package:photos/services/feature_flag_service.dart'; import 'package:photos/services/update_service.dart'; import "package:photos/ui/payment/store_subscription_page.dart"; @@ -9,18 +8,9 @@ StatefulWidget getSubscriptionPage({bool isOnBoarding = false}) { if (UpdateService.instance.isIndependentFlavor()) { return StripeSubscriptionPage(isOnboarding: isOnBoarding); } - if (FeatureFlagService.instance.enableStripe() && - _isUserCreatedPostStripeSupport()) { + if (FeatureFlagService.instance.enableStripe()) { return StripeSubscriptionPage(isOnboarding: isOnBoarding); } else { return StoreSubscriptionPage(isOnboarding: isOnBoarding); } } - -// return true if the user was created after we added support for stripe payment -// on frame. We do this check to avoid showing Stripe payment option for earlier -// users who might have paid via playStore. This method should be removed once -// we have better handling for active play/app store subscription & stripe plans. -bool _isUserCreatedPostStripeSupport() { - return Configuration.instance.getUserID()! > 1580559962386460; -} diff --git a/lib/ui/viewer/file/video_widget_new.dart b/lib/ui/viewer/file/video_widget_new.dart index 018a6f658..ae0462c66 100644 --- a/lib/ui/viewer/file/video_widget_new.dart +++ b/lib/ui/viewer/file/video_widget_new.dart @@ -252,10 +252,14 @@ class _VideoWidgetNewState extends State void _setVideoController(String url) { if (mounted) { - setState(() { - player.setPlaylistMode(PlaylistMode.single); - controller = VideoController(player); - player.open(Media(url), play: _isAppInFG); + setState(() async { + try { + await player.setPlaylistMode(PlaylistMode.single); + controller = VideoController(player); + await player.open(Media(url), play: _isAppInFG); + } catch (e, s) { + _logger.severe("failed to set video url", e, s); + } }); } } diff --git a/lib/utils/file_uploader.dart b/lib/utils/file_uploader.dart index 653b5076b..13d109b7a 100644 --- a/lib/utils/file_uploader.dart +++ b/lib/utils/file_uploader.dart @@ -10,6 +10,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import 'package:photos/core/configuration.dart'; +import "package:photos/core/constants.dart"; import 'package:photos/core/errors.dart'; import 'package:photos/core/event_bus.dart'; import 'package:photos/core/network/network.dart'; @@ -34,6 +35,7 @@ import "package:photos/services/user_service.dart"; import 'package:photos/utils/crypto_util.dart'; import 'package:photos/utils/file_download_util.dart'; import 'package:photos/utils/file_uploader_util.dart'; +import "package:photos/utils/file_util.dart"; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tuple/tuple.dart'; import "package:uuid/uuid.dart"; @@ -307,12 +309,36 @@ class FileUploader { return file.path.contains(kUploadTempPrefix) && file.path.contains(".encrypted"); }); - if (filesToDelete.isEmpty) { - return; + if (filesToDelete.isNotEmpty) { + _logger.info('cleaning up state files ${filesToDelete.length}'); + for (final file in filesToDelete) { + await file.delete(); + } } - _logger.info('cleaning up state files ${filesToDelete.length}'); - for (final file in filesToDelete) { - await file.delete(); + + if (Platform.isAndroid) { + final sharedMediaDir = + Configuration.instance.getSharedMediaDirectory() + "/"; + final sharedFiles = await Directory(sharedMediaDir).list().toList(); + if (sharedFiles.isNotEmpty) { + _logger.info('Shared media directory cleanup ${sharedFiles.length}'); + final int ownerID = Configuration.instance.getUserID()!; + final existingLocalFileIDs = + await FilesDB.instance.getExistingLocalFileIDs(ownerID); + final Set trackedSharedFilePaths = {}; + for (String localID in existingLocalFileIDs) { + if (localID.contains(sharedMediaIdentifier)) { + trackedSharedFilePaths + .add(getSharedMediaPathFromLocalID(localID)); + } + } + for (final file in sharedFiles) { + if (!trackedSharedFilePaths.contains(file.path)) { + _logger.info('Deleting stale shared media file ${file.path}'); + await file.delete(); + } + } + } } } catch (e, s) { _logger.severe("Failed to remove stale files", e, s);