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 d495683 commit afff241
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/com/infomaniak/mail/data/api/ApiRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ object ApiRoutes {
//endregion

//region Calendar
fun calendarEvent(resource: String): String {
return "${resource(resource)}?format=render"
}

fun infomaniakCalendarEventReply(calendarEventId: Int): String {
return "${pim()}/event/$calendarEventId/reply"
}

fun calendarEvent(resource: String): String {
return "${resource(resource)}?format=render"
}

fun icsCalendarEventReply(resource: String): String {
return "${resource(resource)}/reply"
}
Expand Down
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 afff241

Please sign in to comment.