Refine chat and terminal presentation
This commit is contained in:
@@ -128,6 +128,7 @@ public final class MainActivity extends Activity {
|
|||||||
private TextView terminalMetaText;
|
private TextView terminalMetaText;
|
||||||
private TextView terminalConnectionText;
|
private TextView terminalConnectionText;
|
||||||
private Button terminalReadingButton;
|
private Button terminalReadingButton;
|
||||||
|
private Button terminalFullButton;
|
||||||
private ScrollView terminalScroll;
|
private ScrollView terminalScroll;
|
||||||
private LinearLayout terminalChatList;
|
private LinearLayout terminalChatList;
|
||||||
private TextView terminalLiveStatusText;
|
private TextView terminalLiveStatusText;
|
||||||
@@ -136,6 +137,7 @@ public final class MainActivity extends Activity {
|
|||||||
private final Button[] terminalAccessoryTabButtons = new Button[4];
|
private final Button[] terminalAccessoryTabButtons = new Button[4];
|
||||||
private View terminalAccessoryBar;
|
private View terminalAccessoryBar;
|
||||||
private View terminalComposerBar;
|
private View terminalComposerBar;
|
||||||
|
private View terminalComposerTabs;
|
||||||
private LinearLayout terminalImagePreviewBar;
|
private LinearLayout terminalImagePreviewBar;
|
||||||
private ImageView terminalImagePreview;
|
private ImageView terminalImagePreview;
|
||||||
private TextView terminalImagePreviewPath;
|
private TextView terminalImagePreviewPath;
|
||||||
@@ -1660,6 +1662,7 @@ public final class MainActivity extends Activity {
|
|||||||
1
|
1
|
||||||
));
|
));
|
||||||
terminalAccessoryBar = createAccessoryBar();
|
terminalAccessoryBar = createAccessoryBar();
|
||||||
|
terminalAccessoryBar.setVisibility(terminalViewMode == TERMINAL_VIEW_CHAT ? View.GONE : View.VISIBLE);
|
||||||
root.addView(terminalAccessoryBar, new LinearLayout.LayoutParams(
|
root.addView(terminalAccessoryBar, new LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
dp(TERMINAL_KEYS_HEIGHT_DP)
|
dp(TERMINAL_KEYS_HEIGHT_DP)
|
||||||
@@ -1762,13 +1765,13 @@ 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));
|
||||||
terminalReadingButton = terminalToolButton("聊", view -> showTerminalView(
|
terminalReadingButton = terminalToolButton("聊", view -> showTerminalView(TERMINAL_VIEW_CHAT, true));
|
||||||
terminalViewMode == TERMINAL_VIEW_CHAT ? TERMINAL_VIEW_FULL : TERMINAL_VIEW_CHAT,
|
terminalReadingButton.setContentDescription("Chat view");
|
||||||
true
|
terminalFullButton = terminalToolButton("终", view -> showTerminalView(TERMINAL_VIEW_FULL, true));
|
||||||
));
|
terminalFullButton.setContentDescription("Full terminal view");
|
||||||
terminalReadingButton.setContentDescription("Toggle chat and terminal view");
|
|
||||||
styleTerminalReadingButton();
|
styleTerminalReadingButton();
|
||||||
bar.addView(terminalReadingButton);
|
bar.addView(terminalReadingButton);
|
||||||
|
bar.addView(terminalFullButton);
|
||||||
bar.addView(terminalToolButton("☰", view -> showTerminalActions(sessionName)));
|
bar.addView(terminalToolButton("☰", view -> showTerminalActions(sessionName)));
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
@@ -1797,21 +1800,32 @@ public final class MainActivity extends Activity {
|
|||||||
renderTerminalNow();
|
renderTerminalNow();
|
||||||
}
|
}
|
||||||
styleTerminalReadingButton();
|
styleTerminalReadingButton();
|
||||||
|
boolean chat = mode == TERMINAL_VIEW_CHAT;
|
||||||
|
if (terminalAccessoryBar != null) {
|
||||||
|
terminalAccessoryBar.setVisibility(chat ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
if (terminalComposerTabs != null) {
|
||||||
|
terminalComposerTabs.setVisibility(chat ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
if (inputField != null) {
|
||||||
|
inputField.setHint(chat ? "Message" : "type command or text");
|
||||||
|
}
|
||||||
if (announce) {
|
if (announce) {
|
||||||
setStatus(mode == TERMINAL_VIEW_CHAT ? "Chat view" : "Full terminal mode");
|
setStatus(mode == TERMINAL_VIEW_CHAT ? "Chat view" : "Full terminal mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void styleTerminalReadingButton() {
|
private void styleTerminalReadingButton() {
|
||||||
if (terminalReadingButton == null) {
|
if (terminalReadingButton == null || terminalFullButton == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
terminalReadingButton.setText(terminalViewMode == TERMINAL_VIEW_CHAT ? "聊" : "终");
|
styleTerminalViewButton(terminalReadingButton, terminalViewMode == TERMINAL_VIEW_CHAT);
|
||||||
terminalReadingButton.setTextColor(terminalViewMode == TERMINAL_VIEW_CHAT
|
styleTerminalViewButton(terminalFullButton, terminalViewMode == TERMINAL_VIEW_FULL);
|
||||||
? Color.rgb(14, 38, 24) : COLOR_TEXT_MUTED);
|
}
|
||||||
terminalReadingButton.setBackground(terminalViewMode == TERMINAL_VIEW_CHAT
|
|
||||||
? rounded(COLOR_ACCENT, 7, COLOR_ACCENT, 1)
|
private void styleTerminalViewButton(Button button, boolean selected) {
|
||||||
: buttonBackground());
|
button.setTextColor(selected ? Color.rgb(14, 38, 24) : COLOR_TEXT_MUTED);
|
||||||
|
button.setBackground(selected ? rounded(COLOR_ACCENT, 7, COLOR_ACCENT, 1) : buttonBackground());
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalScrollView createTerminalGroupBar() {
|
private HorizontalScrollView createTerminalGroupBar() {
|
||||||
@@ -1970,12 +1984,12 @@ public final class MainActivity extends Activity {
|
|||||||
|
|
||||||
LinearLayout bubble = new LinearLayout(this);
|
LinearLayout bubble = new LinearLayout(this);
|
||||||
bubble.setOrientation(LinearLayout.VERTICAL);
|
bubble.setOrientation(LinearLayout.VERTICAL);
|
||||||
bubble.setPadding(dp(12), dp(9), dp(12), dp(10));
|
bubble.setPadding(user || tool ? dp(12) : dp(2), dp(9), user || tool ? dp(12) : dp(4), dp(10));
|
||||||
bubble.setBackground(tool
|
bubble.setBackground(tool
|
||||||
? rounded(COLOR_PANEL, 8, COLOR_BORDER, 1)
|
? rounded(COLOR_PANEL, 8, COLOR_BORDER, 1)
|
||||||
: user
|
: user
|
||||||
? rounded(COLOR_ACCENT_DARK, 8, COLOR_ACCENT, 1)
|
? rounded(COLOR_ACCENT_DARK, 8, COLOR_ACCENT, 1)
|
||||||
: rounded(COLOR_CARD, 8, COLOR_BORDER_SOFT, 1));
|
: rounded(Color.TRANSPARENT, 0, Color.TRANSPARENT, 0));
|
||||||
|
|
||||||
TextView meta = new TextView(this);
|
TextView meta = new TextView(this);
|
||||||
meta.setTextColor(user ? COLOR_ACCENT : tool ? COLOR_ACCENT_WARM : COLOR_TEXT_MUTED);
|
meta.setTextColor(user ? COLOR_ACCENT : tool ? COLOR_ACCENT_WARM : COLOR_TEXT_MUTED);
|
||||||
@@ -1983,10 +1997,10 @@ public final class MainActivity extends Activity {
|
|||||||
meta.setTypeface(Typeface.MONOSPACE, Typeface.BOLD);
|
meta.setTypeface(Typeface.MONOSPACE, Typeface.BOLD);
|
||||||
meta.setSingleLine(true);
|
meta.setSingleLine(true);
|
||||||
meta.setEllipsize(TextUtils.TruncateAt.END);
|
meta.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
meta.setText(tool
|
meta.setText(tool ? conversationToolTitle(message) : conversationStatusPart(message).replaceFirst("^ · ", ""));
|
||||||
? conversationToolTitle(message)
|
if (tool || (!"complete".equals(message.status) && !message.status.isEmpty())) {
|
||||||
: (user ? "You" : "Assistant") + conversationStatusPart(message));
|
bubble.addView(meta, matchWrap());
|
||||||
bubble.addView(meta, matchWrap());
|
}
|
||||||
|
|
||||||
boolean expanded = terminalExpandedMessages.contains(message.messageId);
|
boolean expanded = terminalExpandedMessages.contains(message.messageId);
|
||||||
if (!tool || expanded) {
|
if (!tool || expanded) {
|
||||||
@@ -2009,14 +2023,14 @@ public final class MainActivity extends Activity {
|
|||||||
LinearLayout.LayoutParams bubbleParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams bubbleParams = new LinearLayout.LayoutParams(
|
||||||
0,
|
0,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
tool ? 1f : 0.82f
|
tool ? 1f : user ? 0.82f : 0.94f
|
||||||
);
|
);
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
View spacer = new View(this);
|
View spacer = new View(this);
|
||||||
LinearLayout.LayoutParams spacerParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams spacerParams = new LinearLayout.LayoutParams(
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
0.18f
|
user ? 0.18f : 0.06f
|
||||||
);
|
);
|
||||||
if (user) {
|
if (user) {
|
||||||
row.addView(spacer, spacerParams);
|
row.addView(spacer, spacerParams);
|
||||||
@@ -2440,6 +2454,8 @@ public final class MainActivity extends Activity {
|
|||||||
|
|
||||||
LinearLayout tabGrid = new LinearLayout(this);
|
LinearLayout tabGrid = new LinearLayout(this);
|
||||||
tabGrid.setOrientation(LinearLayout.VERTICAL);
|
tabGrid.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
terminalComposerTabs = tabGrid;
|
||||||
|
tabGrid.setVisibility(terminalViewMode == TERMINAL_VIEW_CHAT ? View.GONE : View.VISIBLE);
|
||||||
LinearLayout firstTabRow = terminalKeyRow();
|
LinearLayout firstTabRow = terminalKeyRow();
|
||||||
LinearLayout secondTabRow = terminalKeyRow();
|
LinearLayout secondTabRow = terminalKeyRow();
|
||||||
addAccessoryTab(firstTabRow, "Edit", 0);
|
addAccessoryTab(firstTabRow, "Edit", 0);
|
||||||
@@ -2466,7 +2482,7 @@ public final class MainActivity extends Activity {
|
|||||||
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 command or text");
|
inputField.setHint(terminalViewMode == TERMINAL_VIEW_CHAT ? "Message" : "type command or text");
|
||||||
inputField.setSingleLine(false);
|
inputField.setSingleLine(false);
|
||||||
inputField.setMinLines(3);
|
inputField.setMinLines(3);
|
||||||
inputField.setMaxLines(5);
|
inputField.setMaxLines(5);
|
||||||
|
|||||||
Reference in New Issue
Block a user