Skip to content

Commit

Permalink
Fixed the redundancy of the 'All-Books-Mode' option for Bookmarks, No…
Browse files Browse the repository at this point in the history
…tes, 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.
  • Loading branch information
MohitMaliDeveloper committed Nov 6, 2023
1 parent 8f099e6 commit fc5817d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit fc5817d

Please sign in to comment.