fullscreen: added open action
This commit is contained in:
parent
e40136d646
commit
5571f9f236
5 changed files with 72 additions and 39 deletions
|
@ -29,6 +29,20 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
||||||
result.success(null);
|
result.success(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "open": {
|
||||||
|
String title = call.argument("title");
|
||||||
|
Uri uri = Uri.parse(call.argument("uri"));
|
||||||
|
String mimeType = call.argument("mimeType");
|
||||||
|
open(title, uri, mimeType);
|
||||||
|
result.success(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "openMap": {
|
||||||
|
Uri geoUri = Uri.parse(call.argument("geoUri"));
|
||||||
|
openMap(geoUri);
|
||||||
|
result.success(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "setAs": {
|
case "setAs": {
|
||||||
String title = call.argument("title");
|
String title = call.argument("title");
|
||||||
Uri uri = Uri.parse(call.argument("uri"));
|
Uri uri = Uri.parse(call.argument("uri"));
|
||||||
|
@ -45,12 +59,6 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
||||||
result.success(null);
|
result.success(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "showOnMap": {
|
|
||||||
Uri geoUri = Uri.parse(call.argument("geoUri"));
|
|
||||||
showOnMap(geoUri);
|
|
||||||
result.success(null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
result.notImplemented();
|
result.notImplemented();
|
||||||
break;
|
break;
|
||||||
|
@ -63,6 +71,19 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
||||||
context.startActivity(Intent.createChooser(intent, title));
|
context.startActivity(Intent.createChooser(intent, title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void open(String title, Uri uri, String mimeType) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(uri, mimeType);
|
||||||
|
context.startActivity(Intent.createChooser(intent, title));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openMap(Uri geoUri) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, geoUri);
|
||||||
|
if (intent.resolveActivity(context.getPackageManager()) != null) {
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setAs(String title, Uri uri, String mimeType) {
|
private void setAs(String title, Uri uri, String mimeType) {
|
||||||
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
|
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
|
||||||
intent.setDataAndType(uri, mimeType);
|
intent.setDataAndType(uri, mimeType);
|
||||||
|
@ -75,11 +96,4 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,12 @@ public class MediaStoreStreamHandler implements EventChannel.StreamHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListen(Object args, final EventChannel.EventSink events) {
|
public void onListen(Object args, final EventChannel.EventSink events) {
|
||||||
Log.w(LOG_TAG, "onListen with args=" + args);
|
|
||||||
eventSink = events;
|
eventSink = events;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(Object args) {
|
public void onCancel(Object args) {
|
||||||
Log.w(LOG_TAG, "onCancel with args=" + args);
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void fetchAll(Activity activity) {
|
void fetchAll(Activity activity) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ class AndroidAppService {
|
||||||
static edit(String uri, String mimeType) async {
|
static edit(String uri, String mimeType) async {
|
||||||
try {
|
try {
|
||||||
await platform.invokeMethod('edit', <String, dynamic>{
|
await platform.invokeMethod('edit', <String, dynamic>{
|
||||||
'title': 'Edit',
|
'title': 'Edit with:',
|
||||||
'uri': uri,
|
'uri': uri,
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
});
|
});
|
||||||
|
@ -16,10 +16,33 @@ class AndroidAppService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static open(String uri, String mimeType) async {
|
||||||
|
try {
|
||||||
|
await platform.invokeMethod('open', <String, dynamic>{
|
||||||
|
'title': 'Open with:',
|
||||||
|
'uri': uri,
|
||||||
|
'mimeType': mimeType,
|
||||||
|
});
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
debugPrint('open failed with exception=${e.message}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static openMap(String geoUri) async {
|
||||||
|
if (geoUri == null) return;
|
||||||
|
try {
|
||||||
|
await platform.invokeMethod('openMap', <String, dynamic>{
|
||||||
|
'geoUri': geoUri,
|
||||||
|
});
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
debugPrint('openMap failed with exception=${e.message}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static setAs(String uri, String mimeType) async {
|
static setAs(String uri, String mimeType) async {
|
||||||
try {
|
try {
|
||||||
await platform.invokeMethod('setAs', <String, dynamic>{
|
await platform.invokeMethod('setAs', <String, dynamic>{
|
||||||
'title': 'Set as',
|
'title': 'Set as:',
|
||||||
'uri': uri,
|
'uri': uri,
|
||||||
'mimeType': mimeType,
|
'mimeType': mimeType,
|
||||||
});
|
});
|
||||||
|
@ -39,15 +62,4 @@ 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}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,20 +261,23 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
||||||
case FullscreenAction.rename:
|
case FullscreenAction.rename:
|
||||||
showRenameDialog(entry);
|
showRenameDialog(entry);
|
||||||
break;
|
break;
|
||||||
|
case FullscreenAction.open:
|
||||||
|
AndroidAppService.open(entry.uri, entry.mimeType);
|
||||||
|
break;
|
||||||
|
case FullscreenAction.openMap:
|
||||||
|
AndroidAppService.openMap(entry.geoUri);
|
||||||
|
break;
|
||||||
case FullscreenAction.setAs:
|
case FullscreenAction.setAs:
|
||||||
AndroidAppService.setAs(entry.uri, entry.mimeType);
|
AndroidAppService.setAs(entry.uri, entry.mimeType);
|
||||||
break;
|
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 { edit, info, rename, setAs, share, showOnMap }
|
enum FullscreenAction { edit, info, open, openMap, rename, setAs, share }
|
||||||
|
|
||||||
class ImagePage extends StatefulWidget {
|
class ImagePage extends StatefulWidget {
|
||||||
final List<ImageEntry> entries;
|
final List<ImageEntry> entries;
|
||||||
|
|
|
@ -52,22 +52,27 @@ class FullscreenTopOverlay extends StatelessWidget {
|
||||||
value: FullscreenAction.info,
|
value: FullscreenAction.info,
|
||||||
child: Text("Info"),
|
child: Text("Info"),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
|
||||||
value: FullscreenAction.edit,
|
|
||||||
child: Text("Edit"),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: FullscreenAction.rename,
|
value: FullscreenAction.rename,
|
||||||
child: Text("Rename"),
|
child: Text("Rename"),
|
||||||
),
|
),
|
||||||
|
PopupMenuDivider(),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: FullscreenAction.edit,
|
||||||
|
child: Text("Edit with…"),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: FullscreenAction.open,
|
||||||
|
child: Text("Open with…"),
|
||||||
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: FullscreenAction.setAs,
|
value: FullscreenAction.setAs,
|
||||||
child: Text("Set as"),
|
child: Text("Set as…"),
|
||||||
),
|
),
|
||||||
if (entry.hasGps)
|
if (entry.hasGps)
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: FullscreenAction.showOnMap,
|
value: FullscreenAction.openMap,
|
||||||
child: Text("Show on map"),
|
child: Text("Show on map…"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
onSelected: onActionSelected,
|
onSelected: onActionSelected,
|
||||||
|
|
Loading…
Reference in a new issue