@@ -13,22 +13,20 @@ public class KeepAwakePlugin extends Plugin {
1313
1414 @ PluginMethod
1515 public void keepAwake (final PluginCall call ) {
16- getBridge ()
17- .executeOnMainThread (() -> {
18- Window window = getActivity ().getWindow ();
19- window .addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
20- call .resolve ();
21- });
16+ getBridge ().executeOnMainThread (() -> {
17+ Window window = getActivity ().getWindow ();
18+ window .addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
19+ call .resolve ();
20+ });
2221 }
2322
2423 @ PluginMethod
2524 public void allowSleep (final PluginCall call ) {
26- getBridge ()
27- .executeOnMainThread (() -> {
28- Window window = getActivity ().getWindow ();
29- window .clearFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
30- call .resolve ();
31- });
25+ getBridge ().executeOnMainThread (() -> {
26+ Window window = getActivity ().getWindow ();
27+ window .clearFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
28+ call .resolve ();
29+ });
3230 }
3331
3432 @ PluginMethod
@@ -40,16 +38,15 @@ public void isSupported(PluginCall call) {
4038
4139 @ PluginMethod
4240 public void isKeptAwake (final PluginCall call ) {
43- getBridge ()
44- .executeOnMainThread (() -> {
45- // use the "bitwise and" operator to check if FLAG_KEEP_SCREEN_ON is on or off
46- // credits: https://stackoverflow.com/a/24214209/9979122
47- int flags = getActivity ().getWindow ().getAttributes ().flags ;
48- boolean isKeptAwake = (flags & WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON ) != 0 ;
41+ getBridge ().executeOnMainThread (() -> {
42+ // use the "bitwise and" operator to check if FLAG_KEEP_SCREEN_ON is on or off
43+ // credits: https://stackoverflow.com/a/24214209/9979122
44+ int flags = getActivity ().getWindow ().getAttributes ().flags ;
45+ boolean isKeptAwake = (flags & WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON ) != 0 ;
4946
50- JSObject ret = new JSObject ();
51- ret .put ("isKeptAwake" , isKeptAwake );
52- call .resolve (ret );
53- });
47+ JSObject ret = new JSObject ();
48+ ret .put ("isKeptAwake" , isKeptAwake );
49+ call .resolve (ret );
50+ });
5451 }
5552}
0 commit comments