Android: home-screen shortcuts to bookmarks

"Add to home screen" in a bookmark's menu pins a shortcut that connects
to the bookmark, or goes to its channel when already on that server. The
shortcut names the bookmark by a new stable id, so it follows edits and
stops working once the bookmark is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 22:19:52 +00:00
co-authored by Claude Opus 5.5
parent e76804fb2d
commit 60ef727f22
7 changed files with 124 additions and 3 deletions
@@ -1,7 +1,11 @@
package com.ts3client.config;
import java.util.UUID;
/** A saved server for quick connect. */
public final class Bookmark {
/** 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;
@@ -35,6 +39,7 @@ public final class Bookmark {
/** A bookmark of its own with the same fields, to change without touching this one. */
public Bookmark copy() {
Bookmark b = new Bookmark(label, address, port, nickname, password);
b.id = id;
b.identityId = identityId;
b.channel = channel;
b.channelPassword = channelPassword;
@@ -47,6 +47,14 @@ public final class Bookmarks {
return changed;
}
/** The bookmark with this {@link Bookmark#id}, or null. */
public Bookmark find(String id) {
for (Bookmark b : entries) {
if (b.id.equals(id)) return b;
}
return null;
}
/** Bookmarks flagged to connect at startup, each in its own tab. */
public List<Bookmark> startupBookmarks() {
List<Bookmark> out = new ArrayList<>();
@@ -69,6 +77,8 @@ public final class Bookmarks {
for (int i = 0; i < count; i++) {
String prefix = "bookmark." + i + ".";
Bookmark bm = new Bookmark();
String id = p.getProperty(prefix + "id", "");
if (!id.isBlank()) bm.id = id;
bm.label = p.getProperty(prefix + "label", "");
bm.address = p.getProperty(prefix + "address", "");
bm.port = parseInt(p.getProperty(prefix + "port"), 9987);
@@ -90,6 +100,7 @@ public final class Bookmarks {
for (int i = 0; i < entries.size(); i++) {
Bookmark bm = entries.get(i);
String prefix = "bookmark." + i + ".";
p.setProperty(prefix + "id", bm.id);
p.setProperty(prefix + "label", nullToEmpty(bm.label));
p.setProperty(prefix + "address", nullToEmpty(bm.address));
p.setProperty(prefix + "port", Integer.toString(bm.port));