add copy function

This commit is contained in:
6543 2019-09-27 21:17:28 +02:00
parent dcd28e845a
commit 71bb8cc75d
No known key found for this signature in database
GPG Key ID: A1CA74D27FD13271
2 changed files with 42 additions and 0 deletions

View File

@ -16,6 +16,8 @@ import org.mian.gitnex.activities.ReplyToIssueActivity;
import org.mian.gitnex.util.TinyDB;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.content.ClipboardManager;
import android.content.ClipData;
/**
* Author M M Arif
@ -37,6 +39,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
TextView closeIssue = v.findViewById(R.id.closeIssue);
TextView reOpenIssue = v.findViewById(R.id.reOpenIssue);
TextView addRemoveAssignees = v.findViewById(R.id.addRemoveAssignees);
TextView copyIssue = v.findViewById(R.id.copyIssue);
replyToIssue.setOnClickListener(new View.OnClickListener() {
@Override
@ -78,6 +81,33 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
}
});
copyIssue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//get url of repo
String repoFullName = tinyDB.getString("repoFullName");
String instanceUrlWithProtocol = "https://" + tinyDB.getString("instanceUrlRaw");
if(!tinyDB.getString("instanceUrlWithProtocol").isEmpty()) {
instanceUrlWithProtocol = tinyDB.getString("instanceUrlWithProtocol");
}
//get issue number
String issue = tinyDB.getString("issueNumber");
//combine
issue = instanceUrlWithProtocol + "/" + repoFullName + "/issues/" + issue;
// copy to clipboard
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(android.content.Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("issue", issue);
clipboard.setPrimaryClip(clip);
dismiss();
}
});
if(tinyDB.getString("issueState").equals("open")) { // close issue
reOpenIssue.setVisibility(View.GONE);

View File

@ -79,4 +79,16 @@
android:textSize="16sp"
android:padding="16dp" />
<TextView
android:id="@+id/copyIssue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableStart="@drawable/ic_content_copy"
android:drawablePadding="24dp"
android:padding="16dp"
android:text="@string/copyIssue"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>