Skip to content

Commit

Permalink
Merge pull request #370 from Shubham04Jha/loading
Browse files Browse the repository at this point in the history
loading screen bug fixed, by giving permissions
  • Loading branch information
BrawlerXull authored Nov 5, 2024
2 parents cc867ca + b6fe745 commit 3e0a0b7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SettingsController extends GetxController {
profilesWidget.setBaseDirectory(destination);
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('baseDirectory', destination.path);
baseDirectory.value = destination.path;
} else {
showDialog(
context: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget {
await SharedPreferences.getInstance();
await prefs.remove('baseDirectory');
controller.isMovingDirectory.value = false;
controller.baseDirectory.value = "Default";
});
},
child: Text(
Expand Down
7 changes: 7 additions & 0 deletions lib/app/utils/constants/permissions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:permission_handler/permission_handler.dart';

List<Permission> permissions = [
Permission.notification,
Permission.storage,
Permission.manageExternalStorage,
];
27 changes: 27 additions & 0 deletions lib/app/utils/permissions/permissions_manager.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ignore_for_file: avoid_print

import 'package:permission_handler/permission_handler.dart';
import 'package:taskwarrior/app/utils/constants/permissions.dart';

class PermissionsManager {
static Future<void> requestAllPermissions() async {
try {
for (var permission in permissions) {
final status = await _requestPermission(permission);

if (status) {
print("Permission '${permission.toString().split('.').last}' granted.");
} else {
print("Permission '${permission.toString().split('.').last}' denied.");
}
}
} catch (e) {
print("Error requesting permissions: $e");
}
}

static Future<bool> _requestPermission(Permission permission) async {
final status = await permission.request();
return status.isGranted;
}
}
12 changes: 4 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';

import 'package:taskwarrior/app/utils/permissions/permissions_manager.dart';
import 'app/routes/app_pages.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AppSettings.init();

await Permission.notification.isDenied.then((value) {
if (value) {
Permission.notification.request();
}
});
await PermissionsManager.requestAllPermissions();


runApp(
GetMaterialApp(
title: "Application",
Expand Down

0 comments on commit 3e0a0b7

Please sign in to comment.