Compare commits

...
2 Commits
Author SHA1 Message Date
Codex 974abed278 Connect touch scrolling to tmux history
Gitea Smoke / smoke (push) Successful in 2s
Gitea Android APK / build (push) Failing after 55s
2026-07-14 15:52:43 +00:00
Codex 47af792d62 Pin tmux status above soft keys
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Failing after 8m24s
2026-07-14 15:36:49 +00:00
@@ -29,6 +29,7 @@ import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
@@ -166,6 +167,8 @@ public final class MainActivity extends Activity {
private int terminalViewMode = TERMINAL_VIEW_CHAT;
private int terminalKeyPage;
private int terminalHistoryOffset;
private float terminalTouchStartY;
private int terminalTouchStartScrollY;
private int terminalReconnectAttempt;
private int terminalConnectionGeneration;
private int eventReconnectAttempt;
@@ -1734,17 +1737,19 @@ public final class MainActivity extends Activity {
terminalText.setLineSpacing(0, 1.05f);
terminalText.setGravity(Gravity.BOTTOM | Gravity.START);
terminalText.setTextIsSelectable(terminalSelectionEnabled);
terminalText.setPadding(dp(2), dp(8), dp(2), dp(8));
terminalText.setPadding(dp(2), dp(8), dp(2), 0);
terminalText.setBackgroundColor(COLOR_TERMINAL_BG);
terminalChatList = new LinearLayout(this);
terminalChatList.setOrientation(LinearLayout.VERTICAL);
terminalChatList.setPadding(0, dp(12), 0, dp(18));
terminalChatList.setPadding(0, dp(12), 0, 0);
terminalChatList.addView(projectStateText("Loading conversation..."), matchWrap());
showTerminalView(terminalViewMode, false);
terminalScroll.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
resizeTerminalToViewport(false));
terminalScroll.setOnScrollChangeListener((view, scrollX, scrollY, oldScrollX, oldScrollY) ->
terminalFollowOutput = !view.canScrollVertically(1));
terminalScroll.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
terminalScroll.setOnTouchListener(this::handleTerminalScrollTouch);
root.addView(terminalScroll, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
0,
@@ -2159,7 +2164,7 @@ public final class MainActivity extends Activity {
private View conversationLiveTerminalPanel() {
LinearLayout panel = new LinearLayout(this);
panel.setOrientation(LinearLayout.VERTICAL);
panel.setPadding(dp(2), dp(10), dp(2), dp(8));
panel.setPadding(dp(2), dp(10), dp(2), 0);
LinearLayout heading = new LinearLayout(this);
heading.setOrientation(LinearLayout.HORIZONTAL);
@@ -2191,8 +2196,9 @@ public final class MainActivity extends Activity {
terminalLiveOutputText.setTextSize(11);
terminalLiveOutputText.setTypeface(Typeface.MONOSPACE);
terminalLiveOutputText.setIncludeFontPadding(false);
terminalLiveOutputText.setHorizontallyScrolling(true);
terminalLiveOutputText.setHorizontallyScrolling(false);
terminalLiveOutputText.setLineSpacing(0, 1.05f);
terminalLiveOutputText.setGravity(Gravity.BOTTOM | Gravity.START);
terminalLiveOutputText.setBackgroundColor(COLOR_TERMINAL_BG);
terminalLiveOutputText.setPadding(0, dp(5), 0, 0);
terminalLiveOutputText.setMovementMethod(LinkMovementMethod.getInstance());
@@ -3590,6 +3596,10 @@ public final class MainActivity extends Activity {
int usableWidth = Math.max(1, width - horizontalPadding);
int cols = clamp((int) Math.floor(usableWidth / charWidth), MIN_TERMINAL_COLS, MAX_TERMINAL_COLS);
int rows = clamp((height - verticalPadding) / lineHeight, MIN_TERMINAL_ROWS, MAX_TERMINAL_ROWS);
if (terminalLiveOutputText != null) {
terminalLiveOutputText.setMinHeight(rows * lineHeight);
terminalLiveOutputText.setGravity(Gravity.BOTTOM | Gravity.START);
}
if (cols == terminalCols && rows == terminalRows && !forceSend) {
return;
}
@@ -3787,6 +3797,31 @@ public final class MainActivity extends Activity {
: "Terminal history · " + terminalHistoryOffset + " lines back");
}
private boolean handleTerminalScrollTouch(View view, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
terminalTouchStartY = event.getY();
terminalTouchStartScrollY = terminalScroll == null ? 0 : terminalScroll.getScrollY();
return false;
}
if (event.getActionMasked() != MotionEvent.ACTION_UP || terminalScroll == null) {
return false;
}
float distance = event.getY() - terminalTouchStartY;
if (Math.abs(distance) < dp(48)) {
return false;
}
int movedLocally = Math.abs(terminalScroll.getScrollY() - terminalTouchStartScrollY);
int lineHeight = terminalLiveOutputText == null ? dp(16) : terminalLiveOutputText.getLineHeight();
int lines = clamp(Math.round(Math.abs(distance) / Math.max(1, lineHeight)), 4, terminalRows);
if (distance > 0 && !terminalScroll.canScrollVertically(-1) && movedLocally <= dp(24)) {
terminalScroll.post(() -> scrollTerminalHistory(-lines));
} else if (distance < 0 && terminalHistoryOffset > 0
&& !terminalScroll.canScrollVertically(1) && movedLocally <= dp(24)) {
terminalScroll.post(() -> scrollTerminalHistory(lines));
}
return false;
}
private void setTerminalKeyPage(int page) {
terminalKeyPage = (page + 4) % 4;
updateAccessoryTabs();