Skip to content

Commit

Permalink
Set tag for copy button in markdown view for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
duy committed Oct 29, 2024
1 parent 668cdb7 commit cce1de2
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public class MarkdownVisitor extends AbstractVisitor {
private TableRow tableRow;
private boolean inHeader = false;

private int copyButtonCounter = 0;

MarkdownVisitor(@NonNull NativeMarkdownView container, @Nullable MarkdownViewDelegate delegate) {
this.container = container;
this.delegate = delegate;
Expand Down Expand Up @@ -211,17 +213,18 @@ public void visit(FencedCodeBlock fencedCodeBlock) {
btnCopy.setTextColor(editorTheme.getFgColor());
btnCopy.setIconTint(ColorStateList.valueOf(editorTheme.getFgColor()));
divider.setVisibility(View.VISIBLE);
divider.setBackgroundDrawable(new ColorDrawable(editorTheme.getGutterStyle().getFoldColor()));
divider.setBackground(new ColorDrawable(editorTheme.getGutterStyle().getFoldColor()));

btnCopy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (delegate != null) {
delegate.onCopyCodeButtonClicked(v, code);
}
btnCopy.setOnClickListener(v -> {
if (delegate != null) {
delegate.onCopyCodeButtonClicked(v, code);
}
});

// for testing
btnCopy.setTag("Copy button " + copyButtonCounter);
copyButtonCounter++;

} else {
btnCopy.setVisibility(View.GONE);
divider.setVisibility(View.GONE);
Expand Down

0 comments on commit cce1de2

Please sign in to comment.