Partial 7.0 merge - API preview

This commit is contained in:
Anuken
2021-06-02 11:08:08 -04:00
parent ea75a357ca
commit 28b235ef07
531 changed files with 12356 additions and 6286 deletions

View File

@@ -15,9 +15,11 @@ import arc.func.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import dalvik.system.*;
import io.anuke.mindustry.*;
import mindustry.*;
import mindustry.game.Saves.*;
import mindustry.io.*;
import mindustry.mod.*;
import mindustry.net.*;
import mindustry.ui.dialogs.*;
@@ -33,6 +35,9 @@ public class AndroidLauncher extends AndroidApplication{
FileChooser chooser;
Runnable permCallback;
Object gpService;
Class<?> serviceClass;
@Override
protected void onCreate(Bundle savedInstanceState){
UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
@@ -50,7 +55,7 @@ public class AndroidLauncher extends AndroidApplication{
});
super.onCreate(savedInstanceState);
if(doubleScaleTablets && isTablet(this.getContext())){
if(doubleScaleTablets && isTablet(this)){
Scl.setAddition(0.5f);
}
@@ -63,7 +68,9 @@ public class AndroidLauncher extends AndroidApplication{
@Override
public rhino.Context getScriptContext(){
return AndroidRhinoContext.enter(getContext().getCacheDir());
rhino.Context result = AndroidRhinoContext.enter(((Context)AndroidLauncher.this).getCacheDir());
result.setClassShutter(Scripts::allowClass);
return result;
}
@Override
@@ -71,8 +78,8 @@ public class AndroidLauncher extends AndroidApplication{
}
@Override
public ClassLoader loadJar(Fi jar, String mainClass) throws Exception{
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, getClassLoader());
public ClassLoader loadJar(Fi jar, ClassLoader parent) throws Exception{
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent);
}
@Override
@@ -165,9 +172,20 @@ public class AndroidLauncher extends AndroidApplication{
try{
//new external folder
Fi data = Core.files.absolute(getContext().getExternalFilesDir(null).getAbsolutePath());
Fi data = Core.files.absolute(((Context)this).getExternalFilesDir(null).getAbsolutePath());
Core.settings.setDataDirectory(data);
//delete unused cache folder to free up space
try{
Fi cache = Core.settings.getDataDirectory().child("cache");
if(cache.exists()){
cache.deleteDirectory();
}
}catch(Throwable t){
Log.err("Failed to delete cached folder", t);
}
//move to internal storage if there's no file indicating that it moved
if(!Core.files.local("files_moved").exists()){
Log.info("Moving files to external storage...");
@@ -209,6 +227,24 @@ public class AndroidLauncher extends AndroidApplication{
}
}
@Override
public void onResume(){
super.onResume();
//TODO enable once GPGS is set up on the GP console
if(false && BuildConfig.FLAVOR.equals("gp")){
try{
if(gpService == null){
serviceClass = Class.forName("mindustry.android.GPGameService");
gpService = serviceClass.getConstructor().newInstance();
}
serviceClass.getMethod("onResume", Context.class).invoke(gpService, this);
}catch(Exception e){
Log.err("Failed to update Google Play Services", e);
}
}
}
private void checkFiles(Intent intent){
try{
Uri uri = intent.getData();

View File

@@ -175,7 +175,7 @@ public class AndroidRhinoContext{
}catch(IOException e){
e.printStackTrace();
}
android.content.Context context = ((AndroidApplication) Core.app).getContext();
android.content.Context context = (android.content.Context)((AndroidApplication)Core.app);
return new DexClassLoader(dexFile.getPath(), VERSION.SDK_INT >= 21 ? context.getCodeCacheDir().getPath() : context.getCacheDir().getAbsolutePath(), null, getParent()).loadClass(name);
}