Skip to content

Commit 6ced438

Browse files
Fix: Fix keyboard handling and bottom margin
This commit introduces two main improvements to the App Drawer: 1. **Adjusts for Keyboard (IME):** The bottom margin of the `menuView` is now correctly adjusted when the on-screen keyboard is shown or hidden. This prevents the menu from being obscured by the keyboard. The previous implementation, which adjusted the padding of the RecyclerViews, has been removed. 2. **Improves Keyboard Display Logic:** The method used to show the soft keyboard has been updated from the deprecated `SHOW_FORCED` to `SHOW_IMPLICIT`. This is a more modern and recommended approach for programmatically displaying the keyboard. A local `prefs` variable was also introduced to avoid multiple lookups.
1 parent f76aaf9 commit 6ced438

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

app/src/main/java/com/github/codeworkscreativehub/mlauncher/ui/AppDrawerFragment.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import androidx.core.net.toUri
2929
import androidx.core.view.ViewCompat
3030
import androidx.core.view.WindowInsetsCompat
3131
import androidx.core.view.isVisible
32-
import androidx.core.view.updatePadding
3332
import androidx.lifecycle.LiveData
3433
import androidx.lifecycle.MediatorLiveData
3534
import androidx.lifecycle.ViewModelProvider
@@ -93,8 +92,12 @@ class AppDrawerFragment : BaseFragment() {
9392

9493
ViewCompat.setOnApplyWindowInsetsListener(binding.mainLayout) { _, insets ->
9594
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
96-
binding.appsRecyclerView.updatePadding(bottom = imeInsets.bottom)
97-
binding.contactsRecyclerView.updatePadding(bottom = imeInsets.bottom)
95+
96+
// Adjust menuView & sidebarContainer
97+
val menuParams = binding.menuView.layoutParams as ViewGroup.MarginLayoutParams
98+
menuParams.bottomMargin = resources.getDimensionPixelSize(R.dimen.bottom_margin_3_button_nav) + imeInsets.bottom
99+
binding.menuView.layoutParams = menuParams
100+
98101
insets
99102
}
100103

@@ -733,16 +736,17 @@ class AppDrawerFragment : BaseFragment() {
733736

734737

735738
private fun View.showKeyboard() {
736-
if (!Prefs(requireContext()).autoShowKeyboard) return
737-
if (Prefs(requireContext()).hideSearchView) return
739+
val prefs = Prefs(requireContext())
740+
if (!prefs.autoShowKeyboard) return
741+
if (prefs.hideSearchView) return
738742

739743
val searchTextView = binding.search.findViewById<TextView>(R.id.search_src_text)
740744
searchTextView.requestFocus()
745+
741746
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
742747
searchTextView.postDelayed({
743748
searchTextView.requestFocus()
744-
@Suppress("DEPRECATION")
745-
imm.showSoftInput(searchTextView, InputMethodManager.SHOW_FORCED)
749+
imm.showSoftInput(searchTextView, InputMethodManager.SHOW_IMPLICIT)
746750
}, 100)
747751
}
748752

0 commit comments

Comments
 (0)