diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt index edacc432..28f5e16f 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt @@ -213,6 +213,34 @@ class AppHelper @Inject constructor() { } } + fun showNavigationBar(window: Window) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + // For Android 11 (API 30) and above, use WindowInsetsController to show the navigation bar + window.insetsController?.show(WindowInsets.Type.navigationBars()) + } else { + @Suppress("DEPRECATION", "InlinedApi") + // For older versions, show the navigation bar using systemUiVisibility + window.decorView.apply { + systemUiVisibility = + View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + } + } + } + + fun hideNavigationBar(window: Window) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + // For Android 11 (API 30) and above, use WindowInsetsController to hide the navigation bar + window.insetsController?.hide(WindowInsets.Type.navigationBars()) + } else { + @Suppress("DEPRECATION") + // For older versions, hide the navigation bar using systemUiVisibility + window.decorView.apply { + systemUiVisibility = + View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN + } + } + } + fun wordOfTheDay(resources: Resources): String { val dailyWordsArray = resources.getStringArray(R.array.settings_appearance_daily_word_default) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt index fc02d4ee..73523425 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt @@ -27,6 +27,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context) get() = prefs.getBoolean(Constants.SHOW_STATUS_BAR, true) set(value) = prefs.edit().putBoolean(Constants.SHOW_STATUS_BAR, value).apply() + var showNavigationBar: Boolean + get() = prefs.getBoolean(Constants.SHOW_NAVIGATION_BAR, true) + set(value) = prefs.edit().putBoolean(Constants.SHOW_NAVIGATION_BAR, value).apply() + var showTime: Boolean get() = prefs.getBoolean(Constants.SHOW_TIME, true) set(value) = prefs.edit().putBoolean(Constants.SHOW_TIME, value).apply() diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/activities/MainActivity.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/activities/MainActivity.kt index 6da8078b..7d76f438 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/activities/MainActivity.kt @@ -96,7 +96,6 @@ class MainActivity : AppCompatActivity() { setupNavController() setupOrientation() setupLocationManager() - setLanguage() } @Suppress("DEPRECATION") @@ -110,6 +109,7 @@ class MainActivity : AppCompatActivity() { private fun initializeDependencies() { setLocationPermissionDenied(false) preferenceViewModel.setShowStatusBar(preferenceHelper.showStatusBar) + preferenceViewModel.setShowNavigationBar(preferenceHelper.showNavigationBar) preferenceViewModel.setFirstLaunch(preferenceHelper.firstLaunch) window.addFlags(FLAG_LAYOUT_NO_LIMITS) @@ -214,6 +214,12 @@ class MainActivity : AppCompatActivity() { if (it) appHelper.showStatusBar(this.window) else appHelper.hideStatusBar(this.window) } + + preferenceViewModel.setShowNavigationBar(preferenceHelper.showNavigationBar) + preferenceViewModel.showNavigationBarLiveData.observe(this) { + if (it) appHelper.showNavigationBar(this.window) + else appHelper.hideNavigationBar(this.window) + } } private fun setupNavController() { @@ -288,9 +294,11 @@ class MainActivity : AppCompatActivity() { when (navController.currentDestination?.id) { R.id.SettingsFeaturesFragment, R.id.SettingsLookFeelFragment, + R.id.SettingsWidgetFragment, R.id.SettingsAdvancedFragment, R.id.FavoriteFragment, - R.id.HiddenFragment -> { + R.id.HiddenFragment, + -> { val actionTypeNavOptions: NavOptions? = if (preferenceHelper.disableAnimations) null else appHelper.getActionType(Constants.Swipe.Up) @@ -338,7 +346,7 @@ class MainActivity : AppCompatActivity() { override fun onRequestPermissionsResult( requestCode: Int, permissions: Array, - grantResults: IntArray + grantResults: IntArray, ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) when (requestCode) { diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt index 5e9577c2..cf6f5f18 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt @@ -537,8 +537,9 @@ class HomeFragment : Fragment(), } override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { - val actionTypeNavOptions: NavOptions = - appHelper.getActionType(Constants.Swipe.DoubleTap) + val actionTypeNavOptions: NavOptions? = + if (preferenceHelper.disableAnimations) null + else appHelper.getActionType(Constants.Swipe.DoubleTap) findNavController().navigate( R.id.SettingsFragment, null, @@ -554,8 +555,9 @@ class HomeFragment : Fragment(), if (preferenceHelper.settingsLock) { fingerHelper.startBiometricSettingsAuth(R.id.SettingsFragment) } else { - val actionTypeNavOptions: NavOptions = - appHelper.getActionType(Constants.Swipe.DoubleTap) + val actionTypeNavOptions: NavOptions? = + if (preferenceHelper.disableAnimations) null + else appHelper.getActionType(Constants.Swipe.DoubleTap) findNavController().navigate( R.id.SettingsFragment, null, diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt index 4222d83d..78f6f507 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt @@ -89,7 +89,8 @@ class SettingsLookFeelFragment : Fragment(), private fun initializeInjectedDependencies() { // Set initial values and listeners for switches binding.apply { - statueBarSwitchCompat.isChecked = preferenceHelper.showStatusBar + statusBarSwitchCompat.isChecked = preferenceHelper.showStatusBar + navBarSwitchCompat.isChecked = preferenceHelper.showNavigationBar timeSwitchCompat.isChecked = preferenceHelper.showTime dateSwitchCompat.isChecked = preferenceHelper.showDate batterySwitchCompat.isChecked = preferenceHelper.showBattery @@ -142,12 +143,18 @@ class SettingsLookFeelFragment : Fragment(), @RequiresApi(Build.VERSION_CODES.Q) private fun setupSwitchListeners() { binding.apply { - statueBarSwitchCompat.setOnCheckedChangeListener { _, isChecked -> + statusBarSwitchCompat.setOnCheckedChangeListener { _, isChecked -> preferenceViewModel.setShowStatusBar(isChecked) val feedbackType = if (isChecked) "on" else "off" appHelper.triggerHapticFeedback(context, feedbackType) } + navBarSwitchCompat.setOnCheckedChangeListener { _, isChecked -> + preferenceViewModel.setShowNavigationBar(isChecked) + val feedbackType = if (isChecked) "on" else "off" + appHelper.triggerHapticFeedback(context, feedbackType) + } + dateSwitchCompat.setOnCheckedChangeListener { _, isChecked -> preferenceViewModel.setShowDate(isChecked) val feedbackType = if (isChecked) "on" else "off" diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt index 37b6c156..28537a9e 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt @@ -32,6 +32,8 @@ object Constants { const val SHOW_ALARM_CLOCK = "SHOW_ALARM_CLOCK" const val SHOW_BATTERY = "SHOW_BATTERY" const val SHOW_STATUS_BAR = "SHOW_STATUS_BAR" + const val SHOW_NAVIGATION_BAR = "SHOW_NAVIGATION_BAR" + const val SHOW_WEATHER_WIDGET = "SHOW_WEATHER_WIDGET" const val SHOW_WEATHER_WIDGET_SUN_SET_RISE = "SHOW_WEATHER_WIDGET_SUN_SET_RISE" diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt b/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt index 1c21edc2..62f767d0 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt @@ -14,6 +14,7 @@ class PreferenceViewModel @Inject constructor( private val firstLaunchLiveData: MutableLiveData = MutableLiveData() val showStatusBarLiveData: MutableLiveData = MutableLiveData() + val showNavigationBarLiveData: MutableLiveData = MutableLiveData() val showTimeLiveData: MutableLiveData = MutableLiveData() val showDateLiveData: MutableLiveData = MutableLiveData() val showDailyWordLiveData: MutableLiveData = MutableLiveData() @@ -76,6 +77,11 @@ class PreferenceViewModel @Inject constructor( showStatusBarLiveData.postValue(preferenceHelper.showStatusBar) } + fun setShowNavigationBar(showNavigationBar: Boolean) { + preferenceHelper.showNavigationBar = showNavigationBar + showNavigationBarLiveData.postValue(preferenceHelper.showNavigationBar) + } + fun setShowTime(showTime: Boolean) { preferenceHelper.showTime = showTime showTimeLiveData.postValue(preferenceHelper.showTime) diff --git a/app/src/main/res/layout/fragment_settings_look_feel.xml b/app/src/main/res/layout/fragment_settings_look_feel.xml index b3f3dc6a..50345890 100644 --- a/app/src/main/res/layout/fragment_settings_look_feel.xml +++ b/app/src/main/res/layout/fragment_settings_look_feel.xml @@ -60,7 +60,7 @@ tools:ignore="MissingConstraints"> + + + + + + + + - - Others Show Status Bar + Show Navigation Bar Show Date Show Time Show Battery