From 760ee681d27ba3f7879697246d015ebe62585b16 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 12 Jul 2020 21:41:13 +0900 Subject: [PATCH] share: loosened shared mime types to show more receiving apps --- lib/services/android_app_service.dart | 7 ++++++- .../common/action_delegates/entry_action_delegate.dart | 4 +--- .../action_delegates/selection_action_delegate.dart | 8 +------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/services/android_app_service.dart b/lib/services/android_app_service.dart index 886149d02..ab4672036 100644 --- a/lib/services/android_app_service.dart +++ b/lib/services/android_app_service.dart @@ -1,5 +1,7 @@ import 'dart:typed_data'; +import 'package:aves/model/image_entry.dart'; +import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; @@ -86,7 +88,10 @@ class AndroidAppService { } } - static Future share(Map> urisByMimeType) async { + static Future share(Set entries) async { + // loosen mime type to a generic one, so we can share with badly defined apps + // e.g. Google Lens declares receiving "image/jpeg" only, but it can actually handle more formats + final urisByMimeType = groupBy(entries, (e) => e.mimeTypeAnySubtype).map((k, v) => MapEntry(k, v.map((e) => e.uri).toList())); try { await platform.invokeMethod('share', { 'title': 'Share via:', diff --git a/lib/widgets/common/action_delegates/entry_action_delegate.dart b/lib/widgets/common/action_delegates/entry_action_delegate.dart index d64d061f9..56fc62b2a 100644 --- a/lib/widgets/common/action_delegates/entry_action_delegate.dart +++ b/lib/widgets/common/action_delegates/entry_action_delegate.dart @@ -64,9 +64,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin { AndroidAppService.setAs(entry.uri, entry.mimeType); break; case EntryAction.share: - AndroidAppService.share({ - entry.mimeType: [entry.uri] - }); + AndroidAppService.share({entry}); break; case EntryAction.debug: _goToDebug(context, entry); diff --git a/lib/widgets/common/action_delegates/selection_action_delegate.dart b/lib/widgets/common/action_delegates/selection_action_delegate.dart index f80e3af18..c2ecf39fd 100644 --- a/lib/widgets/common/action_delegates/selection_action_delegate.dart +++ b/lib/widgets/common/action_delegates/selection_action_delegate.dart @@ -17,7 +17,6 @@ import 'package:aves/widgets/common/action_delegates/permission_aware.dart'; import 'package:aves/widgets/common/entry_actions.dart'; import 'package:aves/widgets/common/icons.dart'; import 'package:aves/widgets/filter_grid_page.dart'; -import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; @@ -38,7 +37,7 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin { _showDeleteDialog(context); break; case EntryAction.share: - _share(); + AndroidAppService.share(collection.selection); break; default: break; @@ -229,11 +228,6 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin { ); } - void _share() { - final urisByMimeType = groupBy(collection.selection, (e) => e.mimeType).map((k, v) => MapEntry(k, v.map((e) => e.uri).toList())); - AndroidAppService.share(urisByMimeType); - } - // selection action report overlay OverlayEntry _opReportOverlayEntry;