Skip to content

Commit c29997a

Browse files
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.
1 parent 3f80e9d commit c29997a

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@ abstract class CoreReaderFragment :
510510
readAloudService?.registerCallBack(this@CoreReaderFragment)
511511
}
512512
}
513+
requireActivity().observeNavigationResult<String>(
514+
FIND_IN_PAGE_SEARCH_STRING,
515+
viewLifecycleOwner,
516+
Observer(::storeFindInPageTitle)
517+
)
518+
requireActivity().observeNavigationResult<SearchItemToOpen>(
519+
TAG_FILE_SEARCHED,
520+
viewLifecycleOwner,
521+
Observer(::storeSearchItem)
522+
)
513523
handleClicks()
514524
}
515525

@@ -2790,6 +2800,7 @@ abstract class CoreReaderFragment :
27902800
onComplete: () -> Unit
27912801
) {
27922802
try {
2803+
isFromManageExternalLaunch = true
27932804
currentWebViewIndex = 0
27942805
tabsAdapter?.apply {
27952806
webViewList.removeAt(0)
@@ -2807,28 +2818,6 @@ abstract class CoreReaderFragment :
28072818
Log.w(TAG_KIWIX, "Kiwix shared preferences corrupted", ignore)
28082819
activity.toast(R.string.could_not_restore_tabs, Toast.LENGTH_LONG)
28092820
}
2810-
// After restoring the tabs, observe any search actions that the user might have triggered.
2811-
// Since the ZIM file opening functionality has been moved to a background thread,
2812-
// we ensure that all necessary actions are completed before observing these search actions.
2813-
observeSearchActions()
2814-
}
2815-
2816-
/**
2817-
* Observes any search-related actions triggered by the user, such as "Find in Page" or
2818-
* opening a specific search item.
2819-
* This method sets up observers for navigation results related to search functionality.
2820-
*/
2821-
private fun observeSearchActions() {
2822-
requireActivity().observeNavigationResult<String>(
2823-
FIND_IN_PAGE_SEARCH_STRING,
2824-
viewLifecycleOwner,
2825-
Observer(::storeFindInPageTitle)
2826-
)
2827-
requireActivity().observeNavigationResult<SearchItemToOpen>(
2828-
TAG_FILE_SEARCHED,
2829-
viewLifecycleOwner,
2830-
Observer(::storeSearchItem)
2831-
)
28322821
}
28332822

28342823
/**

0 commit comments

Comments
 (0)