Skip to content

Commit

Permalink
Merge pull request #254 from sliverappbar/bookmark-import
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev authored Nov 8, 2023
2 parents 097fa3b + 7a77596 commit 64bd727
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 70 deletions.
6 changes: 4 additions & 2 deletions lib/pages/article_info/article_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ class ArticleInfoPage extends StatelessWidget {
}*/

_downloadButtonEvent(context, data) async {
if (!Settings.useInnerStorage && !await Permission.storage.isGranted) {
if (await Permission.storage.request() == PermissionStatus.denied) {
if (!Settings.useInnerStorage &&
!await Permission.manageExternalStorage.isGranted) {
if (await Permission.manageExternalStorage.request() ==
PermissionStatus.denied) {
await showOkDialog(context,
'If you do not allow file permissions, you cannot continue :(');
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/download/download_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class _DownloadPageState extends ThemeSwitchableState<DownloadPage>
if (!Settings.useInnerStorage &&
prefs.getBool('checkauthalready') == null) {
await prefs.setBool('checkauthalready', true);
if (await Permission.storage.request() ==
if (await Permission.manageExternalStorage.request() ==
PermissionStatus.denied) {
await showOkDialog(context,
'You cannot use downloader, if you not allow external storage permission.');
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/main/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ class _MainPageState extends ThemeSwitchableState<MainPage>
return;
}

if (!await Permission.storage.isGranted) {
if (await Permission.storage.request() == PermissionStatus.denied) {
if (!await Permission.manageExternalStorage.isGranted) {
if (await Permission.manageExternalStorage.request() ==
PermissionStatus.denied) {
await showOkDialog(context,
'If you do not allow file permissions, you cannot continue :(');
return;
Expand Down
48 changes: 1 addition & 47 deletions lib/pages/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
import 'package:mdi/mdi.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:saf/saf.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite/sqflite.dart';
import 'package:url_launcher/url_launcher.dart';
Expand Down Expand Up @@ -1631,7 +1630,7 @@ class _SettingsPageState extends State<SettingsPage>
);
if (dialog != null && dialog == true) {
try {
if (await Permission.storage.isGranted) {
if (await Permission.manageExternalStorage.isGranted) {
var prevDir = Directory(Settings.downloadBasePath);
if (await prevDir.exists()) {
await prevDir.rename(text.text);
Expand Down Expand Up @@ -1921,35 +1920,6 @@ class _SettingsPageState extends State<SettingsPage>
title: Text(Translations.of(context).trans('importingbookmark')),
trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () async {
if (!await Permission.storage.isGranted) {
if (await Permission.storage.request() ==
PermissionStatus.denied) {
flutterToast.showToast(
child: ToastWrapper(
isCheck: false,
msg: Translations.of(context).trans('noauth'),
),
gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 4),
);
return;
}
}

if (Platform.isAndroid) {
final ext = await getExternalStorageDirectory();

final saf = Saf(ext!.path);
bool? isGranted =
await saf.getDirectoryPermission(isDynamic: false);

if (isGranted != null && isGranted) {
// Perform some file operations
} else {
// failed to get the permission
}
}

await FilePicker.platform.clearTemporaryFiles();
final filePickerResult = await FilePicker.platform.pickFiles();
final pickedFilePath = filePickerResult?.files.singleOrNull?.path;
Expand Down Expand Up @@ -2007,22 +1977,6 @@ class _SettingsPageState extends State<SettingsPage>
fileNameToSaveAs: 'violet-bookmarks.db',
);
} else {
if (!await Permission.storage.isGranted) {
if (await Permission.storage.request() ==
PermissionStatus.denied) {
flutterToast.showToast(
child: ToastWrapper(
isCheck: false,
msg: Translations.of(context).trans('noauth'),
),
gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 4),
);

return;
}
}

final selectedPath =
await FilePicker.platform.getDirectoryPath();

Expand Down
3 changes: 2 additions & 1 deletion lib/pages/splash/splash_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ class _SplashPageState extends State<SplashPage> {
final prefs = await SharedPreferences.getInstance();
if (prefs.getBool('checkauthalready') == null) {
await prefs.setBool('checkauthalready', true);
if (await Permission.storage.request() == PermissionStatus.denied) {
if (await Permission.manageExternalStorage.request() ==
PermissionStatus.denied) {
await showOkDialog(context, '파일 권한을 허용하지 않으면 다운로드 기능을 이용할 수 없습니다.');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class Settings {
await prefs.setBool('downloadbasepathcc1', true);

try {
if (await Permission.storage.isGranted) {
if (await Permission.manageExternalStorage.isGranted) {
var prevDir = Directory(join(path, 'Violet'));
if (await prevDir.exists()) {
await prevDir.rename(join(path, '.violet'));
Expand Down
5 changes: 3 additions & 2 deletions lib/update/update_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class UpdateManager {
return;
}

if (!await Permission.storage.isGranted) {
if (await Permission.storage.request() == PermissionStatus.denied) {
if (!await Permission.manageExternalStorage.isGranted) {
if (await Permission.manageExternalStorage.request() ==
PermissionStatus.denied) {
await showOkDialog(context,
'If you do not allow file permissions, you cannot continue :(');
return;
Expand Down
16 changes: 4 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1211,18 +1211,18 @@ packages:
dependency: "direct main"
description:
name: permission_handler
sha256: bc56bfe9d3f44c3c612d8d393bd9b174eb796d706759f9b495ac254e4294baa5
sha256: "284a66179cabdf942f838543e10413246f06424d960c92ba95c84439154fcac8"
url: "https://pub.dev"
source: hosted
version: "10.4.5"
version: "11.0.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47"
sha256: f9fddd3b46109bd69ff3f9efa5006d2d309b7aec0f3c1c5637a60a2d5659e76e
url: "https://pub.dev"
source: hosted
version: "10.3.6"
version: "11.1.0"
permission_handler_apple:
dependency: transitive
description:
Expand Down Expand Up @@ -1344,14 +1344,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.27.7"
saf:
dependency: "direct main"
description:
name: saf
sha256: "3b7565638bc155801dc2b1b948ee0545f8cf9310da6e0f4ded45f62ee83f1321"
url: "https://pub.dev"
source: hosted
version: "1.0.3+4"
scrollable_positioned_list:
dependency: "direct main"
description:
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,13 @@ dependencies:
open_file: ^3.3.1
path:
path_provider: ^2.0.15
permission_handler: ^10.4.3
permission_handler: ^11.0.1
photo_view: ^0.14.0
platform: ^3.1.0
pimp_my_button:
git: https://github.com/MichaelMarner/pimp_my_button
pointycastle:
provider: ^6.0.2
saf: ^1.0.3+4
scrollable_positioned_list: ^0.3.2
shared_preferences: ^2.0.15
sqflite: ^2.0.2
Expand Down

0 comments on commit 64bd727

Please sign in to comment.