Skip to content

Commit

Permalink
Use setSystemBarsColors(…) in more situations
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Feb 1, 2024
1 parent 0fd7cfe commit 93142c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
} else {
R.color.backgroundHeaderColor
}
requireActivity().window.statusBarColor = requireContext().getColor(statusBarColor)
setSystemBarsColors(statusBarColor = statusBarColor, navigationBarColor = null)
}

private fun refreshThreadsIfNotificationsAreDisabled() = with(mainViewModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.infomaniak.mail.utils.AttachmentIntentUtils
import com.infomaniak.mail.utils.UiUtils.FULLY_SLID
import com.infomaniak.mail.utils.UiUtils.progressivelyColorSystemBars
import com.infomaniak.mail.utils.safeNavigateToNewMessageActivity
import com.infomaniak.mail.utils.updateNavigationBarColor
import com.infomaniak.mail.utils.setSystemBarsColors
import javax.inject.Inject

abstract class TwoPaneFragment : Fragment() {
Expand Down Expand Up @@ -121,7 +121,7 @@ abstract class TwoPaneFragment : Fragment() {
val isOpeningThread = threadUid != null
if (isOpeningThread) {
val hasOpened = slidingPaneLayout.openPaneNoAnimation()
if (hasOpened) requireActivity().window.statusBarColor = requireContext().getColor(R.color.backgroundColor)
if (hasOpened) setSystemBarsColors(statusBarColor = R.color.backgroundColor, navigationBarColor = null)
} else {
resetPanes()
}
Expand Down Expand Up @@ -157,13 +157,15 @@ abstract class TwoPaneFragment : Fragment() {
}
}

private fun resetPanes() = with(requireActivity()) {
private fun resetPanes() {

val hasClosed = slidingPaneLayout.closePaneNoAnimation()

if (hasClosed) {
if (this@TwoPaneFragment is ThreadListFragment) window.statusBarColor = getColor(R.color.backgroundHeaderColor)
window.updateNavigationBarColor(getColor(R.color.backgroundColor))
setSystemBarsColors(
statusBarColor = if (this@TwoPaneFragment is ThreadListFragment) R.color.backgroundHeaderColor else null,
navigationBarColor = R.color.backgroundColor,
)
}

threadListAdapter.selectNewThread(newPosition = null, threadUid = null)
Expand Down

0 comments on commit 93142c4

Please sign in to comment.