From 20b203c4ad1bf8c4f42ed117e4922d72dfffc2d5 Mon Sep 17 00:00:00 2001 From: M M Arif Date: Tue, 26 Jan 2021 18:53:59 +0100 Subject: [PATCH] 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 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/805 Reviewed-by: opyale Co-Authored-By: M M Arif Co-Committed-By: M M Arif --- .../gitnex/activities/FileViewActivity.java | 3 ++- .../activities/IssueDetailActivity.java | 6 ++--- .../mian/gitnex/adapters/CommitsAdapter.java | 5 ++-- .../mian/gitnex/adapters/IssuesAdapter.java | 15 ++++++------ .../gitnex/adapters/PullRequestsAdapter.java | 23 ++++++++++--------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java b/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java index 650ec3e6..c533cdbc 100644 --- a/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java @@ -29,6 +29,7 @@ import androidx.appcompat.widget.Toolbar; import com.github.barteksc.pdfviewer.PDFView; import com.github.barteksc.pdfviewer.util.FitPolicy; import com.github.chrisbanes.photoview.PhotoView; +import com.vdurmont.emoji.EmojiParser; import org.apache.commons.io.FileUtils; import org.mian.gitnex.R; import org.mian.gitnex.clients.RetrofitClient; @@ -322,7 +323,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie } 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")) { diff --git a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java index e263953a..6a944713 100644 --- a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java @@ -90,8 +90,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt private List currentLabelsIds = new ArrayList<>(); private List labelsIds = new ArrayList<>(); - private List labelsList = new ArrayList<>(); - private List assigneesList = new ArrayList<>(); + private final List labelsList = new ArrayList<>(); + private final List assigneesList = new ArrayList<>(); private List assigneesListData = new ArrayList<>(); private List 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); String issueNumber_ = "" + appCtx.getResources() .getString(R.string.hash) + singleIssue.getNumber() + ""; - 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(); new Markdown(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription); diff --git a/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java index ae5ad6ac..609c4fa6 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java @@ -11,6 +11,7 @@ import android.widget.Button; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.vdurmont.emoji.EmojiParser; import org.mian.gitnex.R; import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.TimeHelper; @@ -25,7 +26,7 @@ import java.util.Locale; public class CommitsAdapter extends RecyclerView.Adapter { - private Context ctx; + private final Context ctx; private final int TYPE_LOAD = 0; private List commitsList; private CommitsAdapter.OnLoadMoreListener loadMoreListener; @@ -116,7 +117,7 @@ public class CommitsAdapter extends RecyclerView.Adapter { - private Context context; + private final Context context; private final int TYPE_LOAD = 0; private List issuesList; private OnLoadMoreListener loadMoreListener; @@ -100,11 +101,11 @@ public class IssuesAdapter extends RecyclerView.Adapter class IssuesHolder extends RecyclerView.ViewHolder { - private TextView issueNumber; - private ImageView issueAssigneeAvatar; - private TextView issueTitle; - private TextView issueCreatedTime; - private TextView issueCommentsCount; + private final TextView issueNumber; + private final ImageView issueAssigneeAvatar; + private final TextView issueTitle; + private final TextView issueCreatedTime; + private final TextView issueCommentsCount; IssuesHolder(View itemView) { @@ -163,7 +164,7 @@ public class IssuesAdapter extends RecyclerView.Adapter 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_ = "" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + ""; - 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())); issueCommentsCount.setText(String.valueOf(issuesModel.getComments())); diff --git a/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java index 480121c6..f29851d3 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java @@ -13,6 +13,7 @@ import androidx.annotation.NonNull; import androidx.core.content.res.ResourcesCompat; import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; +import com.vdurmont.emoji.EmojiParser; import org.mian.gitnex.R; import org.mian.gitnex.activities.IssueDetailActivity; import org.mian.gitnex.clients.PicassoService; @@ -30,7 +31,7 @@ import java.util.Locale; public class PullRequestsAdapter extends RecyclerView.Adapter { - private Context context; + private final Context context; private final int TYPE_LOAD = 0; private List prList; private PullRequestsAdapter.OnLoadMoreListener loadMoreListener; @@ -97,15 +98,15 @@ public class PullRequestsAdapter extends RecyclerView.Adapter" + context.getResources().getString(R.string.hash) + prModel.getNumber() + ""; - 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())); prMergeable.setText(String.valueOf(prModel.isMergeable()));