Compare commits

...
7 Commits
Author SHA1 Message Date
Codex 6a1052d437 Insert uploaded image paths
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Successful in 11m50s
2026-07-11 08:11:46 +00:00
Codex 7e028b09d4 Reduce terminal key overflow
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Failing after 8m17s
2026-07-11 08:01:21 +00:00
Codex f6e801defc Rearrange terminal composer controls
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Successful in 12m15s
2026-07-11 03:12:52 +00:00
Codex 90f2088265 Support mixed Gitea runners
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Failing after 8m12s
2026-07-10 16:18:55 +00:00
Codex 0d0f218d52 Compact terminal input controls
Gitea Android APK / build (push) Failing after 0s
Gitea Smoke / smoke (push) Successful in 0s
2026-07-10 15:54:51 +00:00
Codex 01f2c66f48 Refine terminal input controls
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Failing after 8m32s
2026-07-10 15:11:12 +00:00
Codex 8fda3fa2da Align primary UI with v0 design
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Failing after 8m54s
2026-07-10 14:23:25 +00:00
2 changed files with 301 additions and 189 deletions
+22 -4
View File
@@ -16,13 +16,31 @@ jobs:
run: | run: |
set -eu set -eu
install_packages() {
if command -v apt-get >/dev/null 2>&1; then
apt-get update
apt-get install -y "$@"
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache "$@"
elif command -v dnf >/dev/null 2>&1; then
dnf install -y "$@"
else
echo "No supported package manager found." >&2
exit 1
fi
}
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
apt-get update install_packages git curl unzip
apt-get install -y git curl unzip
fi fi
if ! command -v java >/dev/null 2>&1; then if ! command -v java >/dev/null 2>&1; then
apt-get update if command -v apk >/dev/null 2>&1; then
apt-get install -y openjdk-17-jdk-headless install_packages openjdk17-jdk
elif command -v dnf >/dev/null 2>&1; then
install_packages java-17-openjdk-devel
else
install_packages openjdk-17-jdk-headless
fi
fi fi
java -version java -version
@@ -66,7 +66,7 @@ public final class MainActivity extends Activity {
private static final int MAX_TERMINAL_COLS = 140; private static final int MAX_TERMINAL_COLS = 140;
private static final int MIN_TERMINAL_ROWS = 8; private static final int MIN_TERMINAL_ROWS = 8;
private static final int MAX_TERMINAL_ROWS = 80; private static final int MAX_TERMINAL_ROWS = 80;
private static final int TERMINAL_KEYS_HEIGHT_DP = 44; private static final int TERMINAL_KEYS_HEIGHT_DP = 34;
private static final int STATUS_NORMAL = 0; private static final int STATUS_NORMAL = 0;
private static final int STATUS_BUSY = 1; private static final int STATUS_BUSY = 1;
private static final int STATUS_SUCCESS = 2; private static final int STATUS_SUCCESS = 2;
@@ -126,7 +126,8 @@ public final class MainActivity extends Activity {
private TextView terminalMetaText; private TextView terminalMetaText;
private ScrollView terminalScroll; private ScrollView terminalScroll;
private EditText inputField; private EditText inputField;
private Button terminalKeyPageButton; private final Button[] terminalAccessoryTabButtons = new Button[4];
private View terminalAccessoryBar;
private View terminalComposerBar; private View terminalComposerBar;
private LinearLayout terminalGroupRow; private LinearLayout terminalGroupRow;
private String activeSessionName; private String activeSessionName;
@@ -135,6 +136,8 @@ public final class MainActivity extends Activity {
private String terminalEventStatus = ""; private String terminalEventStatus = "";
private String activeMainPage = PAGE_SERVERS; private String activeMainPage = PAGE_SERVERS;
private String pendingImageUploadSession; private String pendingImageUploadSession;
private int lastSessionCount = -1;
private int lastActiveSessionCount = -1;
private TerminalScreenBuffer terminalScreen = new TerminalScreenBuffer(DEFAULT_TERMINAL_COLS, DEFAULT_TERMINAL_ROWS); private TerminalScreenBuffer terminalScreen = new TerminalScreenBuffer(DEFAULT_TERMINAL_COLS, DEFAULT_TERMINAL_ROWS);
private final StringBuilder queuedTerminalInput = new StringBuilder(); private final StringBuilder queuedTerminalInput = new StringBuilder();
private boolean terminalConnected; private boolean terminalConnected;
@@ -261,17 +264,13 @@ public final class MainActivity extends Activity {
content.addView(serverProfileCard(url, !isPresetServer(url)), matchWrap()); content.addView(serverProfileCard(url, !isPresetServer(url)), matchWrap());
} }
content.addView(createServerFooterActions()); 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,
0, 0,
1 1
)); ));
root.addView(statusText, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
dp(28)
));
setStatus("Servers"); setStatus("Servers");
} }
@@ -281,7 +280,7 @@ public final class MainActivity extends Activity {
LinearLayout card = new LinearLayout(this); LinearLayout card = new LinearLayout(this);
card.setOrientation(LinearLayout.HORIZONTAL); card.setOrientation(LinearLayout.HORIZONTAL);
card.setGravity(Gravity.CENTER_VERTICAL); card.setGravity(Gravity.CENTER_VERTICAL);
card.setPadding(dp(12), dp(11), dp(8), dp(11)); card.setPadding(dp(13), 0, 0, 0);
card.setBackground(cardBackground()); card.setBackground(cardBackground());
card.setHapticFeedbackEnabled(true); card.setHapticFeedbackEnabled(true);
card.setOnClickListener(view -> { card.setOnClickListener(view -> {
@@ -291,50 +290,56 @@ public final class MainActivity extends Activity {
}); });
TextView icon = new TextView(this); TextView icon = new TextView(this);
icon.setText(""); icon.setText("");
icon.setTextColor(selected ? COLOR_ACCENT : COLOR_TEXT_MUTED); icon.setTextColor(COLOR_TEXT_MUTED);
icon.setTextSize(18); icon.setTextSize(20);
icon.setGravity(Gravity.CENTER); icon.setGravity(Gravity.CENTER);
icon.setBackground(rounded(selected ? COLOR_ACCENT_DARK : COLOR_CARD_ALT, 8, Color.TRANSPARENT, 0)); icon.setBackground(rounded(COLOR_CARD_ALT, 8, Color.TRANSPARENT, 0));
card.addView(icon, new LinearLayout.LayoutParams(dp(40), dp(40))); card.addView(icon, new LinearLayout.LayoutParams(dp(40), dp(40)));
LinearLayout textBlock = new LinearLayout(this); LinearLayout textBlock = new LinearLayout(this);
textBlock.setOrientation(LinearLayout.VERTICAL); textBlock.setOrientation(LinearLayout.VERTICAL);
textBlock.setPadding(dp(11), 0, dp(6), 0); textBlock.setPadding(dp(11), 0, dp(6), 0);
LinearLayout nameRow = new LinearLayout(this);
nameRow.setOrientation(LinearLayout.HORIZONTAL);
nameRow.setGravity(Gravity.CENTER_VERTICAL);
TextView dot = new TextView(this);
dot.setText("");
dot.setTextColor(selected ? COLOR_ACCENT : COLOR_TEXT_DIM);
dot.setTextSize(10);
nameRow.addView(dot);
TextView title = new TextView(this); TextView title = new TextView(this);
title.setText((selected ? " " : "") + label); title.setText(" " + serverDisplayName(url));
title.setTextColor(COLOR_TEXT); title.setTextColor(COLOR_TEXT);
title.setTextSize(15); title.setTextSize(14);
title.setTypeface(Typeface.DEFAULT_BOLD); title.setTypeface(Typeface.DEFAULT_BOLD);
title.setSingleLine(true); title.setSingleLine(true);
nameRow.addView(title, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
TextView meta = bodyText(url); TextView meta = bodyText(url);
meta.setTextSize(11); meta.setTextSize(11);
meta.setTypeface(Typeface.MONOSPACE); meta.setTypeface(Typeface.MONOSPACE);
meta.setSingleLine(true); meta.setSingleLine(true);
textBlock.addView(title); meta.setEllipsize(TextUtils.TruncateAt.MIDDLE);
textBlock.addView(nameRow);
textBlock.addView(meta); textBlock.addView(meta);
card.addView(textBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); card.addView(textBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
LinearLayout stateBlock = new LinearLayout(this); LinearLayout stateBlock = new LinearLayout(this);
stateBlock.setOrientation(LinearLayout.VERTICAL); stateBlock.setOrientation(LinearLayout.VERTICAL);
stateBlock.setGravity(Gravity.END); stateBlock.setGravity(Gravity.END);
TextView port = new TextView(this); TextView active = new TextView(this);
port.setText("3000"); active.setText(selected && lastActiveSessionCount >= 0 ? String.valueOf(lastActiveSessionCount) : "0");
port.setTextColor(selected ? COLOR_ACCENT : COLOR_TEXT_MUTED); active.setTextColor(COLOR_ACCENT);
port.setTextSize(12); active.setTextSize(13);
port.setTypeface(Typeface.MONOSPACE); active.setTypeface(Typeface.MONOSPACE);
TextView state = new TextView(this); TextView total = new TextView(this);
state.setText(selected ? "ACTIVE" : (removable ? "SAVED" : "PRESET")); total.setText("of " + (selected && lastSessionCount >= 0 ? lastSessionCount : 0));
state.setTextColor(COLOR_TEXT_DIM); total.setTextColor(COLOR_TEXT_DIM);
state.setTextSize(9); total.setTextSize(9);
state.setTypeface(Typeface.MONOSPACE); total.setTypeface(Typeface.MONOSPACE);
stateBlock.addView(port); stateBlock.addView(active);
stateBlock.addView(state); stateBlock.addView(total);
card.addView(stateBlock); card.addView(stateBlock);
Button probe = terminalToolButton("", view -> probeSingleServer(url));
probe.setContentDescription("Probe " + label);
card.addView(probe);
if (removable) { if (removable) {
Button remove = terminalToolButton("×", view -> confirmRemoveSavedServer(url)); Button remove = terminalToolButton("×", view -> confirmRemoveSavedServer(url));
remove.setContentDescription("Remove " + label); remove.setContentDescription("Remove " + label);
@@ -351,7 +356,7 @@ public final class MainActivity extends Activity {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT dp(68)
); );
params.bottomMargin = dp(10); params.bottomMargin = dp(10);
card.setLayoutParams(params); card.setLayoutParams(params);
@@ -383,10 +388,6 @@ public final class MainActivity extends Activity {
0, 0,
1 1
)); ));
root.addView(statusText, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
dp(28)
));
setStatus("Sessions"); setStatus("Sessions");
} }
@@ -440,35 +441,14 @@ public final class MainActivity extends Activity {
return header; return header;
} }
private View createServerFooterActions() { private View createServerUtilityRow() {
LinearLayout card = new LinearLayout(this);
card.setOrientation(LinearLayout.VERTICAL);
card.setPadding(dp(12), dp(10), dp(12), dp(10));
card.setBackground(cardBackground());
TextView label = new TextView(this);
label.setText("ACTIVE API");
label.setTextColor(COLOR_TEXT_DIM);
label.setTextSize(9);
label.setTypeface(Typeface.MONOSPACE);
TextView value = bodyText(getServerUrl());
value.setTextColor(COLOR_TEXT);
value.setTextSize(12);
value.setTypeface(Typeface.MONOSPACE);
value.setSingleLine(true);
value.setEllipsize(TextUtils.TruncateAt.MIDDLE);
LinearLayout row = new LinearLayout(this); LinearLayout row = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL); row.setOrientation(LinearLayout.HORIZONTAL);
row.setPadding(0, dp(10), 0, 0); row.setPadding(0, dp(4), 0, 0);
row.addView(compactButton("Probe all", view -> probeServerProfiles())); row.addView(compactButton("Probe all", view -> probeServerProfiles()));
row.addView(compactButton("Update", view -> renderUpdateScreen())); row.addView(compactButton("Update", view -> renderUpdateScreen()));
row.addView(compactButton("More", view -> showMainNavigation())); row.addView(compactButton("More", view -> showMainNavigation()));
return row;
card.addView(label);
card.addView(value);
card.addView(row);
return card;
} }
private View createSessionPageHeader() { private View createSessionPageHeader() {
@@ -520,24 +500,41 @@ public final class MainActivity extends Activity {
private View createNewGroupCard() { private View createNewGroupCard() {
LinearLayout card = new LinearLayout(this); LinearLayout card = new LinearLayout(this);
card.setOrientation(LinearLayout.HORIZONTAL); card.setOrientation(LinearLayout.VERTICAL);
card.setGravity(Gravity.CENTER_VERTICAL); card.setPadding(dp(12), dp(11), dp(12), dp(12));
card.setPadding(dp(12), dp(11), dp(10), dp(11));
card.setBackground(cardBackground()); card.setBackground(cardBackground());
LinearLayout textBlock = new LinearLayout(this);
textBlock.setOrientation(LinearLayout.VERTICAL);
TextView label = new TextView(this); TextView label = new TextView(this);
label.setText("NEW PROJECT GROUP"); label.setText("NEW GROUP");
label.setTextColor(COLOR_TEXT_DIM); label.setTextColor(COLOR_TEXT_DIM);
label.setTextSize(9); label.setTextSize(9);
label.setTypeface(Typeface.MONOSPACE); label.setTypeface(Typeface.MONOSPACE);
TextView detail = bodyText("Group related tmux sessions"); card.addView(label);
detail.setTextSize(12);
textBlock.addView(label); LinearLayout row = new LinearLayout(this);
textBlock.addView(detail); row.setOrientation(LinearLayout.HORIZONTAL);
card.addView(textBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); row.setPadding(0, dp(7), 0, 0);
card.addView(compactButton("Create", view -> promptCreateKanbanProject())); EditText input = new EditText(this);
input.setHint("group name");
input.setSingleLine(true);
input.setInputType(InputType.TYPE_CLASS_TEXT);
styleInput(input);
row.addView(input, new LinearLayout.LayoutParams(0, dp(40), 1));
Button create = compactButton("Create", view -> {
String name = input.getText().toString().trim();
if (name.isEmpty()) {
showMessage("Group name is empty");
return;
}
runApiAction("Create kanban project", () -> api.createKanbanProject(name, "~", ""));
});
LinearLayout.LayoutParams createParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
dp(40)
);
createParams.leftMargin = dp(8);
row.addView(create, createParams);
card.addView(row, matchWrap());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
@@ -1171,6 +1168,14 @@ public final class MainActivity extends Activity {
} }
String finalProjects = projects; String finalProjects = projects;
runOnUiThread(() -> { runOnUiThread(() -> {
lastSessionCount = sessions.size();
lastActiveSessionCount = 0;
for (SessionSummary session : sessions) {
String status = session.status == null ? "" : session.status.toLowerCase(java.util.Locale.ROOT);
if (status.contains("attach") || status.contains("active")) {
lastActiveSessionCount++;
}
}
if (sessionGroupList != null) { if (sessionGroupList != null) {
renderGroupedSessionList(sessions, finalProjects); renderGroupedSessionList(sessions, finalProjects);
} else { } else {
@@ -1458,6 +1463,11 @@ public final class MainActivity extends Activity {
row.setBackground(cardBackground()); row.setBackground(cardBackground());
row.setHapticFeedbackEnabled(true); row.setHapticFeedbackEnabled(true);
row.setOnClickListener(view -> openTerminal(session.name)); row.setOnClickListener(view -> openTerminal(session.name));
row.setOnLongClickListener(view -> {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
showSessionActions(session.name);
return true;
});
boolean attached = session.status != null boolean attached = session.status != null
&& (session.status.toLowerCase(java.util.Locale.ROOT).contains("attach") && (session.status.toLowerCase(java.util.Locale.ROOT).contains("attach")
@@ -1508,9 +1518,9 @@ public final class MainActivity extends Activity {
textBlock.addView(meta); textBlock.addView(meta);
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 more = terminalToolButton("", view -> showSessionActions(session.name)); Button move = terminalToolButton("", view -> promptAddKanbanSession(session.name));
more.setContentDescription("Session actions"); move.setContentDescription("Move " + session.name + " to project");
row.addView(more); 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");
kill.setTextColor(COLOR_DANGER); kill.setTextColor(COLOR_DANGER);
@@ -1625,16 +1635,13 @@ public final class MainActivity extends Activity {
0, 0,
1 1
)); ));
root.addView(statusText, new LinearLayout.LayoutParams( terminalAccessoryBar = createAccessoryBar();
ViewGroup.LayoutParams.MATCH_PARENT, root.addView(terminalAccessoryBar, new LinearLayout.LayoutParams(
dp(28)
));
terminalComposerBar = createComposerBar();
root.addView(terminalComposerBar, matchWrap());
root.addView(createAccessoryBar(), new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
dp(TERMINAL_KEYS_HEIGHT_DP) dp(TERMINAL_KEYS_HEIGHT_DP)
)); ));
terminalComposerBar = createComposerBar();
root.addView(terminalComposerBar, matchWrap());
terminalScroll.post(() -> { terminalScroll.post(() -> {
resizeTerminalToViewport(false); resizeTerminalToViewport(false);
connectTerminal(sessionName); connectTerminal(sessionName);
@@ -1687,8 +1694,7 @@ public final class MainActivity extends Activity {
dp(13) dp(13)
)); ));
bar.addView(titleBlock, new LinearLayout.LayoutParams(0, dp(32), 1)); bar.addView(titleBlock, new LinearLayout.LayoutParams(0, dp(32), 1));
bar.addView(terminalToolButton("", view -> connectTerminal(sessionName))); bar.addView(terminalToolButton("", view -> showTerminalActions(sessionName)));
bar.addView(terminalToolButton("", view -> showTerminalActions(sessionName)));
return bar; return bar;
} }
@@ -1982,6 +1988,7 @@ public final class MainActivity extends Activity {
private void showTerminalActions(String sessionName) { private void showTerminalActions(String sessionName) {
String[] items = { String[] items = {
"Reconnect",
"Clear local view and tmux history", "Clear local view and tmux history",
"Split horizontal", "Split horizontal",
"Split vertical", "Split vertical",
@@ -2000,47 +2007,50 @@ public final class MainActivity extends Activity {
.setItems(items, (dialog, which) -> { .setItems(items, (dialog, which) -> {
switch (which) { switch (which) {
case 0: case 0:
connectTerminal(sessionName);
break;
case 1:
terminalScreen.clear(); terminalScreen.clear();
terminalText.setText(""); terminalText.setText("");
if (terminalSocket != null) { if (terminalSocket != null) {
terminalSocket.clearHistory(); terminalSocket.clearHistory();
} }
break; break;
case 1: case 2:
runApiAction("Split horizontal", () -> api.splitPane(sessionName, "horizontal")); runApiAction("Split horizontal", () -> api.splitPane(sessionName, "horizontal"));
break; break;
case 2: case 3:
runApiAction("Split vertical", () -> api.splitPane(sessionName, "vertical")); runApiAction("Split vertical", () -> api.splitPane(sessionName, "vertical"));
break; break;
case 3: case 4:
if (terminalSocket != null) { if (terminalSocket != null) {
terminalSocket.scroll(-terminalRows); terminalSocket.scroll(-terminalRows);
} }
break; break;
case 4: case 5:
if (terminalSocket != null) { if (terminalSocket != null) {
terminalSocket.scroll(terminalRows); terminalSocket.scroll(terminalRows);
} }
break; break;
case 5: case 6:
showRaw("Session status", () -> api.sessionStatus(sessionName)); showRaw("Session status", () -> api.sessionStatus(sessionName));
break; break;
case 6: case 7:
promptSendCommand(sessionName); promptSendCommand(sessionName);
break; break;
case 7: case 8:
sendTerminalInput("\u0002"); sendTerminalInput("\u0002");
break; break;
case 8: case 9:
sendTerminalInput("\u0002d"); sendTerminalInput("\u0002d");
break; break;
case 9: case 10:
sendTerminalInput("\u0002c"); sendTerminalInput("\u0002c");
break; break;
case 10: case 11:
sendTerminalInput("\u0002n"); sendTerminalInput("\u0002n");
break; break;
case 11: case 12:
sendTerminalInput("\u0002p"); sendTerminalInput("\u0002p");
break; break;
default: default:
@@ -2053,28 +2063,45 @@ public final class MainActivity extends Activity {
private LinearLayout createComposerBar() { private LinearLayout createComposerBar() {
LinearLayout bar = new LinearLayout(this); LinearLayout bar = new LinearLayout(this);
bar.setOrientation(LinearLayout.VERTICAL); bar.setOrientation(LinearLayout.VERTICAL);
bar.setPadding(dp(9), dp(7), dp(9), dp(8)); bar.setPadding(dp(8), dp(5), dp(8), dp(7));
bar.setBackgroundColor(COLOR_BAR); bar.setBackgroundColor(COLOR_BAR);
LinearLayout row = new LinearLayout(this); LinearLayout row = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL); row.setOrientation(LinearLayout.HORIZONTAL);
row.setGravity(Gravity.BOTTOM); row.setGravity(Gravity.CENTER_VERTICAL);
terminalKeyPageButton = terminalPageButton(); LinearLayout tabGrid = new LinearLayout(this);
LinearLayout.LayoutParams pageParams = new LinearLayout.LayoutParams( tabGrid.setOrientation(LinearLayout.VERTICAL);
dp(42), LinearLayout firstTabRow = terminalKeyRow();
dp(40) LinearLayout secondTabRow = terminalKeyRow();
addAccessoryTab(firstTabRow, "Edit", 0);
addAccessoryTab(firstTabRow, "Ctrl", 1);
addAccessoryTab(secondTabRow, "Nav", 2);
addAccessoryTab(secondTabRow, "Sym", 3);
tabGrid.addView(firstTabRow, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
0,
1
));
LinearLayout.LayoutParams secondTabParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
0,
1
); );
pageParams.rightMargin = dp(6); secondTabParams.topMargin = dp(3);
row.addView(terminalKeyPageButton, pageParams); tabGrid.addView(secondTabRow, secondTabParams);
row.addView(tabGrid, new LinearLayout.LayoutParams(
dp(72),
ViewGroup.LayoutParams.MATCH_PARENT
));
inputField = new EditText(this); inputField = new EditText(this);
inputField.setTextColor(COLOR_TEXT); inputField.setTextColor(COLOR_TEXT);
inputField.setHintTextColor(COLOR_TEXT_DIM); inputField.setHintTextColor(COLOR_TEXT_DIM);
inputField.setHint("type a command"); inputField.setHint("type command or text");
inputField.setSingleLine(false); inputField.setSingleLine(false);
inputField.setMinLines(1); inputField.setMinLines(3);
inputField.setMaxLines(2); inputField.setMaxLines(5);
inputField.setCursorVisible(true); inputField.setCursorVisible(true);
inputField.setFocusableInTouchMode(true); inputField.setFocusableInTouchMode(true);
inputField.setGravity(Gravity.TOP | Gravity.START); inputField.setGravity(Gravity.TOP | Gravity.START);
@@ -2099,21 +2126,37 @@ public final class MainActivity extends Activity {
} }
return false; return false;
}); });
Button image = terminalToolButton("", view -> pickImageForSession(activeSessionName));
image.setContentDescription("Upload image");
row.addView(image, new LinearLayout.LayoutParams(dp(40), dp(40)));
LinearLayout.LayoutParams inputParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams inputParams = new LinearLayout.LayoutParams(
0, 0,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
1 1
); );
inputParams.leftMargin = dp(6); inputParams.leftMargin = dp(5);
inputParams.rightMargin = dp(6); inputParams.rightMargin = dp(5);
row.addView(inputField, inputParams); row.addView(inputField, inputParams);
Button send = primaryButton("", view -> sendLine());
send.setTextSize(18); LinearLayout actions = new LinearLayout(this);
actions.setOrientation(LinearLayout.VERTICAL);
Button send = composerPrimaryButton("Send", view -> sendLine());
send.setContentDescription("Send input"); send.setContentDescription("Send input");
row.addView(send, new LinearLayout.LayoutParams(dp(40), dp(40))); actions.addView(send, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
0,
1
));
Button image = composerButton("Img", view -> pickImageForSession(activeSessionName));
image.setContentDescription("Upload image");
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
0,
1
);
imageParams.topMargin = dp(3);
actions.addView(image, imageParams);
row.addView(actions, new LinearLayout.LayoutParams(
dp(48),
ViewGroup.LayoutParams.MATCH_PARENT
));
bar.addView(row, matchWrap()); bar.addView(row, matchWrap());
return bar; return bar;
} }
@@ -2676,19 +2719,26 @@ public final class MainActivity extends Activity {
return input; return input;
} }
private HorizontalScrollView createAccessoryBar() { private LinearLayout createAccessoryBar() {
HorizontalScrollView scroller = new HorizontalScrollView(this); LinearLayout panel = new LinearLayout(this);
scroller.setHorizontalScrollBarEnabled(false); panel.setOrientation(LinearLayout.VERTICAL);
scroller.setBackgroundColor(COLOR_PANEL); panel.setPadding(dp(4), dp(3), dp(4), dp(3));
panel.setBackgroundColor(COLOR_PANEL);
LinearLayout row = terminalKeyRow(); HorizontalScrollView keyScroller = new HorizontalScrollView(this);
row.setPadding(dp(8), dp(5), dp(8), dp(5)); keyScroller.setHorizontalScrollBarEnabled(false);
addAccessoryPageKeys(row); keyScroller.setFillViewport(true);
scroller.addView(row, new HorizontalScrollView.LayoutParams( LinearLayout keyRow = terminalKeyRow();
addAccessoryPageKeys(keyRow);
keyScroller.addView(keyRow, new HorizontalScrollView.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT ViewGroup.LayoutParams.MATCH_PARENT
)); ));
return scroller; panel.addView(keyScroller, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
return panel;
} }
private LinearLayout terminalKeyRow() { private LinearLayout terminalKeyRow() {
@@ -2710,6 +2760,9 @@ public final class MainActivity extends Activity {
addSoftKey(row, "C-r", "\u0012"); addSoftKey(row, "C-r", "\u0012");
addSoftKey(row, "C-a", "\u0001"); addSoftKey(row, "C-a", "\u0001");
addSoftKey(row, "C-e", "\u0005"); addSoftKey(row, "C-e", "\u0005");
addSoftKey(row, "C-u", "\u0015");
addSoftKey(row, "C-k", "\u000b");
addSoftKey(row, "C-b", "\u0002");
break; break;
case 2: case 2:
addSoftKey(row, "", "\u001b[D"); addSoftKey(row, "", "\u001b[D");
@@ -2720,8 +2773,8 @@ public final class MainActivity extends Activity {
addSoftKey(row, "End", "\u001b[F"); addSoftKey(row, "End", "\u001b[F");
addSoftKey(row, "Pg↑", "\u001b[5~"); addSoftKey(row, "Pg↑", "\u001b[5~");
addSoftKey(row, "Pg↓", "\u001b[6~"); addSoftKey(row, "Pg↓", "\u001b[6~");
addSoftKey(row, "Prev", "\u0002p"); addSoftKey(row, "Clear", "\u000c");
addSoftKey(row, "Next", "\u0002n"); addSoftKey(row, "Detach", "\u0002d");
break; break;
case 3: case 3:
addTextKey(row, "~", "~"); addTextKey(row, "~", "~");
@@ -2733,6 +2786,8 @@ public final class MainActivity extends Activity {
addTextKey(row, "&", "&"); addTextKey(row, "&", "&");
addTextKey(row, ";", ";"); addTextKey(row, ";", ";");
addTextKey(row, "$", "$"); addTextKey(row, "$", "$");
addTextKey(row, "\"", "\"");
addTextKey(row, "'", "'");
addTextKey(row, "Space", " "); addTextKey(row, "Space", " ");
break; break;
case 0: case 0:
@@ -2743,30 +2798,22 @@ public final class MainActivity extends Activity {
addSoftKey(row, "", "\u001b[B"); addSoftKey(row, "", "\u001b[B");
addSoftKey(row, "Esc", "\u001b"); addSoftKey(row, "Esc", "\u001b");
addSoftKey(row, "Tab", "\t"); addSoftKey(row, "Tab", "\t");
addSoftKey(row, "Enter", TERMINAL_ENTER); addSoftKey(row, "", TERMINAL_ENTER);
addSoftButton(row, "Paste", view -> pasteClipboard()); addSoftButton(row, "Paste", view -> pasteClipboard());
addAccessoryButton(row, "", view -> backspaceComposerText()); addComposerButton(row, "", this::backspaceComposerText);
addAccessoryButton(row, "", view -> hideKeyboard()); addTextKey(row, "NL", "\n");
addAccessoryButton(row, "", view -> scrollTerminalBottom()); addComposerButton(row, "Bot", this::scrollTerminalBottom);
addAccessoryButton(row, "Sel", view -> toggleTerminalSelection()); addComposerButton(row, "Sel", () -> {
terminalSelectionEnabled = !terminalSelectionEnabled;
if (terminalText != null) {
terminalText.setTextIsSelectable(terminalSelectionEnabled);
}
setStatus(terminalSelectionEnabled ? "Terminal selection on" : "Terminal selection off");
});
break; break;
} }
} }
private String accessoryPageName() {
switch (terminalKeyPage) {
case 1:
return "CTRL";
case 2:
return "NAV";
case 3:
return "SYM";
case 0:
default:
return "EDIT";
}
}
private void connectTerminal(String sessionName) { private void connectTerminal(String sessionName) {
terminalReconnectAttempt = 0; terminalReconnectAttempt = 0;
terminalConnectionGeneration++; terminalConnectionGeneration++;
@@ -3033,19 +3080,20 @@ public final class MainActivity extends Activity {
private void setTerminalKeyPage(int page) { private void setTerminalKeyPage(int page) {
terminalKeyPage = (page + 4) % 4; terminalKeyPage = (page + 4) % 4;
updateTerminalPageButton(); updateAccessoryTabs();
if (activeSessionName != null) { if (activeSessionName != null) {
renderTerminalControlsOnly(); renderTerminalControlsOnly();
} }
} }
private void renderTerminalControlsOnly() { private void renderTerminalControlsOnly() {
int composerIndex = terminalComposerBar == null ? -1 : root.indexOfChild(terminalComposerBar); int accessoryIndex = terminalAccessoryBar == null ? -1 : root.indexOfChild(terminalAccessoryBar);
if (composerIndex < 0 || composerIndex + 1 >= root.getChildCount()) { if (accessoryIndex < 0) {
return; return;
} }
root.removeViewAt(composerIndex + 1); root.removeViewAt(accessoryIndex);
root.addView(createAccessoryBar(), composerIndex + 1, new LinearLayout.LayoutParams( terminalAccessoryBar = createAccessoryBar();
root.addView(terminalAccessoryBar, accessoryIndex, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
dp(TERMINAL_KEYS_HEIGHT_DP) dp(TERMINAL_KEYS_HEIGHT_DP)
)); ));
@@ -3198,29 +3246,23 @@ public final class MainActivity extends Activity {
return button; return button;
} }
private Button terminalPageButton() { private Button composerButton(String label, View.OnClickListener listener) {
Button button = toolbarButton("", view -> setTerminalKeyPage(terminalKeyPage + 1)); Button button = toolbarButton(label, listener);
button.setTextSize(9); button.setTextSize(10);
button.setPadding(dp(4), 0, dp(4), 0); button.setPadding(dp(5), 0, dp(5), 0);
button.setMinWidth(dp(42)); button.setMinWidth(dp(38));
button.setMinimumWidth(dp(42)); button.setMinimumWidth(dp(38));
button.setOnLongClickListener(view -> { button.setMinHeight(0);
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); button.setMinimumHeight(0);
setTerminalKeyPage(terminalKeyPage - 1);
return true;
});
updateTerminalPageButton(button);
return button; return button;
} }
private void updateTerminalPageButton() { private Button composerPrimaryButton(String label, View.OnClickListener listener) {
updateTerminalPageButton(terminalKeyPageButton); Button button = composerButton(label, listener);
} button.setTextColor(Color.rgb(14, 38, 24));
button.setTextSize(11);
private void updateTerminalPageButton(Button button) { button.setBackground(rounded(COLOR_ACCENT, 7, COLOR_ACCENT, 1));
if (button != null) { return button;
button.setText(accessoryPageName());
}
} }
private void styleInput(EditText input) { private void styleInput(EditText input) {
@@ -3235,8 +3277,8 @@ public final class MainActivity extends Activity {
private void styleComposerInput(EditText input) { private void styleComposerInput(EditText input) {
input.setTextColor(COLOR_TEXT); input.setTextColor(COLOR_TEXT);
input.setHintTextColor(COLOR_TEXT_DIM); input.setHintTextColor(COLOR_TEXT_DIM);
input.setTextSize(14); input.setTextSize(13);
input.setPadding(dp(9), dp(6), dp(9), dp(6)); input.setPadding(dp(8), dp(5), dp(8), dp(5));
input.setBackground(inputBackground()); input.setBackground(inputBackground());
} }
@@ -3288,32 +3330,64 @@ public final class MainActivity extends Activity {
addSoftButton(row, label, view -> insertComposerText(text)); addSoftButton(row, label, view -> insertComposerText(text));
} }
private void addAccessoryButton(LinearLayout row, String label, View.OnClickListener listener) {
addSoftButton(row, label, listener);
}
private void addComposerButton(LinearLayout row, String label, Runnable action) { private void addComposerButton(LinearLayout row, String label, Runnable action) {
addSoftButton(row, label, view -> action.run()); addSoftButton(row, label, view -> action.run());
} }
private void addSoftButton(LinearLayout row, String label, View.OnClickListener listener) { private void addSoftButton(LinearLayout row, String label, View.OnClickListener listener) {
Button button = toolbarButton(label, listener); Button button = toolbarButton(label, listener);
button.setTextSize(isArrowLabel(label) ? 15 : 9); button.setTextSize(isArrowLabel(label) ? 14 : 9);
button.setPadding(dp(4), 0, dp(4), 0); button.setPadding(dp(2), 0, dp(2), 0);
int width = "Space".equals(label) ? 56 : (isArrowLabel(label) ? 32 : 38); button.setMinWidth(dp(24));
button.setMinWidth(dp(width)); button.setMinimumWidth(dp(24));
button.setMinimumWidth(dp(width)); button.setMinHeight(0);
button.setMinimumHeight(0);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
dp(27) ViewGroup.LayoutParams.MATCH_PARENT,
0
); );
params.leftMargin = dp(1);
params.rightMargin = dp(1); params.rightMargin = dp(1);
params.topMargin = dp(2);
params.bottomMargin = dp(1);
row.addView(button, params); row.addView(button, params);
} }
private void addAccessoryTab(LinearLayout row, String label, int page) {
Button button = toolbarButton(label, view -> setTerminalKeyPage(page));
button.setTextSize(8);
button.setPadding(dp(3), 0, dp(3), 0);
button.setMinWidth(0);
button.setMinimumWidth(0);
button.setMinHeight(0);
button.setMinimumHeight(0);
terminalAccessoryTabButtons[page] = button;
styleAccessoryTab(button, terminalKeyPage == page);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
0,
ViewGroup.LayoutParams.MATCH_PARENT,
1
);
if (row.getChildCount() > 0) {
params.leftMargin = dp(3);
}
row.addView(button, params);
}
private void updateAccessoryTabs() {
for (int page = 0; page < terminalAccessoryTabButtons.length; page++) {
Button button = terminalAccessoryTabButtons[page];
if (button != null) {
styleAccessoryTab(button, terminalKeyPage == page);
}
}
}
private void styleAccessoryTab(Button button, boolean selected) {
button.setTextColor(selected ? Color.rgb(14, 38, 24) : COLOR_TEXT_MUTED);
button.setBackground(selected
? rounded(COLOR_ACCENT, 6, COLOR_ACCENT, 1)
: rounded(COLOR_CARD_ALT, 6, COLOR_BORDER_SOFT, 1));
}
private boolean isArrowLabel(String label) { private boolean isArrowLabel(String label) {
return "".equals(label) || "".equals(label) || "".equals(label) || "".equals(label); return "".equals(label) || "".equals(label) || "".equals(label) || "".equals(label);
} }
@@ -3621,9 +3695,14 @@ public final class MainActivity extends Activity {
throw new IllegalStateException("Cannot open selected image"); throw new IllegalStateException("Cannot open selected image");
} }
String response = api.uploadImage(sessionName, readAllBytes(input)); String response = api.uploadImage(sessionName, readAllBytes(input));
String imagePath = new JSONObject(response).optString("absolutePath", "").trim();
if (imagePath.isEmpty()) {
throw new IllegalStateException("Upload response did not include absolutePath");
}
runOnUiThread(() -> { runOnUiThread(() -> {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
showTextDialog("Image upload", response); insertComposerPath(imagePath);
setStatus("Image path inserted");
}); });
} catch (Exception error) { } catch (Exception error) {
runOnUiThread(() -> { runOnUiThread(() -> {
@@ -3645,6 +3724,21 @@ public final class MainActivity extends Activity {
return output.toByteArray(); return output.toByteArray();
} }
private void insertComposerPath(String path) {
if (inputField == null) {
return;
}
int start = Math.max(0, inputField.getSelectionStart());
int end = Math.max(0, inputField.getSelectionEnd());
int from = Math.min(start, end);
int to = Math.max(start, end);
CharSequence current = inputField.getText();
String prefix = from > 0 && !Character.isWhitespace(current.charAt(from - 1)) ? " " : "";
String suffix = to < current.length() && Character.isWhitespace(current.charAt(to)) ? "" : " ";
inputField.getText().replace(from, to, prefix + path + suffix);
inputField.requestFocus();
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (activeSessionName != null) { if (activeSessionName != null) {