Skip to content

Commit

Permalink
Fix issue iamrasel#122
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-sifat committed Apr 12, 2024
1 parent 0a02493 commit 7576c2a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
25 changes: 24 additions & 1 deletion app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -125,6 +128,7 @@ internal class AppDrawer : Fragment() {
setLayout()
fetchApps()
getAlphabetItems()
handleWindowInsets()
setKeyboardPadding()

return binding.root
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7576c2a

Please sign in to comment.