diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java index 9be85ab..ca60591 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java @@ -62,7 +62,8 @@ import eu.jonahbauer.android.preference.annotations.Preferences; }), @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), - @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), + @Preference(name = "hide_status_bar", type = boolean.class, defaultValue = "true"), + @Preference(name = "hide_navigation_bar", type = boolean.class, defaultValue = "false"), @Preference(name = "rotate_screen", type = boolean.class, defaultValue = "true"), }), @PreferenceGroup(name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { diff --git a/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt index 973e0ca..61a4250 100644 --- a/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt @@ -9,6 +9,9 @@ import android.util.DisplayMetrics import android.view.KeyEvent import android.view.MotionEvent import android.view.View +import android.view.Window +import android.view.WindowInsets +import android.view.WindowInsetsController import android.window.OnBackInvokedDispatcher import androidx.appcompat.app.AppCompatActivity import androidx.core.view.isVisible @@ -99,6 +102,15 @@ class HomeActivity : UIObject, AppCompatActivity() { } + override fun onWindowFocusChanged(hasFocus: Boolean) { + super.onWindowFocusChanged(hasFocus) + + if (hasFocus && LauncherPreferences.display().hideNavigationBar()) { + hideNavigationBar() + } + } + + private fun updateSettingsFallbackButtonVisibility() { // If µLauncher settings can not be reached from any action bound to an enabled gesture, // show the fallback button. @@ -186,6 +198,7 @@ class HomeActivity : UIObject, AppCompatActivity() { // Only used pre Android 13, cf. onBackInvokedDispatcher handleBack() } + KeyEvent.KEYCODE_VOLUME_UP -> { if (Action.forGesture(Gesture.VOLUME_UP) == LauncherAction.VOLUME_UP) { // Let the OS handle the key event. This works better with some custom ROMs diff --git a/app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt b/app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt index 3702bb2..d97388f 100644 --- a/app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt @@ -3,7 +3,11 @@ package de.jrpie.android.launcher.ui import android.app.Activity import android.content.pm.ActivityInfo import android.content.res.Resources +import android.os.Build +import android.view.View import android.view.Window +import android.view.WindowInsets +import android.view.WindowInsetsController import android.view.WindowManager import de.jrpie.android.launcher.preferences.LauncherPreferences @@ -14,7 +18,7 @@ import de.jrpie.android.launcher.preferences.LauncherPreferences fun setWindowFlags(window: Window, homeScreen: Boolean) { window.setFlags(0, 0) // clear flags // Display notification bar - if (LauncherPreferences.display().fullScreen()) + if (LauncherPreferences.display().hideStatusBar()) window.setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN @@ -36,17 +40,19 @@ fun setWindowFlags(window: Window, homeScreen: Boolean) { } + interface UIObject { fun onCreate() { - if (this is Activity) { - setWindowFlags(window, isHomeScreen()) - - if (!LauncherPreferences.display().rotateScreen()) { - requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR - } + if (this !is Activity) { + return + } + setWindowFlags(window, isHomeScreen()) + if (!LauncherPreferences.display().rotateScreen()) { + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR } } + fun onStart() { setOnClicks() adjustLayout() @@ -70,4 +76,26 @@ interface UIObject { fun isHomeScreen(): Boolean { return false } + + + @Suppress("DEPRECATION") + fun hideNavigationBar() { + if (this !is Activity) { + return + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + window.insetsController?.apply { + hide(WindowInsets.Type.navigationBars()) + systemBarsBehavior = + WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } + } else { + // Try to hide the navigation bar but do not hide the status bar + window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + or View.SYSTEM_UI_FLAG_IMMERSIVE + or View.SYSTEM_UI_FLAG_LAYOUT_STABLE) + } + } } \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt index c4ecded..334bd62 100644 --- a/app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt @@ -155,7 +155,7 @@ class ListActivity : AppCompatActivity(), UIObject { binding.listContainer.context.resources.displayMetrics.heightPixels val diff = height - r.bottom if (diff != 0 && - LauncherPreferences.display().fullScreen() + LauncherPreferences.display().hideStatusBar() ) { if (binding.listContainer.paddingBottom != diff) { binding.listContainer.setPadding(0, 0, 0, diff) diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index a2e4ad6..e5bd375 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -137,8 +137,9 @@ - --> display.disable_timeout - display.use_full_screen display.rotate_screen + display.use_full_screen + display.hide_navigation enabled_gestures.double_actions enabled_gestures.edge_actions diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e13753..902e147 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -153,7 +153,8 @@ Display Keep screen on - Use full screen + Hide status bar + Hide navigation bar Rotate screen Functionality diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index a90debd..6ef5d07 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -174,10 +174,6 @@ - + +