minor fixes
This commit is contained in:
parent
9199047c85
commit
c3ff156282
5 changed files with 33 additions and 13 deletions
|
@ -3,8 +3,21 @@
|
|||
package="deckers.thibault.aves"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!--
|
||||
Scoped storage for primary storage is unusable on Android Q,
|
||||
because it does not allow deleting in bulk items created by other apps.
|
||||
These items can only be deleted one by one after catching
|
||||
a `RecoverableSecurityException` and requesting permission for each.
|
||||
|
||||
On Android 11 it is possible with `createDeleteRequest`:
|
||||
https://developer.android.com/reference/android/provider/MediaStore#createDeleteRequest(android.content.ContentResolver,%20java.util.Collection%3Candroid.net.Uri%3E)
|
||||
-->
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- request write permission until Q (29) included, because scoped storage is unusable -->
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="29" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- to access media with unredacted metadata with scoped storage (Android 10+) -->
|
||||
|
|
|
@ -33,6 +33,7 @@ public class MediaStoreImageProvider extends ImageProvider {
|
|||
MediaStore.MediaColumns.DATA,
|
||||
MediaStore.MediaColumns.MIME_TYPE,
|
||||
MediaStore.MediaColumns.SIZE,
|
||||
// TODO TLAD use `DISPLAY_NAME` instead/along `TITLE`?
|
||||
MediaStore.MediaColumns.TITLE,
|
||||
MediaStore.MediaColumns.WIDTH,
|
||||
MediaStore.MediaColumns.HEIGHT,
|
||||
|
@ -192,12 +193,15 @@ public class MediaStoreImageProvider extends ImageProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
if (activity.getContentResolver().delete(uri, null, null) > 0) {
|
||||
Log.d(LOG_TAG, "deleted from content resolver uri=" + uri);
|
||||
callback.onSuccess(null);
|
||||
return;
|
||||
try {
|
||||
if (activity.getContentResolver().delete(uri, null, null) > 0) {
|
||||
Log.d(LOG_TAG, "deleted from content resolver uri=" + uri);
|
||||
callback.onSuccess(null);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "failed to delete entry", e);
|
||||
}
|
||||
|
||||
callback.onFailure();
|
||||
}
|
||||
|
||||
|
|
|
@ -101,11 +101,13 @@ class _HomePageState extends State<HomePage> {
|
|||
if (snapshot.hasError) return const Icon(OMIcons.error);
|
||||
if (snapshot.connectionState != ConnectionState.done) return const SizedBox.shrink();
|
||||
debugPrint('$runtimeType app setup future complete');
|
||||
return _sharedEntry != null
|
||||
? SingleFullscreenPage(
|
||||
entry: _sharedEntry,
|
||||
)
|
||||
: CollectionPage(_mediaStore.collection);
|
||||
if (_sharedEntry != null) {
|
||||
return SingleFullscreenPage(entry: _sharedEntry);
|
||||
}
|
||||
if (_mediaStore != null) {
|
||||
return CollectionPage(_mediaStore.collection);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class StorageVolume {
|
|||
isPrimary: map['isPrimary'] ?? false,
|
||||
isRemovable: map['isRemovable'] ?? false,
|
||||
path: map['path'] ?? '',
|
||||
state: map['string'] ?? '',
|
||||
state: map['state'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ class SelectionActionDelegate with PermissionAwareMixin {
|
|||
final deletedCount = deletedUris.length;
|
||||
final selectionCount = selection.length;
|
||||
if (deletedCount < selectionCount) {
|
||||
_showFeedback(context, 'Failed to delete ${selectionCount - deletedCount} items');
|
||||
final count = selectionCount - deletedCount;
|
||||
_showFeedback(context, 'Failed to delete ${Intl.plural(count, one: '${count} item', other: '${count} items')}');
|
||||
}
|
||||
if (deletedCount > 0) {
|
||||
collection.source.removeEntries(selection.where((e) => deletedUris.contains(e.uri)));
|
||||
|
|
Loading…
Reference in a new issue