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