-
Notifications
You must be signed in to change notification settings - Fork 23
Restore classic settings UI with current theme colors #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 71 additions & 7 deletions
78
app/src/main/java/cn/lineai/ui/component/CardViewHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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))); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
ActionRowViewor an inactiveOptionRowView.Suggested fix: Retain the pressable background for clickable rows and layer the active option color on top of it where needed.