2019-06-03 23:25:05 +02:00
|
|
|
package org.mian.gitnex.adapters;
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
2020-06-28 19:26:59 +02:00
|
|
|
import android.content.ClipData;
|
|
|
|
import android.content.ClipboardManager;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2019-09-29 18:44:42 +02:00
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.text.Spanned;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
2020-04-30 12:42:22 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
2020-04-01 11:44:38 +02:00
|
|
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
2020-04-30 12:42:22 +02:00
|
|
|
import com.google.gson.JsonElement;
|
2019-06-03 23:25:05 +02:00
|
|
|
import com.vdurmont.emoji.EmojiParser;
|
|
|
|
import org.mian.gitnex.R;
|
|
|
|
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
2020-04-01 13:26:32 +02:00
|
|
|
import org.mian.gitnex.clients.PicassoService;
|
2020-04-30 12:42:22 +02:00
|
|
|
import org.mian.gitnex.clients.RetrofitClient;
|
|
|
|
import org.mian.gitnex.helpers.AlertDialogs;
|
|
|
|
import org.mian.gitnex.helpers.ClickListener;
|
|
|
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.helpers.TimeHelper;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
2020-04-30 12:42:22 +02:00
|
|
|
import org.mian.gitnex.helpers.Toasty;
|
2019-09-30 19:39:33 +02:00
|
|
|
import org.mian.gitnex.helpers.UserMentions;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.models.IssueComments;
|
2019-09-29 18:44:42 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
2019-06-03 23:25:05 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Objects;
|
2019-09-29 18:44:42 +02:00
|
|
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
|
|
import io.noties.markwon.Markwon;
|
|
|
|
import io.noties.markwon.core.CorePlugin;
|
|
|
|
import io.noties.markwon.core.MarkwonTheme;
|
|
|
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
|
|
|
import io.noties.markwon.ext.tables.TablePlugin;
|
|
|
|
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
|
|
|
import io.noties.markwon.html.HtmlPlugin;
|
|
|
|
import io.noties.markwon.image.DefaultMediaDecoder;
|
|
|
|
import io.noties.markwon.image.ImageItem;
|
|
|
|
import io.noties.markwon.image.ImagesPlugin;
|
|
|
|
import io.noties.markwon.image.SchemeHandler;
|
|
|
|
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
|
|
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
|
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
2020-04-30 12:42:22 +02:00
|
|
|
import retrofit2.Call;
|
|
|
|
import retrofit2.Callback;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Author M M Arif
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
private List<IssueComments> issuesComments;
|
|
|
|
private Context mCtx;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
public IssueCommentsAdapter(Context mCtx, List<IssueComments> issuesCommentsMain) {
|
|
|
|
|
|
|
|
this.mCtx = mCtx;
|
|
|
|
this.issuesComments = issuesCommentsMain;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
private TextView issueNumber;
|
|
|
|
private TextView commendId;
|
|
|
|
private ImageView issueCommenterAvatar;
|
|
|
|
private TextView issueComment;
|
|
|
|
private TextView issueCommentDate;
|
|
|
|
private TextView commendBodyRaw;
|
|
|
|
private TextView commentModified;
|
|
|
|
private TextView commenterUsername;
|
|
|
|
private TextView htmlUrl;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
private IssueCommentViewHolder(View itemView) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
super(itemView);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
issueNumber = itemView.findViewById(R.id.issueNumber);
|
|
|
|
commendId = itemView.findViewById(R.id.commendId);
|
|
|
|
issueCommenterAvatar = itemView.findViewById(R.id.issueCommenterAvatar);
|
|
|
|
issueComment = itemView.findViewById(R.id.issueComment);
|
|
|
|
issueCommentDate = itemView.findViewById(R.id.issueCommentDate);
|
2020-04-30 12:42:22 +02:00
|
|
|
ImageView commentsOptionsMenu = itemView.findViewById(R.id.commentsOptionsMenu);
|
2020-04-03 18:48:22 +02:00
|
|
|
commendBodyRaw = itemView.findViewById(R.id.commendBodyRaw);
|
|
|
|
commentModified = itemView.findViewById(R.id.commentModified);
|
|
|
|
commenterUsername = itemView.findViewById(R.id.commenterUsername);
|
|
|
|
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
commentsOptionsMenu.setOnClickListener(v -> {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
final Context ctx = v.getContext();
|
|
|
|
final TinyDB tinyDb = new TinyDB(ctx);
|
2020-04-03 18:48:22 +02:00
|
|
|
final String loginUid = tinyDb.getString("loginUid");
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_issue_comments, null);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
TextView commentMenuEdit = view.findViewById(R.id.commentMenuEdit);
|
|
|
|
TextView commentShare = view.findViewById(R.id.issueCommentShare);
|
2020-06-28 19:26:59 +02:00
|
|
|
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
|
|
|
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
2020-04-30 12:42:22 +02:00
|
|
|
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
2020-08-21 16:17:48 +02:00
|
|
|
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
|
|
|
commentMenuEdit.setVisibility(View.GONE);
|
2020-04-30 12:42:22 +02:00
|
|
|
commentMenuDelete.setVisibility(View.GONE);
|
2020-04-03 18:48:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-06-28 19:26:59 +02:00
|
|
|
if(issueComment.getText().toString().isEmpty()) {
|
|
|
|
commentMenuCopy.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
2020-04-03 18:48:22 +02:00
|
|
|
dialog.setContentView(view);
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
commentMenuEdit.setOnClickListener(ediComment -> {
|
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
Intent intent = new Intent(ctx, ReplyToIssueActivity.class);
|
2020-04-03 18:48:22 +02:00
|
|
|
intent.putExtra("commentId", commendId.getText());
|
|
|
|
intent.putExtra("commentAction", "edit");
|
|
|
|
intent.putExtra("commentBody", commendBodyRaw.getText());
|
2020-04-30 12:42:22 +02:00
|
|
|
ctx.startActivity(intent);
|
2020-04-03 18:48:22 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
commentShare.setOnClickListener(ediComment -> {
|
|
|
|
|
|
|
|
// get comment Url
|
|
|
|
CharSequence commentUrl = htmlUrl.getText();
|
|
|
|
|
|
|
|
// share issue comment
|
|
|
|
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
|
|
|
sharingIntent.setType("text/plain");
|
2020-04-30 12:42:22 +02:00
|
|
|
String intentHeader = tinyDb.getString("issueNumber") + ctx.getResources().getString(R.string.hash) + "issuecomment-" + commendId.getText() + " " + tinyDb.getString("issueTitle");
|
2020-04-03 18:48:22 +02:00
|
|
|
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, intentHeader);
|
|
|
|
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
2020-04-30 12:42:22 +02:00
|
|
|
ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
|
|
|
|
});
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-21 16:17:48 +02:00
|
|
|
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));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-06-28 19:26:59 +02:00
|
|
|
commentMenuQuote.setOnClickListener(v1 -> {
|
|
|
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
2020-06-30 16:43:27 +02:00
|
|
|
String commenterName = commenterUsername.getText().toString();
|
|
|
|
|
|
|
|
if(!commenterName.equals(tinyDb.getString("userLogin"))) {
|
|
|
|
|
|
|
|
stringBuilder.append("@").append(commenterName).append("\n\n");
|
|
|
|
}
|
2020-06-28 19:26:59 +02:00
|
|
|
|
|
|
|
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();
|
2020-08-21 16:17:48 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));
|
2020-06-28 19:26:59 +02:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
commentMenuDelete.setOnClickListener(deleteComment -> {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
deleteIssueComment(ctx, Integer.parseInt(commendId.getText().toString()), getAdapterPosition());
|
|
|
|
dialog.dismiss();
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
});
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
private void updateAdapter(int position) {
|
2020-04-03 18:48:22 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
issuesComments.remove(position);
|
|
|
|
notifyItemRemoved(position);
|
|
|
|
notifyItemRangeChanged(position, issuesComments.size());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
|
|
|
|
|
|
|
final TinyDB tinyDb = new TinyDB(ctx);
|
|
|
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
|
|
final String loginUid = tinyDb.getString("loginUid");
|
|
|
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
|
|
String[] repoFullName = tinyDb.getString("repoFullName").split("/");
|
|
|
|
if (repoFullName.length != 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final String repoOwner = repoFullName[0];
|
|
|
|
final String repoName = repoFullName[1];
|
|
|
|
|
|
|
|
Call<JsonElement> call;
|
|
|
|
|
|
|
|
call = RetrofitClient
|
|
|
|
.getInstance(instanceUrl, ctx)
|
|
|
|
.getApiInterface()
|
|
|
|
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
|
|
|
|
|
|
|
call.enqueue(new Callback<JsonElement>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
|
|
|
|
|
|
|
if(response.code() == 204) {
|
|
|
|
|
|
|
|
updateAdapter(position);
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
2020-04-30 12:42:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else if(response.code() == 401) {
|
|
|
|
|
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
|
|
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
|
|
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
|
|
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(response.code() == 403) {
|
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
2020-04-30 12:42:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else if(response.code() == 404) {
|
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
2020-04-30 12:42:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
2020-04-30 12:42:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
|
|
|
|
|
|
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2020-04-03 18:48:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public IssueCommentsAdapter.IssueCommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
|
|
|
|
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issue_comments, parent, false);
|
|
|
|
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
|
|
|
|
|
|
|
final TinyDB tinyDb = new TinyDB(mCtx);
|
|
|
|
final String locale = tinyDb.getString("locale");
|
|
|
|
final String timeFormat = tinyDb.getString("dateFormat");
|
|
|
|
|
|
|
|
IssueComments currentItem = issuesComments.get(position);
|
|
|
|
|
|
|
|
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
|
|
holder.commenterUsername.setText(currentItem.getUser().getUsername());
|
|
|
|
holder.commendId.setText(String.valueOf(currentItem.getId()));
|
|
|
|
holder.commendBodyRaw.setText(currentItem.getBody());
|
|
|
|
|
|
|
|
if(!currentItem.getUser().getFull_name().equals("")) {
|
|
|
|
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getFull_name(), mCtx));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getLogin(), mCtx));
|
|
|
|
}
|
|
|
|
|
|
|
|
PicassoService.getInstance(mCtx).get().load(currentItem.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.issueCommenterAvatar);
|
|
|
|
|
|
|
|
String cleanIssueComments = currentItem.getBody().trim();
|
|
|
|
|
|
|
|
final Markwon markwon = Markwon.builder(Objects.requireNonNull(mCtx)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void configureImages(@NonNull ImagesPlugin plugin) {
|
|
|
|
|
|
|
|
plugin.addSchemeHandler(new SchemeHandler() {
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
|
|
|
|
|
|
|
final int resourceId = mCtx.getResources().getIdentifier(raw.substring("drawable://".length()), "drawable", mCtx.getPackageName());
|
|
|
|
|
|
|
|
final Drawable drawable = mCtx.getDrawable(resourceId);
|
|
|
|
|
|
|
|
assert drawable != null;
|
|
|
|
return ImageItem.withResult(drawable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public Collection<String> supportedSchemes() {
|
|
|
|
|
|
|
|
return Collections.singleton("drawable");
|
|
|
|
}
|
|
|
|
});
|
2020-04-30 12:42:22 +02:00
|
|
|
plugin.placeholderProvider(drawable -> null);
|
2020-04-03 18:48:22 +02:00
|
|
|
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
|
|
|
plugin.addMediaDecoder(SvgMediaDecoder.create(mCtx.getResources()));
|
|
|
|
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
|
|
|
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.getResources()));
|
|
|
|
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
2020-04-30 12:42:22 +02:00
|
|
|
|
2020-04-03 18:48:22 +02:00
|
|
|
}
|
|
|
|
})).usePlugin(new AbstractMarkwonPlugin() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
|
|
|
|
|
|
|
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground")).linkColor(mCtx.getResources().getColor(R.color.lightBlue));
|
|
|
|
}
|
|
|
|
|
|
|
|
}).usePlugin(TablePlugin.create(mCtx)).usePlugin(TaskListPlugin.create(mCtx)).usePlugin(HtmlPlugin.create()).usePlugin(StrikethroughPlugin.create()).usePlugin(LinkifyPlugin.create()).build();
|
|
|
|
|
|
|
|
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueComments));
|
|
|
|
markwon.setParsedMarkdown(holder.issueComment, UserMentions.UserMentionsFunc(mCtx, bodyWithMD, cleanIssueComments));
|
|
|
|
|
|
|
|
String edited;
|
|
|
|
|
|
|
|
if(!currentItem.getUpdated_at().equals(currentItem.getCreated_at())) {
|
|
|
|
|
|
|
|
edited = mCtx.getResources().getString(R.string.colorfulBulletSpan) + mCtx.getResources().getString(R.string.modifiedText);
|
|
|
|
holder.commentModified.setVisibility(View.VISIBLE);
|
|
|
|
holder.commentModified.setText(edited);
|
|
|
|
holder.commentModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), mCtx));
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
holder.commentModified.setVisibility(View.INVISIBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-18 06:50:36 +02:00
|
|
|
holder.issueCommentDate.setText(TimeHelper.formatTime(currentItem.getCreated_at(), new Locale(locale), timeFormat, mCtx));
|
2020-04-03 18:48:22 +02:00
|
|
|
|
2020-04-07 23:17:12 +02:00
|
|
|
if(timeFormat.equals("pretty")) {
|
|
|
|
holder.issueCommentDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx));
|
2020-04-03 18:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
|
|
|
|
return issuesComments.size();
|
|
|
|
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
}
|