Android: Only keep the screen bright ingame.

This commit is contained in:
Henrik Rydgård 2018-05-08 23:05:09 +02:00
parent 97546d30ff
commit a8083b9684
2 changed files with 20 additions and 3 deletions

View File

@ -30,6 +30,7 @@
#include <condition_variable>
#include "base/timeutil.h"
#include "base/NativeApp.h"
#include "math/math_util.h"
#include "thread/threadutil.h"
#include "util/text/utf8.h"
@ -106,6 +107,16 @@ void UpdateUIState(GlobalUIState newState) {
if (globalUIState != newState && globalUIState != UISTATE_EXIT) {
globalUIState = newState;
host->UpdateDisassembly();
const char *state = nullptr;
switch (globalUIState) {
case UISTATE_EXIT: state = "exit"; break;
case UISTATE_INGAME: state = "ingame"; break;
case UISTATE_MENU: state = "menu"; break;
case UISTATE_PAUSEMENU: state = "pausemenu"; break;
}
if (state) {
System_SendMessage("uistate", state);
}
}
}

View File

@ -476,9 +476,6 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
updateScreenRotation("onCreate");
updateSustainedPerformanceMode();
// Keep the screen bright - very annoying if it goes dark when tilting away
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
gainAudioFocus(this.audioManager, this.audioFocusChangeListener);
@ -1290,6 +1287,15 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
} else if (mCameraHelper != null && params.equals("stopVideo")) {
mCameraHelper.stopCamera();
}
} else if (command.equals("uistate")) {
Window window = this.getWindow();
if (params.equals("ingame")) {
// Keep the screen bright - very annoying if it goes dark when tilting away
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
// Only keep the screen bright ingame.
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
return false;
}