Skip to content

Commit

Permalink
Improve: Moved checkNecessaryPermissions function in the update manag…
Browse files Browse the repository at this point in the history
…er service file
  • Loading branch information
gokadzev committed Nov 13, 2023
1 parent 744dfb4 commit 61c7dc3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
1 change: 0 additions & 1 deletion lib/screens/root_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'package:musify/extensions/l10n.dart';
import 'package:musify/main.dart';
import 'package:musify/screens/now_playing_page.dart';
import 'package:musify/services/download_manager.dart';
import 'package:musify/services/router_service.dart';
import 'package:musify/services/update_manager.dart';
import 'package:musify/style/app_themes.dart';
Expand Down
19 changes: 0 additions & 19 deletions lib/services/download_manager.dart

This file was deleted.

15 changes: 15 additions & 0 deletions lib/services/update_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:musify/API/version.dart';
import 'package:musify/extensions/l10n.dart';
import 'package:musify/main.dart';
import 'package:musify/utilities/flutter_toast.dart';
import 'package:permission_handler/permission_handler.dart';

const String checkUrl =
'https://raw.githubusercontent.com/gokadzev/Musify/update/check.json';
Expand Down Expand Up @@ -96,3 +97,17 @@ Future<String> getDownloadUrl(Map<String, dynamic> map) async {
: map[downloadUrlKey].toString();
return url;
}

Future<void> checkNecessaryPermissions(BuildContext context) async {
await Permission.audio.request();
await Permission.notification.request();
try {
await Permission.storage.request();
} catch (e) {
logger.log('Error while requesting permissions: $e');
showToast(
context,
'${context.l10n!.errorWhileRequestingPerms} + $e',
);
}
}

0 comments on commit 61c7dc3

Please sign in to comment.