Fix terminal composer and status layout
This commit is contained in:
@@ -1738,7 +1738,7 @@ public final class MainActivity extends Activity {
|
|||||||
terminalText.setBackgroundColor(COLOR_TERMINAL_BG);
|
terminalText.setBackgroundColor(COLOR_TERMINAL_BG);
|
||||||
terminalChatList = new LinearLayout(this);
|
terminalChatList = new LinearLayout(this);
|
||||||
terminalChatList.setOrientation(LinearLayout.VERTICAL);
|
terminalChatList.setOrientation(LinearLayout.VERTICAL);
|
||||||
terminalChatList.setPadding(dp(10), dp(12), dp(10), dp(18));
|
terminalChatList.setPadding(0, dp(12), 0, dp(18));
|
||||||
terminalChatList.addView(projectStateText("Loading conversation..."), matchWrap());
|
terminalChatList.addView(projectStateText("Loading conversation..."), matchWrap());
|
||||||
showTerminalView(terminalViewMode, false);
|
showTerminalView(terminalViewMode, false);
|
||||||
terminalScroll.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
|
terminalScroll.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
|
||||||
@@ -1766,6 +1766,8 @@ public final class MainActivity extends Activity {
|
|||||||
});
|
});
|
||||||
inputField.post(() -> {
|
inputField.post(() -> {
|
||||||
inputField.requestFocus();
|
inputField.requestFocus();
|
||||||
|
inputField.setSelection(inputField.length());
|
||||||
|
inputField.setCursorVisible(true);
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2055,7 +2057,7 @@ public final class MainActivity extends Activity {
|
|||||||
boolean user = "user".equals(message.role);
|
boolean user = "user".equals(message.role);
|
||||||
LinearLayout block = new LinearLayout(this);
|
LinearLayout block = new LinearLayout(this);
|
||||||
block.setOrientation(LinearLayout.VERTICAL);
|
block.setOrientation(LinearLayout.VERTICAL);
|
||||||
block.setPadding(dp(2), dp(5), dp(2), dp(7));
|
block.setPadding(dp(10), dp(5), dp(10), dp(7));
|
||||||
|
|
||||||
TextView content = conversationContent(message, false);
|
TextView content = conversationContent(message, false);
|
||||||
content.setText((user ? "› " : "• ") + defaultValue(message.content, "(empty)"));
|
content.setText((user ? "› " : "• ") + defaultValue(message.content, "(empty)"));
|
||||||
@@ -2098,7 +2100,7 @@ public final class MainActivity extends Activity {
|
|||||||
summary.setTextColor(COLOR_ACCENT_WARM);
|
summary.setTextColor(COLOR_ACCENT_WARM);
|
||||||
summary.setTextSize(10);
|
summary.setTextSize(10);
|
||||||
summary.setTypeface(Typeface.MONOSPACE, Typeface.BOLD);
|
summary.setTypeface(Typeface.MONOSPACE, Typeface.BOLD);
|
||||||
summary.setPadding(dp(2), dp(6), dp(2), dp(6));
|
summary.setPadding(dp(10), dp(6), dp(10), dp(6));
|
||||||
summary.setOnClickListener(view -> {
|
summary.setOnClickListener(view -> {
|
||||||
if (!terminalExpandedMessages.add(groupKey)) {
|
if (!terminalExpandedMessages.add(groupKey)) {
|
||||||
terminalExpandedMessages.remove(groupKey);
|
terminalExpandedMessages.remove(groupKey);
|
||||||
@@ -2112,7 +2114,7 @@ public final class MainActivity extends Activity {
|
|||||||
for (ConversationMessage message : tools) {
|
for (ConversationMessage message : tools) {
|
||||||
LinearLayout detail = new LinearLayout(this);
|
LinearLayout detail = new LinearLayout(this);
|
||||||
detail.setOrientation(LinearLayout.VERTICAL);
|
detail.setOrientation(LinearLayout.VERTICAL);
|
||||||
detail.setPadding(dp(14), dp(3), dp(2), dp(7));
|
detail.setPadding(dp(18), dp(3), dp(10), dp(7));
|
||||||
TextView title = bodyText(conversationToolTitle(message));
|
TextView title = bodyText(conversationToolTitle(message));
|
||||||
title.setTextColor(COLOR_ACCENT_WARM);
|
title.setTextColor(COLOR_ACCENT_WARM);
|
||||||
title.setTextSize(9);
|
title.setTextSize(9);
|
||||||
@@ -2188,10 +2190,16 @@ public final class MainActivity extends Activity {
|
|||||||
terminalLiveOutputText.setTextColor(COLOR_TEXT_MUTED);
|
terminalLiveOutputText.setTextColor(COLOR_TEXT_MUTED);
|
||||||
terminalLiveOutputText.setTextSize(11);
|
terminalLiveOutputText.setTextSize(11);
|
||||||
terminalLiveOutputText.setTypeface(Typeface.MONOSPACE);
|
terminalLiveOutputText.setTypeface(Typeface.MONOSPACE);
|
||||||
|
terminalLiveOutputText.setIncludeFontPadding(false);
|
||||||
|
terminalLiveOutputText.setHorizontallyScrolling(true);
|
||||||
|
terminalLiveOutputText.setLineSpacing(0, 1.05f);
|
||||||
|
terminalLiveOutputText.setBackgroundColor(COLOR_TERMINAL_BG);
|
||||||
terminalLiveOutputText.setPadding(0, dp(5), 0, 0);
|
terminalLiveOutputText.setPadding(0, dp(5), 0, 0);
|
||||||
terminalLiveOutputText.setMovementMethod(LinkMovementMethod.getInstance());
|
terminalLiveOutputText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
terminalLiveOutputText.setHighlightColor(Color.TRANSPARENT);
|
terminalLiveOutputText.setHighlightColor(Color.TRANSPARENT);
|
||||||
terminalLiveOutputText.setTextIsSelectable(true);
|
terminalLiveOutputText.setTextIsSelectable(true);
|
||||||
|
terminalLiveOutputText.addOnLayoutChangeListener((view, left, top, right, bottom,
|
||||||
|
oldLeft, oldTop, oldRight, oldBottom) -> resizeTerminalToViewport(false));
|
||||||
panel.addView(terminalLiveOutputText, matchWrap());
|
panel.addView(terminalLiveOutputText, matchWrap());
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
@@ -3559,18 +3567,23 @@ public final class MainActivity extends Activity {
|
|||||||
if (terminalText == null || terminalScroll == null) {
|
if (terminalText == null || terminalScroll == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int width = terminalScroll.getWidth();
|
TextView viewportText = terminalViewMode == TERMINAL_VIEW_CHAT && terminalLiveOutputText != null
|
||||||
|
? terminalLiveOutputText : terminalText;
|
||||||
|
int width = viewportText.getWidth();
|
||||||
|
if (width <= 0) {
|
||||||
|
width = terminalScroll.getWidth();
|
||||||
|
}
|
||||||
int height = terminalScroll.getHeight();
|
int height = terminalScroll.getHeight();
|
||||||
if (width <= 0 || height <= 0) {
|
if (width <= 0 || height <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int horizontalPadding = terminalText.getPaddingLeft() + terminalText.getPaddingRight();
|
int horizontalPadding = viewportText.getPaddingLeft() + viewportText.getPaddingRight();
|
||||||
int verticalPadding = terminalText.getPaddingTop() + terminalText.getPaddingBottom();
|
int verticalPadding = viewportText.getPaddingTop() + viewportText.getPaddingBottom();
|
||||||
float charWidth = terminalText.getPaint().measureText("0000000000") / 10f;
|
float charWidth = viewportText.getPaint().measureText("0000000000") / 10f;
|
||||||
if (charWidth <= 0f) {
|
if (charWidth <= 0f) {
|
||||||
charWidth = dp(8);
|
charWidth = dp(8);
|
||||||
}
|
}
|
||||||
int lineHeight = terminalText.getLineHeight();
|
int lineHeight = viewportText.getLineHeight();
|
||||||
if (lineHeight <= 0) {
|
if (lineHeight <= 0) {
|
||||||
lineHeight = dp(16);
|
lineHeight = dp(16);
|
||||||
}
|
}
|
||||||
@@ -3988,7 +4001,12 @@ public final class MainActivity extends Activity {
|
|||||||
input.setHintTextColor(COLOR_TEXT_DIM);
|
input.setHintTextColor(COLOR_TEXT_DIM);
|
||||||
input.setTextSize(13);
|
input.setTextSize(13);
|
||||||
input.setPadding(dp(8), dp(5), dp(8), dp(5));
|
input.setPadding(dp(8), dp(5), dp(8), dp(5));
|
||||||
input.setBackground(inputBackground());
|
input.setBackground(composerInputBackground());
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
GradientDrawable cursor = rounded(COLOR_ACCENT, 1, Color.TRANSPARENT, 0);
|
||||||
|
cursor.setSize(dp(2), dp(20));
|
||||||
|
input.setTextCursorDrawable(cursor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button compactButton(String label, View.OnClickListener listener) {
|
private Button compactButton(String label, View.OnClickListener listener) {
|
||||||
@@ -4021,6 +4039,14 @@ public final class MainActivity extends Activity {
|
|||||||
return rounded(COLOR_FIELD, 8, COLOR_BORDER, 1);
|
return rounded(COLOR_FIELD, 8, COLOR_BORDER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StateListDrawable composerInputBackground() {
|
||||||
|
StateListDrawable states = new StateListDrawable();
|
||||||
|
states.addState(new int[]{android.R.attr.state_focused},
|
||||||
|
rounded(COLOR_CARD_ALT, 7, COLOR_ACCENT, 1));
|
||||||
|
states.addState(new int[]{}, rounded(COLOR_CARD, 7, COLOR_BORDER, 1));
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
private GradientDrawable rounded(int color, int radiusDp, int strokeColor, int strokeDp) {
|
private GradientDrawable rounded(int color, int radiusDp, int strokeColor, int strokeDp) {
|
||||||
GradientDrawable drawable = new GradientDrawable();
|
GradientDrawable drawable = new GradientDrawable();
|
||||||
drawable.setColor(color);
|
drawable.setColor(color);
|
||||||
|
|||||||
Reference in New Issue
Block a user