File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
java/com/jvdegithub/aiscatcher Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,8 @@ protected void onCreate(Bundle savedInstanceState) {
158158 public void onSharedPreferenceChanged (SharedPreferences sharedPreferences , String key ) {
159159 if (key .equals ("sFORCEDARK" ))
160160 setDarkMode (false );
161+ else if (key .equals ("sKEEPSCREENON" ))
162+ applyKeepScreenOnSetting ();
161163 }
162164 };
163165
@@ -216,6 +218,7 @@ protected void onResume () {
216218
217219 super .onResume ();
218220
221+ applyKeepScreenOnSetting ();
219222 updateUIonSource ();
220223 if (AisService .isRunning (getApplicationContext ())) {
221224 updateUIwithStart ();
@@ -229,6 +232,15 @@ protected void onResume () {
229232 }
230233 }
231234
235+ private void applyKeepScreenOnSetting () {
236+ boolean keepScreenOn = Settings .getKeepScreenOn (this );
237+ if (keepScreenOn ) {
238+ getWindow ().addFlags (android .view .WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
239+ } else {
240+ getWindow ().clearFlags (android .view .WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
241+ }
242+ }
243+
232244 @ Override
233245 protected void onStart () {
234246 super .onStart ();
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ static void setDefault(Context context) {
6060 preferences .edit ().putString ("sSHARINGKEY" , "" ).commit ();
6161 preferences .edit ().putBoolean ("sSHARING" , false ).commit ();
6262 preferences .edit ().putBoolean ("sAUTOSTART" , false ).commit ();
63+ preferences .edit ().putBoolean ("sKEEPSCREENON" , false ).commit ();
6364
6465 preferences .edit ().putBoolean ("w1SWITCH" , false ).commit ();
6566 preferences .edit ().putString ("w1PORT" , "8100" ).commit ();
@@ -308,6 +309,12 @@ static public boolean getAutoStart(Context context)
308309 return preferences .getBoolean ("sAUTOSTART" ,false );
309310 }
310311
312+ static public boolean getKeepScreenOn (Context context )
313+ {
314+ SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (context );
315+ return preferences .getBoolean ("sKEEPSCREENON" ,false );
316+ }
317+
311318 static public boolean getFixedPointDownsampling (Context context )
312319 {
313320 SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (context );
Original file line number Diff line number Diff line change 3131 android : defaultValue =" False"
3232 android : title =" Auto Start" />
3333
34+ <SwitchPreferenceCompat
35+ android : key =" sKEEPSCREENON"
36+ android : summary =" Keep screen on"
37+ android : defaultValue =" False"
38+ android : title =" Keep Screen On" />
39+
3440 </PreferenceCategory >
3541
3642 <PreferenceCategory
You can’t perform that action at this time.
0 commit comments