diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-01-15 14:26:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-15 14:26:12 +0100 |
commit | 7d5c970eff252db7daa1ece449b74afef8f6a561 (patch) | |
tree | 1c925c6a5946dcb87a615113a6f9fa74938386a9 /platform | |
parent | d8cca33038086a65307578daa61cbeec024a1571 (diff) | |
parent | 87db1a897187dfed7d02ce1aa1cce432fa068752 (diff) |
Merge pull request #25011 from volzhs/android-keep-screen
Fix Android keep screen on working properly
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 8041c5f97e..a10d7876f4 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -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,31 +296,26 @@ 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); + runOnUiThread(new Runnable() { + @Override + public void run() { + 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) { |