From 91164e04ed031f5b957e0e9800b4222d91409e32 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 23 Jul 2018 12:54:09 +0200 Subject: [PATCH] Make sure account display name is never null --- app/core/src/main/java/com/fsck/k9/Account.java | 4 ++++ .../src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt | 2 +- .../src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt | 2 +- .../main/java/com/fsck/k9/backends/WebDavBackendFactory.kt | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/core/src/main/java/com/fsck/k9/Account.java b/app/core/src/main/java/com/fsck/k9/Account.java index 7b60bb3f7..713814e98 100644 --- a/app/core/src/main/java/com/fsck/k9/Account.java +++ b/app/core/src/main/java/com/fsck/k9/Account.java @@ -776,6 +776,10 @@ public class Account implements BaseAccount, StoreConfig { this.description = description; } + public String getDisplayName() { + return description != null ? description : getEmail(); + } + public synchronized String getName() { return identities.get(0).getName(); } diff --git a/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt b/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt index d41fa3185..28c5a2c66 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt @@ -27,7 +27,7 @@ class ImapBackendFactory( override val transportUriPrefix = "smtp" override fun createBackend(account: Account): Backend { - val accountName = account.description + val accountName = account.displayName val backendStorage = K9BackendStorage(preferences, account, account.localStore) val imapStore = createImapStore(account) val smtpTransport = createSmtpTransport(account) diff --git a/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt b/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt index 61d98f86b..5a223f9e5 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt @@ -21,7 +21,7 @@ class Pop3BackendFactory(private val context: Context, private val preferences: override val transportUriPrefix = "smtp" override fun createBackend(account: Account): Backend { - val accountName = account.description + val accountName = account.displayName val backendStorage = K9BackendStorage(preferences, account, account.localStore) val pop3Store = createPop3Store(account) val smtpTransport = createSmtpTransport(account) diff --git a/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt b/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt index 8199e3aaf..97686c876 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt @@ -17,7 +17,7 @@ class WebDavBackendFactory(private val preferences: Preferences) : BackendFactor override val transportUriPrefix = "webdav" override fun createBackend(account: Account): Backend { - val accountName = account.description + val accountName = account.displayName val backendStorage = K9BackendStorage(preferences, account, account.localStore) val serverSettings = WebDavStoreUriDecoder.decode(account.storeUri) val webDavStore = createWebDavStore(serverSettings, account)