File tree 3 files changed +25
-0
lines changed
java/com/jvdegithub/aiscatcher 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) {
158
158
public void onSharedPreferenceChanged (SharedPreferences sharedPreferences , String key ) {
159
159
if (key .equals ("sFORCEDARK" ))
160
160
setDarkMode (false );
161
+ else if (key .equals ("sKEEPSCREENON" ))
162
+ applyKeepScreenOnSetting ();
161
163
}
162
164
};
163
165
@@ -216,6 +218,7 @@ protected void onResume () {
216
218
217
219
super .onResume ();
218
220
221
+ applyKeepScreenOnSetting ();
219
222
updateUIonSource ();
220
223
if (AisService .isRunning (getApplicationContext ())) {
221
224
updateUIwithStart ();
@@ -229,6 +232,15 @@ protected void onResume () {
229
232
}
230
233
}
231
234
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
+
232
244
@ Override
233
245
protected void onStart () {
234
246
super .onStart ();
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ static void setDefault(Context context) {
60
60
preferences .edit ().putString ("sSHARINGKEY" , "" ).commit ();
61
61
preferences .edit ().putBoolean ("sSHARING" , false ).commit ();
62
62
preferences .edit ().putBoolean ("sAUTOSTART" , false ).commit ();
63
+ preferences .edit ().putBoolean ("sKEEPSCREENON" , false ).commit ();
63
64
64
65
preferences .edit ().putBoolean ("w1SWITCH" , false ).commit ();
65
66
preferences .edit ().putString ("w1PORT" , "8100" ).commit ();
@@ -308,6 +309,12 @@ static public boolean getAutoStart(Context context)
308
309
return preferences .getBoolean ("sAUTOSTART" ,false );
309
310
}
310
311
312
+ static public boolean getKeepScreenOn (Context context )
313
+ {
314
+ SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (context );
315
+ return preferences .getBoolean ("sKEEPSCREENON" ,false );
316
+ }
317
+
311
318
static public boolean getFixedPointDownsampling (Context context )
312
319
{
313
320
SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (context );
Original file line number Diff line number Diff line change 31
31
android : defaultValue =" False"
32
32
android : title =" Auto Start" />
33
33
34
+ <SwitchPreferenceCompat
35
+ android : key =" sKEEPSCREENON"
36
+ android : summary =" Keep screen on"
37
+ android : defaultValue =" False"
38
+ android : title =" Keep Screen On" />
39
+
34
40
</PreferenceCategory >
35
41
36
42
<PreferenceCategory
You can’t perform that action at this time.
0 commit comments