public void onStart() {
Log.d(TAG, "onStart");
super.onStart();
+
+ CtFwSDisplay.resetWindow(this);
}
@Override
case R.id.mainmenu_judge:
startActivity(new Intent(this, Activity.class));
return true;
- case R.id.mainmenu_screenwake:
- boolean checked = mi.isChecked();
- if (checked) {
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- } else {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- mi.setChecked(!checked);
case R.id.mainmenu_reconn:
if (mSrvBinder != null) {
mSrvBinder.connect(true);
package com.acmetensortoys.ctfwstimer.activity.main;
import android.app.Activity;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.View;
+import android.view.WindowManager;
import android.widget.Chronometer;
import android.widget.ProgressBar;
import android.widget.TextView;
+import androidx.preference.PreferenceManager;
+
import com.acmetensortoys.ctfwstimer.R;
import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager;
import com.acmetensortoys.ctfwstimer.utils.AndroidResourceUtils;
}
// Otherwise, it's game on!
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mAct);
+ if (sp.getBoolean("screen_on_when_game", false)) {
+ Log.d("CtFwS", "Requesting screen on");
+ mAct.runOnUiThread(() -> mAct.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON));
+ }
+
// Upper line text
{
final TextView tv_jb = mAct.findViewById(R.id.tv_jailbreak);
}
}
+ private void resetWindow() {
+ mAct.runOnUiThread(() -> resetWindow(mAct));
+ }
+
+ public static void resetWindow(Activity act) {
+ Log.d("CtFwS", "window reset");
+ act.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+ }
+
private void doReset() {
Log.d("CtFwS", "Display Reset");
+ resetWindow();
+
{
final Chronometer ch = mAct.findViewById(R.id.ch_jailbreak);
ch.post(new Runnable() {
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@+id/mainmenu_screenwake"
- android:checkable="true"
- android:enabled="true"
- android:title="@string/menutext_screenwake"
- android:visible="true"
- app:showAsAction="never" />
<item
android:id="@+id/mainmenu_hand"
android:icon="@drawable/ic_library_books_24dp"
<string name="menutext_prf">Settings</string>
<string name="menutext_quit">Quit</string>
<string name="menutext_reconn">Reconnect</string>
- <string name="menutext_screenwake">Keep Screen On</string>
<string name="menutext_search">Search</string>
<string name="mqtt_state_label">Server State:</string>
<string name="preftext_mqtt_def">Use Default MQTT Server</string>
<string name="preftext_mqtt_prefcat">MQTT Server</string>
<string name="preftext_notif_prefcat">Notification Settings</string>
+ <string name="preftext_screen_prefcat">Screen and Window Behavior</string>
+ <string name="preftext_screen_on_when_game">Stay awake in foreground during games</string>
<string name="preftext_vibrate_jb">Vibrate on Jailbreak?</string>
<string name="preftext_vibrate_flag">Vibrate on Flag Capture?</string>
<string name="preftext_vibrate_mesg">Vibrate on Message?</string>
app:isPreferenceVisible="false"/>\r
\r
</PreferenceCategory>\r
- <PreferenceCategory android:title="@string/preftext_notif_prefcat">\r
+ <PreferenceCategory android:title="@string/preftext_screen_prefcat">
+
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="screen_on_when_game"
+ android:title="@string/preftext_screen_on_when_game" />
\r
+ </PreferenceCategory>
+ <PreferenceCategory android:title="@string/preftext_notif_prefcat">
\r
<CheckBoxPreference\r
android:defaultValue="true"\r