From 4c8f7cb02c4c9fb0eed2b9336132bbc31acddfd7 Mon Sep 17 00:00:00 2001 From: MohitMali Date: Mon, 6 Nov 2023 15:07:26 +0530 Subject: [PATCH] Fixed the redundancy of the 'All-Books-Mode' option for Bookmarks, Notes, and History in custom apps. * Since custom apps only have a single zim file, there is no need to display these switches, which can potentially confuse users. Therefore, we have hidden these switches in custom apps. --- .../kiwixmobile/core/extensions/ActivityExtensions.kt | 6 ++++++ .../java/org/kiwix/kiwixmobile/core/page/PageFragment.kt | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ActivityExtensions.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ActivityExtensions.kt index fb14a13df..ccaa9f283 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ActivityExtensions.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ActivityExtensions.kt @@ -164,4 +164,10 @@ object ActivityExtensions { ) } } + + /** + * Checks if the package name of the current activity's application is not equal to 'org.kiwix.kiwixmobile', + * indicating that it is a custom application. + */ + fun Activity.isCustomApp(): Boolean = packageName != "org.kiwix.kiwixmobile" } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt index fe4aee34c..32b688d1d 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt @@ -43,6 +43,7 @@ import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.base.BaseFragment import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions import org.kiwix.kiwixmobile.core.databinding.FragmentPageBinding +import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.isCustomApp import org.kiwix.kiwixmobile.core.extensions.closeKeyboard import org.kiwix.kiwixmobile.core.main.CoreMainActivity import org.kiwix.kiwixmobile.core.page.adapter.OnItemClickListener @@ -141,8 +142,12 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv fragmentPageBinding?.recyclerView?.adapter = pageAdapter fragmentPageBinding?.noPage?.text = noItemsString - fragmentPageBinding?.pageSwitch?.text = switchString - fragmentPageBinding?.pageSwitch?.isChecked = switchIsChecked + fragmentPageBinding?.pageSwitch?.apply { + text = switchString + isChecked = switchIsChecked + // hide switches for custom apps, see more info here https://github.com/kiwix/kiwix-android/issues/3523 + visibility = if (requireActivity().isCustomApp()) GONE else VISIBLE + } compositeDisposable.add(pageViewModel.effects.subscribe { it.invokeWith(activity) }) fragmentPageBinding?.pageSwitch?.setOnCheckedChangeListener { _, isChecked -> pageViewModel.actions.offer(Action.UserClickedShowAllToggle(isChecked))