fullscreen: edit / set as / show on map
This commit is contained in:
parent
836730f23c
commit
05af913d86
6 changed files with 105 additions and 4 deletions
|
@ -21,12 +21,35 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
|||
@Override
|
||||
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
||||
switch (call.method) {
|
||||
case "edit": {
|
||||
String title = call.argument("title");
|
||||
Uri uri = Uri.parse(call.argument("uri"));
|
||||
String mimeType = call.argument("mimeType");
|
||||
edit(title, uri, mimeType);
|
||||
result.success(null);
|
||||
break;
|
||||
}
|
||||
case "setAs": {
|
||||
String title = call.argument("title");
|
||||
Uri uri = Uri.parse(call.argument("uri"));
|
||||
String mimeType = call.argument("mimeType");
|
||||
setAs(title, uri, mimeType);
|
||||
result.success(null);
|
||||
break;
|
||||
}
|
||||
case "share": {
|
||||
String title = call.argument("title");
|
||||
Uri uri = Uri.parse(call.argument("uri"));
|
||||
String mimeType = call.argument("mimeType");
|
||||
share(context, title, uri, mimeType);
|
||||
share(title, uri, mimeType);
|
||||
result.success(null);
|
||||
break;
|
||||
}
|
||||
case "showOnMap": {
|
||||
Uri geoUri = Uri.parse(call.argument("geoUri"));
|
||||
showOnMap(geoUri);
|
||||
result.success(null);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
result.notImplemented();
|
||||
|
@ -34,10 +57,29 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void share(Context context, String title, Uri uri, String mimeType) {
|
||||
private void edit(String title, Uri uri, String mimeType) {
|
||||
Intent intent = new Intent(Intent.ACTION_EDIT);
|
||||
intent.setDataAndType(uri, mimeType);
|
||||
context.startActivity(Intent.createChooser(intent, title));
|
||||
}
|
||||
|
||||
private void setAs(String title, Uri uri, String mimeType) {
|
||||
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
|
||||
intent.setDataAndType(uri, mimeType);
|
||||
context.startActivity(Intent.createChooser(intent, title));
|
||||
}
|
||||
|
||||
private void share(String title, Uri uri, String mimeType) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||
intent.setType(mimeType);
|
||||
context.startActivity(Intent.createChooser(intent, title));
|
||||
}
|
||||
|
||||
private void showOnMap(Uri geoUri) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, geoUri);
|
||||
if (intent.resolveActivity(context.getPackageManager()) != null) {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class _HomePageState extends State<HomePage> {
|
|||
debugPrint('$runtimeType catalogEntries cataloging complete');
|
||||
|
||||
// sort with more accurate date
|
||||
entries.sort((a,b) => b.bestDate.compareTo(a.bestDate));
|
||||
entries.sort((a, b) => b.bestDate.compareTo(a.bestDate));
|
||||
setState(() {});
|
||||
|
||||
debugPrint('$runtimeType catalogEntries locating start');
|
||||
|
|
|
@ -129,6 +129,8 @@ class ImageEntry with ChangeNotifier {
|
|||
|
||||
Tuple2<double, double> get latLng => isCataloged ? Tuple2(catalogMetadata.latitude, catalogMetadata.longitude) : null;
|
||||
|
||||
String get geoUri => hasGps ? 'geo:${catalogMetadata.latitude},${catalogMetadata.longitude}' : null;
|
||||
|
||||
List<String> get xmpSubjects => catalogMetadata?.xmpSubjects?.split(';')?.where((tag) => tag.isNotEmpty)?.toList() ?? [];
|
||||
|
||||
catalog() async {
|
||||
|
|
|
@ -4,6 +4,30 @@ import 'package:flutter/services.dart';
|
|||
class AndroidAppService {
|
||||
static const platform = const MethodChannel('deckers.thibault/aves/app');
|
||||
|
||||
static edit(String uri, String mimeType) async {
|
||||
try {
|
||||
await platform.invokeMethod('edit', <String, dynamic>{
|
||||
'title': 'Edit',
|
||||
'uri': uri,
|
||||
'mimeType': mimeType,
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
debugPrint('edit failed with exception=${e.message}');
|
||||
}
|
||||
}
|
||||
|
||||
static setAs(String uri, String mimeType) async {
|
||||
try {
|
||||
await platform.invokeMethod('setAs', <String, dynamic>{
|
||||
'title': 'Set as',
|
||||
'uri': uri,
|
||||
'mimeType': mimeType,
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
debugPrint('setAs failed with exception=${e.message}');
|
||||
}
|
||||
}
|
||||
|
||||
static share(String uri, String mimeType) async {
|
||||
try {
|
||||
await platform.invokeMethod('share', <String, dynamic>{
|
||||
|
@ -15,4 +39,15 @@ class AndroidAppService {
|
|||
debugPrint('share failed with exception=${e.message}');
|
||||
}
|
||||
}
|
||||
|
||||
static showOnMap(String geoUri) async {
|
||||
if (geoUri == null) return;
|
||||
try {
|
||||
await platform.invokeMethod('showOnMap', <String, dynamic>{
|
||||
'geoUri': geoUri,
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
debugPrint('share failed with exception=${e.message}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,17 +195,26 @@ class FullscreenPageState extends State<FullscreenPage> with SingleTickerProvide
|
|||
|
||||
onActionSelected(ImageEntry entry, FullscreenAction action) {
|
||||
switch (action) {
|
||||
case FullscreenAction.edit:
|
||||
AndroidAppService.edit(entry.uri, entry.mimeType);
|
||||
break;
|
||||
case FullscreenAction.info:
|
||||
goToVerticalPage(1);
|
||||
break;
|
||||
case FullscreenAction.setAs:
|
||||
AndroidAppService.setAs(entry.uri, entry.mimeType);
|
||||
break;
|
||||
case FullscreenAction.share:
|
||||
AndroidAppService.share(entry.uri, entry.mimeType);
|
||||
break;
|
||||
case FullscreenAction.showOnMap:
|
||||
AndroidAppService.showOnMap(entry.geoUri);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum FullscreenAction { info, share }
|
||||
enum FullscreenAction { edit, info, setAs, share, showOnMap }
|
||||
|
||||
class ImagePage extends StatefulWidget {
|
||||
final List<ImageEntry> entries;
|
||||
|
|
|
@ -52,6 +52,19 @@ class FullscreenTopOverlay extends StatelessWidget {
|
|||
value: FullscreenAction.info,
|
||||
child: Text("Info"),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: FullscreenAction.edit,
|
||||
child: Text("Edit"),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: FullscreenAction.setAs,
|
||||
child: Text("Set as"),
|
||||
),
|
||||
if (entry.hasGps)
|
||||
PopupMenuItem(
|
||||
value: FullscreenAction.showOnMap,
|
||||
child: Text("Show on map"),
|
||||
),
|
||||
],
|
||||
onSelected: onActionSelected,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue