From fb2bf78591672362adbb62ea15e7be4ac34a7dee Mon Sep 17 00:00:00 2001 From: volzhs Date: Fri, 27 Nov 2015 23:40:04 +0900 Subject: Add ability to set "keep screen on" for android --- .../java/src/org/godotengine/godot/Godot.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'platform/android/java') diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index c6bc6a6943..1f208f8fb6 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -113,6 +113,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private boolean use_immersive=false; private boolean mStatePaused; private int mState; + private boolean keep_screen_on=true; private void setState(int newState) { if (mState != newState) { @@ -259,7 +260,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mView = new GodotView(getApplication(),io,use_gl2,use_32_bits, this); layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); - mView.setKeepScreenOn(true); + setKeepScreenOn(GodotLib.getGlobal("display/keep_screen_on").equals("True")); edittext.setView(mView); io.setEdit(edittext); @@ -270,7 +271,19 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC layout.addView(adLayout); } - + + 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); + } + }); + } + } + private static Godot _self; public static Godot getInstance(){ @@ -385,8 +398,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC super.onCreate(icicle); _self = this; Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON - | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + //window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); //check for apk expansion API -- cgit v1.2.3