diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index e78a08d..ae6fa56 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -31,6 +31,12 @@
+
+
+
+
+
+
diff --git a/android/app/src/main/kotlin/com/humhub/humhub/MainActivity.kt b/android/app/src/main/kotlin/com/humhub/humhub/MainActivity.kt
index 1526a55..7696cf3 100644
--- a/android/app/src/main/kotlin/com/humhub/humhub/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/humhub/humhub/MainActivity.kt
@@ -1,6 +1,16 @@
package com.humhub.app
-
+import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
+import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
class MainActivity: FlutterActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ if (intent.getIntExtra("org.chromium.chrome.extra.TASK_ID", -1) == this.taskId) {
+ this.finish()
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ }
+ super.onCreate(savedInstanceState)
+ }
}
diff --git a/lib/main.dart b/lib/main.dart
index dc6c584..5e126fd 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,13 +1,42 @@
+import 'dart:async';
+
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/util/redirect_handler.dart';
+import 'package:receive_sharing_intent/receive_sharing_intent.dart';
void main() {
runApp(const ProviderScope(child: MyApp()));
}
-class MyApp extends StatelessWidget {
- const MyApp({Key? key}) : super(key: key);
+class MyApp extends StatefulWidget {
+ const MyApp({super.key});
+
+ @override
+ MyAppState createState() => MyAppState();
+}
+
+class MyAppState extends State {
+ StreamSubscription? intentDataStreamSubscription;
+ List? sharedFiles;
+
+ @override
+ void initState() {
+ super.initState();
+ intentDataStreamSubscription = ReceiveSharingIntent.getMediaStream()
+ .listen((List value) {
+ setState(() {
+ sharedFiles = value;
+ });
+ });
+
+ // For sharing images coming from outside the app while the app is closed
+ ReceiveSharingIntent.getInitialMedia().then((List value) {
+ setState(() {
+ sharedFiles = value;
+ });
+ });
+ }
@override
Widget build(BuildContext context) {
diff --git a/pubspec.lock b/pubspec.lock
index 4a8bae4..559132e 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -62,6 +62,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ flutter_inappwebview:
+ dependency: "direct main"
+ description:
+ name: flutter_inappwebview
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "5.7.2+3"
flutter_lints:
dependency: "direct dev"
description:
@@ -226,6 +233,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
+ receive_sharing_intent:
+ dependency: "direct main"
+ description:
+ name: receive_sharing_intent
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.4.5"
riverpod:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index f4a5684..99360d6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -42,6 +42,8 @@ dependencies:
flutter_riverpod: ^2.1.3
permission_handler: ^10.2.0
flutter_secure_storage: ^7.0.1
+ flutter_inappwebview: ^5.7.2+3
+ receive_sharing_intent: ^1.4.5
dev_dependencies:
flutter_test: