From 87b5ccb5b9ada47708d81ec7e6edd2f73fcf15a5 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 11 Nov 2020 10:46:53 +0100 Subject: [PATCH] Prevent empty person names --- app/src/main/java/eu/faircode/email/Core.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index eadb9beeab..2e25ca09f5 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3800,10 +3800,17 @@ class Core { if (notify_messaging) { // https://developer.android.com/training/cars/messaging - Person.Builder me = new Person.Builder() - .setName(MessageHelper.formatAddresses(message.to, name_email, false)); - Person.Builder you = new Person.Builder() - .setName(MessageHelper.formatAddresses(message.from, name_email, false)); + String meName = MessageHelper.formatAddresses(message.to, name_email, false); + String youName = MessageHelper.formatAddresses(message.from, name_email, false); + + // Names cannot be empty + if (TextUtils.isEmpty(meName)) + meName = "-"; + if (TextUtils.isEmpty(youName)) + youName = "-"; + + Person.Builder me = new Person.Builder().setName(meName); + Person.Builder you = new Person.Builder().setName(youName); if (info[0].hasPhoto()) you.setIcon(IconCompat.createWithBitmap(info[0].getPhotoBitmap()));