Find in the channel tree and the chat on Android

A find button in the top bar opens a find bar over the tree (clients or
channels) or the conversation on screen, with match stepping, highlights,
only-matches filtering and the desktop's matching options. The tree's
match rule moves to core TreeMatch, which the desktop now uses too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 09:54:02 +00:00
parent 66ef62913a
commit 662e031b6b
10 changed files with 501 additions and 48 deletions

View File

@@ -0,0 +1,22 @@
package com.ts3client.net;
import com.ts3client.text.TextQuery;
/** What finding in the server tree matches a client or a channel on. */
public final class TreeMatch {
private TreeMatch() {
}
/** A client by their nickname, or by the name the contacts give them ({@code null} for none). */
public static boolean client(TextQuery query, String nickname, String contactName) {
return query.matches(nickname) || (contactName != null && query.matches(contactName));
}
/** A channel by its name; a spacer by its caption, unless that only repeats to fill the row. */
public static boolean channel(TextQuery query, String name) {
Spacers.Spacer spacer = Spacers.parse(name);
if (spacer == null) return query.matches(name);
return spacer.align() != '*' && query.matches(spacer.caption());
}
}

View File

@@ -3,8 +3,8 @@ package com.ts3client.ui;
import com.ts3client.contacts.Contact;
import com.ts3client.contacts.ContactStore;
import com.ts3client.net.ChannelNode;
import com.ts3client.net.Spacers;
import com.ts3client.net.ClientEntry;
import com.ts3client.net.TreeMatch;
import com.ts3client.text.TextQuery;
import javax.swing.Icon;
@@ -102,14 +102,9 @@ final class ServerTreeSearch implements FindBar.Listener {
if (node instanceof ClientEntry c) {
if (searchChannels) return false;
Contact contact = contacts.find(c.uniqueId);
return query.matches(c.nickname) || (contact != null && query.matches(contact.displayName(c.nickname)));
}
if (node instanceof ChannelNode ch) {
if (!searchChannels) return false;
Spacers.Spacer spacer = Spacers.parse(ch.name);
if (spacer == null) return query.matches(ch.name);
return spacer.align() != '*' && query.matches(spacer.caption());
return TreeMatch.client(query, c.nickname, contact != null ? contact.displayName(c.nickname) : null);
}
if (node instanceof ChannelNode ch) return searchChannels && TreeMatch.channel(query, ch.name);
return false;
}