From ddcbe27fd3da5bda84127234912e73257e1faf99 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:52:08 +0100 Subject: [PATCH] Fixed search not accepting key input after closing player overlay (#7607) * Fixed search not accepting key input after closing player overlay * Made comments easier to understand * More comments --- .../fragments/detail/VideoDetailFragment.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 5a74dc948..25b87ed6f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -2208,12 +2208,20 @@ public final class VideoDetailFragment mainFragment.setDescendantFocusability(afterDescendants); toolbar.setDescendantFocusability(afterDescendants); ((ViewGroup) requireView()).setDescendantFocusability(blockDescendants); - mainFragment.requestFocus(); + // Only focus the mainFragment if the mainFragment (e.g. search-results) + // or the toolbar (e.g. Textfield for search) don't have focus. + // This was done to fix problems with the keyboard input, see also #7490 + if (!mainFragment.hasFocus() && !toolbar.hasFocus()) { + mainFragment.requestFocus(); + } } else { mainFragment.setDescendantFocusability(blockDescendants); toolbar.setDescendantFocusability(blockDescendants); ((ViewGroup) requireView()).setDescendantFocusability(afterDescendants); - binding.detailThumbnailRootLayout.requestFocus(); + // Only focus the player if it not already has focus + if (!binding.getRoot().hasFocus()) { + binding.detailThumbnailRootLayout.requestFocus(); + } } }