[Android] Manual update instruction.

This commit is contained in:
Anthony Calosa
2020-12-02 06:33:52 +08:00
parent b765f7bb20
commit 0f05620dc9
5 changed files with 19 additions and 17 deletions

View File

@@ -61,14 +61,6 @@ public class Main extends AndroidApplication {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* workaroundfix FileUriExposed on TargetSDK >= 26
* (Tested with RealMe 6 PRO, Teclast M40 on Android 10, installs smoothly after downloading from FTP)
* should verify if working on Android 11 when the program updates...
*/
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
//get total device RAM in mb
ActivityManager actManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
@@ -77,7 +69,7 @@ public class Main extends AndroidApplication {
boolean permissiongranted = checkPermission();
Gadapter = new AndroidAdapter(this.getContext());
initForge(Gadapter, permissiongranted, totalMemory, isTabletDevice(this.getContext()));
initForge(Gadapter, permissiongranted, totalMemory, isTabletDevice(this.getContext()), android.os.Build.VERSION.SDK_INT);
//permission
if(!permissiongranted){
@@ -216,7 +208,7 @@ public class Main extends AndroidApplication {
builder.show();
}
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice){
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice, int AndroidVersion){
boolean isPortrait;
if (permissiongranted){
//establish assets directory
@@ -256,12 +248,12 @@ public class Main extends AndroidApplication {
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM, isTabletDevice));
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM, isTabletDevice, AndroidVersion));
} else {
isPortrait = true;
//set current orientation
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice));
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice, AndroidVersion));
}
}

View File

@@ -33,7 +33,7 @@ public class Main extends IOSApplication.Delegate {
config.useCompass = false;
ForgePreferences prefs = FModel.getPreferences();
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);//todo get totalRAM && isTabletDevice
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false);
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false, 0);
final IOSApplication iosApp = new IOSApplication(app, config);
return iosApp;
}

View File

@@ -97,7 +97,7 @@ public class Main {
ForgePreferences prefs = FModel.getPreferences();
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false), config);
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0), config);
}
private static class DesktopAdapter implements IDeviceAdapter {

View File

@@ -75,8 +75,9 @@ public class Forge implements ApplicationListener {
public static boolean gameInProgress = false;
public static int cacheSize = 400;
public static int totalDeviceRAM = 0;
public static int androidVersion = 0;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet) {
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidVersion) {
if (GuiBase.getInterface() == null) {
clipboard = clipboard0;
deviceAdapter = deviceAdapter0;
@@ -85,6 +86,7 @@ public class Forge implements ApplicationListener {
isPortraitMode = androidOrientation;
totalDeviceRAM = totalRAM;
isTabletDevice = isTablet;
androidVersion = AndroidVersion;
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
if (totalDeviceRAM>5000) //devices with more than 10GB RAM will have 1000 Cache size, 700 Cache size for morethan 5GB RAM
cacheSize = totalDeviceRAM>10000 ? 1000: 700;

View File

@@ -50,8 +50,16 @@ public class AssetsDownloader {
"https://releases.cardforge.org/forge/forge-gui-android/" + version + "/" + filename,
Forge.getDeviceAdapter().getDownloadsDir(), null, splashScreen.getProgressBar()).download(filename);
if (apkFile != null) {
Forge.getDeviceAdapter().openFile(apkFile);
Forge.exit(true);
if (Forge.androidVersion < 29) { //Android 9 and below...
Forge.getDeviceAdapter().openFile(apkFile);
Forge.exit(true);
return;
}
//Android 10 and newer manual apk installation
switch (SOptionPane.showOptionDialog("Download Successful. Go to your downloads folder and install " + filename +" to update Forge. Forge will now exit.", "", null, ImmutableList.of("Ok"))) {
default:
Forge.exit(true);
}
return;
}
SOptionPane.showMessageDialog("Could not download update. " +