Skip to content

Commit 93142c4

Browse files
Use setSystemBarsColors(…) in more situations
1 parent 0fd7cfe commit 93142c4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
237237
} else {
238238
R.color.backgroundHeaderColor
239239
}
240-
requireActivity().window.statusBarColor = requireContext().getColor(statusBarColor)
240+
setSystemBarsColors(statusBarColor = statusBarColor, navigationBarColor = null)
241241
}
242242

243243
private fun refreshThreadsIfNotificationsAreDisabled() = with(mainViewModel) {

app/src/main/java/com/infomaniak/mail/ui/main/folder/TwoPaneFragment.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import com.infomaniak.mail.utils.AttachmentIntentUtils
3838
import com.infomaniak.mail.utils.UiUtils.FULLY_SLID
3939
import com.infomaniak.mail.utils.UiUtils.progressivelyColorSystemBars
4040
import com.infomaniak.mail.utils.safeNavigateToNewMessageActivity
41-
import com.infomaniak.mail.utils.updateNavigationBarColor
41+
import com.infomaniak.mail.utils.setSystemBarsColors
4242
import javax.inject.Inject
4343

4444
abstract class TwoPaneFragment : Fragment() {
@@ -121,7 +121,7 @@ abstract class TwoPaneFragment : Fragment() {
121121
val isOpeningThread = threadUid != null
122122
if (isOpeningThread) {
123123
val hasOpened = slidingPaneLayout.openPaneNoAnimation()
124-
if (hasOpened) requireActivity().window.statusBarColor = requireContext().getColor(R.color.backgroundColor)
124+
if (hasOpened) setSystemBarsColors(statusBarColor = R.color.backgroundColor, navigationBarColor = null)
125125
} else {
126126
resetPanes()
127127
}
@@ -157,13 +157,15 @@ abstract class TwoPaneFragment : Fragment() {
157157
}
158158
}
159159

160-
private fun resetPanes() = with(requireActivity()) {
160+
private fun resetPanes() {
161161

162162
val hasClosed = slidingPaneLayout.closePaneNoAnimation()
163163

164164
if (hasClosed) {
165-
if (this@TwoPaneFragment is ThreadListFragment) window.statusBarColor = getColor(R.color.backgroundHeaderColor)
166-
window.updateNavigationBarColor(getColor(R.color.backgroundColor))
165+
setSystemBarsColors(
166+
statusBarColor = if (this@TwoPaneFragment is ThreadListFragment) R.color.backgroundHeaderColor else null,
167+
navigationBarColor = R.color.backgroundColor,
168+
)
167169
}
168170

169171
threadListAdapter.selectNewThread(newPosition = null, threadUid = null)

0 commit comments

Comments
 (0)