summaryrefslogtreecommitdiff
path: root/platform/android/java/src/org/godotengine
diff options
context:
space:
mode:
authorvolzhs <volzhs@gmail.com>2015-11-27 23:40:04 +0900
committervolzhs <volzhs@gmail.com>2016-01-16 20:57:34 +0900
commitfb2bf78591672362adbb62ea15e7be4ac34a7dee (patch)
tree98da1c62d4183bb0ca2f194f4650595cf386b3e1 /platform/android/java/src/org/godotengine
parent3c6dd5749d445f082fc925a34cc0a26f8d342304 (diff)
Add ability to set "keep screen on" for android
Diffstat (limited to 'platform/android/java/src/org/godotengine')
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java21
1 files changed, 17 insertions, 4 deletions
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