diff --git a/android/.project b/android/.project index 3964dd3f5b7fea7ecf391254ba292fcfe96bb513..3b28f0b1febec351d70462f85966494396ff9dad 100644 --- a/android/.project +++ b/android/.project @@ -14,4 +14,15 @@ org.eclipse.buildship.core.gradleprojectnature + + + 1675831639778 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/android/app/.project b/android/app/.project index ac485d7c3e627d997f59da65ac961160079a0143..8f1d5f8a0499bae47131b508cc58a0b27b71893c 100644 --- a/android/app/.project +++ b/android/app/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature org.eclipse.buildship.core.gradleprojectnature + + + 1675831639783 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/android/app/build.gradle b/android/app/build.gradle index 69b4751961efe5164dec074e95470b89e68ae9f1..57bbcb58c5fbe51111f6a3f43dbaec675a786873 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -79,10 +79,7 @@ android { fdroid { dimension "default" applicationIdSuffix ".fdroid" -<<<<<<< HEAD -======= - // signingConfig null ->>>>>>> 4615956c (feat[gallery_extention]: integrate handler for gallery pick intent) + signingConfig null } } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3c042a5a25c48cd77d73f9e1a498ec0ba7cc7aca..ef7502570e0da14af4fca8ad533bb3663321c63f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -68,15 +68,7 @@ - - - + diff --git a/android/build.gradle b/android/build.gradle index d2f33daf008704d498280c259b8bb9b07baac2ed..04b66726331b087cc6fb7c760413664b62b31b71 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,6 @@ buildscript { ext.kotlin_version = '1.6.21' repositories { google() - mavenCentral() //add this line jcenter() } diff --git a/lib/app.dart b/lib/app.dart index 5b8b0477d93244b1b42682a1ab5af05c9d7e37d5..f80ed85df8f431ec7d63328cafdca39bdfd0f993 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -40,7 +40,7 @@ class _EnteAppState extends State with WidgetsBindingObserver { WidgetsBinding.instance.addObserver(this); } - Future initIntentAction() async { + Future initIntentAction() async { IntentAction intentAction = IntentAction.main; try { final actionResult = await _mediaExtensionPlugin.getIntentAction(); @@ -51,7 +51,8 @@ class _EnteAppState extends State with WidgetsBindingObserver { if (intentAction == IntentAction.main) { _configureBackgroundFetch(); } - return intentAction; + AppLifecycleService.instance.setIntentAction(intentAction); + return true; } @override @@ -59,8 +60,8 @@ class _EnteAppState extends State with WidgetsBindingObserver { if (Platform.isAndroid || kDebugMode) { return FutureBuilder( future: initIntentAction(), - builder: (BuildContext context, AsyncSnapshot snapshot) { - return snapshot.data != null + builder: (BuildContext context, AsyncSnapshot snapshot) { + return snapshot.data != null && snapshot.data == true ? AdaptiveTheme( light: lightThemeData, dark: darkThemeData, @@ -70,7 +71,7 @@ class _EnteAppState extends State with WidgetsBindingObserver { themeMode: ThemeMode.system, theme: lightTheme, darkTheme: dartTheme, - home: HomeWidget(intentAction: snapshot.data!), + home: const HomeWidget(), debugShowCheckedModeBanner: false, builder: EasyLoading.init(), supportedLocales: AppLocalizations.supportedLocales, @@ -87,7 +88,7 @@ class _EnteAppState extends State with WidgetsBindingObserver { themeMode: ThemeMode.system, theme: lightThemeData, darkTheme: darkThemeData, - home: const HomeWidget(intentAction: IntentAction.main), + home: const HomeWidget(), debugShowCheckedModeBanner: false, builder: EasyLoading.init(), supportedLocales: AppLocalizations.supportedLocales, diff --git a/lib/services/app_lifecycle_service.dart b/lib/services/app_lifecycle_service.dart index 55c6bf959c9942e2217a139a23fe880a230667b4..58c7619930cb7a2c51e759a3899172e91772dda8 100644 --- a/lib/services/app_lifecycle_service.dart +++ b/lib/services/app_lifecycle_service.dart @@ -1,15 +1,21 @@ import 'package:logging/logging.dart'; +import 'package:media_extension/media_extension_action_types.dart'; class AppLifecycleService { final _logger = Logger("AppLifecycleService"); bool isForeground = false; + IntentAction intentAction = IntentAction.main; static final AppLifecycleService instance = AppLifecycleService._privateConstructor(); AppLifecycleService._privateConstructor(); + void setIntentAction(IntentAction intentAction) { + this.intentAction = intentAction; + } + void onAppInForeground(String reason) { _logger.info("App in foreground via $reason"); isForeground = true; diff --git a/lib/ui/home/home_gallery_widget.dart b/lib/ui/home/home_gallery_widget.dart index 343c78d0156aa00d753daf0fe56776793556759c..bde394a1001c6fd16a9f57ee14bba5b85c3b92d6 100644 --- a/lib/ui/home/home_gallery_widget.dart +++ b/lib/ui/home/home_gallery_widget.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:media_extension/media_extension_action_types.dart'; import 'package:photos/core/configuration.dart'; import 'package:photos/core/event_bus.dart'; import 'package:photos/db/files_db.dart'; @@ -19,13 +18,11 @@ class HomeGalleryWidget extends StatelessWidget { final Widget? header; final Widget? footer; final SelectedFiles selectedFiles; - final IntentAction intentAction; const HomeGalleryWidget({ Key? key, this.header, this.footer, - required this.intentAction, required this.selectedFiles, }) : super(key: key); @@ -33,7 +30,6 @@ class HomeGalleryWidget extends StatelessWidget { Widget build(BuildContext context) { final double bottomSafeArea = MediaQuery.of(context).padding.bottom; final gallery = Gallery( - intentAction: intentAction, asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) async { final ownerID = Configuration.instance.getUserID(); final hasSelectedAllForBackup = diff --git a/lib/ui/home_widget.dart b/lib/ui/home_widget.dart index bbea9be7e1db80067d713781c4e294649773d592..b35d05f95d95b21f0fcf6c6c8d713e4bcbd792c2 100644 --- a/lib/ui/home_widget.dart +++ b/lib/ui/home_widget.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:logging/logging.dart'; -import 'package:media_extension/media_extension_action_types.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:move_to_background/move_to_background.dart'; import 'package:photos/core/configuration.dart'; @@ -49,12 +48,9 @@ import 'package:uni_links/uni_links.dart'; class HomeWidget extends StatefulWidget { const HomeWidget({ - this.intentAction = IntentAction.main, Key? key, }) : super(key: key); - final IntentAction intentAction; - @override State createState() => _HomeWidgetState(); } @@ -368,7 +364,6 @@ class _HomeWidgetState extends State { showBackupFolderHook ? const StartBackupHookWidget(headerWidget: _headerWidget) : HomeGalleryWidget( - intentAction: widget.intentAction, header: _headerWidget, footer: const PreserveFooterWidget(), selectedFiles: _selectedFiles, diff --git a/lib/ui/huge_listview/lazy_loading_gallery.dart b/lib/ui/huge_listview/lazy_loading_gallery.dart index ebebccebfd1d2147c97d253894af91fad064daaa..9baa94d67537c33c5be3ac682202fe0c88c01885 100644 --- a/lib/ui/huge_listview/lazy_loading_gallery.dart +++ b/lib/ui/huge_listview/lazy_loading_gallery.dart @@ -15,6 +15,7 @@ import 'package:photos/events/files_updated_event.dart'; import 'package:photos/extensions/string_ext.dart'; import 'package:photos/models/file.dart'; import 'package:photos/models/selected_files.dart'; +import 'package:photos/services/app_lifecycle_service.dart'; import 'package:photos/theme/ente_theme.dart'; import 'package:photos/ui/huge_listview/place_holder_widget.dart'; import 'package:photos/ui/viewer/file/detail_page.dart'; @@ -36,7 +37,6 @@ class LazyLoadingGallery extends StatefulWidget { final String? logTag; final Stream currentIndexStream; final int photoGirdSize; - final IntentAction intentAction; LazyLoadingGallery( this.files, this.index, @@ -48,7 +48,6 @@ class LazyLoadingGallery extends StatefulWidget { this.currentIndexStream, { this.logTag = "", this.photoGirdSize = photoGridSizeDefault, - this.intentAction = IntentAction.main, Key? key, }) : super(key: key ?? UniqueKey()); @@ -262,7 +261,6 @@ class _LazyLoadingGalleryState extends State { _toggleSelectAllFromDay, _areAllFromDaySelected, widget.photoGirdSize, - intentAction: widget.intentAction, ), ); } @@ -291,7 +289,6 @@ class LazyLoadingGridView extends StatefulWidget { final ValueNotifier toggleSelectAllFromDay; final ValueNotifier areAllFilesSelected; final int? photoGridSize; - final IntentAction intentAction; LazyLoadingGridView( this.tag, @@ -303,7 +300,6 @@ class LazyLoadingGridView extends StatefulWidget { this.toggleSelectAllFromDay, this.areAllFilesSelected, this.photoGridSize, { - this.intentAction = IntentAction.main, Key? key, }) : super(key: key ?? UniqueKey()); @@ -430,7 +426,7 @@ class _LazyLoadingGridViewState extends State { if (widget.selectedFiles.files.isNotEmpty) { _selectFile(file); } else { - if (widget.intentAction == IntentAction.pick) { + if (AppLifecycleService.instance.intentAction == IntentAction.pick) { final ioFile = await getFile(file); _mediaExtensionPlugin.setResult("file://${ioFile!.path}"); } else { @@ -439,8 +435,10 @@ class _LazyLoadingGridViewState extends State { } }, onLongPress: () { - HapticFeedback.lightImpact(); - _selectFile(file); + if (AppLifecycleService.instance.intentAction == IntentAction.main) { + HapticFeedback.lightImpact(); + _selectFile(file); + } }, child: ClipRRect( borderRadius: BorderRadius.circular(1), diff --git a/lib/ui/viewer/gallery/gallery.dart b/lib/ui/viewer/gallery/gallery.dart index cfafe48cb69f369d61765db0d7bcccc2a1efa47c..9fe53a590d86b414120d29bbb1ffc47bcfa641a8 100644 --- a/lib/ui/viewer/gallery/gallery.dart +++ b/lib/ui/viewer/gallery/gallery.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; -import 'package:media_extension/media_extension_action_types.dart'; import 'package:photos/core/constants.dart'; import 'package:photos/core/event_bus.dart'; import 'package:photos/ente_theme_data.dart'; @@ -29,7 +28,6 @@ typedef GalleryLoader = Future Function( }); class Gallery extends StatefulWidget { - final IntentAction intentAction; final GalleryLoader asyncLoader; final List? initialFiles; final Stream? reloadEvent; @@ -44,7 +42,6 @@ class Gallery extends StatefulWidget { final double scrollBottomSafeArea; const Gallery({ - this.intentAction = IntentAction.main, required this.asyncLoader, required this.selectedFiles, required this.tagPrefix, @@ -251,7 +248,6 @@ class _GalleryState extends State { .map((event) => event.index), logTag: _logTag, photoGirdSize: _photoGridSize, - intentAction: widget.intentAction, ); if (widget.header != null && index == 0) { gallery = Column(children: [widget.header!, gallery]);