Merge pull request #25011 from volzhs/android-keep-screen

Fix Android keep screen on working properly
This commit is contained in:
Rémi Verschelde 2019-01-15 14:26:12 +01:00 committed by GitHub
commit 7d5c970eff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,7 +119,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private boolean use_debug_opengl = false;
private boolean mStatePaused;
private int mState;
private boolean keep_screen_on = true;
static private Intent mCurrentIntent;
@ -297,32 +296,27 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
});
final String[] current_command_line = command_line;
final GodotView view = mView;
mView.queueEvent(new Runnable() {
@Override
public void run() {
GodotLib.setup(current_command_line);
runOnUiThread(new Runnable() {
@Override
public void run() {
view.setKeepScreenOn("True".equals(GodotLib.getGlobal("display/window/energy_saving/keep_screen_on")));
}
});
setKeepScreenOn("True".equals(GodotLib.getGlobal("display/window/energy_saving/keep_screen_on")));
}
});
}
public void setKeepScreenOn(final boolean p_enabled) {
keep_screen_on = p_enabled;
if (mView != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mView.setKeepScreenOn(p_enabled);
if (p_enabled) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
});
}
}
public void alert(final String message, final String title) {
final Activity activity = this;