fixed deleting binned item from the Download album
This commit is contained in:
parent
341ff57dff
commit
a0231de559
5 changed files with 15 additions and 8 deletions
|
@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
|
|||
- photo frame widget rendering in some cases
|
||||
- exporting large images to BMP
|
||||
- replacing entries during move/copy
|
||||
- deleting binned item from the Download album
|
||||
|
||||
## <a id="v1.6.13"></a>[v1.6.13] - 2022-08-29
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ object PermissionManager {
|
|||
// returns paths accessible to the app (granted by the user or by default)
|
||||
private fun getAccessibleDirs(context: Context): Set<String> {
|
||||
val accessibleDirs = HashSet(getGrantedDirs(context))
|
||||
accessibleDirs.addAll(context.getExternalFilesDirs(null).filterNotNull().map { it.path })
|
||||
|
||||
// until API 18 / Android 4.3 / Jelly Bean MR2, removable storage is accessible by default like primary storage
|
||||
// from API 19 / Android 4.4 / KitKat, removable storage requires access permission, at the file level
|
||||
|
|
|
@ -213,9 +213,13 @@ class AvesEntry {
|
|||
return _extension;
|
||||
}
|
||||
|
||||
String? get storagePath => trashed ? trashDetails?.path : path;
|
||||
|
||||
String? get storageDirectory => trashed ? pContext.dirname(trashDetails!.path) : directory;
|
||||
|
||||
bool get isMissingAtPath {
|
||||
final effectivePath = trashed ? trashDetails?.path : path;
|
||||
return effectivePath != null && !File(effectivePath).existsSync();
|
||||
final _storagePath = storagePath;
|
||||
return _storagePath != null && !File(_storagePath).existsSync();
|
||||
}
|
||||
|
||||
// the MIME type reported by the Media Store is unreliable
|
||||
|
|
|
@ -275,7 +275,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
|
|||
|
||||
final l10n = context.l10n;
|
||||
final source = context.read<CollectionSource>();
|
||||
final selectionDirs = entries.map((e) => e.directory).whereNotNull().toSet();
|
||||
final storageDirs = entries.map((e) => e.storageDirectory).whereNotNull().toSet();
|
||||
final todoCount = entries.length;
|
||||
|
||||
if (!await showConfirmationDialog(
|
||||
|
@ -285,7 +285,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
|
|||
confirmationButtonLabel: l10n.deleteButtonLabel,
|
||||
)) return;
|
||||
|
||||
if (!pureTrash && !await checkStoragePermissionForAlbums(context, selectionDirs, entries: entries)) return;
|
||||
if (!await checkStoragePermissionForAlbums(context, storageDirs, entries: entries)) return;
|
||||
|
||||
source.pauseMonitoring();
|
||||
final opId = mediaEditService.newOpId;
|
||||
|
@ -308,7 +308,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
|
|||
}
|
||||
|
||||
// cleanup
|
||||
await storageService.deleteEmptyDirectories(selectionDirs);
|
||||
await storageService.deleteEmptyDirectories(storageDirs);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -8,13 +8,14 @@ import 'package:flutter/material.dart';
|
|||
|
||||
mixin PermissionAwareMixin {
|
||||
Future<bool> checkStoragePermission(BuildContext context, Set<AvesEntry> entries) {
|
||||
return checkStoragePermissionForAlbums(context, entries.map((e) => e.directory).whereNotNull().toSet(), entries: entries);
|
||||
final storageDirs = entries.map((e) => e.storageDirectory).whereNotNull().toSet();
|
||||
return checkStoragePermissionForAlbums(context, storageDirs, entries: entries);
|
||||
}
|
||||
|
||||
Future<bool> checkStoragePermissionForAlbums(BuildContext context, Set<String> albumPaths, {Set<AvesEntry>? entries}) async {
|
||||
Future<bool> checkStoragePermissionForAlbums(BuildContext context, Set<String> storageDirs, {Set<AvesEntry>? entries}) async {
|
||||
final restrictedDirs = await storageService.getRestrictedDirectories();
|
||||
while (true) {
|
||||
final dirs = await storageService.getInaccessibleDirectories(albumPaths);
|
||||
final dirs = await storageService.getInaccessibleDirectories(storageDirs);
|
||||
|
||||
final restrictedInaccessibleDirs = dirs.where(restrictedDirs.contains).toSet();
|
||||
if (restrictedInaccessibleDirs.isNotEmpty) {
|
||||
|
|
Loading…
Reference in a new issue