Repository: thundernest/k-9
Issue: Crash when message contains empty recipient headers

### Checklist

- [X] I have used the search function to see if someone else has already submitted the same bug report.
- [X] I will describe the problem with as much detail as possible.

### App version

6.505

### Where did you get the app from?

None

### Android version

doesn't matter

### Device model

_No response_

### Steps to reproduce

1. Open a message that doesn't contain any recipients, e.g. `To: undisclosed-recipients:;`


### Expected behavior

No crash

### Actual behavior

```text
java.lang.IllegalArgumentException: Failed requirement.
  at com.fsck.k9.ui.messageview.RecipientLayoutCreator.createRecipientLayout(RecipientLayoutCreator.kt:31)
  at com.fsck.k9.ui.messageview.RecipientNamesView.onLayout(RecipientNamesView.kt:113)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
  at android.widget.ScrollView.onLayout(ScrollView.java:1660)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
  at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at androidx.recyclerview.widget.RecyclerView$LayoutManager.layoutDecoratedWithMargins(RecyclerView.java:9878)
  at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1689)
  at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
  at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4309)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4012)
  at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4578)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:527)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1103)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
  at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1263)
  at android.view.View.layout(View.java:22848)
  at android.view.ViewGroup.layout(ViewGroup.java:6389)
```

### Logs

_No response_

Changed files:
app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/RecipientNamesView.kt

diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/RecipientNamesView.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/RecipientNamesView.kt
index b4bc9f043..c1c1c89a0 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/RecipientNamesView.kt
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/RecipientNamesView.kt
@@ -108,6 +108,11 @@ class RecipientNamesView(context: Context, attrs: AttributeSet?) : ViewGroup(con
     }
 
     override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
+        if (numberOfRecipients == 0) {
+            // There's nothing to display
+            return
+        }
+
         val availableWidth = width
 
         val recipientLayoutData = recipientLayoutCreator.createRecipientLayout(