Merge pull request #25011 from volzhs/android-keep-screen
Fix Android keep screen on working properly
This commit is contained in:
commit
7d5c970eff
1 changed files with 10 additions and 16 deletions
|
@ -119,7 +119,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
||||||
private boolean use_debug_opengl = false;
|
private boolean use_debug_opengl = false;
|
||||||
private boolean mStatePaused;
|
private boolean mStatePaused;
|
||||||
private int mState;
|
private int mState;
|
||||||
private boolean keep_screen_on = true;
|
|
||||||
|
|
||||||
static private Intent mCurrentIntent;
|
static private Intent mCurrentIntent;
|
||||||
|
|
||||||
|
@ -297,31 +296,26 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
||||||
});
|
});
|
||||||
|
|
||||||
final String[] current_command_line = command_line;
|
final String[] current_command_line = command_line;
|
||||||
final GodotView view = mView;
|
|
||||||
mView.queueEvent(new Runnable() {
|
mView.queueEvent(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GodotLib.setup(current_command_line);
|
GodotLib.setup(current_command_line);
|
||||||
runOnUiThread(new Runnable() {
|
setKeepScreenOn("True".equals(GodotLib.getGlobal("display/window/energy_saving/keep_screen_on")));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.setKeepScreenOn("True".equals(GodotLib.getGlobal("display/window/energy_saving/keep_screen_on")));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeepScreenOn(final boolean p_enabled) {
|
public void setKeepScreenOn(final boolean p_enabled) {
|
||||||
keep_screen_on = p_enabled;
|
runOnUiThread(new Runnable() {
|
||||||
if (mView != null) {
|
@Override
|
||||||
runOnUiThread(new Runnable() {
|
public void run() {
|
||||||
@Override
|
if (p_enabled) {
|
||||||
public void run() {
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
mView.setKeepScreenOn(p_enabled);
|
} else {
|
||||||
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alert(final String message, final String title) {
|
public void alert(final String message, final String title) {
|
||||||
|
|
Loading…
Reference in a new issue