Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions legacy/ui/legacy/src/main/res/layout/message_list.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.fsck.k9.activity.MainActivity"
>

<androidx.coordinatorlayout.widget.CoordinatorLayout
<!--
As the navigation of Message List (MessageHomeActivity) is based on the ViewSwitcher,
which just toggle the visibility of existing views rather than creating/destroying the
Fragments, the Fragment's lifecycle methods, such as onViewCreated, are not properly called.

Modern layouts (ConstraintLayout, CoordinatorLayout) optimize measurement during visibility
toggles and WindowInsets updates, sometimes causing a transient layout pass with incorrect bounds.
The RecyclerView incorrectly treats this pass as a successful update and marks its state as "clean".
Consequently, it fails to trigger onBindViewHolder when the view is fully restored, leaving the
UI stuck displaying the previous stale state instead of the new data.

RelativeLayout is used to enforce strict vertical dependencies. By using layout_below, it
ensures the Toolbar is measured before the container. This prevents the race condition and forces
the RecyclerView to recognize its actual bounds, ensuring the adapter binds correctly without
performance-heavy requestLayout() calls.

Until we move this screen to use a modern navigation system, or rewrite it using Jetpack Compose,
we need to use this workaround.
-->
<RelativeLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
style="@style/Widget.App.AppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
>

<include
android:id="@+id/toolbar"
layout="@layout/message_list_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>

</com.google.android.material.appbar.AppBarLayout>
Expand All @@ -37,7 +54,7 @@
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_below="@id/app_bar_layout"
>

<ProgressBar
Expand All @@ -58,23 +75,23 @@

<androidx.fragment.app.FragmentContainerView
android:id="@+id/message_list_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/message_list_fragment"
/>

<androidx.fragment.app.FragmentContainerView
android:id="@+id/message_view_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/message"
/>

</com.fsck.k9.view.ViewSwitcher>

</FrameLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>

<include layout="@layout/navigation_drawer_content" />

Expand Down
27 changes: 22 additions & 5 deletions legacy/ui/legacy/src/main/res/layout/split_message_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,44 @@
android:layout_height="match_parent"
tools:context="com.fsck.k9.activity.MainActivity"
>
<!--
As the navigation of Message List (MessageHomeActivity) is based on the ViewSwitcher,
which just toggle the visibility of existing views rather than creating/destroying the
Fragments, the Fragment's lifecycle methods, such as onViewCreated, are not properly called.

<androidx.coordinatorlayout.widget.CoordinatorLayout
Modern layouts (ConstraintLayout, CoordinatorLayout) optimize measurement during visibility
toggles and WindowInsets updates, sometimes causing a transient layout pass with incorrect bounds.
The RecyclerView incorrectly treats this pass as a successful update and marks its state as "clean".
Consequently, it fails to trigger onBindViewHolder when the view is fully restored, leaving the
UI stuck displaying the previous stale state instead of the new data.

RelativeLayout is used to enforce strict vertical dependencies. By using layout_below, it
ensures the Toolbar is measured before the container. This prevents the race condition and forces
the RecyclerView to recognize its actual bounds, ensuring the adapter binds correctly without
performance-heavy requestLayout() calls.

Until we move this screen to use a modern navigation system, or rewrite it using Jetpack Compose,
we need to use this workaround.
-->
<RelativeLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
style="@style/Widget.App.AppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
>

<include
android:id="@+id/toolbar"
layout="@layout/message_list_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>

</com.google.android.material.appbar.AppBarLayout>
Expand All @@ -37,7 +54,7 @@
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_below="@id/app_bar_layout"
>

<ProgressBar
Expand Down Expand Up @@ -86,7 +103,7 @@

</FrameLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>

<include layout="@layout/navigation_drawer_content" />

Expand Down
Loading