Merge pull request #3525 from kiwix/Issue#3523

Fixed the redundancy of the 'All-Books-Mode' option for Bookmarks, Notes, and History in custom apps.
This commit is contained in:
Kelson 2023-11-12 18:04:52 +01:00 committed by GitHub
commit ae413559fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -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"
}

View File

@ -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))