centerlized participants list into one place.

This commit is contained in:
Kosh 2017-05-16 00:04:24 +08:00
parent c28dab3b01
commit fab339a3d8
9 changed files with 141 additions and 197 deletions

View File

@ -27,6 +27,7 @@ import es.dmoral.toasty.Toasty;
public class AppHelper {
public static void hideKeyboard(@NonNull View view) {
InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);

View File

@ -4,10 +4,17 @@ import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import com.fastaccess.R;
import com.fastaccess.data.dao.TimelineModel;
import com.fastaccess.data.dao.model.Comment;
import com.fastaccess.data.dao.types.ReactionTypes;
import com.fastaccess.provider.tasks.git.ReactionService;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Kosh on 30 Mar 2017, 6:44 PM
*/
@ -101,4 +108,19 @@ public class CommentsHelper {
return getEmojiByUnicode(HEART);
}
@NonNull public static ArrayList<String> getUsers(@NonNull List<Comment> comments) {
return Stream.of(comments)
.map(comment -> comment.getUser().getLogin())
.distinct()
.collect(Collectors.toCollection(ArrayList::new));
}
@NonNull public static ArrayList<String> getUsersByTimeline(@NonNull List<TimelineModel> comments) {
return Stream.of(comments)
.filter(timelineModel -> timelineModel.getComment() != null && timelineModel.getComment().getUser() != null)
.map(comment -> comment.getComment().getUser().getLogin())
.distinct()
.collect(Collectors.toCollection(ArrayList::new));
}
}

View File

@ -2,7 +2,6 @@ package com.fastaccess.ui.modules.gists.gist.comments;
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;
@ -10,17 +9,15 @@ import android.support.annotation.StringRes;
import android.support.v4.widget.SwipeRefreshLayout;
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;
import com.fastaccess.data.dao.model.Comment;
import com.fastaccess.data.dao.model.User;
import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.provider.rest.loadmore.OnLoadMore;
import com.fastaccess.provider.timeline.CommentsHelper;
import com.fastaccess.ui.adapter.CommentsAdapter;
import com.fastaccess.ui.base.BaseFragment;
import com.fastaccess.ui.modules.editor.EditorActivity;
@ -28,9 +25,6 @@ import com.fastaccess.ui.widgets.StateLayout;
import com.fastaccess.ui.widgets.dialog.MessageDialogView;
import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import butterknife.BindView;
@ -53,8 +47,6 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
private CommentsAdapter adapter;
private OnLoadMore<String> onLoadMore;
private ArrayList<String> participants;
public static GistCommentsFragment newInstance(@NonNull String gistId) {
GistCommentsFragment view = new GistCommentsFragment();
view.setArguments(Bundler.start().put("gistId", gistId).end());
@ -92,16 +84,6 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
@Override public void onNotifyAdapter(@Nullable List<Comment> items, int page) {
hideProgress();
participants = null;
participants = (ArrayList<String>) Stream.of(items)
.map(comment -> comment.getUser().getLogin())
.collect(Collectors.toList());
HashSet<String> hashSet = new HashSet<String>();
hashSet.addAll(participants);
participants.clear();
participants.addAll(hashSet);
if (items == null || items.isEmpty()) {
adapter.clear();
return;
@ -160,7 +142,7 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
.put(BundleConstant.EXTRA, item.getBody())
.put(BundleConstant.EXTRA_FOUR, item.getId())
.put(BundleConstant.EXTRA_TYPE, EDIT_GIST_COMMENT_EXTRA)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsers(adapter.getData()))
.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);
@ -172,7 +154,7 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
.start()
.put(BundleConstant.ID, gistId)
.put(BundleConstant.EXTRA_TYPE, NEW_GIST_COMMENT_EXTRA)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsers(adapter.getData()))
.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);
@ -184,7 +166,7 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
.put(BundleConstant.EXTRA, id)
.put(BundleConstant.ID, gistId)
.put(BundleConstant.YES_NO_EXTRA, true)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsers(adapter.getData()))
.end())
.show(getChildFragmentManager(), MessageDialogView.TAG);
}
@ -196,7 +178,7 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
.put(BundleConstant.ID, gistId)
.put(BundleConstant.EXTRA, "@" + user.getLogin())
.put(BundleConstant.EXTRA_TYPE, NEW_GIST_COMMENT_EXTRA)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsers(adapter.getData()))
.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);
@ -209,7 +191,7 @@ public class GistCommentsFragment extends BaseFragment<GistCommentsMvp.View, Gis
.put(BundleConstant.ID, gistId)
.put(BundleConstant.EXTRA, "@" + user.getLogin())
.put(BundleConstant.EXTRA_TYPE, NEW_GIST_COMMENT_EXTRA)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsers(adapter.getData()))
.put("message", message)
.end());
View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler;

View File

@ -2,7 +2,6 @@ package com.fastaccess.ui.modules.repos.code.commit.details.comments;
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;
@ -10,8 +9,6 @@ import android.support.annotation.StringRes;
import android.support.v4.widget.SwipeRefreshLayout;
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;
@ -22,6 +19,7 @@ import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.provider.rest.loadmore.OnLoadMore;
import com.fastaccess.provider.timeline.CommentsHelper;
import com.fastaccess.provider.timeline.ReactionsProvider;
import com.fastaccess.ui.adapter.IssuePullsTimelineAdapter;
import com.fastaccess.ui.base.BaseFragment;
@ -31,9 +29,6 @@ import com.fastaccess.ui.widgets.StateLayout;
import com.fastaccess.ui.widgets.dialog.MessageDialogView;
import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import butterknife.BindView;
@ -53,8 +48,6 @@ public class CommitCommentsFragments extends BaseFragment<CommitCommentsMvp.View
private IssuePullsTimelineAdapter adapter;
private OnLoadMore onLoadMore;
private ArrayList<String> participants;
public static CommitCommentsFragments newInstance(@NonNull String login, @NonNull String repoId, @NonNull String sha) {
CommitCommentsFragments view = new CommitCommentsFragments();
view.setArguments(Bundler.start()
@ -95,17 +88,6 @@ public class CommitCommentsFragments extends BaseFragment<CommitCommentsMvp.View
@Override public void onNotifyAdapter(@Nullable List<TimelineModel> items, int page) {
hideProgress();
participants = null;
participants = (ArrayList<String>) Stream.of(items)
.filter(value -> value.getType() == TimelineModel.COMMENT)
.map(value -> value.getComment()).map(comment-> comment.getUser().getLogin())
.collect(Collectors.toList());
HashSet<String> hashSet = new HashSet<String>();
hashSet.addAll(participants);
participants.clear();
participants.addAll(hashSet);
if (items == null || items.isEmpty()) {
adapter.clear();
return;
@ -130,7 +112,7 @@ public class CommitCommentsFragments extends BaseFragment<CommitCommentsMvp.View
@Override public void showProgress(@StringRes int resId) {
refresh.setRefreshing(true);
refresh.setRefreshing(true);
stateLayout.showProgress();
}
@ -166,7 +148,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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.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);
@ -194,7 +176,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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.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);
@ -209,7 +191,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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.put("message", message)
.end());
View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler;

View File

@ -2,15 +2,12 @@ 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;
@ -21,6 +18,7 @@ import com.fastaccess.data.dao.types.ReactionTypes;
import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.provider.timeline.CommentsHelper;
import com.fastaccess.provider.timeline.ReactionsProvider;
import com.fastaccess.ui.adapter.IssuePullsTimelineAdapter;
import com.fastaccess.ui.adapter.viewholder.TimelineCommentsViewHolder;
@ -33,9 +31,6 @@ 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;
@ -51,10 +46,8 @@ public class IssueTimelineFragment extends BaseFragment<IssueTimelineMvp.View, I
@BindView(R.id.refresh) AppbarRefreshLayout refresh;
@BindView(R.id.fastScroller) RecyclerFastScroller fastScroller;
@BindView(R.id.stateLayout) StateLayout stateLayout;
private IssuePullsTimelineAdapter adapter;
@State SparseBooleanArrayParcelable sparseBooleanArray;
private ArrayList<String> participants;
private IssuePullsTimelineAdapter adapter;
public static IssueTimelineFragment newInstance(@NonNull Issue issueModel) {
IssueTimelineFragment view = new IssueTimelineFragment();
@ -68,17 +61,6 @@ public class IssueTimelineFragment extends BaseFragment<IssueTimelineMvp.View, I
@Override public void onNotifyAdapter(@Nullable List<TimelineModel> items) {
hideProgress();
participants = null;
participants = (ArrayList<String>) Stream.of(items)
.filter(value -> value.getType() == TimelineModel.COMMENT)
.map(value -> value.getComment()).map(comment-> comment.getUser().getLogin())
.collect(Collectors.toList());
HashSet<String> hashSet = new HashSet<String>();
hashSet.addAll(participants);
participants.clear();
participants.addAll(hashSet);
if (items == null || items.isEmpty()) {
adapter.clear();
return;
@ -145,7 +127,7 @@ public class IssueTimelineFragment extends BaseFragment<IssueTimelineMvp.View, I
.put(BundleConstant.EXTRA_FOUR, item.getId())
.put(BundleConstant.EXTRA, item.getBody())
.put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.EDIT_ISSUE_COMMENT_EXTRA)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.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,7 +147,7 @@ public class IssueTimelineFragment extends BaseFragment<IssueTimelineMvp.View, I
Bundler.start()
.put(BundleConstant.EXTRA, id)
.put(BundleConstant.YES_NO_EXTRA, true)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.end())
.show(getChildFragmentManager(), MessageDialogView.TAG);
}
@ -179,7 +161,7 @@ public class IssueTimelineFragment extends BaseFragment<IssueTimelineMvp.View, I
.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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.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);
@ -194,7 +176,7 @@ public class IssueTimelineFragment extends BaseFragment<IssueTimelineMvp.View, I
.put(BundleConstant.EXTRA_THREE, getPresenter().number())
.put(BundleConstant.EXTRA, "@" + user.getLogin())
.put(BundleConstant.EXTRA_TYPE, BundleConstant.ExtraTYpe.NEW_ISSUE_COMMENT_EXTRA)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.put("message", message)
.end());
View view = getActivity() != null && getActivity().findViewById(R.id.fab) != null ? getActivity().findViewById(R.id.fab) : recycler;

View File

@ -2,15 +2,12 @@ package com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.timel
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.ReviewCommentModel;
import com.fastaccess.data.dao.SparseBooleanArrayParcelable;
@ -22,6 +19,7 @@ import com.fastaccess.data.dao.types.ReactionTypes;
import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.provider.timeline.CommentsHelper;
import com.fastaccess.ui.adapter.IssuePullsTimelineAdapter;
import com.fastaccess.ui.adapter.viewholder.TimelineCommentsViewHolder;
import com.fastaccess.ui.base.BaseFragment;
@ -33,9 +31,6 @@ 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;
@ -55,8 +50,6 @@ public class PullRequestTimelineFragment extends BaseFragment<PullRequestTimelin
private IssuePullsTimelineAdapter adapter;
@State SparseBooleanArrayParcelable sparseBooleanArray;
private ArrayList<String> participants;
public static PullRequestTimelineFragment newInstance(@NonNull PullRequest pullRequest) {
PullRequestTimelineFragment view = new PullRequestTimelineFragment();
view.setArguments(Bundler.start().put(BundleConstant.ITEM, pullRequest).end());//TODO fix this
@ -69,17 +62,6 @@ public class PullRequestTimelineFragment extends BaseFragment<PullRequestTimelin
@Override public void onNotifyAdapter(@Nullable List<TimelineModel> items) {
hideProgress();
participants = null;
participants = (ArrayList<String>) Stream.of(items)
.filter(value -> value.getType() == TimelineModel.COMMENT)
.map(value -> value.getComment()).map(comment-> comment.getUser().getLogin())
.collect(Collectors.toList());
HashSet<String> hashSet = new HashSet<String>();
hashSet.addAll(participants);
participants.clear();
participants.addAll(hashSet);
if (items == null || items.isEmpty()) {
adapter.clear();
return;
@ -118,7 +100,7 @@ public class PullRequestTimelineFragment extends BaseFragment<PullRequestTimelin
@Override public void showProgress(@StringRes int resId) {
refresh.setRefreshing(true);
refresh.setRefreshing(true);
stateLayout.showProgress();
}
@ -160,7 +142,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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.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);
@ -185,7 +167,7 @@ refresh.setRefreshing(true);
.put(BundleConstant.EXTRA, id)
.put(BundleConstant.YES_NO_EXTRA, true)
.put(BundleConstant.EXTRA_TWO, isReviewComment)
.putStringArrayList("participants", participants)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.end())
.show(getChildFragmentManager(), MessageDialogView.TAG);
}
@ -199,7 +181,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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.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);
@ -214,15 +196,15 @@ 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)
.putStringArrayList("participants", CommentsHelper.getUsersByTimeline(adapter.getData()))
.put("message", message)
.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);
}
@Override
public void showReactionsPopup(@NonNull ReactionTypes type, @NonNull String login, @NonNull String repoId, long idOrNumber, int reactionType) {
@Override public void showReactionsPopup(@NonNull ReactionTypes type, @NonNull String login, @NonNull String repoId,
long idOrNumber, int reactionType) {
ReactionsDialogFragment.newInstance(login, repoId, type, idOrNumber, reactionType).show(getChildFragmentManager(), "ReactionsDialogFragment");
}

View File

@ -1,6 +1,5 @@
package com.fastaccess.ui.modules.settings;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
@ -12,7 +11,6 @@ import android.widget.RadioButton;
import android.widget.RadioGroup;
import com.fastaccess.R;
import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.helper.PrefHelper;
import com.fastaccess.ui.base.BaseBottomSheetDialog;
import com.fastaccess.ui.widgets.FontButton;
@ -31,91 +29,88 @@ import static android.app.Activity.RESULT_OK;
*/
public class LanguageBottomSheetDialog extends BaseBottomSheetDialog {
public interface LanguageDialogListener {
void onDismissed();
}
public interface LanguageDialogListener {
void onDismissed();
}
public static final String TAG = LanguageBottomSheetDialog.class.getSimpleName();
public static final String TAG = LanguageBottomSheetDialog.class.getSimpleName();
private String names[];
private String values[];
private String names[];
private String values[];
@BindView(R.id.title)
FontTextView title;
@BindView(R.id.picker)
RadioGroup radioGroup;
@BindView(R.id.cancel)
FontButton cancel;
@BindView(R.id.ok) FontButton ok;
private SlackBottomSheetDialog.SlackDialogListener listener;
@BindView(R.id.title) FontTextView title;
@BindView(R.id.picker) RadioGroup radioGroup;
@BindView(R.id.cancel) FontButton cancel;
@BindView(R.id.ok) FontButton ok;
private SlackBottomSheetDialog.SlackDialogListener listener;
@Override public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof SlackBottomSheetDialog.SlackDialogListener) {
listener = (SlackBottomSheetDialog.SlackDialogListener) context;
}
@Override public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof SlackBottomSheetDialog.SlackDialogListener) {
listener = (SlackBottomSheetDialog.SlackDialogListener) context;
}
names = context.getResources().getStringArray(R.array.languages_array);
values = context.getResources().getStringArray(R.array.languages_array_values);
}
names = context.getResources().getStringArray(R.array.languages_array);
values = context.getResources().getStringArray(R.array.languages_array_values);
}
@Override public void onDetach() {
listener = null;
super.onDetach();
}
@Override public void onDetach() {
listener = null;
super.onDetach();
}
@Override protected int layoutRes() {
return R.layout.picker_dialog;
}
@Override protected int layoutRes() {
return R.layout.picker_dialog;
}
@OnClick({R.id.cancel, R.id.ok}) public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.cancel:
getActivity().setResult(RESULT_CANCELED);
}
if (listener != null) listener.onDismissed();
dismiss();
}
@OnClick({R.id.cancel, R.id.ok}) public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.cancel:
getActivity().setResult(RESULT_CANCELED);
}
if (listener != null) listener.onDismissed();
dismiss();
}
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
int selected = Arrays.asList(values).indexOf(PrefHelper.getString("app_language"));
String language = PrefHelper.getString("app_language");
cancel.setText(R.string.no);
ok.setText(R.string.yes);
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
int selected = Arrays.asList(values).indexOf(PrefHelper.getString("app_language"));
String language = PrefHelper.getString("app_language");
cancel.setText(R.string.no);
ok.setText(R.string.yes);
for (int i = 0; i < names.length; i++) {
RadioButton radioButtonView = new RadioButton(getContext());
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
radioButtonView.setLayoutParams(params);
radioButtonView.setText(names[i]);
radioButtonView.setId(i);
radioButtonView.setGravity(Gravity.CENTER_VERTICAL);
radioButtonView.setPadding((int) getResources().getDimension(R.dimen.spacing_xs_large), (int) getResources().getDimension(R.dimen
.spacing_xs_large),
(int) getResources().getDimension(R.dimen.spacing_xs_large), (int) getResources().getDimension(R.dimen.spacing_xs_large));
radioGroup.addView(radioButtonView);
if (i == selected)
radioGroup.check(i);
}
for (int i = 0; i < names.length; i++) {
RadioButton radioButtonView = new RadioButton(getContext());
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
radioButtonView.setLayoutParams(params);
radioButtonView.setText(names[i]);
radioButtonView.setId(i);
radioButtonView.setGravity(Gravity.CENTER_VERTICAL);
radioButtonView.setPadding((int) getResources().getDimension(R.dimen.spacing_xs_large), (int) getResources().getDimension(R.dimen
.spacing_xs_large),
(int) getResources().getDimension(R.dimen.spacing_xs_large), (int) getResources().getDimension(R.dimen.spacing_xs_large));
radioGroup.addView(radioButtonView);
if (i == selected)
radioGroup.check(i);
}
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
int index = radioGroup.indexOfChild(radioGroup.findViewById(radioGroup.getCheckedRadioButtonId()));
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
int index = radioGroup.indexOfChild(radioGroup.findViewById(radioGroup.getCheckedRadioButtonId()));
PrefHelper.set("app_language", values[index]);
if (language != values[index])
getActivity().setResult(RESULT_OK);
});
PrefHelper.set("app_language", values[index]);
if (language != values[index])
getActivity().setResult(RESULT_OK);
});
}
}
@Override protected void onHidden() {
if (listener != null) listener.onDismissed();
super.onHidden();
}
@Override protected void onHidden() {
if (listener != null) listener.onDismissed();
super.onHidden();
}
@Override protected void onDismissedByScrolling() {
if (listener != null) listener.onDismissed();
super.onDismissedByScrolling();
}
@Override protected void onDismissedByScrolling() {
if (listener != null) listener.onDismissed();
super.onDismissedByScrolling();
}
}

View File

@ -6,36 +6,34 @@ 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 class MentionsFontEditText extends MentionsEditText {
public MentionsFontEditText(@NonNull Context context) {
super(context);
init();
}
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) {
super(context, attrs);
init();
}
}
public MentionsFontEditText(@NonNull Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
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);
}
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);
}
}

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:pathData="M7.58,4.08L6.15,2.65C3.75,4.48 2.17,7.3 2.03,10.5h2c0.15,-2.65 1.51,-4.97 3.55,-6.42zM19.97,10.5h2c-0.15,-3.2 -1.73,-6.02 -4.12,-7.85l-1.42,1.43c2.02,1.45 3.39,3.77 3.54,6.42zM18,11c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2v-5zM12,22c0.14,0 0.27,-0.01 0.4,-0.04 0.65,-0.14 1.18,-0.58 1.44,-1.18 0.1,-0.24 0.15,-0.5 0.15,-0.78h-4c0.01,1.1 0.9,2 2.01,2z"
android:fillColor="?icon_color"/>
</vector>
android:fillColor="?icon_color"
android:pathData="M7.58,4.08L6.15,2.65C3.75,4.48 2.17,7.3 2.03,10.5h2c0.15,-2.65 1.51,-4.97 3.55,-6.42zM19.97,10.5h2c-0.15,-3.2 -1.73,-6.02 -4.12,-7.85l-1.42,1.43c2.02,1.45 3.39,3.77 3.54,6.42zM18,11c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2v-5zM12,22c0.14,0 0.27,-0.01 0.4,-0.04 0.65,-0.14 1.18,-0.58 1.44,-1.18 0.1,-0.24 0.15,-0.5 0.15,-0.78h-4c0.01,1.1 0.9,2 2.01,2z"/>
</vector>