From 87b8ecfc50a42bd4c80b6f90affddcad4d202cb7 Mon Sep 17 00:00:00 2001 From: CDrummond Date: Sun, 4 Aug 2024 19:54:40 +0100 Subject: [PATCH] Only draw behind status and navigation bars for Android 8.0 and above. --- .../metadata/android/en-US/changelogs/601.txt | 1 + .../craigd/lmsmaterial/app/MainActivity.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fastlane/metadata/android/en-US/changelogs/601.txt b/fastlane/metadata/android/en-US/changelogs/601.txt index 29e8c4d..bf0282d 100644 --- a/fastlane/metadata/android/en-US/changelogs/601.txt +++ b/fastlane/metadata/android/en-US/changelogs/601.txt @@ -3,3 +3,4 @@ Fixed • Handle screen rotation. • Fix edge-to-edge view for pre Android 14 devices. • Set Android 6.0 as minimum level. +• Only draw behind status and navigation bars for Android 8.0 and above. diff --git a/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java b/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java index 8123762..3e38862 100644 --- a/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java +++ b/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java @@ -291,7 +291,8 @@ private String getConfiguredUrl() { if (Utils.notificationAllowed(this, DownloadService.NOTIFICATION_CHANNEL_ID)) { builder.appendQueryParameter("download", "native"); } - if (!sharedPreferences.getBoolean(SettingsActivity.FULLSCREEN_PREF_KEY, false)) { + if (!sharedPreferences.getBoolean(SettingsActivity.FULLSCREEN_PREF_KEY, false) && + Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { boolean gestureNav = usingGestureNavigation(); builder.appendQueryParameter("topPad", "24"); builder.appendQueryParameter("botPad", gestureNav ? "12" : "40"); @@ -508,9 +509,14 @@ public void onConfigurationChanged(Configuration newConfig) { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "MainActivity.onCreate"); - requestWindowFeature(Window.FEATURE_NO_TITLE); - Window window = getWindow(); - WindowCompat.setDecorFitsSystemWindows(window, false); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + } else { + getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorBackground)); + getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorBackground)); + } sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); //isDark = sharedPreferences.getBoolean(SettingsActivity.IS_DARK_PREF_KEY, true); @@ -531,7 +537,6 @@ protected void onCreate(Bundle savedInstanceState) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } setContentView(R.layout.activity_main); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); init5497Workaround(); manageShowOverLockscreen(); webView = findViewById(R.id.webview); @@ -1215,7 +1220,9 @@ private void setFullScreen(boolean on, boolean isStartup) { getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; } getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + } if (!isStartup) { recreate(); recreateTime = SystemClock.elapsedRealtime();