Skip to content

Commit

Permalink
Merge pull request #230 from humhub/f-links-to-humhub-files-are-not-c…
Browse files Browse the repository at this point in the history
…lickable

Add extended storage permission handler for ios and android.
  • Loading branch information
luke- authored Sep 23, 2024
2 parents eca5fce + 05654be commit 910914a
Show file tree
Hide file tree
Showing 25 changed files with 317 additions and 186 deletions.
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

<!-- For older versions (For Android 12 (API 31) and Below) -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:label="HumHub"
android:name="${applicationName}"
Expand Down
21 changes: 6 additions & 15 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 5439UTM27E;
DEVELOPMENT_TEAM = 5439UTM27E;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = HumHub;
Expand All @@ -407,7 +405,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.humhub.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = humhub_distribution_profile;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand Down Expand Up @@ -536,11 +533,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 5439UTM27E;
DEVELOPMENT_TEAM = 5439UTM27E;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = HumHub;
Expand All @@ -553,7 +548,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.humhub.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = humhub_distribution_profile;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand All @@ -574,11 +568,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 5439UTM27E;
DEVELOPMENT_TEAM = 5439UTM27E;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = HumHub;
Expand All @@ -591,7 +583,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.humhub.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = humhub_distribution_profile;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand Down
6 changes: 6 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,11 @@
<string>14.4</string>
<key>FLTEnableImpeller</key>
<false />
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to save photos and videos.</string>
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
</dict>
</plist>
1 change: 1 addition & 0 deletions ios/build/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e728d5ba4e52068eb059d8c80cc8e750
14 changes: 8 additions & 6 deletions lib/app_flavored.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/flavored/models/humhub.f.dart';
import 'package:humhub/flavored/util/intent_plugin.f.dart';
import 'package:humhub/flavored/util/router.f.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/loading_provider.dart';
import 'package:humhub/util/notifications/plugin.dart';
import 'package:humhub/util/override_locale.dart';
import 'package:humhub/util/permission_handler.dart';
import 'package:humhub/util/push/push_plugin.dart';
import 'package:humhub/util/storage_service.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -24,10 +26,10 @@ class FlavoredAppState extends ConsumerState<FlavoredApp> {
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
final status = await Permission.notification.status;
if (!status.isGranted) {
await Permission.notification.request();
}
await PermissionHandler.requestPermissions([
Permission.notification,
Permission.manageExternalStorage,
]);
});
}

Expand All @@ -41,13 +43,13 @@ class FlavoredAppState extends ConsumerState<FlavoredApp> {
child: OverrideLocale(
builder: (overrideLocale) => Builder(
builder: (context) => MaterialApp(
scaffoldMessengerKey: scaffoldMessengerStateKeyF,
scaffoldMessengerKey: scaffoldMessengerStateKey,
debugShowCheckedModeBanner: false,
initialRoute: RouterF.initRoute,
routes: RouterF.routes,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
navigatorKey: navigatorKeyF,
navigatorKey: navigatorKey,
builder: (context, child) => child!,
theme: ThemeData(
fontFamily: 'OpenSans',
Expand Down
10 changes: 6 additions & 4 deletions lib/app_opener.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/intent/intent_plugin.dart';
import 'package:humhub/util/loading_provider.dart';
import 'package:humhub/util/notifications/plugin.dart';
import 'package:humhub/util/override_locale.dart';
import 'package:humhub/util/permission_handler.dart';
import 'package:humhub/util/push/push_plugin.dart';
import 'package:humhub/util/router.dart';
import 'package:humhub/util/storage_service.dart';
Expand All @@ -23,10 +25,10 @@ class OpenerAppState extends ConsumerState<OpenerApp> {
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
final status = await Permission.notification.status;
if (!status.isGranted) {
await Permission.notification.request();
}
await PermissionHandler.requestPermissions([
Permission.notification,
Permission.manageExternalStorage,
]);
});
}

Expand Down
12 changes: 6 additions & 6 deletions lib/flavored/util/intent_plugin.f.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/flavored/util/router.f.dart';
import 'package:humhub/flavored/web_view.f.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/loading_provider.dart';
import 'package:loggy/loggy.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
Expand Down Expand Up @@ -68,7 +68,7 @@ class IntentPluginFState extends ConsumerState<IntentPluginF> {
if (!mounted) return;
_latestUri = uri;
String? redirectUrl = uri?.toString();
if (redirectUrl != null && navigatorKeyF.currentState != null) {
if (redirectUrl != null && navigatorKey.currentState != null) {
tryNavigateWithOpener(redirectUrl);
}
_err = null;
Expand Down Expand Up @@ -103,11 +103,11 @@ class IntentPluginFState extends ConsumerState<IntentPluginF> {
}
_latestUri = uri;
String? redirectUrl = uri.queryParameters['url'];
if (redirectUrl != null && navigatorKeyF.currentState != null) {
if (redirectUrl != null && navigatorKey.currentState != null) {
tryNavigateWithOpener(redirectUrl);
} else {
if (redirectUrl != null) {
navigatorKeyF.currentState!.pushNamed(WebViewF.path, arguments: redirectUrl);
navigatorKey.currentState!.pushNamed(WebViewF.path, arguments: redirectUrl);
return;
}
}
Expand All @@ -125,13 +125,13 @@ class IntentPluginFState extends ConsumerState<IntentPluginF> {
Future<bool> tryNavigateWithOpener(String redirectUrl) async {
LoadingProvider.of(ref).showLoading();
bool isNewRouteSameAsCurrent = false;
navigatorKeyF.currentState!.popUntil((route) {
navigatorKey.currentState!.popUntil((route) {
if (route.settings.name == WebViewF.path) {
isNewRouteSameAsCurrent = true;
}
return true;
});
navigatorKeyF.currentState!.pushNamed(WebViewF.path, arguments: redirectUrl);
navigatorKey.currentState!.pushNamed(WebViewF.path, arguments: redirectUrl);
return isNewRouteSameAsCurrent;
}
}
10 changes: 5 additions & 5 deletions lib/flavored/util/notifications/channel.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:humhub/flavored/util/router.f.dart';
import 'package:humhub/flavored/web_view.f.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/notifications/channel.dart';
import 'package:humhub/util/notifications/init_from_push.dart';

Expand All @@ -14,19 +14,19 @@ class NotificationChannelF extends NotificationChannel {
///
@override
Future<void> onTap(String? payload) async {
if (payload != null && navigatorKeyF.currentState != null) {
if (payload != null && navigatorKey.currentState != null) {
bool isNewRouteSameAsCurrent = false;
navigatorKeyF.currentState!.popUntil((route) {
navigatorKey.currentState!.popUntil((route) {
if (route.settings.name == WebViewF.path) {
isNewRouteSameAsCurrent = true;
}
return true;
});
if (isNewRouteSameAsCurrent) {
navigatorKeyF.currentState!.pushNamed(WebViewF.path, arguments: payload);
navigatorKey.currentState!.pushNamed(WebViewF.path, arguments: payload);
return;
}
navigatorKeyF.currentState!.pushNamed(WebViewF.path, arguments: payload);
navigatorKey.currentState!.pushNamed(WebViewF.path, arguments: payload);
} else {
if (payload != null) {
InitFromPush.setPayload(payload);
Expand Down
6 changes: 2 additions & 4 deletions lib/flavored/util/router.f.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:humhub/flavored/web_view.f.dart';
import 'package:humhub/util/const.dart';

final GlobalKey<NavigatorState> navigatorKeyF = GlobalKey<NavigatorState>();
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerStateKeyF = GlobalKey<ScaffoldMessengerState>();

NavigatorState? get navigator => navigatorKeyF.currentState;
NavigatorState? get navigator => navigatorKey.currentState;

class RouterF {
static String? initRoute = WebViewF.path;
Expand Down
6 changes: 3 additions & 3 deletions lib/flavored/web_view.f.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/app_flavored.dart';
import 'package:humhub/flavored/models/humhub.f.dart';
import 'package:humhub/flavored/util/router.f.dart';
import 'package:humhub/util/auth_in_app_browser.dart';
import 'package:humhub/models/channel_message.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/extensions.dart';
import 'package:humhub/util/loading_provider.dart';
import 'package:humhub/util/notifications/init_from_push.dart';
Expand Down Expand Up @@ -279,7 +279,7 @@ class FlavoredWebViewState extends ConsumerState<WebViewF> {
downloadStartRequest: downloadStartRequest,
controller: controller,
onSuccess: (File file, String filename) {
scaffoldMessengerStateKeyF.currentState?.showSnackBar(
scaffoldMessengerStateKey.currentState?.showSnackBar(
SnackBar(
content: Text('${AppLocalizations.of(context)!.file_download}: $filename'),
action: SnackBarAction(
Expand All @@ -293,7 +293,7 @@ class FlavoredWebViewState extends ConsumerState<WebViewF> {
);
},
onError: (er) {
scaffoldMessengerStateKeyF.currentState?.showSnackBar(
scaffoldMessengerStateKey.currentState?.showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context)!.generic_error),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"file_download": "Datei heruntergeladen",
"generic_error": "Uups! Etwas ist schiefgelaufen.",

"enable_permissions": "Berechtigungen aktivieren.",

"settings": "Einstellungen",
"connect": "Verbinden",
"open": "Öffnen",
"cancel": "Abbrechen",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"file_download": "File downloaded",
"generic_error": "Oops! Something went wrong.",

"enable_permissions": "Enable permissions.",

"settings": "Settings",
"connect": "Connect",
"open": "Open",
"cancel" : "Cancel",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"file_download": "Fichier téléchargé",
"generic_error": "Oups ! Quelque chose s'est mal passé.",

"enable_permissions": "Activer les autorisations.",

"settings": "Paramètres",
"connect": "Connecter",
"open": "Ouvrir",
"cancel": "Annuler",
Expand Down
8 changes: 7 additions & 1 deletion lib/models/manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ class Manifest {
final String backgroundColor;
final String themeColor;

Manifest({required this.display, required this.startUrl, required this.shortName, required this.name, required this.backgroundColor, required this.themeColor});
Manifest(
{required this.display,
required this.startUrl,
required this.shortName,
required this.name,
required this.backgroundColor,
required this.themeColor});

String get baseUrl {
Uri url = Uri.parse(startUrl);
Expand Down
Loading

0 comments on commit 910914a

Please sign in to comment.