diff options
6 files changed, 31 insertions, 34 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index beb9612d..2244645b 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -281,14 +281,13 @@ public class MucOptions { public String getProposedNick() { if (conversation.getBookmark() != null - && conversation.getBookmark().getNick() != null) { + && conversation.getBookmark().getNick() != null + && !conversation.getBookmark().getNick().isEmpty()) { return conversation.getBookmark().getNick(); + } else if (!conversation.getContactJid().isBareJid()) { + return conversation.getContactJid().getResourcepart(); } else { - if (!conversation.getContactJid().isBareJid()) { - return conversation.getContactJid().getResourcepart(); - } else { - return account.getUsername(); - } + return account.getUsername(); } } diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index e2028c7b..8e559bd5 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -27,8 +27,10 @@ public class MessageParser extends AbstractParser implements private Message parseChat(MessagePacket packet, Account account) { final Jid jid = packet.getFrom(); - Conversation conversation = mXmppConnectionService - .findOrCreateConversation(account, jid.toBareJid(), false); + if (jid == null) { + return null; + } + Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid.toBareJid(), false); updateLastseen(packet, account, true); String pgpBody = getPgpBody(packet); Message finishedMessage; @@ -61,6 +63,9 @@ public class MessageParser extends AbstractParser implements boolean properlyAddressed = (!packet.getTo().isBareJid()) || (account.countPresences() == 1); final Jid from = packet.getFrom(); + if (from == null) { + return null; + } Conversation conversation = mXmppConnectionService .findOrCreateConversation(account, from.toBareJid(), false); String presence; diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index 70c1d4dd..3ac4462d 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -121,8 +121,8 @@ public class AvatarService { if (count == 0) { String name = mucOptions.getConversation().getName(); - String letter = name.substring(0, 1); - int color = UIHelper.getColorForName(name); + final String letter = name.isEmpty() ? "X" : name.substring(0,1); + final int color = UIHelper.getColorForName(name); drawTile(canvas, letter, color, 0, 0, size, size); } else if (count == 1) { drawTile(canvas, users.get(0), 0, 0, size, size); @@ -212,15 +212,8 @@ public class AvatarService { } bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); - String letter; - int color; - if (name.length() > 0) { - letter = name.substring(0, 1); - color = UIHelper.getColorForName(name); - } else { - letter = "X"; - color = PLACEHOLDER_COLOR; - } + final String letter = name.isEmpty() ? "X" : name.substring(0,1); + final int color = UIHelper.getColorForName(name); drawTile(canvas, letter, color, 0, 0, size, size); mXmppConnectionService.getBitmapCache().put(KEY, bitmap); return bitmap; @@ -275,15 +268,8 @@ public class AvatarService { } } String name = contact != null ? contact.getDisplayName() : user.getName(); - String letter; - int color; - if (name.length() > 0) { - letter = name.substring(0, 1); - color = UIHelper.getColorForName(name); - } else { - letter = "X"; - color = PLACEHOLDER_COLOR; - } + final String letter = name.isEmpty() ? "X" : name.substring(0,1); + final int color = UIHelper.getColorForName(name); drawTile(canvas, letter, color, left, top, right, bottom); } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 128f61a1..9cc4c2c6 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1301,10 +1301,12 @@ public class XmppConnectionService extends Service { account.pendingConferenceJoins.remove(conversation); account.pendingConferenceLeaves.remove(conversation); if (account.getStatus() == Account.State.ONLINE) { - Log.d(Config.LOGTAG, - "joining conversation " + conversation.getContactJid()); - String nick = conversation.getMucOptions().getProposedNick(); - Jid joinJid = conversation.getMucOptions().createJoinJid(nick); + final String nick = conversation.getMucOptions().getProposedNick(); + final Jid joinJid = conversation.getMucOptions().createJoinJid(nick); + if (joinJid == null) { + return; //safety net + } + Log.d(Config.LOGTAG,account.getJid().toBareJid().toString()+": joining conversation " + joinJid.toString()); PresencePacket packet = new PresencePacket(); packet.setFrom(conversation.getAccount().getJid()); packet.setTo(joinJid); diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index 341b3d77..28a2bb4c 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -128,6 +128,9 @@ public class UIHelper { } public static int getColorForName(String name) { + if (name.isEmpty()) { + return 0xFF202020; + } int colors[] = {0xFFe91e63, 0xFF9c27b0, 0xFF673ab7, 0xFF3f51b5, 0xFF5677fc, 0xFF03a9f4, 0xFF00bcd4, 0xFF009688, 0xFFff5722, 0xFF795548, 0xFF607d8b}; diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 198fc89a..cade782a 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -324,9 +324,9 @@ <string name="no_application_found_to_open_file">Keine Anwendung zum Öffnen der Datei gefunden</string> <string name="could_not_verify_fingerprint">Kann Fingerabdruck nicht überprüfen</string> <string name="manually_verify">Manuell überprüfen</string> - <string name="are_you_sure_verify_fingerprint">Bist du sicher, dass du die OTR Fingerabdrücke des Kontakts überprüfen willst?</string> + <string name="are_you_sure_verify_fingerprint">Bist du sicher, dass du die OTR-Fingerabdrücke des Kontakts überprüfen willst?</string> <string name="pref_show_dynamic_tags">Dynamische Tags anzeigen</string> - <string name="pref_show_dynamic_tags_summary">Zeige schreibgeschützte Tags Unterhalb der Kontakte</string> + <string name="pref_show_dynamic_tags_summary">Zeige schreibgeschützte Tags unterhalb der Kontakte</string> <string name="enable_notifications">Aktiviere Benachrichtigungen</string> <string name="conference_with">Starte Konferenze mit…</string> <string name="no_conference_server_found">Konferenz-Server kann nicht gefunden werden</string> @@ -334,4 +334,6 @@ <string name="conference_created">Konferenz erstellt!</string> <string name="secret_accepted">Schlüssel akzeptiert!</string> <string name="reset">Zurücksetzen</string> + <string name="account_image_description">Konto-Avatar</string> + <string name="copy_otr_clipboard_description">OTR-Fingerabdruck in Zwischenablage kopieren</string> </resources> |