Skip to content

Commit

Permalink
fix: fix not asking for permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunali321 committed Jun 12, 2023
1 parent da0d88d commit 13b7179
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/ui/views/navigation/navigation_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class NavigationViewModel extends IndexTrackingViewModel {
Future<void> initialize(BuildContext context) async {
locator<Toast>().initialize(context);
final SharedPreferences prefs = await SharedPreferences.getInstance();
requestManageExternalStorage();

if (prefs.getBool('permissionsRequested') == null) {
await Permission.storage.request();
await Permission.manageExternalStorage.request();
Expand All @@ -28,6 +30,7 @@ class NavigationViewModel extends IndexTrackingViewModel {
),
);
}

if (prefs.getBool('useDarkTheme') == null) {
final bool isDark =
MediaQuery.of(context).platformBrightness != Brightness.light;
Expand All @@ -46,6 +49,17 @@ class NavigationViewModel extends IndexTrackingViewModel {
);
}

Future<void> requestManageExternalStorage() async {
final manageExternalStorageStatus =
await Permission.manageExternalStorage.status;
if (manageExternalStorageStatus.isDenied) {
await Permission.manageExternalStorage.request();
}
if (manageExternalStorageStatus.isPermanentlyDenied) {
await openAppSettings();
}
}

Widget getViewForIndex(int index) {
switch (index) {
case 0:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager

publish_to: 'none'

version: 1.3.4+100300004
version: 1.3.5+100300005

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

2 comments on commit 13b7179

@NatoBoram
Copy link

@NatoBoram NatoBoram commented on 13b7179 Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need that permission? It worked well before…

Screenshot_20230613-082020

And it still works when the permission is denied…

Screenshot_20230613-083047

@Aunali321
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed because of Sync for Rddit's change-oauth-clientId patch which looks for txt file in /sdcard. You can PR if you want to scope it to Downloads directory.

Please sign in to comment.