v0.7.0a: fixed various issues with screen layout and power saver mode

This commit is contained in:
Evan Debenham 2018-10-24 00:27:44 -04:00
parent 02e0de6273
commit 06a6116852
2 changed files with 12 additions and 5 deletions

View File

@ -75,6 +75,8 @@ public class SPDSettings extends GameSettings {
((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize();
}
//FIXME in certain multi-window cases this can disagree with the actual screen size
//there should be an option to check for landscape the setting, and actual screen size
public static boolean landscape() {
return getBoolean(KEY_LANDSCAPE, Game.dispWidth > Game.dispHeight);
}

View File

@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -252,6 +253,13 @@ public class ShatteredPixelDungeon extends Game {
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateDisplaySize();
}
public void updateDisplaySize(){
boolean landscape = SPDSettings.landscape();
@ -267,11 +275,8 @@ public class ShatteredPixelDungeon extends Game {
}
}
if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0)
return;
dispWidth = view.getMeasuredWidth();
dispHeight = view.getMeasuredHeight();
dispHeight = getWindow().getWindowManager().getDefaultDisplay().getHeight();
dispWidth = getWindow().getWindowManager().getDefaultDisplay().getWidth();
float dispRatio = dispWidth / (float)dispHeight;