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
|
@Override
|
||||||
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
||||||
switch (call.method) {
|
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": {
|
case "share": {
|
||||||
String title = call.argument("title");
|
String title = call.argument("title");
|
||||||
Uri uri = Uri.parse(call.argument("uri"));
|
Uri uri = Uri.parse(call.argument("uri"));
|
||||||
String mimeType = call.argument("mimeType");
|
String mimeType = call.argument("mimeType");
|
||||||
share(context, title, uri, mimeType);
|
share(title, uri, mimeType);
|
||||||
result.success(null);
|
result.success(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "showOnMap": {
|
||||||
|
Uri geoUri = Uri.parse(call.argument("geoUri"));
|
||||||
|
showOnMap(geoUri);
|
||||||
|
result.success(null);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
result.notImplemented();
|
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 intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
intent.setType(mimeType);
|
intent.setType(mimeType);
|
||||||
context.startActivity(Intent.createChooser(intent, title));
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,8 @@ class ImageEntry with ChangeNotifier {
|
||||||
|
|
||||||
Tuple2<double, double> get latLng => isCataloged ? Tuple2(catalogMetadata.latitude, catalogMetadata.longitude) : null;
|
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() ?? [];
|
List<String> get xmpSubjects => catalogMetadata?.xmpSubjects?.split(';')?.where((tag) => tag.isNotEmpty)?.toList() ?? [];
|
||||||
|
|
||||||
catalog() async {
|
catalog() async {
|
||||||
|
|
|
@ -4,6 +4,30 @@ import 'package:flutter/services.dart';
|
||||||
class AndroidAppService {
|
class AndroidAppService {
|
||||||
static const platform = const MethodChannel('deckers.thibault/aves/app');
|
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 {
|
static share(String uri, String mimeType) async {
|
||||||
try {
|
try {
|
||||||
await platform.invokeMethod('share', <String, dynamic>{
|
await platform.invokeMethod('share', <String, dynamic>{
|
||||||
|
@ -15,4 +39,15 @@ class AndroidAppService {
|
||||||
debugPrint('share failed with exception=${e.message}');
|
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) {
|
onActionSelected(ImageEntry entry, FullscreenAction action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case FullscreenAction.edit:
|
||||||
|
AndroidAppService.edit(entry.uri, entry.mimeType);
|
||||||
|
break;
|
||||||
case FullscreenAction.info:
|
case FullscreenAction.info:
|
||||||
goToVerticalPage(1);
|
goToVerticalPage(1);
|
||||||
break;
|
break;
|
||||||
|
case FullscreenAction.setAs:
|
||||||
|
AndroidAppService.setAs(entry.uri, entry.mimeType);
|
||||||
|
break;
|
||||||
case FullscreenAction.share:
|
case FullscreenAction.share:
|
||||||
AndroidAppService.share(entry.uri, entry.mimeType);
|
AndroidAppService.share(entry.uri, entry.mimeType);
|
||||||
break;
|
break;
|
||||||
|
case FullscreenAction.showOnMap:
|
||||||
|
AndroidAppService.showOnMap(entry.geoUri);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FullscreenAction { info, share }
|
enum FullscreenAction { edit, info, setAs, share, showOnMap }
|
||||||
|
|
||||||
class ImagePage extends StatefulWidget {
|
class ImagePage extends StatefulWidget {
|
||||||
final List<ImageEntry> entries;
|
final List<ImageEntry> entries;
|
||||||
|
|
|
@ -52,6 +52,19 @@ class FullscreenTopOverlay extends StatelessWidget {
|
||||||
value: FullscreenAction.info,
|
value: FullscreenAction.info,
|
||||||
child: Text("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,
|
onSelected: onActionSelected,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue