From 0a8735cbb1da231a1bc8e17ec6f68d3d7571f4f6 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Thu, 29 Feb 2024 16:11:52 +0530 Subject: [PATCH] =?UTF-8?q?Fixed:=20[Bug]=20Pop-up=20Function=20does=20not?= =?UTF-8?q?=20work=20correctly=20(fails=20to=20automatically=20=E2=80=9Cde?= =?UTF-8?q?tect=E2=80=9D=20headword=20and=20show=20results).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed the scenario where "Search kiwix" on any text does not show the expected result. Because we were passing the activity's intent instead of the actual intent we are getting to open the search, which leads to unexpected results. So now we are passing the actual intent to process the request that fixes this issue. * Fixed one more scenario that occurred after placing this fix, where one more instance is created of the search screen because the activity has the intent with this type, and we are processing this intent in our `onViewCreated` for the scenario where our application launched(it is not running in the background). So when we close the search screen for then our `onViewCreated` method is called, and the activity has the intent so it creates one more search instance. So to fix this issue we are setting both intents as null after using them. --- .../nav/destination/reader/KiwixReaderFragment.kt | 2 +- .../org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt index 8525d2b44..3ab8c3b32 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt @@ -291,7 +291,7 @@ class KiwixReaderFragment : CoreReaderFragment() { intent: Intent, activity: AppCompatActivity ): Super { - super.onNewIntent(activity.intent, activity) + super.onNewIntent(intent, activity) intent.data?.let { when (it.scheme) { "file" -> openZimFile(it.toFile()) 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 4895e14e2..924720e35 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 @@ -1753,21 +1753,26 @@ abstract class CoreReaderFragment : goToSearchWithText(intent) // see https://github.com/kiwix/kiwix-android/issues/2607 intent.action = null + // if used once then clear it to avoid affecting any other functionality of the application + requireActivity().intent.action = null } CoreSearchWidget.TEXT_CLICKED -> { goToSearch(false) intent.action = null + requireActivity().intent.action = null } CoreSearchWidget.STAR_CLICKED -> { goToBookmarks() intent.action = null + requireActivity().intent.action = null } CoreSearchWidget.MIC_CLICKED -> { goToSearch(true) intent.action = null + requireActivity().intent.action = null } Intent.ACTION_VIEW -> if (intent.type == null ||