Skip to content

Commit

Permalink
Merge pull request #3525 from kiwix/Issue#3523
Browse files Browse the repository at this point in the history
Fixed the redundancy of the 'All-Books-Mode' option for Bookmarks, Notes, and History in custom apps.
  • Loading branch information
kelson42 committed Nov 12, 2023
2 parents a8eb53f + 4c8f7cb commit ae41355
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 ae41355

Please sign in to comment.