diff options
Diffstat (limited to 'app/src/main/java')
| -rw-r--r-- | app/src/main/java/app/olauncher/data/Constants.kt | 2 | ||||
| -rw-r--r-- | app/src/main/java/app/olauncher/ui/HomeFragment.kt | 50 |
2 files changed, 30 insertions, 22 deletions
diff --git a/app/src/main/java/app/olauncher/data/Constants.kt b/app/src/main/java/app/olauncher/data/Constants.kt index 206a45f..6882b59 100644 --- a/app/src/main/java/app/olauncher/data/Constants.kt +++ b/app/src/main/java/app/olauncher/data/Constants.kt @@ -23,7 +23,7 @@ object Constants { const val HINT_EMAIL_US = 20 const val HINT_RATE_US = 30 - const val TRIPLE_TAP_DELAY_MS = 400 + const val TRIPLE_TAP_DELAY_MS = 300 const val LONG_PRESS_DELAY_MS = 600 const val URL_ABOUT_OLAUNCHER = "https://www.notion.so/About-Olauncher-4843e398b05a455bb521b0665b26fbcd" diff --git a/app/src/main/java/app/olauncher/ui/HomeFragment.kt b/app/src/main/java/app/olauncher/ui/HomeFragment.kt index dfe03e0..be116e4 100644 --- a/app/src/main/java/app/olauncher/ui/HomeFragment.kt +++ b/app/src/main/java/app/olauncher/ui/HomeFragment.kt @@ -172,7 +172,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener private fun populateHomeApps(appCountUpdated: Boolean) { if (appCountUpdated) hideHomeApps() - dateTimeLayout.visibility = View.VISIBLE +// dateTimeLayout.visibility = View.VISIBLE val homeAppsNum = prefs.homeAppsNum if (homeAppsNum == 0) return @@ -370,9 +370,10 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener private fun showNavBarAndResetScreenTimeout() { if (Settings.System.canWrite(requireContext())) Settings.System.putInt(requireContext().contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, prefs.screenTimeout); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + requireActivity().window.insetsController?.show(WindowInsets.Type.statusBars()) requireActivity().window.insetsController?.show(WindowInsets.Type.navigationBars()) - else + } else requireActivity().window.decorView.apply { systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION @@ -380,6 +381,29 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener } } + private fun hideNavBar() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + requireActivity().window.insetsController?.hide(WindowInsets.Type.statusBars()) + requireActivity().window.insetsController?.hide(WindowInsets.Type.navigationBars()) + } else { + @Suppress("DEPRECATION") + requireActivity().window.decorView.apply { + systemUiVisibility = + View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + } + } + } + + private fun setScreenTimeout() { + // Save the existing screen off timeout + val screenTimeoutInSettings = + Settings.System.getInt(requireContext().contentResolver, Settings.System.SCREEN_OFF_TIMEOUT) + if (screenTimeoutInSettings >= 5000) prefs.screenTimeout = screenTimeoutInSettings + + // Set timeout to 5 seconds + Settings.System.putInt(requireContext().contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, 5000) + } + private fun textOnClick(view: View) = onClick(view) private fun textOnLongClick(view: View) = onLongClick(view) @@ -420,24 +444,8 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener if (Settings.System.canWrite(requireContext())) { requireActivity().runOnUiThread { blackOverlay.visibility = View.VISIBLE - - // Save the existing screen off timeout - val screenTimeoutInSettings = - Settings.System.getInt(requireContext().contentResolver, Settings.System.SCREEN_OFF_TIMEOUT) - if (screenTimeoutInSettings >= 5000) prefs.screenTimeout = screenTimeoutInSettings - - // Set timeout to 5 seconds - Settings.System.putInt(requireContext().contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, 5000) - - // Hide the navigation bar - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - requireActivity().window.insetsController?.hide(WindowInsets.Type.navigationBars()) - } else { - @Suppress("DEPRECATION") - requireActivity().window.decorView.apply { - systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - } - } + setScreenTimeout() + hideNavBar() } } else { lockPhone() |
