From f9ede752f25d228e7786fbb23b8333926d019fb4 Mon Sep 17 00:00:00 2001 From: Agetian Date: Sat, 26 Aug 2017 15:13:46 +0000 Subject: [PATCH] - Added a new option to mobile Forge which might help deal with the texture issues after locking/unlocking the screen (suggested by kevlahnota). --- forge-gui-android/src/forge/app/Main.java | 26 +++++++++++++++---- .../forge/screens/settings/SettingsPage.java | 5 +++- forge-gui/release-files/CHANGES.txt | 3 +++ .../forge/properties/ForgePreferences.java | 1 + 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/forge-gui-android/src/forge/app/Main.java b/forge-gui-android/src/forge/app/Main.java index 68caf095480..a7299410da9 100644 --- a/forge-gui-android/src/forge/app/Main.java +++ b/forge-gui-android/src/forge/app/Main.java @@ -1,8 +1,5 @@ package forge.app; -import java.io.File; -import java.util.concurrent.Callable; - import android.app.AlarmManager; import android.app.PendingIntent; import android.content.ClipData; @@ -17,18 +14,22 @@ import android.net.NetworkInfo; import android.net.Uri; import android.os.Bundle; import android.os.Environment; +import android.os.PowerManager; import android.view.WindowManager; import android.webkit.MimeTypeMap; - import com.badlogic.gdx.Gdx; import com.badlogic.gdx.backends.android.AndroidApplication; - import forge.FThreads; import forge.Forge; import forge.interfaces.IDeviceAdapter; +import forge.model.FModel; +import forge.properties.ForgePreferences; import forge.util.FileUtil; import forge.util.ThreadUtil; +import java.io.File; +import java.util.concurrent.Callable; + public class Main extends AndroidApplication { @Override protected void onCreate(Bundle savedInstanceState) { @@ -80,6 +81,21 @@ public class Main extends AndroidApplication { }*/ + @Override + protected void onPause() + { + if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ANDROID_MINIMIZE_ON_SCRLOCK)) { + super.onPause(); + // If the screen is off then the device has been locked + PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); + boolean isScreenOn = powerManager.isScreenOn(); + if (!isScreenOn) { + this.moveTaskToBack(true); + // Minimize the app to the background... + } + } + } + //special clipboard that words on Android private class AndroidClipboard implements com.badlogic.gdx.utils.Clipboard { private final ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); diff --git a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java index a918bfb03ef..66477532c33 100644 --- a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java +++ b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java @@ -75,7 +75,10 @@ public class SettingsPage extends TabPage { } } }, 0); - + lstSettings.addItem(new BooleanSetting(FPref.UI_ANDROID_MINIMIZE_ON_SCRLOCK, + "Minimize on Screen Lock", + "Minimize Forge when screen is locked (enable if you experience graphic glitches after locking your screen)."), + 0); //Gameplay Options lstSettings.addItem(new CustomSelectSetting(FPref.UI_CURRENT_AI_PROFILE, "AI Personality", diff --git a/forge-gui/release-files/CHANGES.txt b/forge-gui/release-files/CHANGES.txt index 296eb497edc..38cf64f463c 100644 --- a/forge-gui/release-files/CHANGES.txt +++ b/forge-gui/release-files/CHANGES.txt @@ -4,6 +4,9 @@ A simple "create a puzzle" mode has been added, which presents you with a clean - Targeting Overlay - The planeswalker attacker targeting arrows now use a distinct color from the blocker arrows, to make them easier to distinguish during a complex combat scenario. The default theme uses orange targeting arrows for this purpose, but they can be redefined in custom themes by editing sprite_icons.png (please consult the updated default file for details). +- Mobile Forge: Minimize on Screen Lock (option) - +A new option is available in Mobile Forge, which sends the game to background ("minimizes" it) when the screen is locked. This might help in case you are experiencing graphic issues (missing card pictures, black squares instead of font letters, etc.) after locking the screen for some time. This option is opt-in for now, and is thus off by default. This option and the fix were suggested by kevlahnota. + - Mobile Forge: Texture Filtering - Texture filtering is now enabled by default for new Mobile Forge installations on Android. After extensive testing this mode has shown no noticeable performance downgrade on modern Android devices while offering a significantly higher quality of card rendering on the battlefield. Older installations will not be affected by this and you will still need to enable the feature manually if desired (in Forge preferences). If you are on a significantly older or low-end device and you are experiencing inadequately low game performance, please try disabling this option in case it is enabled on your installation. diff --git a/forge-gui/src/main/java/forge/properties/ForgePreferences.java b/forge-gui/src/main/java/forge/properties/ForgePreferences.java index c1310508c07..b0f0a073d83 100644 --- a/forge-gui/src/main/java/forge/properties/ForgePreferences.java +++ b/forge-gui/src/main/java/forge/properties/ForgePreferences.java @@ -93,6 +93,7 @@ public class ForgePreferences extends PreferencesStore { UI_SHOW_STORM_COUNT_IN_PROMPT ("false"), UI_CARD_COUNTER_DISPLAY_TYPE(ForgeConstants.CounterDisplayType.TEXT.getName()), UI_CARD_COUNTER_DISPLAY_LOCATION(ForgeConstants.CounterDisplayLocation.TOP.getName()), + UI_ANDROID_MINIMIZE_ON_SCRLOCK("false"), UI_FOR_TOUCHSCREN("false"),