feat[gallery_extention]: integrate handler for gallery pick intent
This commit is contained in:
parent
6d6afba002
commit
ad63290d47
16 changed files with 147 additions and 64 deletions
1
.env.example
Normal file
1
.env.example
Normal file
|
@ -0,0 +1 @@
|
|||
endpoint=https://dev-api.ente.io/
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -35,3 +35,4 @@ lib/generated_plugin_registrant.dart
|
|||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||
|
||||
android/key.properties
|
||||
.env
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
arguments=
|
||||
auto.sync=false
|
||||
build.scans.enabled=false
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||
connection.project.dir=
|
||||
eclipse.preferences.version=1
|
||||
gradle.user.home=
|
||||
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
|
||||
jvm.arguments=
|
||||
offline.mode=false
|
||||
override.workspace.settings=true
|
||||
show.console.view=true
|
||||
show.executions.view=true
|
|
@ -1,13 +0,0 @@
|
|||
arguments=
|
||||
auto.sync=false
|
||||
build.scans.enabled=false
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
|
||||
connection.project.dir=..
|
||||
eclipse.preferences.version=1
|
||||
gradle.user.home=
|
||||
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
|
||||
jvm.arguments=
|
||||
offline.mode=false
|
||||
override.workspace.settings=true
|
||||
show.console.view=true
|
||||
show.executions.view=true
|
|
@ -79,6 +79,10 @@ android {
|
|||
fdroid {
|
||||
dimension "default"
|
||||
applicationIdSuffix ".fdroid"
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// signingConfig null
|
||||
>>>>>>> 4615956c (feat[gallery_extention]: integrate handler for gallery pick intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,31 @@
|
|||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="ente"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="video/*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PICK" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="video/*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.GET_CONTENT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.OPENABLE" />
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="video/*" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- file provider to share files having a file:// URI -->
|
||||
|
||||
<!--Filter to support sharing images into our app-->
|
||||
<intent-filter android:label="@string/backup">
|
||||
|
@ -54,6 +68,15 @@
|
|||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.file_provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data android:name="flutterEmbedding" android:value="2"/>
|
||||
|
|
11
android/app/src/main/res/xml/provider_paths.xml
Normal file
11
android/app/src/main/res/xml/provider_paths.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<external-path
|
||||
name="external_files"
|
||||
path="." />
|
||||
|
||||
<!-- embedded images & other media that are exported for viewing and sharing -->
|
||||
<cache-path
|
||||
name="embedded"
|
||||
path="." />
|
||||
</paths>
|
|
@ -2,6 +2,7 @@ buildscript {
|
|||
ext.kotlin_version = '1.6.21'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral() //add this line
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
|
61
lib/app.dart
61
lib/app.dart
|
@ -4,17 +4,18 @@ import 'package:adaptive_theme/adaptive_theme.dart';
|
|||
import 'package:background_fetch/background_fetch.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:media_extension/media_extension.dart';
|
||||
import 'package:media_extension/media_extension_action_types.dart';
|
||||
import 'package:photos/ente_theme_data.dart';
|
||||
import 'package:photos/services/app_lifecycle_service.dart';
|
||||
import 'package:photos/services/sync_service.dart';
|
||||
import 'package:photos/ui/home_widget.dart';
|
||||
|
||||
class EnteApp extends StatefulWidget {
|
||||
static const _homeWidget = HomeWidget();
|
||||
|
||||
final Future<void> Function(String) runBackgroundTask;
|
||||
final Future<void> Function(String) killBackgroundTask;
|
||||
|
||||
|
@ -30,33 +31,55 @@ class EnteApp extends StatefulWidget {
|
|||
|
||||
class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
||||
final _logger = Logger("EnteAppState");
|
||||
final _mediaExtensionPlugin = MediaExtension();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_logger.info('init App');
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_configureBackgroundFetch();
|
||||
}
|
||||
|
||||
Future<IntentAction> initIntentAction() async {
|
||||
IntentAction intentAction = IntentAction.main;
|
||||
try {
|
||||
final actionResult = await _mediaExtensionPlugin.getIntentAction();
|
||||
intentAction = actionResult.action!;
|
||||
} on PlatformException {
|
||||
intentAction = IntentAction.unknown;
|
||||
}
|
||||
if (intentAction == IntentAction.main) {
|
||||
_configureBackgroundFetch();
|
||||
}
|
||||
return intentAction;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (Platform.isAndroid || kDebugMode) {
|
||||
return AdaptiveTheme(
|
||||
light: lightThemeData,
|
||||
dark: darkThemeData,
|
||||
initial: AdaptiveThemeMode.system,
|
||||
builder: (lightTheme, dartTheme) => MaterialApp(
|
||||
title: "ente",
|
||||
themeMode: ThemeMode.system,
|
||||
theme: lightTheme,
|
||||
darkTheme: dartTheme,
|
||||
home: EnteApp._homeWidget,
|
||||
debugShowCheckedModeBanner: false,
|
||||
builder: EasyLoading.init(),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
),
|
||||
return FutureBuilder(
|
||||
future: initIntentAction(),
|
||||
builder: (BuildContext context, AsyncSnapshot<IntentAction> snapshot) {
|
||||
return snapshot.data != null
|
||||
? AdaptiveTheme(
|
||||
light: lightThemeData,
|
||||
dark: darkThemeData,
|
||||
initial: AdaptiveThemeMode.system,
|
||||
builder: (lightTheme, dartTheme) => MaterialApp(
|
||||
title: "ente",
|
||||
themeMode: ThemeMode.system,
|
||||
theme: lightTheme,
|
||||
darkTheme: dartTheme,
|
||||
home: HomeWidget(intentAction: snapshot.data!),
|
||||
debugShowCheckedModeBanner: false,
|
||||
builder: EasyLoading.init(),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates:
|
||||
AppLocalizations.localizationsDelegates,
|
||||
),
|
||||
)
|
||||
: Container();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return MaterialApp(
|
||||
|
@ -64,7 +87,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
|||
themeMode: ThemeMode.system,
|
||||
theme: lightThemeData,
|
||||
darkTheme: darkThemeData,
|
||||
home: EnteApp._homeWidget,
|
||||
home: const HomeWidget(intentAction: IntentAction.main),
|
||||
debugShowCheckedModeBanner: false,
|
||||
builder: EasyLoading.init(),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
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';
|
||||
|
@ -18,11 +19,13 @@ 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);
|
||||
|
||||
|
@ -30,6 +33,7 @@ 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 =
|
||||
|
|
|
@ -5,6 +5,7 @@ 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';
|
||||
|
@ -47,7 +48,12 @@ import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
|||
import 'package:uni_links/uni_links.dart';
|
||||
|
||||
class HomeWidget extends StatefulWidget {
|
||||
const HomeWidget({Key? key}) : super(key: key);
|
||||
const HomeWidget({
|
||||
this.intentAction = IntentAction.main,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
final IntentAction intentAction;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _HomeWidgetState();
|
||||
|
@ -362,6 +368,7 @@ class _HomeWidgetState extends State<HomeWidget> {
|
|||
showBackupFolderHook
|
||||
? const StartBackupHookWidget(headerWidget: _headerWidget)
|
||||
: HomeGalleryWidget(
|
||||
intentAction: widget.intentAction,
|
||||
header: _headerWidget,
|
||||
footer: const PreserveFooterWidget(),
|
||||
selectedFiles: _selectedFiles,
|
||||
|
|
|
@ -5,6 +5,8 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:media_extension/media_extension.dart';
|
||||
import 'package:media_extension/media_extension_action_types.dart';
|
||||
import 'package:photos/core/configuration.dart';
|
||||
import 'package:photos/core/constants.dart';
|
||||
import 'package:photos/core/event_bus.dart';
|
||||
|
@ -19,6 +21,7 @@ import 'package:photos/ui/viewer/file/detail_page.dart';
|
|||
import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
|
||||
import 'package:photos/ui/viewer/gallery/gallery.dart';
|
||||
import 'package:photos/utils/date_time_util.dart';
|
||||
import 'package:photos/utils/file_util.dart';
|
||||
import 'package:photos/utils/navigation_util.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
|
||||
|
@ -33,7 +36,7 @@ class LazyLoadingGallery extends StatefulWidget {
|
|||
final String? logTag;
|
||||
final Stream<int> currentIndexStream;
|
||||
final int photoGirdSize;
|
||||
|
||||
final IntentAction intentAction;
|
||||
LazyLoadingGallery(
|
||||
this.files,
|
||||
this.index,
|
||||
|
@ -45,6 +48,7 @@ class LazyLoadingGallery extends StatefulWidget {
|
|||
this.currentIndexStream, {
|
||||
this.logTag = "",
|
||||
this.photoGirdSize = photoGridSizeDefault,
|
||||
this.intentAction = IntentAction.main,
|
||||
Key? key,
|
||||
}) : super(key: key ?? UniqueKey());
|
||||
|
||||
|
@ -258,6 +262,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
|
|||
_toggleSelectAllFromDay,
|
||||
_areAllFromDaySelected,
|
||||
widget.photoGirdSize,
|
||||
intentAction: widget.intentAction,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -286,6 +291,7 @@ class LazyLoadingGridView extends StatefulWidget {
|
|||
final ValueNotifier toggleSelectAllFromDay;
|
||||
final ValueNotifier areAllFilesSelected;
|
||||
final int? photoGridSize;
|
||||
final IntentAction intentAction;
|
||||
|
||||
LazyLoadingGridView(
|
||||
this.tag,
|
||||
|
@ -297,6 +303,7 @@ class LazyLoadingGridView extends StatefulWidget {
|
|||
this.toggleSelectAllFromDay,
|
||||
this.areAllFilesSelected,
|
||||
this.photoGridSize, {
|
||||
this.intentAction = IntentAction.main,
|
||||
Key? key,
|
||||
}) : super(key: key ?? UniqueKey());
|
||||
|
||||
|
@ -308,6 +315,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
|
|||
bool? _shouldRender;
|
||||
int? _currentUserID;
|
||||
late StreamSubscription<ClearSelectionsEvent> _clearSelectionsEvent;
|
||||
final _mediaExtensionPlugin = MediaExtension();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -418,11 +426,16 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
|
|||
selectionColor = avatarColors[(randomID).remainder(avatarColors.length)];
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
if (widget.selectedFiles.files.isNotEmpty) {
|
||||
_selectFile(file);
|
||||
} else {
|
||||
_routeToDetailPage(file, context);
|
||||
if (widget.intentAction == IntentAction.pick) {
|
||||
final ioFile = await getFile(file);
|
||||
_mediaExtensionPlugin.setResult("file://${ioFile!.path}");
|
||||
} else {
|
||||
_routeToDetailPage(file, context);
|
||||
}
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
|
|
|
@ -3,6 +3,7 @@ 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';
|
||||
|
@ -28,6 +29,7 @@ typedef GalleryLoader = Future<FileLoadResult> Function(
|
|||
});
|
||||
|
||||
class Gallery extends StatefulWidget {
|
||||
final IntentAction intentAction;
|
||||
final GalleryLoader asyncLoader;
|
||||
final List<File>? initialFiles;
|
||||
final Stream<FilesUpdatedEvent>? reloadEvent;
|
||||
|
@ -42,6 +44,7 @@ class Gallery extends StatefulWidget {
|
|||
final double scrollBottomSafeArea;
|
||||
|
||||
const Gallery({
|
||||
this.intentAction = IntentAction.main,
|
||||
required this.asyncLoader,
|
||||
required this.selectedFiles,
|
||||
required this.tagPrefix,
|
||||
|
@ -248,6 +251,7 @@ class _GalleryState extends State<Gallery> {
|
|||
.map((event) => event.index),
|
||||
logTag: _logTag,
|
||||
photoGirdSize: _photoGridSize,
|
||||
intentAction: widget.intentAction,
|
||||
);
|
||||
if (widget.header != null && index == 0) {
|
||||
gallery = Column(children: [widget.header!, gallery]);
|
||||
|
|
|
@ -912,8 +912,8 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: "68ffdad3db713b630e0d52edc2a45d23b438de6e"
|
||||
ref: intent-action
|
||||
resolved-ref: "399d5d01340bdc094735e0b1a7e7437b6d389542"
|
||||
url: "https://github.com/ente-io/media_extension.git"
|
||||
source: git
|
||||
version: "0.0.3"
|
||||
|
|
|
@ -77,8 +77,10 @@ dependencies:
|
|||
logging: ^1.0.1
|
||||
lottie: ^1.2.2
|
||||
media_extension:
|
||||
git: "https://github.com/ente-io/media_extension.git"
|
||||
modal_bottom_sheet: ^3.0.0-pre
|
||||
git:
|
||||
url: "https://github.com/ente-io/media_extension.git"
|
||||
ref: "intent-action"
|
||||
modal_bottom_sheet: ^2.1.2
|
||||
motionphoto:
|
||||
git: "https://github.com/ente-io/motionphoto.git"
|
||||
move_to_background: ^1.0.2
|
||||
|
|
15
run.sh
Executable file
15
run.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
FLUTTER_RUN="flutter run --flavor dev "
|
||||
|
||||
if [ ! -z "$1" ]
|
||||
then
|
||||
SUPPLIED_ENV_FILE="$1"
|
||||
while IFS= read -r line
|
||||
do
|
||||
FLUTTER_RUN="$FLUTTER_RUN --dart-define $line"
|
||||
|
||||
done < "$SUPPLIED_ENV_FILE"
|
||||
fi
|
||||
echo "Running: $FLUTTER_RUN"
|
||||
$FLUTTER_RUN
|
Loading…
Add table
Reference in a new issue