From ff4f93b95a3bc72dc948ed109571abe21f36b8d8 Mon Sep 17 00:00:00 2001
From: Janne Koschinski <janne@kuschku.de>
Date: Thu, 6 Sep 2018 09:55:49 +0200
Subject: [PATCH] Fix bug with background-only hex colors

---
 .../quasseldroid/util/irc/format/IrcFormatSerializer.kt   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/app/src/main/java/de/kuschku/quasseldroid/util/irc/format/IrcFormatSerializer.kt b/app/src/main/java/de/kuschku/quasseldroid/util/irc/format/IrcFormatSerializer.kt
index dcf56c508..7a2880d72 100644
--- a/app/src/main/java/de/kuschku/quasseldroid/util/irc/format/IrcFormatSerializer.kt
+++ b/app/src/main/java/de/kuschku/quasseldroid/util/irc/format/IrcFormatSerializer.kt
@@ -66,6 +66,10 @@ class IrcFormatSerializer @Inject constructor(context: Context) {
     getColor(0, 0)
   }
 
+  private val colorForegroundHex = context.theme.styledAttributes(R.attr.colorForeground) {
+    getColor(0, 0)
+  }
+
   fun toEscapeCodes(text: Spanned): String {
     val out = StringBuilder()
     withinParagraph(out, text, 0, text.length)
@@ -120,6 +124,10 @@ class IrcFormatSerializer @Inject constructor(context: Context) {
           out.append(',')
           out.append(String.format(Locale.US, "%06x", background and 0x00FFFFFF))
         }
+      } else if (background != null) {
+        out.append(String.format(Locale.US, "%06x", this.colorForegroundHex and 0x00FFFFFF))
+        out.append(',')
+        out.append(String.format(Locale.US, "%06x", background and 0x00FFFFFF))
       }
     }
 
-- 
GitLab