Changed sharing mechanism again
This commit is contained in:
@@ -33,6 +33,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
|
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
|
||||||
|
|
||||||
public class IOSLauncher extends IOSApplication.Delegate {
|
public class IOSLauncher extends IOSApplication.Delegate {
|
||||||
@Override
|
@Override
|
||||||
@@ -77,11 +78,14 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shareFile(FileHandle file){
|
public void shareFile(FileHandle file){
|
||||||
NSURL url = new NSURL(file.file());
|
FileHandle to = Gdx.files.absolute(getDocumentsDirectory()).child(file.name());
|
||||||
|
file.copyTo(to);
|
||||||
|
|
||||||
|
NSURL url = new NSURL(to.file());
|
||||||
UIActivityViewController p = new UIActivityViewController(Collections.singletonList(url), null);
|
UIActivityViewController p = new UIActivityViewController(Collections.singletonList(url), null);
|
||||||
|
|
||||||
UIApplication.getSharedApplication().getKeyWindow().getRootViewController()
|
UIApplication.getSharedApplication().getKeyWindow().getRootViewController()
|
||||||
.presentViewController(p, true, () -> io.anuke.ucore.util.Log.info("Success! Presented {0}", file));
|
.presentViewController(p, true, () -> io.anuke.ucore.util.Log.info("Success! Presented {0}", to));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,12 +113,14 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void openURL(NSURL url){
|
void openURL(NSURL url){
|
||||||
String str = url.getAbsoluteString().toLowerCase();
|
String str = url.getAbsoluteURL().getAbsoluteString().toLowerCase();
|
||||||
|
System.err.println("STR: " + str);
|
||||||
|
|
||||||
if(str.endsWith("mins")){ //open save
|
|
||||||
Timers.runTask(30f, () -> {
|
Timers.runTask(30f, () -> {
|
||||||
FileHandle file = Gdx.files.absolute(url.getAbsoluteString());
|
FileHandle file = Gdx.files.absolute(url.getAbsoluteString());
|
||||||
|
|
||||||
|
if(str.endsWith("mins")){ //open save
|
||||||
|
|
||||||
if(SaveIO.isSaveValid(file)){
|
if(SaveIO.isSaveValid(file)){
|
||||||
try{
|
try{
|
||||||
control.getSaves().importSave(file);
|
control.getSaves().importSave(file);
|
||||||
@@ -124,15 +130,14 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
}else{
|
}else{
|
||||||
ui.showError("$text.save.import.invalid");
|
ui.showError("$text.save.import.invalid");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}else if(str.endsWith("png")){ //open map
|
}else if(str.endsWith("png")){ //open map
|
||||||
Timers.runTask(30f, () -> {
|
|
||||||
if(!ui.editor.isShown()){
|
if(!ui.editor.isShown()){
|
||||||
ui.editor.show();
|
ui.editor.show();
|
||||||
}
|
}
|
||||||
ui.editor.tryLoadMap(Gdx.files.absolute(url.getAbsoluteString()));
|
ui.editor.tryLoadMap(file);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] argv) {
|
public static void main(String[] argv) {
|
||||||
|
|||||||
Reference in New Issue
Block a user