From 6d2ffe0048172cefb911bb3c162b329a6efd3cd1 Mon Sep 17 00:00:00 2001 From: Jedi Burrell Date: Mon, 15 May 2017 10:27:02 -0400 Subject: [PATCH] FR Prepping. Preparation for future commit. --- app/build.gradle | 1 + .../ui/modules/editor/EditorActivity.java | 23 +++++++++-- .../gist/comments/GistCommentsFragment.java | 26 +++++++++++- .../comments/CommitCommentsFragments.java | 22 ++++++++++ .../timeline/IssueTimelineFragment.java | 27 +++++++++++- .../timeline/PullRequestTimelineFragment.java | 23 +++++++++++ .../ui/widgets/MentionsFontEditText.java | 41 +++++++++++++++++++ .../main_layouts/layout/editor_layout.xml | 8 +++- 8 files changed, 164 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/com/fastaccess/ui/widgets/MentionsFontEditText.java diff --git a/app/build.gradle b/app/build.gradle index ff92668b..93a65720 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -148,6 +148,7 @@ dependencies { compile 'com.github.nightwhistler:HtmlSpanner:0.4' compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.2' compile 'com.github.matthiasrobbers:shortbread:1.0.1' + compile 'com.linkedin.android.spyglass:spyglass:1.4.0' provided "org.projectlombok:lombok:${lombokVersion}" annotationProcessor 'io.requery:requery-processor:1.2.0' annotationProcessor "org.projectlombok:lombok:${lombokVersion}" diff --git a/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java b/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java index a9e7a5bb..45ba5094 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java @@ -11,9 +11,10 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.widget.CheckBox; -import android.widget.CompoundButton; import android.widget.LinearLayout; +import android.widget.ListView; +import com.fastaccess.BuildConfig; import com.fastaccess.R; import com.fastaccess.data.dao.model.Comment; import com.fastaccess.helper.ActivityHelper; @@ -28,14 +29,16 @@ import com.fastaccess.helper.ViewHelper; import com.fastaccess.provider.markdown.MarkDownProvider; import com.fastaccess.ui.base.BaseActivity; import com.fastaccess.ui.modules.editor.popup.EditorLinkImageDialogFragment; -import com.fastaccess.ui.widgets.FontEditText; import com.fastaccess.ui.widgets.FontTextView; import com.fastaccess.ui.widgets.ForegroundImageView; import com.fastaccess.ui.widgets.dialog.MessageDialogView; +import com.linkedin.android.spyglass.tokenization.impl.WordTokenizerConfig; +import com.linkedin.android.spyglass.ui.MentionsEditText; import butterknife.BindView; import butterknife.OnClick; import butterknife.OnTextChanged; +import es.dmoral.toasty.Toasty; import icepick.State; import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt; @@ -49,13 +52,20 @@ public class EditorActivity extends BaseActivity onLoadMore; + private ArrayList participants; + public static GistCommentsFragment newInstance(@NonNull String gistId) { GistCommentsFragment view = new GistCommentsFragment(); view.setArguments(Bundler.start().put("gistId", gistId).end()); @@ -83,6 +92,16 @@ public class GistCommentsFragment extends BaseFragment items, int page) { hideProgress(); + + participants = null; + participants = (ArrayList) Stream.of(items) + .map(comment -> comment.getUser().getLogin()) + .collect(Collectors.toList()); + HashSet hashSet = new HashSet(); + hashSet.addAll(participants); + participants.clear(); + participants.addAll(hashSet); + if (items == null || items.isEmpty()) { adapter.clear(); return; @@ -107,7 +126,7 @@ public class GistCommentsFragment extends BaseFragment participants; + public static CommitCommentsFragments newInstance(@NonNull String login, @NonNull String repoId, @NonNull String sha) { CommitCommentsFragments view = new CommitCommentsFragments(); view.setArguments(Bundler.start() @@ -87,6 +95,17 @@ public class CommitCommentsFragments extends BaseFragment items, int page) { hideProgress(); + + participants = null; + participants = (ArrayList) Stream.of(items) + .filter(value -> value.getType() == TimelineModel.COMMENT) + .map(value -> value.getComment()).map(comment-> comment.getUser().getLogin()) + .collect(Collectors.toList()); + HashSet hashSet = new HashSet(); + hashSet.addAll(participants); + participants.clear(); + participants.addAll(hashSet); + if (items == null || items.isEmpty()) { adapter.clear(); return; @@ -147,6 +166,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA_FOUR, item.getId()) .put(BundleConstant.EXTRA, item.getBody()) .put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.EDIT_COMMIT_COMMENT_EXTRA) + .putStringArrayList("participants", participants) .end()); View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler; ActivityHelper.startReveal(this, intent, view, BundleConstant.REQUEST_CODE); @@ -174,6 +194,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA_THREE, getPresenter().sha()) .put(BundleConstant.EXTRA, user != null ? "@" + user.getLogin() : "") .put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.NEW_COMMIT_COMMENT_EXTRA) + .putStringArrayList("participants", participants) .end()); View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler; ActivityHelper.startReveal(this, intent, view, BundleConstant.REQUEST_CODE); @@ -188,6 +209,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA_THREE, getPresenter().sha()) .put(BundleConstant.EXTRA, "@" + user.getLogin()) .put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.NEW_COMMIT_COMMENT_EXTRA) + .putStringArrayList("participants", participants) .put("message", message) .end()); View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler; diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/timeline/IssueTimelineFragment.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/timeline/IssueTimelineFragment.java index d8ab86c6..c89758a8 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/timeline/IssueTimelineFragment.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/timeline/IssueTimelineFragment.java @@ -2,12 +2,15 @@ package com.fastaccess.ui.modules.repos.issues.issue.details.timeline; import android.app.Activity; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.view.View; +import com.annimon.stream.Collectors; +import com.annimon.stream.Stream; import com.fastaccess.R; import com.fastaccess.data.dao.SparseBooleanArrayParcelable; import com.fastaccess.data.dao.TimelineModel; @@ -30,6 +33,9 @@ import com.fastaccess.ui.widgets.dialog.MessageDialogView; import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView; import com.fastaccess.ui.widgets.recyclerview.scroll.RecyclerFastScroller; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import butterknife.BindView; @@ -48,6 +54,8 @@ public class IssueTimelineFragment extends BaseFragment participants; + public static IssueTimelineFragment newInstance(@NonNull Issue issueModel) { IssueTimelineFragment view = new IssueTimelineFragment(); view.setArguments(Bundler.start().put(BundleConstant.ITEM, issueModel).end());//TODO fix this @@ -60,6 +68,19 @@ public class IssueTimelineFragment extends BaseFragment items) { hideProgress(); + + participants = null; + participants = (ArrayList) Stream.of(items) + .filter(value -> value.getType() == TimelineModel.COMMENT) + .map(value -> value.getComment()).map(comment-> comment.getUser().getLogin()) + .collect(Collectors.toList()); + HashSet hashSet = new HashSet(); + hashSet.addAll(participants); + participants.clear(); + participants.addAll(hashSet); + + System.out.println("READ THIS: " + participants); + if (items == null || items.isEmpty()) { adapter.clear(); return; @@ -96,7 +117,7 @@ public class IssueTimelineFragment extends BaseFragment participants; + public static PullRequestTimelineFragment newInstance(@NonNull PullRequest pullRequest) { PullRequestTimelineFragment view = new PullRequestTimelineFragment(); view.setArguments(Bundler.start().put(BundleConstant.ITEM, pullRequest).end());//TODO fix this @@ -61,6 +69,17 @@ public class PullRequestTimelineFragment extends BaseFragment items) { hideProgress(); + + participants = null; + participants = (ArrayList) Stream.of(items) + .filter(value -> value.getType() == TimelineModel.COMMENT) + .map(value -> value.getComment()).map(comment-> comment.getUser().getLogin()) + .collect(Collectors.toList()); + HashSet hashSet = new HashSet(); + hashSet.addAll(participants); + participants.clear(); + participants.addAll(hashSet); + if (items == null || items.isEmpty()) { adapter.clear(); return; @@ -141,6 +160,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA_FOUR, item.getId()) .put(BundleConstant.EXTRA, item.getBody()) .put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.EDIT_ISSUE_COMMENT_EXTRA) + .putStringArrayList("participants", participants) .end()); View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler; ActivityHelper.startReveal(this, intent, view, BundleConstant.REQUEST_CODE); @@ -165,6 +185,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA, id) .put(BundleConstant.YES_NO_EXTRA, true) .put(BundleConstant.EXTRA_TWO, isReviewComment) + .putStringArrayList("participants", participants) .end()) .show(getChildFragmentManager(), MessageDialogView.TAG); } @@ -178,6 +199,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA_THREE, getPresenter().number()) .put(BundleConstant.EXTRA, user != null ? "@" + user.getLogin() : "") .put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.NEW_ISSUE_COMMENT_EXTRA) + .putStringArrayList("participants", participants) .end()); View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler; ActivityHelper.startReveal(this, intent, view, BundleConstant.REQUEST_CODE); @@ -192,6 +214,7 @@ refresh.setRefreshing(true); .put(BundleConstant.EXTRA_THREE, getPresenter().number()) .put(BundleConstant.EXTRA, "@" + user.getLogin()) .put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.NEW_ISSUE_COMMENT_EXTRA) + .putStringArrayList("participants", participants) .put("message", message) .end()); View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler; diff --git a/app/src/main/java/com/fastaccess/ui/widgets/MentionsFontEditText.java b/app/src/main/java/com/fastaccess/ui/widgets/MentionsFontEditText.java new file mode 100644 index 00000000..14f9fdc4 --- /dev/null +++ b/app/src/main/java/com/fastaccess/ui/widgets/MentionsFontEditText.java @@ -0,0 +1,41 @@ +package com.fastaccess.ui.widgets; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.util.AttributeSet; +import android.view.inputmethod.EditorInfo; + +import com.fastaccess.helper.TypeFaceHelper; +import com.linkedin.android.spyglass.tokenization.impl.WordTokenizer; +import com.linkedin.android.spyglass.ui.MentionsEditText; +import com.linkedin.android.spyglass.ui.RichEditorView; + +/** + * Created by JediB on 5/15/2017. + */ + +public class MentionsFontEditText extends MentionsEditText{ + + public MentionsFontEditText(@NonNull Context context) { + super(context); + init(); + } + + public MentionsFontEditText(@NonNull Context context, AttributeSet attrs) { + super(context, attrs); + init(); + + } + + public MentionsFontEditText(@NonNull Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + private void init() { + if (isInEditMode()) return; + setInputType(getInputType() | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN); + setImeOptions(getImeOptions() | EditorInfo.IME_FLAG_NO_FULLSCREEN); + TypeFaceHelper.applyTypeface(this); + } +} diff --git a/app/src/main/res/layouts/main_layouts/layout/editor_layout.xml b/app/src/main/res/layouts/main_layouts/layout/editor_layout.xml index 53ee1c36..edbc4a7f 100644 --- a/app/src/main/res/layouts/main_layouts/layout/editor_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout/editor_layout.xml @@ -39,7 +39,7 @@ android:background="?dividerColor"/> - + +