Compare commits

..
8 Commits
Author SHA1 Message Date
Codex de0f7654d0 Integrate group management into sessions
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Successful in 12m42s
2026-07-15 16:10:18 +00:00
Codex 650431e3d1 Compact action buttons across pages
Gitea Smoke / smoke (push) Successful in 2s
Gitea Android APK / build (push) Failing after 1m1s
2026-07-15 15:15:09 +00:00
Codex 412c69cc36 Replace native dialogs with app sheets
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Has been cancelled
2026-07-15 15:03:56 +00:00
Codex 813a74f3ef Simplify server page actions
Gitea Smoke / smoke (push) Successful in 2s
Gitea Android APK / build (push) Failing after 1m2s
2026-07-15 14:40:01 +00:00
Codex 0d32e6105a Move secondary navigation into header menu
Gitea Smoke / smoke (push) Successful in 2s
Gitea Android APK / build (push) Failing after 1m33s
2026-07-15 10:37:22 +00:00
Codex 0cf8de3dda Fix Gitea release asset uploads
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Successful in 12m1s
2026-07-15 08:36:33 +00:00
Codex 4f1b24c1c3 Bound Gitea release mirror retries
Gitea Android APK / build (push) Failing after 2s
Gitea Smoke / smoke (push) Successful in 0s
2026-07-15 08:28:54 +00:00
Codex 5c76bc87ba Mirror signed GitHub APKs to Gitea
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Has been cancelled
2026-07-15 08:16:29 +00:00
2 changed files with 502 additions and 72 deletions
+83 -1
View File
@@ -33,6 +33,88 @@ jobs:
if ! command -v git >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1 || ! command -v unzip >/dev/null 2>&1; then if ! command -v git >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1 || ! command -v unzip >/dev/null 2>&1; then
install_packages git curl unzip install_packages git curl unzip
fi fi
REF="${GITHUB_REF:-}"
REF_NAME="${GITHUB_REF_NAME:-}"
if [ -z "${REF_NAME}" ]; then
REF_NAME="${REF##*/}"
fi
if [ "${REF#refs/tags/v}" != "${REF}" ]; then
if [ -z "${CLONE_TOKEN:-}" ]; then
echo "Gitea release publishing requires TMUX_GITEA_TOKEN." >&2
exit 1
fi
TAG="${REF_NAME}"
VERSION_NAME="${TAG#v}"
MAJOR="$(printf '%s' "${VERSION_NAME}" | cut -d. -f1)"
MINOR="$(printf '%s' "${VERSION_NAME}" | cut -d. -f2)"
PATCH="$(printf '%s' "${VERSION_NAME}" | cut -d. -f3)"
VERSION_CODE=$((MAJOR * 1000000 + MINOR * 1000 + PATCH))
GITHUB_APK_URL="https://github.com/neatstudio/tmux-browser-android/releases/download/${TAG}/tmux-android.apk"
mkdir -p release
ATTEMPT=1
while [ "${ATTEMPT}" -le 6 ]; do
if curl -fsSL "${GITHUB_APK_URL}" -o release/tmux-android.apk; then
break
fi
rm -f release/tmux-android.apk
echo "Waiting for GitHub release ${TAG} (${ATTEMPT}/6)..."
sleep 10
ATTEMPT=$((ATTEMPT + 1))
done
if [ ! -s release/tmux-android.apk ]; then
echo "GitHub release APK unavailable for ${TAG}." >&2
exit 1
fi
SHA256="$(sha256sum release/tmux-android.apk | cut -d ' ' -f1)"
APK_URL="https://gitea.neatcn.com/tmux/tmux-browser-android/releases/download/${TAG}/tmux-android.apk"
RELEASE_PAGE_URL="https://gitea.neatcn.com/tmux/tmux-browser-android/releases/tag/${TAG}"
cat > release/latest.json << JSON
{
"versionCode": ${VERSION_CODE},
"versionName": "${VERSION_NAME}",
"apkUrl": "${APK_URL}",
"sha256": "${SHA256}",
"releasePageUrl": "${RELEASE_PAGE_URL}",
"minSdk": 26
}
JSON
API_ROOT="https://gitea.neatcn.com/api/v1/repos/tmux/tmux-browser-android"
RELEASE_BODY='{"tag_name":"'"${TAG}"'","target_commitish":"main","name":"tmux Android '"${VERSION_NAME}"'","body":"Android APK for tmux-ui remote testing.","draft":false,"prerelease":false}'
if ! curl -fsSL -X POST \
-H "Authorization: token ${CLONE_TOKEN}" \
-H "Content-Type: application/json" \
-d "${RELEASE_BODY}" \
"${API_ROOT}/releases" \
-o /tmp/gitea-release.json; then
curl -fsSL -H "Authorization: token ${CLONE_TOKEN}" \
"${API_ROOT}/releases/tags/${TAG}" \
-o /tmp/gitea-release.json
fi
RELEASE_ID="$(sed -n 's/^{"id":\([0-9][0-9]*\),.*/\1/p' /tmp/gitea-release.json | head -1)"
if [ -z "${RELEASE_ID}" ]; then
echo "Cannot resolve Gitea release id for ${TAG}." >&2
exit 1
fi
curl -fsSL -X POST -H "Authorization: token ${CLONE_TOKEN}" \
-F "attachment=@release/tmux-android.apk;type=application/vnd.android.package-archive" \
"${API_ROOT}/releases/${RELEASE_ID}/assets?name=tmux-android.apk" \
-o /tmp/gitea-apk-asset.json
curl -fsSL -X POST -H "Authorization: token ${CLONE_TOKEN}" \
-F "attachment=@release/latest.json;type=application/json" \
"${API_ROOT}/releases/${RELEASE_ID}/assets?name=latest.json" \
-o /tmp/gitea-latest-asset.json
echo "Mirrored GitHub release ${TAG} to Gitea."
echo "versionCode=${VERSION_CODE}"
echo "versionName=${VERSION_NAME}"
echo "sha256=${SHA256}"
exit 0
fi
if ! command -v java >/dev/null 2>&1; then if ! command -v java >/dev/null 2>&1; then
if command -v apk >/dev/null 2>&1; then if command -v apk >/dev/null 2>&1; then
install_packages openjdk17-jdk install_packages openjdk17-jdk
@@ -166,7 +248,7 @@ jobs:
"${API_ROOT}/releases/tags/${TAG}" \ "${API_ROOT}/releases/tags/${TAG}" \
-o /tmp/gitea-release.json -o /tmp/gitea-release.json
fi fi
RELEASE_ID="$(sed -n 's/.*"id":\([0-9][0-9]*\).*/\1/p' /tmp/gitea-release.json | head -1)" RELEASE_ID="$(sed -n 's/^{"id":\([0-9][0-9]*\),.*/\1/p' /tmp/gitea-release.json | head -1)"
if [ -z "${RELEASE_ID}" ]; then if [ -z "${RELEASE_ID}" ]; then
echo "Cannot resolve Gitea release id." >&2 echo "Cannot resolve Gitea release id." >&2
cat /tmp/gitea-release.json >&2 cat /tmp/gitea-release.json >&2
@@ -2,11 +2,11 @@ package com.neatstudio.tmuxandroid;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@@ -27,6 +27,7 @@ import android.text.TextUtils;
import android.text.InputType; import android.text.InputType;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.Gravity; import android.view.Gravity;
import android.view.DragEvent;
import android.view.HapticFeedbackConstants; import android.view.HapticFeedbackConstants;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
@@ -293,17 +294,11 @@ public final class MainActivity extends Activity {
ScrollView scroll = new ScrollView(this); ScrollView scroll = new ScrollView(this);
LinearLayout content = pageContent(); LinearLayout content = pageContent();
List<String> serverUrls = savedServerUrls(); List<String> serverUrls = savedServerUrls();
content.addView(createPageHeader( content.addView(createServerPageHeader(serverUrls.size() + " nodes"));
serverUrls.size() + " nodes",
"Servers",
" Add",
view -> promptCustomServer()
));
for (String url : serverUrls) { for (String url : serverUrls) {
content.addView(serverProfileCard(url), spacedHeight(72, 0, 12)); content.addView(serverProfileCard(url), spacedHeight(72, 0, 12));
} }
content.addView(createServerUtilityRow());
scroll.addView(content); scroll.addView(content);
root.addView(scroll, new LinearLayout.LayoutParams( root.addView(scroll, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
@@ -523,14 +518,46 @@ public final class MainActivity extends Activity {
return header; return header;
} }
private View createServerUtilityRow() { private View createServerPageHeader(String eyebrow) {
LinearLayout row = new LinearLayout(this); LinearLayout header = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL); header.setOrientation(LinearLayout.HORIZONTAL);
row.setPadding(0, dp(4), 0, 0); header.setGravity(Gravity.BOTTOM);
row.addView(compactButton("Probe all", view -> probeServerProfiles())); header.setPadding(dp(2), dp(6), dp(2), dp(18));
row.addView(compactButton("Update", view -> renderUpdateScreen()));
row.addView(compactButton("More", view -> showMainNavigation())); LinearLayout titleBlock = new LinearLayout(this);
return row; titleBlock.setOrientation(LinearLayout.VERTICAL);
TextView eyebrowView = new TextView(this);
eyebrowView.setText(eyebrow.toUpperCase(java.util.Locale.ROOT));
eyebrowView.setTextColor(COLOR_TEXT_MUTED);
eyebrowView.setTextSize(10);
eyebrowView.setTypeface(Typeface.MONOSPACE);
TextView title = new TextView(this);
title.setText("Servers");
title.setTextColor(COLOR_TEXT);
title.setTextSize(25);
title.setTypeface(Typeface.DEFAULT_BOLD);
title.setIncludeFontPadding(false);
titleBlock.addView(eyebrowView);
titleBlock.addView(title);
header.addView(titleBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
addHeaderTool(header, "", "Refresh servers", view -> probeServerProfiles());
addHeaderTool(header, "", "Add server", view -> promptCustomServer());
addHeaderTool(header, "", "More navigation", view -> showMainNavigation());
return header;
}
private void addHeaderTool(
LinearLayout header,
String label,
String description,
View.OnClickListener action
) {
Button button = terminalToolButton(label, action);
button.setContentDescription(description);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dp(38), dp(38));
params.leftMargin = dp(4);
header.addView(button, params);
} }
private View createSessionPageHeader() { private View createSessionPageHeader() {
@@ -569,25 +596,11 @@ public final class MainActivity extends Activity {
titleBlock.addView(title); titleBlock.addView(title);
row.addView(titleBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); row.addView(titleBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
row.addView(primaryButton(" Session", view -> promptCreateSession()), new LinearLayout.LayoutParams( addHeaderTool(row, "", "Session display settings", view -> promptSessionSettings(""));
ViewGroup.LayoutParams.WRAP_CONTENT, addHeaderTool(row, "", "Refresh sessions", view -> refreshSessions());
dp(38) addHeaderTool(row, "", "Create session", view -> promptCreateSession());
)); addHeaderTool(row, "", "Manage groups", view -> showGroupManagement());
header.addView(row, matchWrap()); header.addView(row, matchWrap());
LinearLayout utilities = new LinearLayout(this);
utilities.setOrientation(LinearLayout.HORIZONTAL);
utilities.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
Button display = terminalToolButton("", view -> promptSessionSettings(""));
display.setContentDescription("Session display settings");
utilities.addView(display);
Button refresh = compactButton("↻ Refresh", view -> refreshSessions());
refresh.setContentDescription("Refresh sessions");
utilities.addView(refresh);
Button addGroup = compactButton(" New group", view -> promptCreateKanbanProject());
addGroup.setContentDescription("Add group");
utilities.addView(addGroup);
header.addView(utilities, spacedMatchWrap(8, 0));
return header; return header;
} }
@@ -728,7 +741,7 @@ public final class MainActivity extends Activity {
} }
private void confirmRemoveSavedServer(String url) { private void confirmRemoveSavedServer(String url) {
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Remove server") .setTitle("Remove server")
.setMessage("Remove " + url + " from this device?") .setMessage("Remove " + url + " from this device?")
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -762,12 +775,12 @@ public final class MainActivity extends Activity {
} }
private void showMainNavigation() { private void showMainNavigation() {
String[] items = {"Projects", "Tools", "Update", "About"}; String[] items = {"Sessions / groups", "Tools", "Update", "About"};
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("tmuxctl") .setTitle("tmuxctl")
.setItems(items, (dialog, which) -> { .setItems(items, (dialog, which) -> {
if (which == 0) { if (which == 0) {
renderProjectsScreen(); openSessionPage();
} else if (which == 1) { } else if (which == 1) {
renderToolsScreen(); renderToolsScreen();
} else if (which == 2) { } else if (which == 2) {
@@ -813,7 +826,7 @@ public final class MainActivity extends Activity {
)); ));
content.addView(sectionTitle("Kanban / Messages")); content.addView(sectionTitle("Kanban / Messages"));
content.addView(actionPanel( content.addView(actionPanel(
actionButton("Projects", view -> showRaw("Kanban projects", () -> api.kanbanProjects())), actionButton("Groups", view -> showRaw("Groups", () -> api.kanbanProjects())),
actionButton("New project", view -> promptCreateKanbanProject()), actionButton("New project", view -> promptCreateKanbanProject()),
actionButton("Delete project", view -> promptDeleteKanbanProject()), actionButton("Delete project", view -> promptDeleteKanbanProject()),
actionButton("Remove session", view -> promptRemoveKanbanSession()) actionButton("Remove session", view -> promptRemoveKanbanSession())
@@ -1027,11 +1040,15 @@ public final class MainActivity extends Activity {
LinearLayout actions = new LinearLayout(this); LinearLayout actions = new LinearLayout(this);
actions.setOrientation(LinearLayout.HORIZONTAL); actions.setOrientation(LinearLayout.HORIZONTAL);
actions.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
Button copy = compactButton("Copy commands", view -> copyText("Server install", SERVER_INSTALL_COMMANDS)); Button copy = compactButton("Copy commands", view -> copyText("Server install", SERVER_INSTALL_COMMANDS));
actions.addView(copy, new LinearLayout.LayoutParams(0, dp(40), 1)); actions.addView(copy, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dp(32)));
Button add = compactButton("Add server", view -> promptCustomServer()); Button add = compactButton("Add server", view -> promptCustomServer());
LinearLayout.LayoutParams addParams = new LinearLayout.LayoutParams(0, dp(40), 1); LinearLayout.LayoutParams addParams = new LinearLayout.LayoutParams(
addParams.leftMargin = dp(7); ViewGroup.LayoutParams.WRAP_CONTENT,
dp(32)
);
addParams.leftMargin = dp(5);
actions.addView(add, addParams); actions.addView(add, addParams);
panel.addView(actions, spacedMatchWrap(10, 0)); panel.addView(actions, spacedMatchWrap(10, 0));
@@ -1215,7 +1232,6 @@ public final class MainActivity extends Activity {
row.setPadding(dp(8), dp(5), dp(8), dp(5)); row.setPadding(dp(8), dp(5), dp(8), dp(5));
row.addView(navButton(PAGE_SERVERS, selected, view -> renderServerScreen())); row.addView(navButton(PAGE_SERVERS, selected, view -> renderServerScreen()));
row.addView(navButton(PAGE_SESSIONS, selected, view -> openSessionPage())); row.addView(navButton(PAGE_SESSIONS, selected, view -> openSessionPage()));
row.addView(navButton(PAGE_PROJECTS, selected, view -> renderProjectsScreen()));
row.addView(navButton(PAGE_TOOLS, selected, view -> renderToolsScreen())); row.addView(navButton(PAGE_TOOLS, selected, view -> renderToolsScreen()));
row.addView(navButton(PAGE_UPDATE, selected, view -> renderUpdateScreen())); row.addView(navButton(PAGE_UPDATE, selected, view -> renderUpdateScreen()));
row.addView(navButton(PAGE_ABOUT, selected, view -> renderAboutScreen())); row.addView(navButton(PAGE_ABOUT, selected, view -> renderAboutScreen()));
@@ -1294,28 +1310,40 @@ public final class MainActivity extends Activity {
} }
private LinearLayout actionPanel(Button... buttons) { private LinearLayout actionPanel(Button... buttons) {
final int columns = 3;
LinearLayout panel = new LinearLayout(this); LinearLayout panel = new LinearLayout(this);
panel.setOrientation(LinearLayout.VERTICAL); panel.setOrientation(LinearLayout.VERTICAL);
panel.setPadding(dp(6), dp(6), dp(6), dp(1)); panel.setPadding(dp(4), dp(4), dp(4), 0);
panel.setBackground(panelBackground()); panel.setBackground(panelBackground());
LinearLayout row = null; LinearLayout row = null;
for (int index = 0; index < buttons.length; index++) { for (int index = 0; index < buttons.length; index++) {
if (index % 2 == 0) { if (index % columns == 0) {
row = new LinearLayout(this); row = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL); row.setOrientation(LinearLayout.HORIZONTAL);
panel.addView(row, matchWrap()); panel.addView(row, matchWrap());
} }
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, dp(38), 1); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, dp(32), 1);
params.leftMargin = dp(3); params.leftMargin = dp(2);
params.rightMargin = dp(3); params.rightMargin = dp(2);
params.bottomMargin = dp(6); params.bottomMargin = dp(4);
buttons[index].setTextSize(9);
buttons[index].setPadding(dp(4), 0, dp(4), 0);
row.addView(buttons[index], params); row.addView(buttons[index], params);
} }
int remainder = buttons.length % columns;
if (row != null && remainder != 0) {
for (int index = remainder; index < columns; index++) {
LinearLayout.LayoutParams spacerParams = new LinearLayout.LayoutParams(0, dp(32), 1);
spacerParams.leftMargin = dp(2);
spacerParams.rightMargin = dp(2);
row.addView(new View(this), spacerParams);
}
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT ViewGroup.LayoutParams.WRAP_CONTENT
); );
params.bottomMargin = dp(8); params.bottomMargin = dp(6);
panel.setLayoutParams(params); panel.setLayoutParams(params);
return panel; return panel;
} }
@@ -1456,6 +1484,7 @@ public final class MainActivity extends Activity {
private View sessionGroupSection(String name, List<SessionSummary> sessions, boolean project) { private View sessionGroupSection(String name, List<SessionSummary> sessions, boolean project) {
LinearLayout section = new LinearLayout(this); LinearLayout section = new LinearLayout(this);
section.setOrientation(LinearLayout.VERTICAL); section.setOrientation(LinearLayout.VERTICAL);
section.setOnDragListener((view, event) -> handleSessionDrop(section, name, project, event));
LinearLayout heading = new LinearLayout(this); LinearLayout heading = new LinearLayout(this);
heading.setOrientation(LinearLayout.HORIZONTAL); heading.setOrientation(LinearLayout.HORIZONTAL);
@@ -1478,6 +1507,10 @@ public final class MainActivity extends Activity {
count.setTextSize(11); count.setTextSize(11);
count.setTypeface(Typeface.MONOSPACE); count.setTypeface(Typeface.MONOSPACE);
heading.addView(count); heading.addView(count);
Button actions = terminalToolButton("", view -> showGroupActions(name, project));
actions.setContentDescription("Actions for " + name);
heading.addView(new View(this), new LinearLayout.LayoutParams(0, 1, 1));
heading.addView(actions);
section.addView(heading); section.addView(heading);
if (sessions.isEmpty()) { if (sessions.isEmpty()) {
@@ -1489,13 +1522,79 @@ public final class MainActivity extends Activity {
section.addView(empty, matchWrap()); section.addView(empty, matchWrap());
} else { } else {
for (SessionSummary session : sessions) { for (SessionSummary session : sessions) {
section.addView(sessionRow(session), spacedMatchWrap(0, 10)); section.addView(sessionRow(session, project ? name : null), spacedMatchWrap(0, 10));
} }
} }
return section; return section;
} }
private boolean handleSessionDrop(
LinearLayout section,
String targetGroup,
boolean targetIsGroup,
DragEvent event
) {
if (!(event.getLocalState() instanceof SessionDrag)) {
return false;
}
if (event.getAction() == DragEvent.ACTION_DRAG_ENTERED) {
section.setBackground(rounded(COLOR_CARD_ALT, 8, COLOR_ACCENT, 1));
return true;
}
if (event.getAction() == DragEvent.ACTION_DRAG_EXITED
|| event.getAction() == DragEvent.ACTION_DRAG_ENDED) {
section.setBackgroundColor(Color.TRANSPARENT);
return true;
}
if (event.getAction() == DragEvent.ACTION_DROP) {
section.setBackgroundColor(Color.TRANSPARENT);
SessionDrag drag = (SessionDrag) event.getLocalState();
moveSessionBetweenGroups(drag.sessionName, drag.sourceGroup, targetIsGroup ? targetGroup : null);
return true;
}
return true;
}
private void showGroupActions(String groupName, boolean project) {
String[] items = project
? new String[]{"Add session", "Messages", "Delete group"}
: new String[]{"Create group", "Refresh sessions"};
new AppDialogBuilder()
.setTitle(groupName)
.setItems(items, (dialog, which) -> {
if (!project) {
if (which == 0) {
promptCreateKanbanProject();
} else {
refreshSessions();
}
} else if (which == 0) {
promptAddKanbanSessionToProject(groupName);
} else if (which == 1) {
showRaw("Group messages: " + groupName, () -> api.groupMessages(groupName));
} else {
runApiAction("Delete group", () -> api.deleteKanbanProject(groupName));
}
})
.show();
}
private void showGroupManagement() {
new AppDialogBuilder()
.setTitle("Groups")
.setItems(new String[]{"Create group", "Delete group", "Group messages"}, (dialog, which) -> {
if (which == 0) {
promptCreateKanbanProject();
} else if (which == 1) {
promptDeleteKanbanProject();
} else {
promptGroupMessages();
}
})
.show();
}
private void refreshProjects() { private void refreshProjects() {
if (projectList != null) { if (projectList != null) {
projectList.removeAllViews(); projectList.removeAllViews();
@@ -1643,7 +1742,7 @@ public final class MainActivity extends Activity {
list.addView(empty); list.addView(empty);
} }
for (SessionSummary session : sessions) { for (SessionSummary session : sessions) {
list.addView(sessionRow(session), spacedMatchWrap(0, 10)); list.addView(sessionRow(session, null), spacedMatchWrap(0, 10));
} }
if (sessionSummaryText != null) { if (sessionSummaryText != null) {
sessionSummaryText.setText("Server: " + getServerUrl() + "\nSessions: " + sessions.size()); sessionSummaryText.setText("Server: " + getServerUrl() + "\nSessions: " + sessions.size());
@@ -1651,7 +1750,7 @@ public final class MainActivity extends Activity {
setStatus("Loaded " + sessions.size() + " sessions"); setStatus("Loaded " + sessions.size() + " sessions");
} }
private View sessionRow(SessionSummary session) { private View sessionRow(SessionSummary session, String sourceGroup) {
LinearLayout row = new LinearLayout(this); LinearLayout row = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL); row.setOrientation(LinearLayout.HORIZONTAL);
row.setGravity(Gravity.CENTER_VERTICAL); row.setGravity(Gravity.CENTER_VERTICAL);
@@ -1661,7 +1760,13 @@ public final class MainActivity extends Activity {
row.setOnClickListener(view -> openTerminal(session.name)); row.setOnClickListener(view -> openTerminal(session.name));
row.setOnLongClickListener(view -> { row.setOnLongClickListener(view -> {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
showSessionActions(session.name); ClipData data = ClipData.newPlainText("tmux-session", session.name);
view.startDragAndDrop(
data,
new View.DragShadowBuilder(view),
new SessionDrag(session.name, sourceGroup),
0
);
return true; return true;
}); });
@@ -1715,7 +1820,7 @@ public final class MainActivity extends Activity {
row.addView(textBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); row.addView(textBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
Button move = terminalToolButton("", view -> promptAddKanbanSession(session.name)); Button move = terminalToolButton("", view -> promptAddKanbanSession(session.name));
move.setContentDescription("Move " + session.name + " to project"); move.setContentDescription("Move " + session.name + " to group");
row.addView(move); row.addView(move);
Button kill = terminalToolButton("×", view -> confirmKill(session.name)); Button kill = terminalToolButton("×", view -> confirmKill(session.name));
kill.setContentDescription("Kill session"); kill.setContentDescription("Kill session");
@@ -1829,7 +1934,7 @@ public final class MainActivity extends Activity {
} }
private void confirmKill(String sessionName) { private void confirmKill(String sessionName) {
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Kill session") .setTitle("Kill session")
.setMessage("Kill tmux session \"" + sessionName + "\"?") .setMessage("Kill tmux session \"" + sessionName + "\"?")
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3013,7 +3118,103 @@ public final class MainActivity extends Activity {
} }
private void promptAddKanbanSession(String sessionName) { private void promptAddKanbanSession(String sessionName) {
promptText("Add to kanban project", "project", "", projectName -> api.addKanbanSession(projectName, sessionName)); progressBar.setVisibility(View.VISIBLE);
executor.execute(() -> {
try {
List<String> groups = kanbanGroupNames(api.kanbanProjects());
runOnUiThread(() -> {
progressBar.setVisibility(View.GONE);
List<String> choices = new ArrayList<>();
choices.add("Ungrouped");
choices.addAll(groups);
choices.add(" Create new group");
new AppDialogBuilder()
.setTitle("Move " + sessionName)
.setItems(choices.toArray(new String[0]), (dialog, which) -> {
if (which == 0) {
moveSessionToGroup(sessionName, null);
} else if (which == choices.size() - 1) {
promptCreateGroupForSession(sessionName);
} else {
moveSessionToGroup(sessionName, choices.get(which));
}
})
.show();
});
} catch (Exception error) {
runOnUiThread(() -> {
progressBar.setVisibility(View.GONE);
showMessage("Group load failed: " + error.getMessage());
});
}
});
}
private List<String> kanbanGroupNames(String projectsText) throws Exception {
List<String> groups = new ArrayList<>();
JSONObject object = new JSONObject(projectsText == null || projectsText.isEmpty() ? "{}" : projectsText);
JSONArray projects = object.optJSONArray("projects");
for (int index = 0; projects != null && index < projects.length(); index++) {
JSONObject project = projects.optJSONObject(index);
if (project != null && !project.optString("name").isEmpty()) {
groups.add(project.optString("name"));
}
}
return groups;
}
private void promptCreateGroupForSession(String sessionName) {
promptText("Create group for " + sessionName, "group name", "", groupName -> {
if (groupName.isEmpty()) {
throw new IllegalArgumentException("Group name is required");
}
api.createKanbanProject(groupName, "~", "");
api.addKanbanSession(groupName, sessionName);
});
}
private void moveSessionToGroup(String sessionName, String targetGroup) {
runApiAction("Move session", () -> {
JSONObject object = new JSONObject(api.kanbanProjects());
JSONArray projects = object.optJSONArray("projects");
boolean alreadyInTarget = false;
for (int projectIndex = 0; projects != null && projectIndex < projects.length(); projectIndex++) {
JSONObject project = projects.optJSONObject(projectIndex);
if (project == null) {
continue;
}
String projectName = project.optString("name");
JSONArray agents = project.optJSONArray("agents");
for (int agentIndex = 0; agents != null && agentIndex < agents.length(); agentIndex++) {
if (!sessionName.equals(agentSessionName(agents.optJSONObject(agentIndex)))) {
continue;
}
if (projectName.equals(targetGroup)) {
alreadyInTarget = true;
} else {
api.removeKanbanSession(projectName, sessionName, false);
}
}
}
if (targetGroup != null && !alreadyInTarget) {
api.addKanbanSession(targetGroup, sessionName);
}
});
}
private void moveSessionBetweenGroups(String sessionName, String sourceGroup, String targetGroup) {
if ((sourceGroup == null && targetGroup == null)
|| (sourceGroup != null && sourceGroup.equals(targetGroup))) {
return;
}
runApiAction("Move session", () -> {
if (sourceGroup != null) {
api.removeKanbanSession(sourceGroup, sessionName, false);
}
if (targetGroup != null) {
api.addKanbanSession(targetGroup, sessionName);
}
});
} }
private void promptAddKanbanSessionToProject(String projectName) { private void promptAddKanbanSessionToProject(String projectName) {
@@ -3025,7 +3226,7 @@ public final class MainActivity extends Activity {
EditText project = formField(form, "Project", ""); EditText project = formField(form, "Project", "");
EditText agent = formField(form, "Agent/session name", ""); EditText agent = formField(form, "Agent/session name", "");
EditText kill = formField(form, "Kill too: true or false", "false"); EditText kill = formField(form, "Kill too: true or false", "false");
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Remove kanban session") .setTitle("Remove kanban session")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3345,7 +3546,7 @@ public final class MainActivity extends Activity {
EditText body = formField(form, "Message", ""); EditText body = formField(form, "Message", "");
body.setMinLines(3); body.setMinLines(3);
body.setSingleLine(false); body.setSingleLine(false);
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Send group message") .setTitle("Send group message")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3366,7 +3567,7 @@ public final class MainActivity extends Activity {
LinearLayout form = formRoot(); LinearLayout form = formRoot();
EditText project = formField(form, "Project", ""); EditText project = formField(form, "Project", "");
EditText message = formField(form, "Message ID", ""); EditText message = formField(form, "Message ID", "");
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Scan group message") .setTitle("Scan group message")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3391,7 +3592,7 @@ public final class MainActivity extends Activity {
EditText body = formField(form, "Body", ""); EditText body = formField(form, "Body", "");
body.setMinLines(2); body.setMinLines(2);
body.setSingleLine(false); body.setSingleLine(false);
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Post hook event") .setTitle("Post hook event")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3410,7 +3611,7 @@ public final class MainActivity extends Activity {
LinearLayout form = formRoot(); LinearLayout form = formRoot();
EditText session = formField(form, "Session optional", ""); EditText session = formField(form, "Session optional", "");
EditText url = formField(form, "Image URL", ""); EditText url = formField(form, "Image URL", "");
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Upload image URL") .setTitle("Upload image URL")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3427,7 +3628,7 @@ public final class MainActivity extends Activity {
EditText session = new EditText(this); EditText session = new EditText(this);
session.setSingleLine(true); session.setSingleLine(true);
session.setHint("session optional"); session.setHint("session optional");
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Upload image file") .setTitle("Upload image file")
.setView(session) .setView(session)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3453,7 +3654,7 @@ public final class MainActivity extends Activity {
LinearLayout form = formRoot(); LinearLayout form = formRoot();
EditText path = formField(form, "Path", ""); EditText path = formField(form, "Path", "");
EditText basePath = formField(form, "Base path optional", ""); EditText basePath = formField(form, "Base path optional", "");
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Image preview info") .setTitle("Image preview info")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3470,7 +3671,7 @@ public final class MainActivity extends Activity {
LinearLayout form = formRoot(); LinearLayout form = formRoot();
EditText path = formField(form, "Path", ""); EditText path = formField(form, "Path", "");
EditText basePath = formField(form, "Base path optional", ""); EditText basePath = formField(form, "Base path optional", "");
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Open image preview") .setTitle("Open image preview")
.setView(form) .setView(form)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3505,7 +3706,7 @@ public final class MainActivity extends Activity {
text.append('\n'); text.append('\n');
text.append(permissionSummary()); text.append(permissionSummary());
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Permissions / update") .setTitle("Permissions / update")
.setMessage(text.toString()) .setMessage(text.toString())
.setNegativeButton("Close", null) .setNegativeButton("Close", null)
@@ -3543,7 +3744,7 @@ public final class MainActivity extends Activity {
"Preview manual: " + BuildConfig.DEFAULT_PREVIEW_UPDATE_URL, "Preview manual: " + BuildConfig.DEFAULT_PREVIEW_UPDATE_URL,
"Custom URL" "Custom URL"
}; };
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Update source") .setTitle("Update source")
.setItems(items, (dialog, which) -> { .setItems(items, (dialog, which) -> {
if (which == 0) { if (which == 0) {
@@ -3678,7 +3879,7 @@ public final class MainActivity extends Activity {
image.setImageBitmap(bitmap); image.setImageBitmap(bitmap);
image.setAdjustViewBounds(true); image.setAdjustViewBounds(true);
image.setPadding(dp(8), dp(8), dp(8), dp(8)); image.setPadding(dp(8), dp(8), dp(8), dp(8));
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle("Image preview") .setTitle("Image preview")
.setView(image) .setView(image)
.setPositiveButton("Close", null) .setPositiveButton("Close", null)
@@ -3716,7 +3917,7 @@ public final class MainActivity extends Activity {
input.setHint(hint); input.setHint(hint);
input.setText(value); input.setText(value);
input.setSelectAllOnFocus(true); input.setSelectAllOnFocus(true);
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle(title) .setTitle(title)
.setView(input) .setView(input)
.setNegativeButton("Cancel", null) .setNegativeButton("Cancel", null)
@@ -3774,7 +3975,7 @@ public final class MainActivity extends Activity {
ScrollView scroll = new ScrollView(this); ScrollView scroll = new ScrollView(this);
TextView content = new TextView(this); TextView content = new TextView(this);
content.setText(text == null || text.isEmpty() ? "(empty)" : text); content.setText(text == null || text.isEmpty() ? "(empty)" : text);
content.setTextColor(Color.rgb(20, 24, 30)); content.setTextColor(COLOR_TEXT);
content.setTextSize(12); content.setTextSize(12);
content.setTypeface(Typeface.MONOSPACE); content.setTypeface(Typeface.MONOSPACE);
content.setTextIsSelectable(true); content.setTextIsSelectable(true);
@@ -3783,13 +3984,150 @@ public final class MainActivity extends Activity {
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT ViewGroup.LayoutParams.WRAP_CONTENT
)); ));
new AlertDialog.Builder(this) new AppDialogBuilder()
.setTitle(title) .setTitle(title)
.setView(scroll) .setView(scroll)
.setPositiveButton("Close", null) .setPositiveButton("Close", null)
.show(); .show();
} }
private final class AppDialogBuilder {
private String title = "";
private String message;
private View content;
private String[] items;
private DialogInterface.OnClickListener itemAction;
private String negativeLabel;
private DialogInterface.OnClickListener negativeAction;
private String neutralLabel;
private DialogInterface.OnClickListener neutralAction;
private String positiveLabel;
private DialogInterface.OnClickListener positiveAction;
AppDialogBuilder setTitle(String value) {
title = value;
return this;
}
AppDialogBuilder setMessage(String value) {
message = value;
return this;
}
AppDialogBuilder setView(View value) {
content = value;
return this;
}
AppDialogBuilder setItems(String[] values, DialogInterface.OnClickListener action) {
items = values;
itemAction = action;
return this;
}
AppDialogBuilder setNegativeButton(String label, DialogInterface.OnClickListener action) {
negativeLabel = label;
negativeAction = action;
return this;
}
AppDialogBuilder setNeutralButton(String label, DialogInterface.OnClickListener action) {
neutralLabel = label;
neutralAction = action;
return this;
}
AppDialogBuilder setPositiveButton(String label, DialogInterface.OnClickListener action) {
positiveLabel = label;
positiveAction = action;
return this;
}
Dialog show() {
Dialog dialog = new Dialog(MainActivity.this);
LinearLayout sheet = bottomSheetContent(dialog, title, dialogSubtitle());
if (message != null) {
TextView body = bodyText(message);
body.setTextSize(12);
body.setTextIsSelectable(true);
body.setPadding(dp(2), dp(4), dp(2), dp(8));
sheet.addView(body, matchWrap());
}
if (content != null) {
LinearLayout.LayoutParams contentParams = matchWrap();
contentParams.bottomMargin = dp(10);
sheet.addView(content, contentParams);
}
if (items != null) {
for (int index = 0; index < items.length; index++) {
final int selected = index;
Button choice = toolbarButton(items[index], view -> {
dialog.dismiss();
if (itemAction != null) {
itemAction.onClick(dialog, selected);
}
});
choice.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
choice.setTextSize(11);
LinearLayout.LayoutParams choiceParams = matchWrap();
choiceParams.height = dp(42);
choiceParams.bottomMargin = dp(6);
sheet.addView(choice, choiceParams);
}
}
addDialogActions(dialog, sheet);
showBottomSheet(dialog, sheet, null);
return dialog;
}
private String dialogSubtitle() {
if (items != null) {
return "Choose an option";
}
if (content != null) {
return "Complete the fields below";
}
return "Confirm this action";
}
private void addDialogActions(Dialog dialog, LinearLayout sheet) {
if (negativeLabel == null && neutralLabel == null && positiveLabel == null) {
return;
}
LinearLayout actions = new LinearLayout(MainActivity.this);
actions.setOrientation(LinearLayout.HORIZONTAL);
actions.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
addDialogAction(actions, dialog, neutralLabel, neutralAction, DialogInterface.BUTTON_NEUTRAL, false);
addDialogAction(actions, dialog, negativeLabel, negativeAction, DialogInterface.BUTTON_NEGATIVE, false);
addDialogAction(actions, dialog, positiveLabel, positiveAction, DialogInterface.BUTTON_POSITIVE,
"Remove".equals(positiveLabel) || "Kill".equals(positiveLabel) || "Delete".equals(positiveLabel));
sheet.addView(actions, spacedMatchWrap(4, 0));
}
private void addDialogAction(
LinearLayout actions,
Dialog dialog,
String label,
DialogInterface.OnClickListener action,
int which,
boolean danger
) {
if (label == null) {
return;
}
Button button = compactButton(label, view -> {
dialog.dismiss();
if (action != null) {
action.onClick(dialog, which);
}
});
if (danger) {
button.setTextColor(COLOR_DANGER);
}
actions.addView(button);
}
}
private LinearLayout formRoot() { private LinearLayout formRoot() {
LinearLayout form = new LinearLayout(this); LinearLayout form = new LinearLayout(this);
form.setOrientation(LinearLayout.VERTICAL); form.setOrientation(LinearLayout.VERTICAL);
@@ -5130,6 +5468,16 @@ public final class MainActivity extends Activity {
void onValue(int value); void onValue(int value);
} }
private static final class SessionDrag {
final String sessionName;
final String sourceGroup;
SessionDrag(String sessionName, String sourceGroup) {
this.sessionName = sessionName;
this.sourceGroup = sourceGroup;
}
}
private static final class SheetAction { private static final class SheetAction {
final String icon; final String icon;
final String title; final String title;