Hide the default port in bookmark lists
Bookmark.hostPort gives the address alone for port 9987 and address:port otherwise. The Android connect screen, the myTeamSpeak item lists on desktop and Android, and the display name of an unnamed bookmark use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,11 +4,13 @@ import java.util.UUID;
|
||||
|
||||
/** A saved server for quick connect. */
|
||||
public final class Bookmark {
|
||||
public static final int DEFAULT_PORT = 9987;
|
||||
|
||||
/** Stays the same through edits, for whatever refers to the bookmark from outside, like a launcher shortcut. */
|
||||
public String id = UUID.randomUUID().toString();
|
||||
public String label;
|
||||
public String address;
|
||||
public int port = 9987;
|
||||
public int port = DEFAULT_PORT;
|
||||
public String nickname;
|
||||
public String password = "";
|
||||
/** Identity to connect with; empty means "use the default identity". */
|
||||
@@ -53,10 +55,19 @@ public final class Bookmark {
|
||||
return this.port == port && this.address != null && this.address.trim().equalsIgnoreCase(address.trim());
|
||||
}
|
||||
|
||||
/** Display name, falling back to "address:port" when no label is set. */
|
||||
/** Display name, falling back to {@link #hostPort()} when no label is set. */
|
||||
public String displayName() {
|
||||
if (label != null && !label.isBlank()) return label;
|
||||
return address + ":" + port;
|
||||
return hostPort();
|
||||
}
|
||||
|
||||
public String hostPort() {
|
||||
return hostPort(address, port);
|
||||
}
|
||||
|
||||
/** {@code address}, followed by {@code :port} unless it is {@link #DEFAULT_PORT}. */
|
||||
public static String hostPort(String address, int port) {
|
||||
return port == DEFAULT_PORT ? address : address + ":" + port;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user