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;
|
2022-09-14 20:40:44 +02:00
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Typeface;
|
2020-10-12 20:11:23 +02:00
|
|
|
import android.os.Bundle;
|
2022-08-01 09:24:23 +02:00
|
|
|
import android.os.Handler;
|
2022-09-14 20:40:44 +02:00
|
|
|
import android.text.Spannable;
|
|
|
|
import android.text.SpannableString;
|
|
|
|
import android.text.style.ImageSpan;
|
2021-10-04 15:35:34 +02:00
|
|
|
import android.view.Gravity;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2022-09-14 20:40:44 +02:00
|
|
|
import android.widget.FrameLayout;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.widget.ImageView;
|
2020-11-08 19:58:47 +01:00
|
|
|
import android.widget.LinearLayout;
|
2022-09-14 20:40:44 +02:00
|
|
|
import android.widget.RelativeLayout;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.widget.TextView;
|
2020-04-30 12:42:22 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2022-09-14 20:40:44 +02:00
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
|
|
import androidx.core.text.HtmlCompat;
|
2020-10-12 20:11:23 +02:00
|
|
|
import androidx.fragment.app.FragmentManager;
|
2020-04-30 12:42:22 +02:00
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
2022-09-14 20:40:44 +02:00
|
|
|
import com.amulyakhare.textdrawable.TextDrawable;
|
2020-04-01 11:44:38 +02:00
|
|
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
2022-09-14 20:40:44 +02:00
|
|
|
import com.google.android.material.card.MaterialCardView;
|
2019-06-03 23:25:05 +02:00
|
|
|
import com.vdurmont.emoji.EmojiParser;
|
2022-09-21 07:43:00 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Objects;
|
2022-09-14 20:40:44 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.gitnex.tea4j.v2.models.TimelineComment;
|
|
|
|
import org.json.JSONArray;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.R;
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
import org.mian.gitnex.activities.BaseActivity;
|
2022-09-14 20:40:44 +02:00
|
|
|
import org.mian.gitnex.activities.CommitDetailActivity;
|
|
|
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
2021-08-02 20:04:33 +02:00
|
|
|
import org.mian.gitnex.activities.ProfileActivity;
|
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;
|
2020-10-12 20:11:23 +02:00
|
|
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
2022-03-28 19:57:47 +02:00
|
|
|
import org.mian.gitnex.fragments.IssuesFragment;
|
2022-09-14 20:40:44 +02:00
|
|
|
import org.mian.gitnex.helpers.AlertDialogs;
|
|
|
|
import org.mian.gitnex.helpers.AppUtil;
|
2022-10-01 06:16:19 +02:00
|
|
|
import org.mian.gitnex.helpers.ClickListener;
|
2022-09-14 20:40:44 +02:00
|
|
|
import org.mian.gitnex.helpers.ColorInverter;
|
|
|
|
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
|
|
|
import org.mian.gitnex.helpers.Markdown;
|
|
|
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
|
|
|
import org.mian.gitnex.helpers.TimeHelper;
|
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
|
|
|
import org.mian.gitnex.helpers.Toasty;
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
import org.mian.gitnex.helpers.contexts.IssueContext;
|
2020-11-08 19:58:47 +01:00
|
|
|
import org.mian.gitnex.views.ReactionList;
|
|
|
|
import org.mian.gitnex.views.ReactionSpinner;
|
2020-04-30 12:42:22 +02:00
|
|
|
import retrofit2.Call;
|
|
|
|
import retrofit2.Callback;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
/**
|
2022-04-22 17:18:38 +02:00
|
|
|
* @author M M Arif
|
2019-06-03 23:25:05 +02:00
|
|
|
*/
|
2022-09-14 20:40:44 +02:00
|
|
|
public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
private final Context context;
|
2020-11-08 19:58:47 +01:00
|
|
|
private final TinyDB tinyDB;
|
|
|
|
private final Bundle bundle;
|
2020-11-02 16:17:00 +01:00
|
|
|
private final FragmentManager fragmentManager;
|
2022-02-25 23:35:51 +01:00
|
|
|
private final Runnable onInteractedListener;
|
2021-05-30 19:28:14 +02:00
|
|
|
private final Locale locale;
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
private final IssueContext issue;
|
2022-09-14 20:40:44 +02:00
|
|
|
private List<TimelineComment> issuesComments;
|
|
|
|
private OnLoadMoreListener loadMoreListener;
|
|
|
|
private boolean isLoading = false, isMoreDataAvailable = true, timelineLastView = false;
|
|
|
|
private Intent intent;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
public IssueCommentsAdapter(
|
|
|
|
Context ctx,
|
|
|
|
Bundle bundle,
|
|
|
|
List<TimelineComment> issuesCommentsMain,
|
|
|
|
FragmentManager fragmentManager,
|
|
|
|
Runnable onInteractedListener,
|
|
|
|
IssueContext issue) {
|
2020-04-30 12:42:22 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
this.context = ctx;
|
2020-11-08 19:58:47 +01:00
|
|
|
this.bundle = bundle;
|
2020-04-30 12:42:22 +02:00
|
|
|
this.issuesComments = issuesCommentsMain;
|
2020-11-02 16:17:00 +01:00
|
|
|
this.fragmentManager = fragmentManager;
|
|
|
|
this.onInteractedListener = onInteractedListener;
|
2020-11-08 19:58:47 +01:00
|
|
|
tinyDB = TinyDB.getInstance(ctx);
|
2021-05-30 19:28:14 +02:00
|
|
|
locale = ctx.getResources().getConfiguration().locale;
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
this.issue = issue;
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
|
2022-08-15 16:26:02 +02:00
|
|
|
private void updateAdapter(int position) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2022-08-15 16:26:02 +02:00
|
|
|
issuesComments.remove(position);
|
|
|
|
notifyItemRemoved(position);
|
|
|
|
notifyItemRangeChanged(position, issuesComments.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
Call<Void> call =
|
|
|
|
RetrofitClient.getApiInterface(ctx)
|
|
|
|
.issueDeleteComment(
|
|
|
|
issue.getRepository().getOwner(),
|
|
|
|
issue.getRepository().getName(),
|
|
|
|
(long) commentId);
|
|
|
|
|
|
|
|
call.enqueue(
|
|
|
|
new Callback<>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResponse(
|
|
|
|
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
|
|
|
|
|
|
|
switch (response.code()) {
|
|
|
|
case 204:
|
|
|
|
updateAdapter(position);
|
|
|
|
Toasty.success(
|
|
|
|
ctx,
|
|
|
|
ctx.getResources()
|
|
|
|
.getString(R.string.deleteCommentSuccess));
|
|
|
|
IssuesFragment.resumeIssues = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 401:
|
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 403:
|
|
|
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 404:
|
|
|
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
|
|
|
}
|
|
|
|
}
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
Toasty.error(
|
|
|
|
ctx,
|
|
|
|
ctx.getResources().getString(R.string.genericServerResponseError));
|
|
|
|
}
|
|
|
|
});
|
2022-08-15 16:26:02 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
@NonNull @Override
|
2022-09-14 20:40:44 +02:00
|
|
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(context);
|
2022-09-21 07:43:00 +02:00
|
|
|
return new IssueCommentViewHolder(
|
|
|
|
inflater.inflate(R.layout.list_issue_comments, parent, false));
|
2022-08-15 16:26:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-09-14 20:40:44 +02:00
|
|
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
2022-09-21 07:43:00 +02:00
|
|
|
if (position >= getItemCount() - 1
|
|
|
|
&& isMoreDataAvailable
|
|
|
|
&& !isLoading
|
|
|
|
&& loadMoreListener != null) {
|
2022-09-14 20:40:44 +02:00
|
|
|
isLoading = true;
|
|
|
|
loadMoreListener.onLoadMore();
|
|
|
|
timelineLastView = true;
|
2022-08-15 16:26:02 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
((IssueCommentsAdapter.IssueCommentViewHolder) holder)
|
|
|
|
.bindData(issuesComments.get(position));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
public void notifyDataChanged() {
|
|
|
|
notifyItemInserted(issuesComments.size());
|
|
|
|
isLoading = false;
|
|
|
|
loadMoreListener.onLoadFinished();
|
|
|
|
}
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
|
|
|
isMoreDataAvailable = moreDataAvailable;
|
2022-09-21 07:43:00 +02:00
|
|
|
if (!isMoreDataAvailable) {
|
2022-09-14 20:40:44 +02:00
|
|
|
loadMoreListener.onLoadFinished();
|
|
|
|
}
|
|
|
|
}
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
|
|
|
this.loadMoreListener = loadMoreListener;
|
|
|
|
}
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
public void updateList(List<TimelineComment> list) {
|
|
|
|
issuesComments = list;
|
|
|
|
notifyDataChanged();
|
|
|
|
}
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
@Override
|
|
|
|
public int getItemViewType(int position) {
|
|
|
|
return position;
|
2022-08-15 16:26:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
return issuesComments.size();
|
|
|
|
}
|
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
public interface OnLoadMoreListener {
|
|
|
|
|
|
|
|
void onLoadMore();
|
2022-09-21 07:43:00 +02:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
void onLoadFinished();
|
|
|
|
}
|
|
|
|
|
2022-08-15 16:26:02 +02:00
|
|
|
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
2020-11-02 16:17:00 +01:00
|
|
|
|
|
|
|
private final ImageView avatar;
|
|
|
|
private final TextView author;
|
|
|
|
private final TextView information;
|
2021-12-15 23:39:04 +01:00
|
|
|
private final RecyclerView comment;
|
2020-11-08 19:58:47 +01:00
|
|
|
private final LinearLayout commentReactionBadges;
|
2022-09-14 20:40:44 +02:00
|
|
|
private final MaterialCardView commentView;
|
|
|
|
private final RelativeLayout timelineView;
|
|
|
|
private final LinearLayout timelineData;
|
|
|
|
private final ImageView timelineIcon;
|
2022-08-15 16:26:02 +02:00
|
|
|
private String userLoginId;
|
2022-09-14 20:40:44 +02:00
|
|
|
private TimelineComment issueComment;
|
|
|
|
private final LinearLayout timelineDividerView;
|
|
|
|
private final FrameLayout timelineLine2;
|
2020-11-02 16:17:00 +01:00
|
|
|
|
|
|
|
private IssueCommentViewHolder(View view) {
|
|
|
|
|
|
|
|
super(view);
|
|
|
|
|
|
|
|
avatar = view.findViewById(R.id.avatar);
|
|
|
|
author = view.findViewById(R.id.author);
|
|
|
|
information = view.findViewById(R.id.information);
|
|
|
|
ImageView menu = view.findViewById(R.id.menu);
|
|
|
|
comment = view.findViewById(R.id.comment);
|
2020-11-08 19:58:47 +01:00
|
|
|
commentReactionBadges = view.findViewById(R.id.commentReactionBadges);
|
2020-11-02 16:17:00 +01:00
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
commentView = view.findViewById(R.id.comment_view);
|
|
|
|
|
|
|
|
timelineView = view.findViewById(R.id.timeline_view);
|
|
|
|
timelineData = view.findViewById(R.id.timeline_data);
|
|
|
|
timelineIcon = view.findViewById(R.id.timeline_icon);
|
|
|
|
timelineDividerView = view.findViewById(R.id.timeline_divider_view);
|
|
|
|
timelineLine2 = view.findViewById(R.id.timeline_line_2);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
menu.setOnClickListener(
|
|
|
|
v -> {
|
|
|
|
final String loginUid =
|
|
|
|
((BaseActivity) context).getAccount().getAccount().getUserName();
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams")
|
|
|
|
View vw =
|
|
|
|
LayoutInflater.from(context)
|
|
|
|
.inflate(R.layout.bottom_sheet_issue_comments, null);
|
|
|
|
|
|
|
|
TextView commentMenuEdit = vw.findViewById(R.id.commentMenuEdit);
|
|
|
|
TextView commentShare = vw.findViewById(R.id.issueCommentShare);
|
|
|
|
TextView commentMenuQuote = vw.findViewById(R.id.commentMenuQuote);
|
|
|
|
TextView commentMenuCopy = vw.findViewById(R.id.commentMenuCopy);
|
|
|
|
TextView commentMenuDelete = vw.findViewById(R.id.commentMenuDelete);
|
|
|
|
TextView issueCommentCopyUrl = vw.findViewById(R.id.issueCommentCopyUrl);
|
|
|
|
TextView open = vw.findViewById(R.id.open);
|
|
|
|
LinearLayout linearLayout = vw.findViewById(R.id.commentReactionButtons);
|
|
|
|
|
|
|
|
if (issue.getRepository().getRepository().isArchived()) {
|
|
|
|
commentMenuEdit.setVisibility(View.GONE);
|
|
|
|
commentMenuDelete.setVisibility(View.GONE);
|
|
|
|
commentMenuQuote.setVisibility(View.GONE);
|
|
|
|
linearLayout.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!loginUid.contentEquals(issueComment.getUser().getLogin())
|
|
|
|
&& !issue.getRepository().getPermissions().isPush()) {
|
|
|
|
commentMenuEdit.setVisibility(View.GONE);
|
|
|
|
commentMenuDelete.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (issueComment.getBody().isEmpty()) {
|
|
|
|
commentMenuCopy.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
|
|
dialog.setContentView(vw);
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
TextView loadReactions = new TextView(context);
|
|
|
|
loadReactions.setText(context.getString(R.string.genericWaitFor));
|
|
|
|
loadReactions.setGravity(Gravity.CENTER);
|
|
|
|
loadReactions.setLayoutParams(
|
|
|
|
new ViewGroup.LayoutParams(
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, 160));
|
|
|
|
linearLayout.addView(loadReactions);
|
|
|
|
|
|
|
|
Bundle bundle1 = new Bundle();
|
|
|
|
bundle1.putAll(bundle);
|
|
|
|
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
|
|
|
|
|
|
|
ReactionSpinner reactionSpinner = new ReactionSpinner(context, bundle1);
|
|
|
|
reactionSpinner.setOnInteractedListener(
|
|
|
|
() -> {
|
|
|
|
onInteractedListener.run();
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
reactionSpinner.setOnLoadingFinishedListener(
|
|
|
|
() -> {
|
|
|
|
linearLayout.removeView(loadReactions);
|
|
|
|
reactionSpinner.setLayoutParams(
|
|
|
|
new ViewGroup.LayoutParams(
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, 160));
|
|
|
|
linearLayout.addView(reactionSpinner);
|
|
|
|
});
|
|
|
|
|
|
|
|
commentMenuEdit.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putInt(
|
|
|
|
"commentId", Math.toIntExact(issueComment.getId()));
|
|
|
|
bundle.putString("commentAction", "edit");
|
|
|
|
bundle.putString("commentBody", issueComment.getBody());
|
|
|
|
|
|
|
|
BottomSheetReplyFragment bottomSheetReplyFragment =
|
|
|
|
BottomSheetReplyFragment.newInstance(bundle, issue);
|
|
|
|
bottomSheetReplyFragment.setOnInteractedListener(
|
|
|
|
onInteractedListener);
|
|
|
|
bottomSheetReplyFragment.show(
|
|
|
|
fragmentManager, "replyBottomSheet");
|
|
|
|
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
commentShare.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
AppUtil.sharingIntent(context, issueComment.getHtmlUrl());
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
issueCommentCopyUrl.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
AppUtil.copyToClipboard(
|
|
|
|
context,
|
|
|
|
issueComment.getHtmlUrl(),
|
|
|
|
context.getString(R.string.copyIssueUrlToastMsg));
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
open.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
AppUtil.openUrlInBrowser(context, issueComment.getHtmlUrl());
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
commentMenuQuote.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
String commenterName = issueComment.getUser().getLogin();
|
|
|
|
|
|
|
|
if (!commenterName.equals(
|
|
|
|
((BaseActivity) context)
|
|
|
|
.getAccount()
|
|
|
|
.getAccount()
|
|
|
|
.getUserName())) {
|
|
|
|
stringBuilder
|
|
|
|
.append("@")
|
|
|
|
.append(commenterName)
|
|
|
|
.append("\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] lines = issueComment.getBody().split("\\R");
|
|
|
|
|
|
|
|
for (String line : lines) {
|
|
|
|
stringBuilder.append(">").append(line).append("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
stringBuilder.append("\n");
|
|
|
|
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putString("commentBody", stringBuilder.toString());
|
|
|
|
bundle.putBoolean("cursorToEnd", true);
|
|
|
|
|
|
|
|
dialog.dismiss();
|
|
|
|
BottomSheetReplyFragment.newInstance(bundle, issue)
|
|
|
|
.show(fragmentManager, "replyBottomSheet");
|
|
|
|
});
|
|
|
|
|
|
|
|
commentMenuCopy.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
ClipboardManager clipboard =
|
|
|
|
(ClipboardManager)
|
|
|
|
Objects.requireNonNull(context)
|
|
|
|
.getSystemService(
|
|
|
|
Context.CLIPBOARD_SERVICE);
|
|
|
|
assert clipboard != null;
|
|
|
|
|
|
|
|
ClipData clip =
|
|
|
|
ClipData.newPlainText(
|
|
|
|
"Comment on issue #" + issue.getIssueIndex(),
|
|
|
|
issueComment.getBody());
|
|
|
|
clipboard.setPrimaryClip(clip);
|
|
|
|
|
|
|
|
dialog.dismiss();
|
|
|
|
Toasty.success(
|
|
|
|
context,
|
|
|
|
context.getString(R.string.copyIssueCommentToastMsg));
|
|
|
|
});
|
|
|
|
|
|
|
|
commentMenuDelete.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
deleteIssueComment(
|
|
|
|
context,
|
|
|
|
Math.toIntExact(issueComment.getId()),
|
|
|
|
getBindingAdapterPosition());
|
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2022-08-01 09:24:23 +02:00
|
|
|
});
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
new Handler()
|
|
|
|
.postDelayed(
|
|
|
|
() -> {
|
|
|
|
if (!AppUtil.checkGhostUsers(userLoginId)) {
|
|
|
|
avatar.setOnClickListener(
|
|
|
|
loginId -> {
|
|
|
|
Intent intent =
|
|
|
|
new Intent(context, ProfileActivity.class);
|
|
|
|
intent.putExtra("username", userLoginId);
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
|
|
|
|
|
|
|
avatar.setOnLongClickListener(
|
|
|
|
loginId -> {
|
|
|
|
AppUtil.copyToClipboard(
|
|
|
|
context,
|
|
|
|
userLoginId,
|
|
|
|
context.getString(
|
|
|
|
R.string.copyLoginIdToClipBoard,
|
|
|
|
userLoginId));
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
500);
|
2020-04-03 18:48:22 +02:00
|
|
|
}
|
|
|
|
|
2022-09-14 20:40:44 +02:00
|
|
|
void bindData(TimelineComment timelineComment) {
|
|
|
|
|
|
|
|
int fontSize = 14;
|
|
|
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
|
|
|
|
|
|
|
userLoginId = timelineComment.getUser().getLogin();
|
|
|
|
|
|
|
|
this.issueComment = timelineComment;
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (timelineLastView) {
|
|
|
|
// timelineLine2.setVisibility(View.GONE);
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
2022-09-19 06:10:05 +02:00
|
|
|
StringBuilder infoBuilder = null;
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getCreatedAt() != null) {
|
|
|
|
|
2022-10-01 06:16:19 +02:00
|
|
|
infoBuilder =
|
|
|
|
new StringBuilder(
|
|
|
|
TimeHelper.formatTime(issueComment.getCreatedAt(), locale));
|
|
|
|
|
|
|
|
information.setOnClickListener(
|
|
|
|
new ClickListener(
|
|
|
|
TimeHelper.customDateFormatForToastDateFormat(
|
|
|
|
issueComment.getCreatedAt()),
|
|
|
|
context));
|
2022-09-14 20:40:44 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (!issueComment.getCreatedAt().equals(issueComment.getUpdatedAt())) {
|
2022-10-01 06:16:19 +02:00
|
|
|
infoBuilder
|
|
|
|
.append(context.getString(R.string.colorfulBulletSpan))
|
|
|
|
.append(context.getString(R.string.modifiedText));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-19 06:10:05 +02:00
|
|
|
String info = infoBuilder.toString();
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
// label view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("label")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
int color = Color.parseColor("#" + issueComment.getLabel().getColor());
|
|
|
|
int height = AppUtil.getPixelsFromDensity(context, 20);
|
|
|
|
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
TextDrawable drawable =
|
|
|
|
TextDrawable.builder()
|
|
|
|
.beginConfig()
|
|
|
|
.useFont(Typeface.DEFAULT)
|
|
|
|
.textColor(new ColorInverter().getContrastColor(color))
|
|
|
|
.fontSize(textSize)
|
|
|
|
.width(
|
|
|
|
LabelWidthCalculator.calculateLabelWidth(
|
|
|
|
issueComment.getLabel().getName(),
|
|
|
|
Typeface.DEFAULT,
|
|
|
|
textSize,
|
|
|
|
AppUtil.getPixelsFromDensity(context, 10)))
|
|
|
|
.height(height)
|
|
|
|
.endConfig()
|
|
|
|
.buildRoundRect(
|
|
|
|
issueComment.getLabel().getName(),
|
|
|
|
color,
|
|
|
|
AppUtil.getPixelsFromDensity(context, 18));
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView textView = new TextView(context);
|
2022-09-19 06:10:05 +02:00
|
|
|
String text;
|
2022-09-14 20:40:44 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getBody().equals("")) {
|
|
|
|
text =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineRemovedLabel,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info);
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
|
|
|
} else {
|
|
|
|
text =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineAddedLabel,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info);
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_tag));
|
2022-09-14 20:40:44 +02:00
|
|
|
|
2022-09-19 06:10:05 +02:00
|
|
|
SpannableString spannableString = new SpannableString(text.replace('|', ' '));
|
2022-09-14 20:40:44 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
drawable.setBounds(
|
|
|
|
0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
2022-09-14 20:40:44 +02:00
|
|
|
ImageSpan image = new ImageSpan(drawable);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
new Handler()
|
|
|
|
.postDelayed(
|
|
|
|
() -> {
|
|
|
|
spannableString.setSpan(
|
|
|
|
image,
|
|
|
|
text.indexOf('|'),
|
|
|
|
text.indexOf('|') + 1,
|
|
|
|
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
|
|
textView.setText(spannableString);
|
|
|
|
timelineData.addView(textView);
|
|
|
|
},
|
|
|
|
250);
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
// pull/push/commit data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("pull_push")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
|
|
|
JSONObject commitsObj = null;
|
|
|
|
try {
|
|
|
|
commitsObj = new JSONObject(issueComment.getBody());
|
2022-09-21 07:43:00 +02:00
|
|
|
} catch (JSONException ignored) {
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
JSONArray commitsShaArray = null;
|
|
|
|
try {
|
|
|
|
commitsShaArray = Objects.requireNonNull(commitsObj).getJSONArray("commit_ids");
|
2022-09-21 07:43:00 +02:00
|
|
|
} catch (JSONException ignored) {
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
String commitText =
|
|
|
|
context.getResources().getString(R.string.commits).toLowerCase();
|
|
|
|
if (Objects.requireNonNull(commitsShaArray).length() == 1) {
|
|
|
|
commitText =
|
|
|
|
context.getResources().getString(R.string.commitText).toLowerCase();
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
String commitString =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineAddedCommit,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
commitText,
|
|
|
|
info);
|
2022-09-14 20:40:44 +02:00
|
|
|
start.setText(HtmlCompat.fromHtml(commitString, HtmlCompat.FROM_HTML_MODE_LEGACY));
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
|
|
|
timelineData.setOrientation(LinearLayout.VERTICAL);
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_commit));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
for (int i = 0; i < Objects.requireNonNull(commitsShaArray).length(); i++) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
String timelineCommits =
|
|
|
|
"<font color='"
|
|
|
|
+ ResourcesCompat.getColor(
|
|
|
|
context.getResources(), R.color.lightBlue, null)
|
|
|
|
+ "'>"
|
|
|
|
+ StringUtils.substring(
|
|
|
|
String.valueOf(commitsShaArray.get(i)), 0, 10)
|
|
|
|
+ "</font>";
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView dynamicCommitTv = new TextView(context);
|
|
|
|
dynamicCommitTv.setId(View.generateViewId());
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
dynamicCommitTv.setText(
|
|
|
|
HtmlCompat.fromHtml(
|
|
|
|
timelineCommits, HtmlCompat.FROM_HTML_MODE_LEGACY));
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
JSONArray finalCommitsArray = commitsShaArray;
|
|
|
|
int finalI = i;
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
dynamicCommitTv.setOnClickListener(
|
|
|
|
v14 -> {
|
|
|
|
intent =
|
|
|
|
IssueContext.fromIntent(
|
|
|
|
((IssueDetailActivity) context)
|
|
|
|
.getIntent())
|
|
|
|
.getRepository()
|
|
|
|
.getIntent(context, CommitDetailActivity.class);
|
|
|
|
try {
|
|
|
|
intent.putExtra(
|
|
|
|
"sha", (String) finalCommitsArray.get(finalI));
|
|
|
|
} catch (JSONException ignored) {
|
|
|
|
}
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
timelineData.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
timelineData.addView(dynamicCommitTv);
|
2022-09-21 07:43:00 +02:00
|
|
|
} catch (JSONException ignored) {
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// assignees data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("assignees")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.isRemovedAssignee()) {
|
|
|
|
|
|
|
|
if (issueComment
|
|
|
|
.getUser()
|
|
|
|
.getLogin()
|
|
|
|
.equalsIgnoreCase(issueComment.getAssignee().getLogin())) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineAssigneesRemoved,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
} else {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineAssigneesUnassigned,
|
|
|
|
issueComment.getAssignee().getLogin(),
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
|
|
|
} else {
|
|
|
|
if (issueComment
|
|
|
|
.getUser()
|
|
|
|
.getLogin()
|
|
|
|
.equalsIgnoreCase(issueComment.getAssignee().getLogin())) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineAssigneesSelfAssigned,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
} else {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineAssigneesAssigned,
|
|
|
|
issueComment.getAssignee().getLogin(),
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_person));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// milestone data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("milestone")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getMilestone() != null) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineMilestoneAdded,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getMilestone().getTitle(),
|
|
|
|
info));
|
|
|
|
} else {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineMilestoneRemoved,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getOldMilestone().getTitle(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_milestone));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// status view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("close")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("reopen")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("merge_pull")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("commit_ref")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issue.getIssueType().equalsIgnoreCase("Issue")) {
|
|
|
|
if (issueComment.getType().equals("close")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusClosedIssue,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources()
|
|
|
|
.getColor(R.color.iconIssuePrClosedColor, null));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("reopen")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusReopenedIssue,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("commit_ref")) {
|
|
|
|
String commitString =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusRefIssue,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
ResourcesCompat.getColor(
|
|
|
|
context.getResources(), R.color.lightBlue, null),
|
|
|
|
context.getResources()
|
|
|
|
.getString(R.string.commitText)
|
|
|
|
.toLowerCase(),
|
|
|
|
info);
|
|
|
|
start.setText(
|
|
|
|
HtmlCompat.fromHtml(
|
|
|
|
commitString, HtmlCompat.FROM_HTML_MODE_LEGACY));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
|
|
|
|
|
|
|
|
start.setOnClickListener(
|
|
|
|
v14 -> {
|
|
|
|
intent =
|
|
|
|
IssueContext.fromIntent(
|
|
|
|
((IssueDetailActivity) context)
|
|
|
|
.getIntent())
|
|
|
|
.getRepository()
|
|
|
|
.getIntent(context, CommitDetailActivity.class);
|
|
|
|
intent.putExtra("sha", issueComment.getRefCommitSha());
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_issue));
|
|
|
|
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
|
|
|
if (issueComment.getType().equalsIgnoreCase("close")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusClosedPr,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_pull_request));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources()
|
|
|
|
.getColor(R.color.iconIssuePrClosedColor, null));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("merge_pull")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusMergedPr,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_pull_request));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconPrMergedColor, null));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("commit_ref")) {
|
|
|
|
String commitString =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusRefPr,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
ResourcesCompat.getColor(
|
|
|
|
context.getResources(), R.color.lightBlue, null),
|
|
|
|
context.getResources()
|
|
|
|
.getString(R.string.commitText)
|
|
|
|
.toLowerCase(),
|
|
|
|
info);
|
|
|
|
start.setText(
|
|
|
|
HtmlCompat.fromHtml(
|
|
|
|
commitString, HtmlCompat.FROM_HTML_MODE_LEGACY));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
|
|
|
|
|
|
|
|
start.setOnClickListener(
|
|
|
|
v14 -> {
|
|
|
|
intent =
|
|
|
|
IssueContext.fromIntent(
|
|
|
|
((IssueDetailActivity) context)
|
|
|
|
.getIntent())
|
|
|
|
.getRepository()
|
|
|
|
.getIntent(context, CommitDetailActivity.class);
|
|
|
|
intent.putExtra("sha", issueComment.getRefCommitSha());
|
|
|
|
context.startActivity(intent);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineStatusReopenedPr,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_pull_request));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// review data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("review_request")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("review")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("dismiss_review")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("review")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineView.setVisibility(View.GONE);
|
|
|
|
timelineDividerView.setVisibility(View.GONE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("dismiss_review")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineView.setVisibility(View.GONE);
|
|
|
|
timelineDividerView.setVisibility(View.GONE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("review_request")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineReviewRequest,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getAssignee().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_unwatch));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// change title data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("change_title")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
2022-09-21 07:43:00 +02:00
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineChangeTitle,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getOldTitle(),
|
|
|
|
issueComment.getNewTitle(),
|
|
|
|
info));
|
2022-09-14 20:40:44 +02:00
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_edit));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// lock/unlock data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("lock")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("unlock")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("lock")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineLocked,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getBody(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_lock));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("unlock")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineUnlocked,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_key));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// dependency data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("add_dependency")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("remove_dependency")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("add_dependency")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineDependencyAdded,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getDependentIssue().getNumber(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("remove_dependency")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineDependencyRemoved,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getDependentIssue().getNumber(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_dependency));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// project data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("project")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("project_board")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getProjectId() > 0) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineProjectAdded,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
} else {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineProjectRemoved,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_kanban));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// due date/deadline data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("added_deadline")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("modified_deadline")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("removed_deadline")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-19 06:10:05 +02:00
|
|
|
// TODO pretty-print
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("added_deadline")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
start.setText(
|
2022-09-21 07:43:00 +02:00
|
|
|
context.getString(
|
|
|
|
R.string.timelineDueDateAdded,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getBody(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("modified_deadline")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineDueDateModified,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getBody().split("\\|")[0],
|
|
|
|
issueComment.getBody().split("\\|")[1],
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("removed_deadline")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineDueDateRemoved,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getBody(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_clock));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// branch data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("change_target_branch")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("delete_branch")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("change_target_branch")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineBranchChanged,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getOldRef(),
|
|
|
|
issueComment.getNewRef(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("delete_branch")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineBranchDeleted,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getOldRef(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_branch));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// time tracking data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("start_tracking")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("stop_tracking")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("cancel_tracking")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("add_time_manual")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("delete_time_manual")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
TextView start = new TextView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("start_tracking")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineTimeTrackingStart,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("stop_tracking")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineTimeTrackingStop,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("cancel_tracking")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineTimeTrackingCancel,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("add_time_manual")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineTimeTrackingAddManualTime,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getBody(),
|
|
|
|
info));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("delete_time_manual")) {
|
|
|
|
start.setText(
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineTimeTrackingDeleteManualTime,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getBody(),
|
|
|
|
info));
|
|
|
|
timelineIcon.setColorFilter(
|
|
|
|
context.getResources().getColor(R.color.iconIssuePrClosedColor, null));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
start.setTextSize(fontSize);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_clock));
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineData.addView(start);
|
|
|
|
}
|
|
|
|
// issue/pr refs data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("change_issue_ref")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("issue_ref")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("comment_ref")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("pull_ref")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
RecyclerView recyclerView = new RecyclerView(context);
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("change_issue_ref")) {
|
|
|
|
String text =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineChangeIssueRef,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getNewRef(),
|
|
|
|
info);
|
|
|
|
Markdown.render(
|
|
|
|
context,
|
|
|
|
EmojiParser.parseToUnicode(text),
|
|
|
|
recyclerView,
|
|
|
|
issue.getRepository());
|
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_branch));
|
|
|
|
} else if (issueComment.getType().equalsIgnoreCase("comment_ref")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("issue_ref")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("pull_ref")) {
|
|
|
|
|
|
|
|
if (issue.getIssueType().equalsIgnoreCase("Issue")) {
|
|
|
|
String text =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineRefIssue,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getRefIssue().getNumber(),
|
|
|
|
info);
|
|
|
|
Markdown.render(
|
|
|
|
context,
|
|
|
|
EmojiParser.parseToUnicode(text),
|
|
|
|
recyclerView,
|
|
|
|
issue.getRepository());
|
|
|
|
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
|
|
|
String text =
|
|
|
|
context.getString(
|
|
|
|
R.string.timelineRefPr,
|
|
|
|
issueComment.getUser().getLogin(),
|
|
|
|
issueComment.getRefIssue().getNumber(),
|
|
|
|
info);
|
|
|
|
Markdown.render(
|
|
|
|
context,
|
|
|
|
EmojiParser.parseToUnicode(text),
|
|
|
|
recyclerView,
|
|
|
|
issue.getRepository());
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
timelineIcon.setImageDrawable(
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_bookmark));
|
2022-09-14 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
timelineData.addView(recyclerView);
|
|
|
|
}
|
|
|
|
// code data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("code")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineView.setVisibility(View.GONE);
|
|
|
|
timelineDividerView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
// schedule pr view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
else if (issueComment.getType().equalsIgnoreCase("pull_scheduled_merge")
|
|
|
|
|| issueComment.getType().equalsIgnoreCase("pull_cancel_scheduled_merge")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineView.setVisibility(View.GONE);
|
|
|
|
timelineDividerView.setVisibility(View.GONE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
2022-09-14 20:40:44 +02:00
|
|
|
timelineView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// comment data view in timeline
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issueComment.getType().equalsIgnoreCase("comment")) {
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
author.setText(issueComment.getUser().getLogin());
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
PicassoService.getInstance(context)
|
|
|
|
.get()
|
|
|
|
.load(issueComment.getUser().getAvatarUrl())
|
|
|
|
.placeholder(R.drawable.loader_animated)
|
|
|
|
.transform(new RoundedTransformation(imgRadius, 0))
|
|
|
|
.resize(
|
|
|
|
AppUtil.getPixelsFromDensity(context, 35),
|
|
|
|
AppUtil.getPixelsFromDensity(context, 35))
|
|
|
|
.centerCrop()
|
|
|
|
.into(avatar);
|
|
|
|
|
|
|
|
Markdown.render(
|
|
|
|
context,
|
|
|
|
EmojiParser.parseToUnicode(issueComment.getBody()),
|
|
|
|
comment,
|
|
|
|
issue.getRepository());
|
2022-09-14 20:40:44 +02:00
|
|
|
|
2022-09-19 06:10:05 +02:00
|
|
|
information.setText(info);
|
2022-09-14 20:40:44 +02:00
|
|
|
|
|
|
|
Bundle bundle1 = new Bundle();
|
|
|
|
bundle1.putAll(bundle);
|
|
|
|
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
|
|
|
|
|
|
|
ReactionList reactionList = new ReactionList(context, bundle1);
|
|
|
|
|
|
|
|
commentReactionBadges.addView(reactionList);
|
2022-09-21 07:43:00 +02:00
|
|
|
reactionList.setOnReactionAddedListener(
|
|
|
|
() -> {
|
|
|
|
if (commentReactionBadges.getVisibility() != View.VISIBLE) {
|
|
|
|
commentReactionBadges.post(
|
|
|
|
() -> commentReactionBadges.setVisibility(View.VISIBLE));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2022-09-14 20:40:44 +02:00
|
|
|
commentView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
2020-04-03 18:48:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
}
|