Skip to content

Commit

Permalink
Merge pull request #236 from humhub/f-internal-59-set-permissions
Browse files Browse the repository at this point in the history
Request additional permissions.
  • Loading branch information
luke- authored Oct 3, 2024
2 parents 9d4fbde + 4d5c1ec commit b2508be
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 28 deletions.
13 changes: 0 additions & 13 deletions lib/app_flavored.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/flavored/models/humhub.f.dart';
import 'package:humhub/flavored/util/intent_plugin.f.dart';
Expand All @@ -8,11 +7,9 @@ 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';
import 'package:permission_handler/permission_handler.dart';

class FlavoredApp extends ConsumerStatefulWidget {
const FlavoredApp({super.key});
Expand All @@ -22,16 +19,6 @@ class FlavoredApp extends ConsumerStatefulWidget {
}

class FlavoredAppState extends ConsumerState<FlavoredApp> {
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
await PermissionHandler.requestPermissions([
Permission.notification,
]);
});
}

@override
Widget build(BuildContext context) {
SecureStorageService.clearSecureStorageOnReinstall();
Expand Down
13 changes: 0 additions & 13 deletions lib/app_opener.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
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';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:permission_handler/permission_handler.dart';

class OpenerApp extends ConsumerStatefulWidget {
const OpenerApp({super.key});
Expand All @@ -21,16 +18,6 @@ class OpenerApp extends ConsumerStatefulWidget {
}

class OpenerAppState extends ConsumerState<OpenerApp> {
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
await PermissionHandler.requestPermissions([
Permission.notification,
]);
});
}

@override
Widget build(BuildContext context) {
SecureStorageService.clearSecureStorageOnReinstall();
Expand Down
4 changes: 4 additions & 0 deletions lib/flavored/web_view.f.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class FlavoredWebViewState extends ConsumerState<WebViewF> {
onReceivedError: _onLoadError,
onProgressChanged: _onProgressChanged,
onDownloadStartRequest: _onDownloadStartRequest,
onPermissionRequest: (controller, permissionRequest) {
logInfo('onPermissionRequest', [controller, permissionRequest]);
return Future.value(PermissionResponse(action: PermissionResponseAction.DENY));
},
),
),
),
Expand Down
12 changes: 11 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/models/hum_hub.dart';
import 'package:humhub/util/log.dart';
import 'package:humhub/util/permission_handler.dart';
import 'package:humhub/util/storage_service.dart';
import 'package:loggy/loggy.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:permission_handler/permission_handler.dart';

main() async {
Loggy.initLoggy(
Expand All @@ -14,6 +16,14 @@ main() async {
await SecureStorageService.clearSecureStorageOnReinstall();
PackageInfo packageInfo = await PackageInfo.fromPlatform();
final app = await HumHub.app(packageInfo.packageName);

await PermissionHandler.requestPermissions(
[
Permission.notification,
Permission.camera,
Permission.microphone,
Permission.storage,
Permission.photos
],
);
runApp(ProviderScope(child: app));
}
2 changes: 1 addition & 1 deletion lib/util/notifications/channel.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/flavored/util/notifications/channel.dart';
import 'package:humhub/flavored/util/notifications/channel.f.dart';
import 'package:humhub/pages/web_view.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/notifications/init_from_push.dart';
Expand Down

0 comments on commit b2508be

Please sign in to comment.