Skip to content

Commit a2805a3

Browse files
Fix/bottom nav visibility mediadetails (#6520)
* Ensure bottom navigation bar is visible on back navigation * Prevent hiding bottom navigation bar in MediaDetailPagerFragment * Removed the redundant showTabs() calls from onBackPressed() as they are no longer needed * Explicitly hide and show the bottom navigation bar on entering/exiting Media Details --------- Co-authored-by: Nicolas Raoul <[email protected]>
1 parent a8a569b commit a2805a3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import fr.free.nrw.commons.category.CategoryClient
8787
import fr.free.nrw.commons.category.CategoryDetailsActivity
8888
import fr.free.nrw.commons.category.CategoryEditHelper
8989
import fr.free.nrw.commons.contributions.ContributionsFragment
90+
import fr.free.nrw.commons.contributions.MainActivity
9091
import fr.free.nrw.commons.coordinates.CoordinateEditHelper
9192
import fr.free.nrw.commons.databinding.FragmentMediaDetailBinding
9293
import fr.free.nrw.commons.delete.DeleteHelper
@@ -793,6 +794,14 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
793794
super.onDestroyView()
794795
}
795796

797+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
798+
super.onViewCreated(view, savedInstanceState)
799+
if (activity is MainActivity) {
800+
//explicitly hides the tabs when the media details screen is opened.
801+
(activity as MainActivity).hideTabs()
802+
}
803+
}
804+
796805
private fun setTextFields(media: Media) {
797806
setupImageView()
798807
binding.mediaDetailTitle.text = media.displayTitle

app/src/main/java/fr/free/nrw/commons/media/MediaDetailPagerFragment.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ class MediaDetailPagerFragment : CommonsDaggerSupportFragment(), OnPageChangeLis
109109
// If fragment is associated with ProfileActivity, then hide the tabLayout
110110
if (activity is ProfileActivity) {
111111
(activity as ProfileActivity).setTabLayoutVisibility(false)
112-
} else if (activity is MainActivity) {
113-
(activity as MainActivity).hideTabs()
114112
}
115113

116114
binding!!.mediaDetailsPager.adapter = adapter
@@ -142,6 +140,14 @@ class MediaDetailPagerFragment : CommonsDaggerSupportFragment(), OnPageChangeLis
142140
initProvider()
143141
}
144142

143+
override fun onDestroyView() {
144+
super.onDestroyView()
145+
if (activity is MainActivity) {
146+
(activity as MainActivity).showTabs()
147+
}
148+
binding = null
149+
}
150+
145151
/**
146152
* initialise the provider, based on from where the fragment was started, as in from an activity
147153
* or a fragment

0 commit comments

Comments
 (0)