From c29997aa1254fd0e982db2b42f12dcdf5b74dda8 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 7 Feb 2025 22:32:19 +0530 Subject: [PATCH] Fixed: Opening a searched item and "Find in Page" was not working after rebasing. * Removed unnecessary code from the project to simplify it and make it more robust. --- .../core/main/CoreReaderFragment.kt | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt index 7fb73b6f9..3d49580f3 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt @@ -510,6 +510,16 @@ abstract class CoreReaderFragment : readAloudService?.registerCallBack(this@CoreReaderFragment) } } + requireActivity().observeNavigationResult( + FIND_IN_PAGE_SEARCH_STRING, + viewLifecycleOwner, + Observer(::storeFindInPageTitle) + ) + requireActivity().observeNavigationResult( + TAG_FILE_SEARCHED, + viewLifecycleOwner, + Observer(::storeSearchItem) + ) handleClicks() } @@ -2790,6 +2800,7 @@ abstract class CoreReaderFragment : onComplete: () -> Unit ) { try { + isFromManageExternalLaunch = true currentWebViewIndex = 0 tabsAdapter?.apply { webViewList.removeAt(0) @@ -2807,28 +2818,6 @@ abstract class CoreReaderFragment : Log.w(TAG_KIWIX, "Kiwix shared preferences corrupted", ignore) activity.toast(R.string.could_not_restore_tabs, Toast.LENGTH_LONG) } - // After restoring the tabs, observe any search actions that the user might have triggered. - // Since the ZIM file opening functionality has been moved to a background thread, - // we ensure that all necessary actions are completed before observing these search actions. - observeSearchActions() - } - - /** - * Observes any search-related actions triggered by the user, such as "Find in Page" or - * opening a specific search item. - * This method sets up observers for navigation results related to search functionality. - */ - private fun observeSearchActions() { - requireActivity().observeNavigationResult( - FIND_IN_PAGE_SEARCH_STRING, - viewLifecycleOwner, - Observer(::storeFindInPageTitle) - ) - requireActivity().observeNavigationResult( - TAG_FILE_SEARCHED, - viewLifecycleOwner, - Observer(::storeSearchItem) - ) } /**