Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/src/main/java/cn/lineai/ui/component/ActionRowView.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ public ActionRowView(Context context, int iconType, String label, String desc, b
super(context);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
setMinimumHeight(LineTheme.dp(context, 56));
setMinimumHeight(LineTheme.dp(context, 68));
LineTheme.padding(this, LineTheme.LG, LineTheme.MD, LineTheme.LG, LineTheme.MD);

FrameLayout iconWrap = new FrameLayout(context);
iconWrap.setBackground(LineTheme.rounded(context, destructive ? LineTheme.DANGER_MUTED : LineTheme.ACCENT_MUTED, 8));

IconButtonView icon = new IconButtonView(context, iconType);
icon.setIconColor(destructive ? LineTheme.DANGER : LineTheme.TEXT_SECONDARY);
icon.setIconSizeDp(24, 20);
icon.setIconColor(destructive ? LineTheme.DANGER : LineTheme.ACCENT);
icon.setIconSizeDp(36, 20);
icon.setClickable(false);
iconWrap.addView(icon, new FrameLayout.LayoutParams(LineTheme.dp(context, 24), LineTheme.dp(context, 24), Gravity.CENTER));
addView(iconWrap, new LayoutParams(LineTheme.dp(context, 24), LineTheme.dp(context, 24)));
iconWrap.addView(icon, new FrameLayout.LayoutParams(LineTheme.dp(context, 36), LineTheme.dp(context, 36), Gravity.CENTER));
addView(iconWrap, new LayoutParams(LineTheme.dp(context, 36), LineTheme.dp(context, 36)));

LinearLayout textWrap = new LinearLayout(context);
textWrap.setOrientation(VERTICAL);
Expand All @@ -37,10 +38,10 @@ public ActionRowView(Context context, int iconType, String label, String desc, b
textWrap.addView(title, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

if (desc != null && desc.length() > 0) {
TextView description = LineTheme.text(context, desc, 14, LineTheme.TEXT_TERTIARY, Typeface.NORMAL);
TextView description = LineTheme.text(context, desc, LineTheme.FONT_XS, LineTheme.TEXT_TERTIARY, Typeface.NORMAL);
description.setLineSpacing(LineTheme.dp(context, 3), 1f);
LinearLayout.LayoutParams descParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
descParams.topMargin = LineTheme.dp(context, 6);
descParams.topMargin = LineTheme.dp(context, 2);
textWrap.addView(description, descParams);
}

Expand All @@ -54,7 +55,6 @@ public ActionRowView(Context context, int iconType, String label, String desc, b

if (onClick != null) {
setClickable(true);
setBackground(LineTheme.pressable(context));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (bug_risk): Clickable action and option rows no longer have a pressable background, so taps invoke their listeners without any pressed/ripple visual feedback. This removes the interaction affordance from every caller that relies on these shared row components.

Triggers: When the user taps an ActionRowView or an inactive OptionRowView.

Suggested fix: Retain the pressable background for clickable rows and layer the active option color on top of it where needed.

setOnClickListener(v -> onClick.run());
}
}
Expand Down
78 changes: 71 additions & 7 deletions app/src/main/java/cn/lineai/ui/component/CardViewHelper.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,76 @@
package cn.lineai.ui.component;
import cn.lineai.ui.theme.IconButtonView;
import cn.lineai.ui.theme.LineTheme;

import android.content.Context;
import android.graphics.Typeface;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

public final class CardViewHelper {
public interface OnCardClickListener { void onCardClick(String id); }
private CardViewHelper() { }
public static void addCard(LinearLayout content, String id, String title, String desc, String badge, int icon, OnCardClickListener listener) {
ActionRowView row = new ActionRowView(content.getContext(), icon, title, desc, false, true, () -> listener.onCardClick(id));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
params.bottomMargin = cn.lineai.ui.theme.LineTheme.dp(content.getContext(), 12);
content.addView(row, params);

public interface OnCardClickListener {
void onCardClick(String id);
}

private CardViewHelper() {
}

public static void addCard(LinearLayout content, String id, String title, String desc, String badge, int iconType, OnCardClickListener clickListener) {
Context context = content.getContext();
LinearLayout card = new LinearLayout(context);
card.setOrientation(LinearLayout.HORIZONTAL);
card.setGravity(Gravity.CENTER_VERTICAL);
card.setClickable(true);
card.setOnClickListener(v -> clickListener.onCardClick(id));
card.setBackground(LineTheme.roundedStroke(context, LineTheme.SURFACE_ELEVATED, 12, LineTheme.BORDER));
LineTheme.padding(card, LineTheme.LG, LineTheme.MD, LineTheme.MD, LineTheme.MD);
LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
cardParams.bottomMargin = LineTheme.dp(context, LineTheme.SM);
content.addView(card, cardParams);

FrameLayout iconWrap = new FrameLayout(context);
iconWrap.setBackground(LineTheme.rounded(context, LineTheme.ACCENT_MUTED, 12));
IconButtonView icon = new IconButtonView(context, iconType);
icon.setIconColor(LineTheme.ACCENT);
icon.setIconSizeDp(44, 22);
icon.setClickable(false);
iconWrap.addView(icon, new FrameLayout.LayoutParams(LineTheme.dp(context, 44), LineTheme.dp(context, 44), Gravity.CENTER));
card.addView(iconWrap, new LinearLayout.LayoutParams(LineTheme.dp(context, 44), LineTheme.dp(context, 44)));

LinearLayout text = new LinearLayout(context);
text.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
textParams.leftMargin = LineTheme.dp(context, LineTheme.MD);
textParams.rightMargin = LineTheme.dp(context, LineTheme.MD);
card.addView(text, textParams);

LinearLayout titleRow = new LinearLayout(context);
titleRow.setOrientation(LinearLayout.HORIZONTAL);
titleRow.setGravity(Gravity.CENTER_VERTICAL);
text.addView(titleRow, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

TextView titleView = LineTheme.text(context, title, LineTheme.FONT_LG, LineTheme.TEXT, Typeface.BOLD);
titleRow.addView(titleView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
TextView badgeView = LineTheme.text(context, badge, LineTheme.FONT_XS, LineTheme.ACCENT, Typeface.BOLD);
badgeView.setBackground(LineTheme.rounded(context, LineTheme.ACCENT_MUTED, 999));
LineTheme.padding(badgeView, LineTheme.SM, 3, LineTheme.SM, 3);
LinearLayout.LayoutParams badgeParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
badgeParams.leftMargin = LineTheme.dp(context, LineTheme.SM);
titleRow.addView(badgeView, badgeParams);

TextView descView = LineTheme.text(context, desc, LineTheme.FONT_SM, LineTheme.TEXT_TERTIARY, Typeface.NORMAL);
descView.setLineSpacing(LineTheme.dp(context, 3), 1f);
LinearLayout.LayoutParams descParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
descParams.topMargin = LineTheme.dp(context, LineTheme.XS);
text.addView(descView, descParams);

IconButtonView chevron = new IconButtonView(context, IconButtonView.CHEVRON_RIGHT);
chevron.setIconColor(LineTheme.TEXT_TERTIARY);
chevron.setIconSizeDp(20, 17);
chevron.setClickable(false);
card.addView(chevron, new LinearLayout.LayoutParams(LineTheme.dp(context, 20), LineTheme.dp(context, 20)));
}
}
27 changes: 14 additions & 13 deletions app/src/main/java/cn/lineai/ui/component/MCPSettingsScreenView.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public MCPSettingsScreenView(Context context, McpSettingsState state, Listener l
this.listener = listener;
this.state = state == null ? new McpSettingsState(EXECUTION_LOCAL, null) : state;
LinearLayout content = getContent();
LineTheme.padding(content, 16, 8, 16, 48);
LineTheme.padding(content, LineTheme.LG, LineTheme.LG, LineTheme.LG, 100);

addExecutionTarget(content);
if (EXECUTION_SSH.equals(this.state.getExecutionMode())) {
Expand All @@ -54,13 +54,16 @@ private void addExecutionTarget(LinearLayout content) {
Context context = content.getContext();
LinearLayout card = card(context);
card.addView(title(context, context.getString(R.string.screen_mcp_section_execution)));
for (String mode : new String[] {EXECUTION_LOCAL, EXECUTION_SSH, EXECUTION_TERMINAL_PROVIDER}) {
int label = EXECUTION_LOCAL.equals(mode) ? R.string.screen_mcp_execution_local : EXECUTION_SSH.equals(mode) ? R.string.screen_mcp_execution_ssh : R.string.screen_mcp_execution_terminal_provider;
LayoutParams modeParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
modeParams.topMargin = LineTheme.dp(context, 8);
card.addView(new OptionRowView(context, IconButtonView.TERMINAL, context.getString(label), null,
mode.equals(state.getExecutionMode()), () -> listener.onExecutionModeChanged(mode)), modeParams);
}
LinearLayout segment = new LinearLayout(context);
segment.setOrientation(HORIZONTAL);
segment.setBackground(LineTheme.rounded(context, LineTheme.SURFACE_LIGHT, 8));
LineTheme.padding(segment, 3, 3, 3, 3);
addModeButton(segment, context.getString(R.string.screen_mcp_execution_local), EXECUTION_LOCAL);
addModeButton(segment, context.getString(R.string.screen_mcp_execution_ssh), EXECUTION_SSH);
addModeButton(segment, context.getString(R.string.screen_mcp_execution_terminal_provider), EXECUTION_TERMINAL_PROVIDER);
LinearLayout.LayoutParams segmentParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LineTheme.dp(context, 42));
segmentParams.topMargin = LineTheme.dp(context, LineTheme.SM);
card.addView(segment, segmentParams);
String executionDesc;
if (EXECUTION_LOCAL.equals(state.getExecutionMode())) {
executionDesc = context.getString(R.string.screen_mcp_execution_local_desc);
Expand Down Expand Up @@ -129,6 +132,7 @@ private void addToolCard(LinearLayout content, int iconType, McpToolConfig confi
icon.setIconColor(config.isEnabled() ? LineTheme.ACCENT : LineTheme.TEXT_TERTIARY);
icon.setIconSizeDp(36, 18);
icon.setClickable(false);
icon.setBackground(LineTheme.rounded(context, LineTheme.ACCENT_MUTED, 18));

header.addView(icon, new LinearLayout.LayoutParams(LineTheme.dp(context, 36), LineTheme.dp(context, 36)));

Expand Down Expand Up @@ -177,11 +181,8 @@ private void tintSwitch(Switch toggle, CompoundButton.OnCheckedChangeListener li
private LinearLayout card(Context context) {
LinearLayout card = new LinearLayout(context);
card.setOrientation(LinearLayout.VERTICAL);
card.setBackground(LineTheme.roundedStroke(context, LineTheme.SURFACE_ELEVATED, 14, LineTheme.BORDER_LIGHT));
LineTheme.padding(card, 16, 14, 16, 16);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.bottomMargin = LineTheme.dp(context, 14);
card.setLayoutParams(params);
card.setBackground(LineTheme.rounded(context, LineTheme.SURFACE_ELEVATED, 12));
LineTheme.padding(card, LineTheme.LG, LineTheme.LG, LineTheme.LG, LineTheme.LG);
return card;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
Expand All @@ -30,7 +29,7 @@
import java.util.Locale;
import java.util.Set;

public final class MemorySettingsScreenView extends ScreenSurfaceView {
public final class MemorySettingsScreenView extends LinearLayout {
public interface Listener {
void onBack();

Expand Down Expand Up @@ -385,7 +384,7 @@ private Dialog createDialog() {
private LinearLayout dialogPanel(Context context) {
LinearLayout panel = new LinearLayout(context);
panel.setOrientation(LinearLayout.VERTICAL);
panel.setBackground(LineTheme.rounded(context, LineTheme.BG, 24));
panel.setBackground(LineTheme.rounded(context, LineTheme.SURFACE_ELEVATED, 12));
LineTheme.padding(panel, LineTheme.LG, LineTheme.LG, LineTheme.LG, LineTheme.LG);
return panel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface Listener {
public ModelAddOptionsScreenView(Context context, Listener listener) {
super(context, context.getString(R.string.screen_model_add_options_title), listener::onBack, null);
LinearLayout content = getContent();
LineTheme.padding(content, 16, 8, 16, 48);
LineTheme.padding(content, LineTheme.LG, LineTheme.LG, LineTheme.LG, LineTheme.LG);

addLargeCard(content, IconButtonView.SLIDERS_HORIZONTAL, context.getString(R.string.screen_model_add_options_custom),
context.getString(R.string.screen_model_add_options_custom_desc), listener::onCustom);
Expand Down Expand Up @@ -57,19 +57,89 @@ public ModelAddOptionsScreenView(Context context, Listener listener) {
}

private void addLargeCard(LinearLayout content, int iconType, String title, String desc, Runnable onClick) {
content.addView(new ActionRowView(getContext(), iconType, title, desc, false, true, onClick), cardParams());
Context context = content.getContext();
LinearLayout card = new LinearLayout(context);
card.setOrientation(HORIZONTAL);
card.setGravity(Gravity.CENTER_VERTICAL);
card.setMinimumHeight(LineTheme.dp(context, 92));
card.setBackground(LineTheme.roundedStroke(context, LineTheme.SURFACE_ELEVATED, 12, LineTheme.BORDER_LIGHT));
card.setClickable(true);
card.setOnClickListener(v -> onClick.run());
LineTheme.padding(card, LineTheme.LG, LineTheme.LG, LineTheme.LG, LineTheme.LG);

FrameLayout largeIcon = new FrameLayout(context);
largeIcon.setBackground(LineTheme.rounded(context, LineTheme.ACCENT_MUTED, 8));
IconButtonView icon = new IconButtonView(context, iconType);
icon.setIconColor(LineTheme.ACCENT);
icon.setIconSizeDp(44, 22);
icon.setClickable(false);
largeIcon.addView(icon, new FrameLayout.LayoutParams(LineTheme.dp(context, 44), LineTheme.dp(context, 44), Gravity.CENTER));
card.addView(largeIcon, new LinearLayout.LayoutParams(LineTheme.dp(context, 44), LineTheme.dp(context, 44)));

LinearLayout text = new LinearLayout(context);
text.setOrientation(VERTICAL);
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f);
textParams.leftMargin = LineTheme.dp(context, LineTheme.MD);
textParams.rightMargin = LineTheme.dp(context, LineTheme.MD);
card.addView(text, textParams);
text.addView(LineTheme.text(context, title, LineTheme.FONT_MD, LineTheme.TEXT, Typeface.BOLD), new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
TextView descView = LineTheme.text(context, desc, LineTheme.FONT_XS, LineTheme.TEXT_TERTIARY, Typeface.NORMAL);
descView.setLineSpacing(LineTheme.dp(context, 3), 1f);
LinearLayout.LayoutParams descParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
descParams.topMargin = LineTheme.dp(context, LineTheme.XS);
text.addView(descView, descParams);

IconButtonView chevron = new IconButtonView(context, IconButtonView.CHEVRON_RIGHT);
chevron.setIconColor(LineTheme.TEXT_TERTIARY);
chevron.setIconSizeDp(19, 17);
chevron.setClickable(false);
card.addView(chevron, new LinearLayout.LayoutParams(LineTheme.dp(context, 19), LineTheme.dp(context, 19)));

LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
cardParams.bottomMargin = LineTheme.dp(context, LineTheme.SM);
content.addView(card, cardParams);
}

private void addProvider(LinearLayout content, ModelProviderPreset preset, Listener listener) {
content.addView(new ActionRowView(getContext(), IconButtonView.BOX,
ModelProviderPresetStrings.getLabel(getContext(), preset.getId()),
ModelProviderPresetStrings.getDesc(getContext(), preset.getId()), false, true,
() -> listener.onProvider(preset.getId())), cardParams());
}
Context context = content.getContext();
String name = ModelProviderPresetStrings.getLabel(context, preset.getId());
LinearLayout row = new LinearLayout(context);
row.setOrientation(HORIZONTAL);
row.setGravity(Gravity.CENTER_VERTICAL);
row.setBackground(LineTheme.roundedStroke(context, LineTheme.SURFACE_ELEVATED, 12, LineTheme.BORDER_LIGHT));
row.setClickable(true);
row.setOnClickListener(v -> listener.onProvider(preset.getId()));
LineTheme.padding(row, LineTheme.MD, LineTheme.MD, LineTheme.MD, LineTheme.MD);

TextView initial = LineTheme.text(context, name.substring(0, 1), LineTheme.FONT_MD, LineTheme.ACCENT, Typeface.BOLD);
initial.setGravity(Gravity.CENTER);
initial.setBackground(LineTheme.rounded(context, LineTheme.ACCENT_MUTED, 8));
row.addView(initial, new LinearLayout.LayoutParams(LineTheme.dp(context, 38), LineTheme.dp(context, 38)));

LinearLayout text = new LinearLayout(context);
text.setOrientation(VERTICAL);
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f);
textParams.leftMargin = LineTheme.dp(context, LineTheme.MD);
textParams.rightMargin = LineTheme.dp(context, LineTheme.MD);
row.addView(text, textParams);
TextView title = LineTheme.text(context, name, LineTheme.FONT_MD, LineTheme.TEXT, Typeface.BOLD);
title.setSingleLine(true);
text.addView(title, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
TextView sub = LineTheme.text(context, ModelProviderPresetStrings.getDesc(context, preset.getId()) + " · " + protocolLabel(preset), LineTheme.FONT_XS, LineTheme.TEXT_TERTIARY, Typeface.NORMAL);
sub.setSingleLine(true);
LinearLayout.LayoutParams subParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
subParams.topMargin = LineTheme.dp(context, 3);
text.addView(sub, subParams);

IconButtonView chevron = new IconButtonView(context, IconButtonView.CHEVRON_RIGHT);
chevron.setIconColor(LineTheme.TEXT_TERTIARY);
chevron.setIconSizeDp(18, 16);
chevron.setClickable(false);
row.addView(chevron, new LinearLayout.LayoutParams(LineTheme.dp(context, 18), LineTheme.dp(context, 18)));

private LayoutParams cardParams() {
LayoutParams params = new LayoutParams(-1, -2);
params.bottomMargin = LineTheme.dp(getContext(), 8);
return params;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.bottomMargin = LineTheme.dp(context, LineTheme.SM);
content.addView(row, params);
}

private String protocolLabel(ModelProviderPreset preset) {
Expand Down
Loading
Loading