SAF is terrible

This commit is contained in:
Anuken
2019-09-18 19:24:49 -04:00
parent 0d29d94800
commit 5a0669d437
3 changed files with 25 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry; package io.anuke.mindustry;
import android.*;
import android.app.*; import android.app.*;
import android.content.*; import android.content.*;
import android.content.pm.*; import android.content.pm.*;
@@ -21,6 +22,7 @@ import io.anuke.mindustry.ui.dialogs.*;
import java.io.*; import java.io.*;
import java.lang.System; import java.lang.System;
import java.util.*;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
@@ -68,10 +70,10 @@ public class AndroidLauncher extends AndroidApplication{
@Override @Override
public void showFileChooser(boolean open, String extension, Consumer<FileHandle> cons){ public void showFileChooser(boolean open, String extension, Consumer<FileHandle> cons){
if(VERSION.SDK_INT >= 19){ if(VERSION.SDK_INT >= VERSION_CODES.Q){
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT); Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*"); intent.setType(extension.equals("zip") ? "application/zip" : "*/*");
addResultListener(i -> startActivityForResult(intent, i), (code, in) -> { addResultListener(i -> startActivityForResult(intent, i), (code, in) -> {
if(code == Activity.RESULT_OK && in != null && in.getData() != null){ if(code == Activity.RESULT_OK && in != null && in.getData() != null){
Uri uri = in.getData(); Uri uri = in.getData();
@@ -99,6 +101,24 @@ public class AndroidLauncher extends AndroidApplication{
}))); })));
} }
}); });
}else if(VERSION.SDK_INT >= VERSION_CODES.M && !(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
chooser = new FileChooser(open ? "$open" : "$save", file -> file.extension().equalsIgnoreCase(extension), open, file -> {
if(!open){
cons.accept(file.parent().child(file.nameWithoutExtension() + "." + extension));
}else{
cons.accept(file);
}
});
ArrayList<String> perms = new ArrayList<>();
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE);
}else{ }else{
super.showFileChooser(open, extension, cons); super.showFileChooser(open, extension, cons);
} }

View File

@@ -47,7 +47,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
} }
/** Do not invoke! */ /** Do not invoke! */
@Remote(called = Loc.server) @Remote(called = Loc.server, unreliable = true)
public static void createLighting(int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){ public static void createLighting(int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){
Lightning l = Pools.obtain(Lightning.class, Lightning::new); Lightning l = Pools.obtain(Lightning.class, Lightning::new);

View File

@@ -16,6 +16,7 @@ import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.*; import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.blocks.defense.DeflectorWall.*; import io.anuke.mindustry.world.blocks.defense.DeflectorWall.*;
import io.anuke.mindustry.world.blocks.units.CommandCenter.*; import io.anuke.mindustry.world.blocks.units.CommandCenter.*;
import io.anuke.mindustry.world.blocks.units.UnitFactory.*; import io.anuke.mindustry.world.blocks.units.UnitFactory.*;
@@ -273,7 +274,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
return; return;
} }
if(!isFlying() && (world.tileWorld(x, y) != null && world.tileWorld(x, y).solid())){ if(!isFlying() && (world.tileWorld(x, y) != null && !(world.tileWorld(x, y).block() instanceof BuildBlock) && world.tileWorld(x, y).solid())){
kill(); kill();
} }