Copy comment url to clipboard (#655)

Copy comment url to clipboard

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/655
This commit is contained in:
M M Arif 2020-08-21 16:17:48 +02:00
parent 5fc6cdde63
commit 6d8a87358d
3 changed files with 32 additions and 2 deletions

View File

@ -109,6 +109,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote); TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy); TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete); TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
if(!loginUid.contentEquals(commenterUsername.getText())) { if(!loginUid.contentEquals(commenterUsername.getText())) {
commentMenuEdit.setVisibility(View.GONE); commentMenuEdit.setVisibility(View.GONE);
@ -151,6 +152,22 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
}); });
issueCommentCopyUrl.setOnClickListener(ediComment -> {
// comment Url
CharSequence commentUrl = htmlUrl.getText();
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
assert clipboard != null;
ClipData clip = ClipData.newPlainText(commentUrl, commentUrl);
clipboard.setPrimaryClip(clip);
dialog.dismiss();
Toasty.success(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
});
commentMenuQuote.setOnClickListener(v1 -> { commentMenuQuote.setOnClickListener(v1 -> {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
@ -189,7 +206,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
dialog.dismiss(); dialog.dismiss();
Toasty.info(ctx, ctx.getString(R.string.copyIssueCommentToastMsg)); Toasty.success(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));
}); });

View File

@ -58,7 +58,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/menuCopyText" android:text="@string/copyCommentText"
android:drawableStart="@drawable/ic_copy" android:drawableStart="@drawable/ic_copy"
android:drawablePadding="24dp" android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
@ -77,6 +77,18 @@
android:textSize="16sp" android:textSize="16sp"
android:padding="12dp" /> android:padding="12dp" />
<TextView
android:id="@+id/issueCommentCopyUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/genericCopyUrl"
android:drawableStart="@drawable/ic_link"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@ -342,6 +342,7 @@
<string name="editCommentUpdatedText">Comment updated</string> <string name="editCommentUpdatedText">Comment updated</string>
<string name="issueCommentShare">Share Comment</string> <string name="issueCommentShare">Share Comment</string>
<string name="deleteCommentSuccess">Comment deleted successfully</string> <string name="deleteCommentSuccess">Comment deleted successfully</string>
<string name="copyCommentText">Copy Comment</string>
<!-- issue comments --> <!-- issue comments -->
<!-- add collaborator --> <!-- add collaborator -->