From 2bd892d8804d9bf9b7c56e366ad4de9f8c045607 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 22 Feb 2022 19:28:15 -0500 Subject: [PATCH] Possible iOS sharing fix --- ios/src/mindustry/ios/IOSLauncher.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ios/src/mindustry/ios/IOSLauncher.java b/ios/src/mindustry/ios/IOSLauncher.java index efb0874504..fa12ea0e48 100644 --- a/ios/src/mindustry/ios/IOSLauncher.java +++ b/ios/src/mindustry/ios/IOSLauncher.java @@ -141,11 +141,15 @@ public class IOSLauncher extends IOSApplication.Delegate{ public void shareFile(Fi file){ try{ Log.info("Attempting to share file " + file); - Fi to = Core.files.absolute(getDocumentsDirectory()).child(file.name()); - file.copyTo(to); + List list = new ArrayList<>(); - NSURL url = new NSURL(to.file()); - UIActivityViewController p = new UIActivityViewController(Collections.singletonList(url), null); + list.add(file.name()); + list.add(NSData.read(file.file())); + + //better choice? + //list.add(new NSURL(file.file())); + + UIActivityViewController p = new UIActivityViewController(list, null); UIViewController rootVc = UIApplication.getSharedApplication().getKeyWindow().getRootViewController(); if(UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad){ // Set up the pop-over for iPad @@ -156,7 +160,7 @@ public class IOSLauncher extends IOSApplication.Delegate{ pop.setSourceRect(targetRect); pop.setPermittedArrowDirections(UIPopoverArrowDirection.None); } - rootVc.presentViewController(p, true, () -> Log.info("Success! Presented @", to)); + rootVc.presentViewController(p, true, () -> Log.info("Success! Presented @", file)); }catch(Throwable t){ ui.showException(t); }