Skip to content

Commit

Permalink
Add canDisplayOnlyOnePane()
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Jan 25, 2024
1 parent d48191c commit d05e8a3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class MainActivity : BaseActivity() {
R.id.detailedContactBottomSheetDialog -> {
val fragment = currentFragment
if (fragment is TwoPaneFragment) {
val navigationBarColor = if (fragment.isThreadOpen() && !canDisplayBothPanes()) {
val navigationBarColor = if (fragment.isThreadOpen() && canDisplayOnlyOnePane()) {
R.color.elevatedBackground
} else {
R.color.backgroundColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)

val statusBarColor = if (isThreadOpen() && !canDisplayBothPanes()) {
val statusBarColor = if (isThreadOpen() && canDisplayOnlyOnePane()) {
R.color.backgroundColor
} else {
R.color.backgroundHeaderColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import com.infomaniak.mail.ui.main.thread.ThreadFragment
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.canDisplayBothPanes
import com.infomaniak.mail.utils.canDisplayOnlyOnePane
import com.infomaniak.mail.utils.safeNavigateToNewMessageActivity
import com.infomaniak.mail.utils.updateNavigationBarColor
import javax.inject.Inject
Expand Down Expand Up @@ -187,7 +187,7 @@ abstract class TwoPaneFragment : Fragment() {
// TODO: When we'll add the feature of swiping between Threads, we'll need to check if this function is still needed.
private fun updateDrawerLockMode() {
if (this is ThreadListFragment) {
(requireActivity() as MainActivity).setDrawerLockMode(isLocked = twoPaneViewModel.isThreadOpen && !canDisplayBothPanes())
(requireActivity() as MainActivity).setDrawerLockMode(isLocked = isThreadOpen() && canDisplayOnlyOnePane())
}
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/infomaniak/mail/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ fun Date.isLastWeek(): Boolean {
//region UI
fun Context.isInPortrait(): Boolean = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT

private fun Context.canDisplayBothPanes(): Boolean = resources.getBoolean(R.bool.canDisplayBothPanes)
fun Fragment.canDisplayBothPanes(): Boolean = requireContext().canDisplayBothPanes()
fun Context.canDisplayBothPanes(): Boolean = resources.getBoolean(R.bool.canDisplayBothPanes)
fun Context.canDisplayOnlyOnePane(): Boolean = !canDisplayBothPanes()
fun Fragment.canDisplayOnlyOnePane(): Boolean = requireContext().canDisplayOnlyOnePane()

fun View.toggleChevron(
isCollapsed: Boolean,
Expand Down

0 comments on commit d05e8a3

Please sign in to comment.