From eddbc1e94ab26ca42341c4875369d91db89f727f Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 11 Sep 2021 17:13:20 +0800 Subject: [PATCH] [Mobile] Disable cardBG Texture for Android 9 and below on Android 10+ (4 GB RAM) it works fine however Android 9 and below with at least 4 GB RAM, it crashes at startup if it tries to read and load the big texture file. Needs investigation --- forge-gui-mobile/src/forge/Forge.java | 8 ++++++++ forge-gui-mobile/src/forge/card/CardImageRenderer.java | 2 +- .../forge/localinstance/properties/ForgeConstants.java | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 4376d0476e3..4dc7e0ca439 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -67,6 +67,7 @@ public class Forge implements ApplicationListener { public static float heigtModifier = 0.0f; private static boolean isloadingaMatch = false; public static boolean showFPS = false; + public static boolean allowCardBG = false; public static boolean altPlayerLayout = false; public static boolean altZoneTabs = false; public static String enableUIMask = "Crop"; @@ -111,6 +112,13 @@ public class Forge implements ApplicationListener { GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android); + if (!GuiBase.isAndroid() || androidVersion > 28) { + allowCardBG = true; + } else { + // don't allow to read and process + ForgeConstants.SPRITE_CARDBG_FILE = ""; + } + graphics = new Graphics(); splashScreen = new SplashScreen(); frameRate = new FrameRate(); diff --git a/forge-gui-mobile/src/forge/card/CardImageRenderer.java b/forge-gui-mobile/src/forge/card/CardImageRenderer.java index a7b267366f5..af2e1b36e18 100644 --- a/forge-gui-mobile/src/forge/card/CardImageRenderer.java +++ b/forge-gui-mobile/src/forge/card/CardImageRenderer.java @@ -120,7 +120,7 @@ public class CardImageRenderer { } else { borderColors = CardDetailUtil.getBorderColors(state, canShow); } - Color[] colors = useCardBGTexture ? drawCardBackgroundTexture(state, g, borderColors, x, y, w, h) : fillColorBackground(g, borderColors, x, y, w, h); + Color[] colors = useCardBGTexture && Forge.allowCardBG ? drawCardBackgroundTexture(state, g, borderColors, x, y, w, h) : fillColorBackground(g, borderColors, x, y, w, h); float artInset = blackBorderThickness * 0.5f; float outerBorderThickness = 2 * blackBorderThickness - artInset; diff --git a/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java index 313d27841b5..81eded8cce2 100644 --- a/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java @@ -123,7 +123,7 @@ public final class ForgeConstants { public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png"; public static final String SPRITE_SETLOGO_FILE = "sprite_setlogo.png"; public static final String SPRITE_WATERMARK_FILE = "sprite_watermark.png"; - public static final String SPRITE_CARDBG_FILE = "sprite_cardbg.png"; + public static String SPRITE_CARDBG_FILE = "sprite_cardbg.png"; public static final String FONT_FILE = "font1.ttf"; public static final String SPLASH_BG_FILE = "bg_splash.png"; public static final String MATCH_BG_FILE = "bg_match.jpg";