ignore bookmark name of 'None'
This commit is contained in:
parent
3be95cd7ba
commit
ce00767777
|
@ -2,6 +2,7 @@ package eu.siacs.conversations.entities;
|
|||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
@ -55,18 +56,25 @@ public class Bookmark extends Element implements ListItem {
|
|||
@Override
|
||||
public String getDisplayName() {
|
||||
final Conversation c = getConversation();
|
||||
final String name = getBookmarkName();
|
||||
if (c != null) {
|
||||
return c.getName().toString();
|
||||
} else if (getBookmarkName() != null
|
||||
&& !getBookmarkName().trim().isEmpty()) {
|
||||
return getBookmarkName().trim();
|
||||
} else if (printableValue(name, false)) {
|
||||
return name.trim();
|
||||
} else {
|
||||
Jid jid = this.getJid();
|
||||
String name = jid != null ? jid.getLocal() : getAttribute("jid");
|
||||
return name != null ? name : "";
|
||||
return jid != null && jid.getLocal() != null ? jid.getLocal() : "";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean printableValue(@Nullable String value, boolean permitNone) {
|
||||
return value != null && !value.trim().isEmpty() && (permitNone || !"None".equals(value));
|
||||
}
|
||||
|
||||
public static boolean printableValue(@Nullable String value) {
|
||||
return printableValue(value, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jid getJid() {
|
||||
return this.jid;
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
@ -112,13 +113,13 @@ public class Contact implements ListItem, Blockable {
|
|||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
if (Config.X509_VERIFICATION && this.commonName != null && !this.commonName.isEmpty()) {
|
||||
if (Config.X509_VERIFICATION && !TextUtils.isEmpty(this.commonName)) {
|
||||
return this.commonName;
|
||||
} else if (this.systemName != null && !this.systemName.isEmpty()) {
|
||||
} else if (!TextUtils.isEmpty(this.systemName)) {
|
||||
return this.systemName;
|
||||
} else if (this.serverName != null && !this.serverName.isEmpty()) {
|
||||
} else if (!TextUtils.isEmpty(this.serverName)) {
|
||||
return this.serverName;
|
||||
} else if (this.presenceName != null && !this.presenceName.isEmpty() && mutualPresenceSubscription() ) {
|
||||
} else if (!TextUtils.isEmpty(this.presenceName) && mutualPresenceSubscription() ) {
|
||||
return this.presenceName;
|
||||
} else if (jid.getLocal() != null) {
|
||||
return JidHelper.localPartOrFallback(jid);
|
||||
|
@ -152,7 +153,7 @@ public class Contact implements ListItem, Blockable {
|
|||
}
|
||||
|
||||
public boolean match(Context context, String needle) {
|
||||
if (needle == null || needle.isEmpty()) {
|
||||
if (TextUtils.isEmpty(needle)) {
|
||||
return true;
|
||||
}
|
||||
needle = needle.toLowerCase(Locale.US).trim();
|
||||
|
|
|
@ -26,6 +26,8 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
|||
import eu.siacs.conversations.xmpp.mam.MamReference;
|
||||
import rocks.xmpp.addr.Jid;
|
||||
|
||||
import static eu.siacs.conversations.entities.Bookmark.printableValue;
|
||||
|
||||
|
||||
public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation> {
|
||||
public static final String TABLENAME = "conversations";
|
||||
|
@ -479,15 +481,15 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|||
public CharSequence getName() {
|
||||
if (getMode() == MODE_MULTI) {
|
||||
final String subject = getMucOptions().getSubject();
|
||||
Bookmark bookmark = getBookmark();
|
||||
final Bookmark bookmark = getBookmark();
|
||||
final String bookmarkName = bookmark != null ? bookmark.getBookmarkName() : null;
|
||||
if (subject != null && !subject.trim().isEmpty()) {
|
||||
if (printableValue(subject)) {
|
||||
return subject;
|
||||
} else if (bookmarkName != null && !bookmarkName.trim().isEmpty()) {
|
||||
} else if (printableValue(bookmarkName, false)) {
|
||||
return bookmarkName;
|
||||
} else {
|
||||
String generatedName = getMucOptions().createNameFromParticipants();
|
||||
if (generatedName != null) {
|
||||
final String generatedName = getMucOptions().createNameFromParticipants();
|
||||
if (printableValue(generatedName)) {
|
||||
return generatedName;
|
||||
} else {
|
||||
return getJid().getLocal();
|
||||
|
|
Loading…
Reference in a new issue