v0.7.4b: fixed additional rare system UI issues

This commit is contained in:
Evan Debenham 2019-08-05 14:44:31 -04:00
parent c93bc9784b
commit a3e04de98c
5 changed files with 34 additions and 12 deletions

View File

@ -21,21 +21,29 @@
package com.watabou.utils;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
public class GameSettings {
//TODO might want to rename this file. this is the auto-generated name for android atm
public static final String PREFS_FILE = "ShatteredPixelDungeon";
private static Preferences prefs;
private static Preferences get() {
if (prefs == null) {
//TODO might want to rename this file. this is the auto-generated name for android atm
prefs = Gdx.app.getPreferences("ShatteredPixelDungeon");
prefs = Gdx.app.getPreferences(PREFS_FILE);
}
return prefs;
}
//allows setting up of preferences without Gdx.app being initialized
public static void setPrefsFromInstance (Application instance){
prefs = instance.getPreferences(PREFS_FILE);
}
public static boolean contains( String key ){
return get().contains( key );
}

View File

@ -32,6 +32,7 @@ import android.telephony.TelephonyManager;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.watabou.noosa.Game;
import com.watabou.noosa.audio.Music;
@ -60,9 +61,13 @@ public class AndroidLauncher extends AndroidApplication {
Game.versionCode = 0;
}
// grab preferences directly using our instance first
// so that we don't need to rely on Gdx.app, which isn't initialized yet.
SPDSettings.setPrefsFromInstance(instance);
//set desired orientation (if it exists) before initializing the app.
if (getPreferences("ShatteredPixelDungeon").contains("landscape")) {
if (getPreferences("ShatteredPixelDungeon").getBoolean("landscape")){
if (SPDSettings.landscapeFromSettings() != null) {
if (SPDSettings.landscapeFromSettings()){
instance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else {
instance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
@ -83,6 +88,8 @@ public class AndroidLauncher extends AndroidApplication {
support = new AndroidPlatformSupport();
support.updateSystemUI();
initialize(new ShatteredPixelDungeon(support), config);
view = (GLSurfaceView)graphics.getView();
@ -115,4 +122,10 @@ public class AndroidLauncher extends AndroidApplication {
super.onWindowFocusChanged(hasFocus);
support.updateSystemUI();
}
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
super.onMultiWindowModeChanged(isInMultiWindowMode);
support.updateSystemUI();
}
}

View File

@ -115,7 +115,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
if (DeviceCompat.supportsFullScreen()){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
if (SPDSettings.fullscreen()) {
AndroidLauncher.instance.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

View File

@ -76,6 +76,14 @@ public class SPDSettings extends GameSettings {
return getBoolean(KEY_LANDSCAPE, Game.dispWidth > Game.dispHeight);
}
public static Boolean landscapeFromSettings(){
if (contains(KEY_LANDSCAPE)){
return getBoolean(KEY_LANDSCAPE, false);
} else {
return null;
}
}
public static void powerSaver( boolean value ){
put( KEY_POWER_SAVER, value );
((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize();

View File

@ -104,7 +104,6 @@ public class ShatteredPixelDungeon extends Game {
super.create();
updateSystemUI();
SPDSettings.landscape ( SPDSettings.landscape() );
Music.INSTANCE.enable( SPDSettings.music() );
Music.INSTANCE.volume( SPDSettings.musicVol()/10f );
@ -220,10 +219,4 @@ public class ShatteredPixelDungeon extends Game {
public static void updateSystemUI() {
platform.updateSystemUI();
}
@Override
public void resume() {
super.resume();
updateSystemUI();
}
}