diff --git a/forge-gui-android/src/forge/app/Main.java b/forge-gui-android/src/forge/app/Main.java index c7e71411c8e..869a2bc5d6c 100644 --- a/forge-gui-android/src/forge/app/Main.java +++ b/forge-gui-android/src/forge/app/Main.java @@ -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)); } } diff --git a/forge-gui-ios/src/forge/ios/Main.java b/forge-gui-ios/src/forge/ios/Main.java index 3b6e20a8cf5..1e9562f2ecb 100644 --- a/forge-gui-ios/src/forge/ios/Main.java +++ b/forge-gui-ios/src/forge/ios/Main.java @@ -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; } diff --git a/forge-gui-mobile-dev/src/forge/app/Main.java b/forge-gui-mobile-dev/src/forge/app/Main.java index cb6567ac702..ce513cb5f5c 100644 --- a/forge-gui-mobile-dev/src/forge/app/Main.java +++ b/forge-gui-mobile-dev/src/forge/app/Main.java @@ -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 { diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index e49f1caebc8..7870c987f29 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -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; diff --git a/forge-gui-mobile/src/forge/assets/AssetsDownloader.java b/forge-gui-mobile/src/forge/assets/AssetsDownloader.java index 2d5ce4ed6af..fc4971ea829 100644 --- a/forge-gui-mobile/src/forge/assets/AssetsDownloader.java +++ b/forge-gui-mobile/src/forge/assets/AssetsDownloader.java @@ -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. " +