mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Render emoji in issue/pr titles, commit msg and markdown files (#805)
Merge branch 'master' into render-emoji-in-titles Merge branch 'master' into render-emoji-in-titles Merge branch 'master' into render-emoji-in-titles # Conflicts: # app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java # app/src/main/java/org/mian/gitnex/adapters/IssuesAdapter.java # app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java Render emoji in issue/pr titles, commit msg and markdown files Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/805 Reviewed-by: opyale <opyale@noreply.codeberg.org> Co-Authored-By: M M Arif <mmarif@noreply.codeberg.org> Co-Committed-By: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
parent
b02c87b143
commit
20b203c4ad
@ -29,6 +29,7 @@ import androidx.appcompat.widget.Toolbar;
|
|||||||
import com.github.barteksc.pdfviewer.PDFView;
|
import com.github.barteksc.pdfviewer.PDFView;
|
||||||
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
||||||
import com.github.chrisbanes.photoview.PhotoView;
|
import com.github.chrisbanes.photoview.PhotoView;
|
||||||
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
@ -322,7 +323,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
}
|
}
|
||||||
else if(id == R.id.markdown) {
|
else if(id == R.id.markdown) {
|
||||||
|
|
||||||
new Markdown(ctx, appUtil.decodeBase64(tinyDB.getString("downloadFileContents")), singleFileContents);
|
new Markdown(ctx, EmojiParser.parseToUnicode(appUtil.decodeBase64(tinyDB.getString("downloadFileContents"))), singleFileContents);
|
||||||
|
|
||||||
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
private List<Integer> currentLabelsIds = new ArrayList<>();
|
private List<Integer> currentLabelsIds = new ArrayList<>();
|
||||||
private List<Integer> labelsIds = new ArrayList<>();
|
private List<Integer> labelsIds = new ArrayList<>();
|
||||||
private List<Labels> labelsList = new ArrayList<>();
|
private final List<Labels> labelsList = new ArrayList<>();
|
||||||
private List<Collaborators> assigneesList = new ArrayList<>();
|
private final List<Collaborators> assigneesList = new ArrayList<>();
|
||||||
private List<String> assigneesListData = new ArrayList<>();
|
private List<String> assigneesListData = new ArrayList<>();
|
||||||
private List<String> currentAssignees = new ArrayList<>();
|
private List<String> currentAssignees = new ArrayList<>();
|
||||||
|
|
||||||
@ -579,7 +579,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||||
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||||
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + singleIssue.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(singleIssue.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
String cleanIssueDescription = singleIssue.getBody().trim();
|
String cleanIssueDescription = singleIssue.getBody().trim();
|
||||||
|
|
||||||
new Markdown(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription);
|
new Markdown(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription);
|
||||||
|
@ -11,6 +11,7 @@ import android.widget.Button;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
@ -25,7 +26,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private Context ctx;
|
private final Context ctx;
|
||||||
private final int TYPE_LOAD = 0;
|
private final int TYPE_LOAD = 0;
|
||||||
private List<Commits> commitsList;
|
private List<Commits> commitsList;
|
||||||
private CommitsAdapter.OnLoadMoreListener loadMoreListener;
|
private CommitsAdapter.OnLoadMoreListener loadMoreListener;
|
||||||
@ -116,7 +117,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
commitTitle.setText(commitsModel.getCommit().getMessage());
|
commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage()));
|
||||||
commitCommitter.setText(ctx.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName()));
|
commitCommitter.setText(ctx.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName()));
|
||||||
|
|
||||||
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, ctx));
|
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, ctx));
|
||||||
|
@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
@ -33,7 +34,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private final int TYPE_LOAD = 0;
|
private final int TYPE_LOAD = 0;
|
||||||
private List<Issues> issuesList;
|
private List<Issues> issuesList;
|
||||||
private OnLoadMoreListener loadMoreListener;
|
private OnLoadMoreListener loadMoreListener;
|
||||||
@ -100,11 +101,11 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
|
|
||||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView issueNumber;
|
private final TextView issueNumber;
|
||||||
private ImageView issueAssigneeAvatar;
|
private final ImageView issueAssigneeAvatar;
|
||||||
private TextView issueTitle;
|
private final TextView issueTitle;
|
||||||
private TextView issueCreatedTime;
|
private final TextView issueCreatedTime;
|
||||||
private TextView issueCommentsCount;
|
private final TextView issueCommentsCount;
|
||||||
|
|
||||||
IssuesHolder(View itemView) {
|
IssuesHolder(View itemView) {
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
PicassoService.getInstance(context).get().load(issuesModel.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
PicassoService.getInstance(context).get().load(issuesModel.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
||||||
|
|
||||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + "</font>";
|
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + "</font>";
|
||||||
issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + issuesModel.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issuesModel.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
|
|
||||||
issueNumber.setText(String.valueOf(issuesModel.getNumber()));
|
issueNumber.setText(String.valueOf(issuesModel.getNumber()));
|
||||||
issueCommentsCount.setText(String.valueOf(issuesModel.getComments()));
|
issueCommentsCount.setText(String.valueOf(issuesModel.getComments()));
|
||||||
|
@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
@ -30,7 +31,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private final int TYPE_LOAD = 0;
|
private final int TYPE_LOAD = 0;
|
||||||
private List<PullRequests> prList;
|
private List<PullRequests> prList;
|
||||||
private PullRequestsAdapter.OnLoadMoreListener loadMoreListener;
|
private PullRequestsAdapter.OnLoadMoreListener loadMoreListener;
|
||||||
@ -97,15 +98,15 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
|
|
||||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView prNumber;
|
private final TextView prNumber;
|
||||||
private TextView prMergeable;
|
private final TextView prMergeable;
|
||||||
private TextView prHeadBranch;
|
private final TextView prHeadBranch;
|
||||||
private TextView prIsFork;
|
private final TextView prIsFork;
|
||||||
private TextView prForkFullName;
|
private final TextView prForkFullName;
|
||||||
private ImageView assigneeAvatar;
|
private final ImageView assigneeAvatar;
|
||||||
private TextView prTitle;
|
private final TextView prTitle;
|
||||||
private TextView prCreatedTime;
|
private final TextView prCreatedTime;
|
||||||
private TextView prCommentsCount;
|
private final TextView prCommentsCount;
|
||||||
|
|
||||||
PullRequestsHolder(View itemView) {
|
PullRequestsHolder(View itemView) {
|
||||||
|
|
||||||
@ -185,7 +186,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
}
|
}
|
||||||
|
|
||||||
String prNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + prModel.getNumber() + "</font>";
|
String prNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + prModel.getNumber() + "</font>";
|
||||||
prTitle.setText(HtmlCompat.fromHtml(prNumber_ + " " + prModel.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
prTitle.setText(HtmlCompat.fromHtml(prNumber_ + " " + EmojiParser.parseToUnicode(prModel.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
|
|
||||||
prNumber.setText(String.valueOf(prModel.getNumber()));
|
prNumber.setText(String.valueOf(prModel.getNumber()));
|
||||||
prMergeable.setText(String.valueOf(prModel.isMergeable()));
|
prMergeable.setText(String.valueOf(prModel.isMergeable()));
|
||||||
|
Loading…
Reference in New Issue
Block a user