From 2490cc50b4a86c1e92c20f6112bf0035b0db6aa1 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 18 Sep 2022 10:59:47 +0200 Subject: [PATCH 1/2] fix back behavior --- .../java/com/github/libretube/activities/MainActivity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/com/github/libretube/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/activities/MainActivity.kt index 1d09692b9..45986e5b6 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -289,6 +289,13 @@ class MainActivity : BaseActivity() { } override fun onQueryTextChange(newText: String?): Boolean { + // prevent malicious navigation when the search view is getting collapsed + if (navController.currentDestination?.id == R.id.searchResultFragment && + (newText == null || newText == "") + ) { + return false + } + if (navController.currentDestination?.id != R.id.searchFragment) { val bundle = Bundle() bundle.putString("query", newText) @@ -296,6 +303,7 @@ class MainActivity : BaseActivity() { } else { searchViewModel.setQuery(newText) } + return true } }) From 4f27dfc7b770006f1558df94e05d84b16c7bd22c Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 18 Sep 2022 11:02:08 +0200 Subject: [PATCH 2/2] small fix --- .../main/java/com/github/libretube/activities/MainActivity.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/activities/MainActivity.kt index 45986e5b6..58751d4d4 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -165,8 +165,6 @@ class MainActivity : BaseActivity() { // new way of handling back presses onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { - navController.popBackStack(R.id.searchFragment, false) - if (binding.mainMotionLayout.progress == 0F) { try { minimizePlayer()