From 7576c2adbb3ea551fbd9ea84b56a348dd068a6c4 Mon Sep 17 00:00:00 2001 From: FS Sifat <125657944+fs-sifat@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:58:11 +0600 Subject: [PATCH] Fix issue #122 --- .../rasel/lunar/launcher/LauncherActivity.kt | 3 ++- .../rasel/lunar/launcher/apps/AppDrawer.kt | 25 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt index 324b8f0..7dc585c 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt @@ -204,7 +204,8 @@ internal class LauncherActivity : AppCompatActivity() { view.updatePadding(0, topInset, 0, it.bottom) } - WindowInsetsCompat.CONSUMED + // return the insets to get it in AppDrawer>handleWindowInsets() + windowInsets } } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt index ceea36d..13974d2 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt @@ -24,6 +24,7 @@ import android.content.Intent import android.content.SharedPreferences import android.content.pm.PackageManager import android.content.pm.ResolveInfo +import android.content.res.Configuration import android.graphics.Rect import android.os.Build import android.os.Bundle @@ -34,7 +35,10 @@ import android.view.View.GONE import android.view.View.VISIBLE import android.view.ViewGroup import android.view.inputmethod.InputMethodManager +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams +import androidx.core.view.updatePadding import androidx.core.widget.doOnTextChanged import androidx.fragment.app.Fragment import androidx.recyclerview.widget.GridLayoutManager @@ -57,7 +61,6 @@ import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_APP_NAMES import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS import java.text.Normalizer -import java.util.* import java.util.regex.Pattern @@ -125,6 +128,7 @@ internal class AppDrawer : Fragment() { setLayout() fetchApps() getAlphabetItems() + handleWindowInsets() setKeyboardPadding() return binding.root @@ -242,6 +246,25 @@ internal class AppDrawer : Fragment() { } } + @SuppressLint("RtlHardcoded") + private fun handleWindowInsets() { + ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, windowInsets -> + if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { + windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars()).let { + val leftInsets = + if (settingsPrefs!!.getInt(KEY_DRAW_ALIGN, Gravity.CENTER) == Gravity.LEFT || + settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0) != 0) { + it.left + } else 0 + + binding.root.updatePadding(leftInsets, 0, it.right, 0) + } + } + + WindowInsetsCompat.CONSUMED + } + } + private fun filterAppsList(searchString: String) { /* check each app name and add if it matches the search string */ packageList.clear()