#562 Adding ability to quote and to copy issue comments.

Merged
mmarif merged 6 commits from opyale/GitNex:reply-tools into master 4 months ago
  1. +1
    -1
      app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
  2. +45
    -0
      app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java
  3. +24
    -0
      app/src/main/res/layout/bottom_sheet_issue_comments.xml
  4. +2
    -3
      app/src/main/res/layout/list_issue_comments.xml
  5. +3
    -0
      app/src/main/res/values/strings.xml

+ 1
- 1
app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java View File

@@ -64,7 +64,7 @@ public class ReplyToIssueActivity extends BaseActivity {
addComment = findViewById(R.id.addComment);
addComment.setShowSoftInputOnFocus(true);

defaultMentionAdapter = new MentionArrayAdapter<>(this);
defaultMentionAdapter = new MentionArrayAdapter<>(ctx);
loadCollaboratorsList();

addComment.setMentionAdapter(defaultMentionAdapter);


+ 45
- 0
app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java View File

@@ -1,6 +1,8 @@
package org.mian.gitnex.adapters;

import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -104,6 +106,8 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap

TextView commentMenuEdit = view.findViewById(R.id.commentMenuEdit);
TextView commentShare = view.findViewById(R.id.issueCommentShare);
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);

if(!loginUid.contentEquals(commenterUsername.getText())) {
@@ -111,6 +115,10 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
commentMenuDelete.setVisibility(View.GONE);
}

if(issueComment.getText().toString().isEmpty()) {
commentMenuCopy.setVisibility(View.GONE);
}

BottomSheetDialog dialog = new BottomSheetDialog(ctx);
dialog.setContentView(view);
dialog.show();
@@ -143,6 +151,43 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap

});

commentMenuQuote.setOnClickListener(v1 -> {

StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("@").append(commenterUsername.getText().toString()).append("\n\n");

String[] lines = commendBodyRaw.getText().toString().split("\\R");

for(String line : lines) {

stringBuilder.append(">").append(line).append("\n");
}

stringBuilder.append("\n");

Intent intent = new Intent(ctx, ReplyToIssueActivity.class);
intent.putExtra("commentBody", stringBuilder.toString());
intent.putExtra("cursorToEnd", true);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

dialog.dismiss();
ctx.startActivity(intent);

});

commentMenuCopy.setOnClickListener(view1 -> {

ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
assert clipboard != null;

ClipData clip = ClipData.newPlainText("Comment on issue #" + issueNumber.getText().toString(), issueComment.getText().toString());
clipboard.setPrimaryClip(clip);

dialog.dismiss();
Toasty.info(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));

});

commentMenuDelete.setOnClickListener(deleteComment -> {

deleteIssueComment(ctx, Integer.parseInt(commendId.getText().toString()), getAdapterPosition());


+ 24
- 0
app/src/main/res/layout/bottom_sheet_issue_comments.xml View File

@@ -41,6 +41,30 @@
android:textSize="16sp"
android:padding="12dp" />

<TextView
android:id="@+id/commentMenuQuote"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/menuQuoteText"
android:drawableStart="@drawable/ic_comment"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />

<TextView
android:id="@+id/commentMenuCopy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/menuCopyText"
android:drawableStart="@drawable/ic_content_copy"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />

<TextView
android:id="@+id/issueCommentShare"
android:layout_width="match_parent"


+ 2
- 3
app/src/main/res/layout/list_issue_comments.xml View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -24,7 +23,7 @@
android:id="@+id/commendBodyRaw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
android:visibility="gone" />

<TextView
android:id="@+id/commenterUsername"


+ 3
- 0
app/src/main/res/values/strings.xml View File

@@ -517,6 +517,7 @@

<string name="copyIssueUrl">Copy Issue URL</string>
<string name="copyIssueUrlToastMsg">URL copied to clipboard</string>
<string name="copyIssueCommentToastMsg">Copied comment to clipboard</string>

<string name="milestoneCompletion">%1$d\uFF05 completed</string>

@@ -539,6 +540,8 @@
<string name="menuContentDesc">Menu</string>
<string name="menuEditText">Edit</string>
<string name="menuDeleteText">Delete</string>
<string name="menuCopyText">Copy</string>
<string name="menuQuoteText">Quote and Reply</string>
<string name="colorfulBulletSpan" translatable="false">\u0020\u0020\u0020\u25CF\u0020\u0020\u0020</string>
<string name="modifiedText">edited</string>
<string name="saveButton">Save</string>


Loading…
Cancel
Save