minor fixes
This commit is contained in:
parent
030afc70f7
commit
404bc5471b
16 changed files with 24 additions and 19 deletions
|
@ -340,7 +340,7 @@ class EmbeddedDataHandler(private val context: Context) : MethodCallHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
ioScope.launch {
|
ioScope.launch {
|
||||||
provider.fetchSingle(context, uri, mimeType, object : ImageProvider.ImageOpCallback {
|
provider.fetchSingle(context, uri, mimeType, false, object : ImageProvider.ImageOpCallback {
|
||||||
override fun onSuccess(fields: FieldMap) {
|
override fun onSuccess(fields: FieldMap) {
|
||||||
resultFields.putAll(fields)
|
resultFields.putAll(fields)
|
||||||
result.success(resultFields)
|
result.success(resultFields)
|
||||||
|
|
|
@ -29,6 +29,7 @@ class MediaFetchObjectHandler(private val context: Context) : MethodCallHandler
|
||||||
private fun getEntry(call: MethodCall, result: MethodChannel.Result) {
|
private fun getEntry(call: MethodCall, result: MethodChannel.Result) {
|
||||||
val mimeType = call.argument<String>("mimeType") // MIME type is optional
|
val mimeType = call.argument<String>("mimeType") // MIME type is optional
|
||||||
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
|
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
|
||||||
|
val allowUnsized = call.argument<Boolean>("allowUnsized") ?: false
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
result.error("getEntry-args", "missing arguments", null)
|
result.error("getEntry-args", "missing arguments", null)
|
||||||
return
|
return
|
||||||
|
@ -40,7 +41,7 @@ class MediaFetchObjectHandler(private val context: Context) : MethodCallHandler
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
provider.fetchSingle(context, uri, mimeType, object : ImageOpCallback {
|
provider.fetchSingle(context, uri, mimeType, allowUnsized, object : ImageOpCallback {
|
||||||
override fun onSuccess(fields: FieldMap) = result.success(fields)
|
override fun onSuccess(fields: FieldMap) = result.success(fields)
|
||||||
override fun onFailure(throwable: Throwable) = result.error("getEntry-failure", "failed to get entry for uri=$uri mimeType=$mimeType", throwable.message)
|
override fun onFailure(throwable: Throwable) = result.error("getEntry-failure", "failed to get entry for uri=$uri mimeType=$mimeType", throwable.message)
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ import deckers.thibault.aves.utils.LogUtils
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
internal class FileImageProvider : ImageProvider() {
|
internal class FileImageProvider : ImageProvider() {
|
||||||
override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, callback: ImageOpCallback) {
|
override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, allowUnsized: Boolean, callback: ImageOpCallback) {
|
||||||
var mimeType = sourceMimeType
|
var mimeType = sourceMimeType
|
||||||
|
|
||||||
if (mimeType == null) {
|
if (mimeType == null) {
|
||||||
|
@ -54,7 +54,7 @@ internal class FileImageProvider : ImageProvider() {
|
||||||
}
|
}
|
||||||
entry.fillPreCatalogMetadata(context)
|
entry.fillPreCatalogMetadata(context)
|
||||||
|
|
||||||
if (entry.isSized || entry.isSvg || entry.isVideo) {
|
if (allowUnsized || entry.isSized || entry.isSvg || entry.isVideo) {
|
||||||
callback.onSuccess(entry.toMap())
|
callback.onSuccess(entry.toMap())
|
||||||
} else {
|
} else {
|
||||||
callback.onFailure(Exception("entry has no size"))
|
callback.onFailure(Exception("entry has no size"))
|
||||||
|
|
|
@ -70,7 +70,7 @@ import java.util.TimeZone
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
abstract class ImageProvider {
|
abstract class ImageProvider {
|
||||||
open fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, callback: ImageOpCallback) {
|
open fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, allowUnsized: Boolean, callback: ImageOpCallback) {
|
||||||
callback.onFailure(UnsupportedOperationException("`fetchSingle` is not supported by this image provider"))
|
callback.onFailure(UnsupportedOperationException("`fetchSingle` is not supported by this image provider"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class MediaStoreImageProvider : ImageProvider() {
|
||||||
// the provided URI can point to the wrong media collection,
|
// the provided URI can point to the wrong media collection,
|
||||||
// e.g. a GIF image with the URI `content://media/external/video/media/[ID]`
|
// e.g. a GIF image with the URI `content://media/external/video/media/[ID]`
|
||||||
// so the effective entry URI may not match the provided URI
|
// so the effective entry URI may not match the provided URI
|
||||||
override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, callback: ImageOpCallback) {
|
override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, allowUnsized: Boolean, callback: ImageOpCallback) {
|
||||||
var found = false
|
var found = false
|
||||||
val fetched = arrayListOf<FieldMap>()
|
val fetched = arrayListOf<FieldMap>()
|
||||||
val id = uri.tryParseId()
|
val id = uri.tryParseId()
|
||||||
|
|
|
@ -17,7 +17,7 @@ open class UnknownContentProvider : ImageProvider() {
|
||||||
open val reliableProviderMimeType: Boolean
|
open val reliableProviderMimeType: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
|
||||||
override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, callback: ImageOpCallback) {
|
override fun fetchSingle(context: Context, uri: Uri, sourceMimeType: String?, allowUnsized: Boolean, callback: ImageOpCallback) {
|
||||||
var mimeType = sourceMimeType
|
var mimeType = sourceMimeType
|
||||||
if (sourceMimeType == null || !reliableProviderMimeType) {
|
if (sourceMimeType == null || !reliableProviderMimeType) {
|
||||||
// source MIME type may be incorrect, so we get a second opinion if possible
|
// source MIME type may be incorrect, so we get a second opinion if possible
|
||||||
|
@ -71,7 +71,7 @@ open class UnknownContentProvider : ImageProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val entry = SourceEntry(fields).fillPreCatalogMetadata(context)
|
val entry = SourceEntry(fields).fillPreCatalogMetadata(context)
|
||||||
if (entry.isSized || entry.isSvg || entry.isVideo) {
|
if (allowUnsized || entry.isSized || entry.isSvg || entry.isVideo) {
|
||||||
callback.onSuccess(entry.toMap())
|
callback.onSuccess(entry.toMap())
|
||||||
} else {
|
} else {
|
||||||
callback.onFailure(Exception("entry has no size"))
|
callback.onFailure(Exception("entry has no size"))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
agp_version = '8.4.1' // same as `settings.ext.agp_version` in `/android/settings.gradle`
|
agp_version = '8.5.0' // same as `settings.ext.agp_version` in `/android/settings.gradle`
|
||||||
glide_version = '4.16.0'
|
glide_version = '4.16.0'
|
||||||
// AppGallery Connect plugin versions: https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-sdk-changenotes-0000001058732550
|
// AppGallery Connect plugin versions: https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-sdk-changenotes-0000001058732550
|
||||||
huawei_agconnect_version = '1.9.1.300'
|
huawei_agconnect_version = '1.9.1.300'
|
||||||
|
|
|
@ -10,7 +10,7 @@ pluginManagement {
|
||||||
|
|
||||||
settings.ext.kotlin_version = '1.9.24'
|
settings.ext.kotlin_version = '1.9.24'
|
||||||
settings.ext.ksp_version = "$kotlin_version-1.0.20"
|
settings.ext.ksp_version = "$kotlin_version-1.0.20"
|
||||||
settings.ext.agp_version = '8.4.1'
|
settings.ext.agp_version = '8.5.0'
|
||||||
|
|
||||||
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
|
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ class MediaStoreSource extends CollectionSource {
|
||||||
existingDirectories.add(existingDirectory);
|
existingDirectories.add(existingDirectory);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final sourceEntry = await mediaFetchService.getEntry(uri, null);
|
final sourceEntry = await mediaFetchService.getEntry(uri, null, allowUnsized: true);
|
||||||
if (sourceEntry != null) {
|
if (sourceEntry != null) {
|
||||||
newEntries.add(sourceEntry.copyWith(
|
newEntries.add(sourceEntry.copyWith(
|
||||||
id: metadataDb.nextId,
|
id: metadataDb.nextId,
|
||||||
|
|
|
@ -67,7 +67,7 @@ mixin TrashMixin on SourceBase {
|
||||||
await metadataDb.updateTrash(id, entry.trashDetails);
|
await metadataDb.updateTrash(id, entry.trashDetails);
|
||||||
} else {
|
} else {
|
||||||
// there is no matching entry
|
// there is no matching entry
|
||||||
final sourceEntry = await mediaFetchService.getEntry(uri, null);
|
final sourceEntry = await mediaFetchService.getEntry(uri, null, allowUnsized: true);
|
||||||
if (sourceEntry != null) {
|
if (sourceEntry != null) {
|
||||||
final id = metadataDb.nextId;
|
final id = metadataDb.nextId;
|
||||||
sourceEntry.id = id;
|
sourceEntry.id = id;
|
||||||
|
|
|
@ -166,7 +166,7 @@ class Vaults extends ChangeNotifier {
|
||||||
debugPrint('Recovering ${untrackedPaths.length} untracked vault items');
|
debugPrint('Recovering ${untrackedPaths.length} untracked vault items');
|
||||||
await Future.forEach(untrackedPaths, (untrackedPath) async {
|
await Future.forEach(untrackedPaths, (untrackedPath) async {
|
||||||
final uri = Uri.file(untrackedPath).toString();
|
final uri = Uri.file(untrackedPath).toString();
|
||||||
final sourceEntry = await mediaFetchService.getEntry(uri, null);
|
final sourceEntry = await mediaFetchService.getEntry(uri, null, allowUnsized: true);
|
||||||
if (sourceEntry != null) {
|
if (sourceEntry != null) {
|
||||||
sourceEntry.id = metadataDb.nextId;
|
sourceEntry.id = metadataDb.nextId;
|
||||||
sourceEntry.origin = EntryOrigins.vault;
|
sourceEntry.origin = EntryOrigins.vault;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:streams_channel/streams_channel.dart';
|
import 'package:streams_channel/streams_channel.dart';
|
||||||
|
|
||||||
abstract class MediaFetchService {
|
abstract class MediaFetchService {
|
||||||
Future<AvesEntry?> getEntry(String uri, String? mimeType);
|
Future<AvesEntry?> getEntry(String uri, String? mimeType, {bool allowUnsized = false});
|
||||||
|
|
||||||
Future<Uint8List> getSvg(
|
Future<Uint8List> getSvg(
|
||||||
String uri,
|
String uri,
|
||||||
|
@ -75,11 +75,12 @@ class PlatformMediaFetchService implements MediaFetchService {
|
||||||
static const double _thumbnailDefaultSize = 64.0;
|
static const double _thumbnailDefaultSize = 64.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<AvesEntry?> getEntry(String uri, String? mimeType) async {
|
Future<AvesEntry?> getEntry(String uri, String? mimeType, {bool allowUnsized = false}) async {
|
||||||
try {
|
try {
|
||||||
final result = await _platformObject.invokeMethod('getEntry', <String, dynamic>{
|
final result = await _platformObject.invokeMethod('getEntry', <String, dynamic>{
|
||||||
'uri': uri,
|
'uri': uri,
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
|
'allowUnsized': allowUnsized,
|
||||||
}) as Map;
|
}) as Map;
|
||||||
return AvesEntry.fromMap(result);
|
return AvesEntry.fromMap(result);
|
||||||
} on PlatformException catch (e, stack) {
|
} on PlatformException catch (e, stack) {
|
||||||
|
|
|
@ -286,5 +286,8 @@ class _InfoPageContentState extends State<_InfoPageContent> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onFilter(CollectionFilter filter) => FilterSelectedNotification(filter).dispatch(context);
|
void _onFilter(CollectionFilter filter) {
|
||||||
|
if (!mounted) return;
|
||||||
|
FilterSelectedNotification(filter).dispatch(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,6 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
|
||||||
|
|
||||||
double? _progressToDx(double progress) {
|
double? _progressToDx(double progress) {
|
||||||
final box = _getProgressBarRenderBox();
|
final box = _getProgressBarRenderBox();
|
||||||
return box == null ? null : progress * box.size.width;
|
return box != null && box.hasSize ? progress * box.size.width : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ version '1.0-SNAPSHOT'
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
kotlin_version = '1.9.24'
|
kotlin_version = '1.9.24'
|
||||||
agp_version = '8.4.1'
|
agp_version = '8.5.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -7,7 +7,7 @@ class FakeMediaFetchService extends Fake implements MediaFetchService {
|
||||||
Set<AvesEntry> entries = {};
|
Set<AvesEntry> entries = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<AvesEntry?> getEntry(String uri, String? mimeType) async {
|
Future<AvesEntry?> getEntry(String uri, String? mimeType, {bool allowUnsized = false}) async {
|
||||||
return entries.firstWhereOrNull((v) => v.uri == uri);
|
return entries.firstWhereOrNull((v) => v.uri == uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue