From ebf7b0a0c3ac5200db553a6446179772063bab62 Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Thu, 30 Jul 2020 17:58:58 +0200 Subject: [PATCH] TrackRecordingActivity: added setting for fullscreen. Fixes #342. --- .../opentracks/TrackRecordingActivity.java | 20 +++++++++++++++---- .../opentracks/util/IntentDashboardUtils.java | 2 ++ .../opentracks/util/PreferencesUtils.java | 5 +++++ src/main/res/values/settings.xml | 3 +++ src/main/res/values/strings.xml | 2 ++ src/main/res/xml/settings.xml | 5 +++++ 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java index 63bb6b3c5c..e21c6885b8 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java @@ -110,6 +110,9 @@ public void onSharedPreferenceChanged(SharedPreferences preferences, String key) if (PreferencesUtils.isKey(TrackRecordingActivity.this, R.string.stats_keep_screen_on_while_recording_key, key)) { setScreenOnPolicy(); } + if (PreferencesUtils.isKey(TrackRecordingActivity.this, R.string.stats_fullscreen_while_recording_key, key)) { + setFullscreenPolicy(); + } if (key == null) return; @@ -190,12 +193,12 @@ protected void onCreate(Bundle savedInstanceState) { public void onAttachedToWindow() { setLockscreenPolicy(); setScreenOnPolicy(); + setFullscreenPolicy(); super.onAttachedToWindow(); } private void setLockscreenPolicy() { - boolean showOnLockScreen = PreferencesUtils.shouldShowStatsOnLockscreen(TrackRecordingActivity.this) - && PreferencesUtils.isRecording(this); + boolean showOnLockScreen = PreferencesUtils.shouldShowStatsOnLockscreen(TrackRecordingActivity.this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { setShowWhenLocked(showOnLockScreen); @@ -207,8 +210,7 @@ private void setLockscreenPolicy() { } private void setScreenOnPolicy() { - boolean keepScreenOn = PreferencesUtils.shouldKeepScreenOn(TrackRecordingActivity.this) - && PreferencesUtils.isRecording(this); + boolean keepScreenOn = PreferencesUtils.shouldKeepScreenOn(TrackRecordingActivity.this); if (keepScreenOn) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -217,6 +219,16 @@ private void setScreenOnPolicy() { } } + private void setFullscreenPolicy() { + boolean keepScreenOn = PreferencesUtils.shouldUseFullscreen(TrackRecordingActivity.this); + + if (keepScreenOn) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + } + @Override protected void onStart() { super.onStart(); diff --git a/src/main/java/de/dennisguse/opentracks/util/IntentDashboardUtils.java b/src/main/java/de/dennisguse/opentracks/util/IntentDashboardUtils.java index 65378c8a7d..bf4895c91a 100644 --- a/src/main/java/de/dennisguse/opentracks/util/IntentDashboardUtils.java +++ b/src/main/java/de/dennisguse/opentracks/util/IntentDashboardUtils.java @@ -26,6 +26,7 @@ public class IntentDashboardUtils { private static final String EXTRAS_SHOULD_KEEP_SCREEN_ON = "EXTRAS_SHOULD_KEEP_SCREEN_ON"; private static final String EXTRAS_SHOW_WHEN_LOCKED = "EXTRAS_SHOULD_KEEP_SCREEN_ON"; + private static final String EXTRAS_SHOW_FULLSCREEN = "EXTRAS_SHOULD_FULLSCREEN"; private static final int TRACK_URI_INDEX = 0; private static final int TRACKPOINTS_URI_INDEX = 1; @@ -58,6 +59,7 @@ public static void startDashboard(Context context, long[] trackIds) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(EXTRAS_SHOULD_KEEP_SCREEN_ON, PreferencesUtils.shouldKeepScreenOn(context)); intent.putExtra(EXTRAS_SHOW_WHEN_LOCKED, PreferencesUtils.shouldShowStatsOnLockscreen(context)); + intent.putExtra(EXTRAS_SHOW_FULLSCREEN, PreferencesUtils.shouldUseFullscreen(context)); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); ClipData clipData = ClipData.newRawUri(null, uris.get(TRACK_URI_INDEX)); diff --git a/src/main/java/de/dennisguse/opentracks/util/PreferencesUtils.java b/src/main/java/de/dennisguse/opentracks/util/PreferencesUtils.java index 819fdc852b..a875a09487 100644 --- a/src/main/java/de/dennisguse/opentracks/util/PreferencesUtils.java +++ b/src/main/java/de/dennisguse/opentracks/util/PreferencesUtils.java @@ -275,6 +275,11 @@ public static boolean shouldKeepScreenOn(Context context) { return getBoolean(context, R.string.stats_keep_screen_on_while_recording_key, DEFAULT); } + public static boolean shouldUseFullscreen(Context context) { + final boolean DEFAULT = context.getResources().getBoolean(R.bool.stats_fullscreen_while_recording_default); + return getBoolean(context, R.string.stats_fullscreen_while_recording_key, DEFAULT); + } + public static boolean isShowStatsElevation(Context context) { final boolean STATS_SHOW_ELEVATION = context.getResources().getBoolean(R.bool.stats_show_elevation_default); return getBoolean(context, R.string.stats_show_grade_elevation_key, STATS_SHOW_ELEVATION); diff --git a/src/main/res/values/settings.xml b/src/main/res/values/settings.xml index 22e2ab38d8..c6b69c8e11 100644 --- a/src/main/res/values/settings.xml +++ b/src/main/res/values/settings.xml @@ -13,6 +13,9 @@ trackdetail_keep_screen_on_while_recording false + trackdetail_fullscreen_while_recording + false + settingsReset bluetoothSensor diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4fb14ad5e0..a5b350cee0 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -349,6 +349,8 @@ limitations under the License. While recording, show statistics without unlocking the device. Keep screen on While recording, keep the screen on. + Fullscreen + While recording, present in fullscreen. Recording Always resume a recording after reboot Never resume a recording after reboot diff --git a/src/main/res/xml/settings.xml b/src/main/res/xml/settings.xml index a92987466e..6da8f3fcfa 100644 --- a/src/main/res/xml/settings.xml +++ b/src/main/res/xml/settings.xml @@ -67,6 +67,11 @@ limitations under the License. android:key="@string/stats_keep_screen_on_while_recording_key" android:summary="@string/settings_recording_keep_screen_on_while_recording_summary" android:title="@string/settings_recording_keep_screen_on_while_recording_title" /> +