Compare commits

..

No commits in common. "bf45b6602eade0691e60dfae6ff128e6150d45dc" and "8df9aae0295ec7a003a392e0e515703fcc2d0672" have entirely different histories.

8 changed files with 21 additions and 74 deletions

View file

@ -93,17 +93,12 @@ fun getUserFromId(userId: Int?, context: Context): UserHandle {
fun removeUnusedShortcuts(context: Context) {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
fun getShortcuts(profile: UserHandle): List<ShortcutInfo>? {
return try {
launcherApps.getShortcuts(
ShortcutQuery().apply {
setQueryFlags(ShortcutQuery.FLAG_MATCH_PINNED)
},
profile
)
} catch (e: IllegalStateException) {
// https://github.com/jrpie/launcher/issues/116
return null
}
return launcherApps.getShortcuts(
ShortcutQuery().apply {
setQueryFlags(ShortcutQuery.FLAG_MATCH_PINNED)
},
profile
)
}
val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager

View file

@ -62,8 +62,7 @@ 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 = "hide_status_bar", type = boolean.class, defaultValue = "true"),
@Preference(name = "hide_navigation_bar", type = boolean.class, defaultValue = "false"),
@Preference(name = "full_screen", type = boolean.class, defaultValue = "true"),
@Preference(name = "rotate_screen", type = boolean.class, defaultValue = "true"),
}),
@PreferenceGroup(name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = {

View file

@ -9,9 +9,6 @@ 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
@ -102,15 +99,6 @@ 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.
@ -198,7 +186,6 @@ 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

View file

@ -3,11 +3,7 @@ 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
@ -18,7 +14,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().hideStatusBar())
if (LauncherPreferences.display().fullScreen())
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
@ -40,19 +36,17 @@ fun setWindowFlags(window: Window, homeScreen: Boolean) {
}
interface UIObject {
fun onCreate() {
if (this !is Activity) {
return
}
setWindowFlags(window, isHomeScreen())
if (this is Activity) {
setWindowFlags(window, isHomeScreen())
if (!LauncherPreferences.display().rotateScreen()) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
}
if (!LauncherPreferences.display().rotateScreen()) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
}
}
fun onStart() {
setOnClicks()
adjustLayout()
@ -76,26 +70,4 @@ 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)
}
}
}

View file

@ -155,7 +155,7 @@ class ListActivity : AppCompatActivity(), UIObject {
binding.listContainer.context.resources.displayMetrics.heightPixels
val diff = height - r.bottom
if (diff != 0 &&
LauncherPreferences.display().hideStatusBar()
LauncherPreferences.display().fullScreen()
) {
if (binding.listContainer.paddingBottom != diff) {
binding.listContainer.setPadding(0, 0, 0, diff)

View file

@ -137,9 +137,8 @@
-
-->
<string name="settings_display_screen_timeout_disabled_key" translatable="false">display.disable_timeout</string>
<string name="settings_display_full_screen_key" translatable="false">display.use_full_screen</string>
<string name="settings_display_rotate_screen_key" translatable="false">display.rotate_screen</string>
<string name="settings_display_hide_status_bar_key" translatable="false">display.use_full_screen</string>
<string name="settings_display_hide_navigation_bar_key" translatable="false">display.hide_navigation</string>
<string name="settings_enabled_gestures_double_swipe_key" translatable="false">enabled_gestures.double_actions</string>
<string name="settings_enabled_gestures_edge_swipe_key" translatable="false">enabled_gestures.edge_actions</string>

View file

@ -153,8 +153,7 @@
<string name="settings_launcher_section_display">Display</string>
<string name="settings_display_screen_timeout_disabled">Keep screen on</string>
<string name="settings_display_hide_status_bar">Hide status bar</string>
<string name="settings_display_hide_navigation_bar">Hide navigation bar</string>
<string name="settings_display_full_screen">Use full screen</string>
<string name="settings_display_rotate_screen">Rotate screen</string>
<string name="settings_launcher_section_functionality">Functionality</string>

View file

@ -174,6 +174,10 @@
<PreferenceCategory
android:title="@string/settings_launcher_section_display"
app:allowDividerAbove="false">
<SwitchPreference
android:key="@string/settings_display_full_screen_key"
android:defaultValue="true"
android:title="@string/settings_display_full_screen"/>
<SwitchPreference
android:key="@string/settings_display_rotate_screen_key"
android:defaultValue="true"
@ -182,14 +186,6 @@
android:key="@string/settings_display_screen_timeout_disabled_key"
android:defaultValue="false"
android:title="@string/settings_display_screen_timeout_disabled"/>
<SwitchPreference
android:key="@string/settings_display_hide_status_bar_key"
android:defaultValue="true"
android:title="@string/settings_display_hide_status_bar"/>
<SwitchPreference
android:key="@string/settings_display_hide_navigation_bar_key"
android:defaultValue="false"
android:title="@string/settings_display_hide_navigation_bar"/>
</PreferenceCategory>