mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Add more themeing options for links, private messages, etc. Restructure class files.
This commit is contained in:
parent
4f8b313b3c
commit
90f741e9e1
@ -49,14 +49,14 @@ import io.noties.markwon.recycler.table.TableEntryPlugin;
|
|||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||||
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
|
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.CommentData;
|
import ml.docilealligator.infinityforreddit.Comment.Comment;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SendComment;
|
import ml.docilealligator.infinityforreddit.Comment.SendComment;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -330,13 +330,13 @@ public class CommentActivity extends BaseActivity {
|
|||||||
mAccessToken,
|
mAccessToken,
|
||||||
new SendComment.SendCommentListener() {
|
new SendComment.SendCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void sendCommentSuccess(CommentData commentData) {
|
public void sendCommentSuccess(Comment comment) {
|
||||||
isSubmitting = false;
|
isSubmitting = false;
|
||||||
item.setEnabled(true);
|
item.setEnabled(true);
|
||||||
item.getIcon().setAlpha(255);
|
item.getIcon().setAlpha(255);
|
||||||
Toast.makeText(CommentActivity.this, R.string.send_comment_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(CommentActivity.this, R.string.send_comment_success, Toast.LENGTH_SHORT).show();
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(RETURN_EXTRA_COMMENT_DATA_KEY, commentData);
|
returnIntent.putExtra(RETURN_EXTRA_COMMENT_DATA_KEY, comment);
|
||||||
returnIntent.putExtra(EXTRA_PARENT_FULLNAME_KEY, parentFullname);
|
returnIntent.putExtra(EXTRA_PARENT_FULLNAME_KEY, parentFullname);
|
||||||
if (isReplying) {
|
if (isReplying) {
|
||||||
returnIntent.putExtra(EXTRA_PARENT_POSITION_KEY, parentPosition);
|
returnIntent.putExtra(EXTRA_PARENT_POSITION_KEY, parentPosition);
|
||||||
|
@ -38,7 +38,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask
|
|||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
import ml.docilealligator.infinityforreddit.FetchMessages;
|
import ml.docilealligator.infinityforreddit.Message.FetchMessage;
|
||||||
import ml.docilealligator.infinityforreddit.Fragment.InboxFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.InboxFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
@ -280,14 +280,14 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
InboxFragment fragment = new InboxFragment();
|
InboxFragment fragment = new InboxFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_INBOX);
|
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
} else {
|
} else {
|
||||||
InboxFragment fragment = new InboxFragment();
|
InboxFragment fragment = new InboxFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_MESSAGES);
|
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MESSAGES);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo;
|
|||||||
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.PullNotificationWorker;
|
import ml.docilealligator.infinityforreddit.PullNotificationWorker;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
|
@ -62,7 +62,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask
|
|||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostCommentSortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostCommentSortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.CommentData;
|
import ml.docilealligator.infinityforreddit.Comment.Comment;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer;
|
import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer;
|
||||||
import ml.docilealligator.infinityforreddit.DeleteThing;
|
import ml.docilealligator.infinityforreddit.DeleteThing;
|
||||||
@ -72,18 +72,18 @@ import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
|
|||||||
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
|
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
|
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
|
||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
import ml.docilealligator.infinityforreddit.FetchComment;
|
import ml.docilealligator.infinityforreddit.Comment.FetchComment;
|
||||||
import ml.docilealligator.infinityforreddit.FetchRemovedComment;
|
import ml.docilealligator.infinityforreddit.FetchRemovedComment;
|
||||||
import ml.docilealligator.infinityforreddit.FetchRemovedPost;
|
import ml.docilealligator.infinityforreddit.FetchRemovedPost;
|
||||||
import ml.docilealligator.infinityforreddit.Flair;
|
import ml.docilealligator.infinityforreddit.Flair;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.ParseComment;
|
import ml.docilealligator.infinityforreddit.Comment.ParseComment;
|
||||||
import ml.docilealligator.infinityforreddit.Post.FetchPost;
|
import ml.docilealligator.infinityforreddit.Post.FetchPost;
|
||||||
import ml.docilealligator.infinityforreddit.Post.HidePost;
|
import ml.docilealligator.infinityforreddit.Post.HidePost;
|
||||||
import ml.docilealligator.infinityforreddit.Post.ParsePost;
|
import ml.docilealligator.infinityforreddit.Post.ParsePost;
|
||||||
import ml.docilealligator.infinityforreddit.Post.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
@ -126,7 +126,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
@State
|
@State
|
||||||
boolean isSingleCommentThreadMode = false;
|
boolean isSingleCommentThreadMode = false;
|
||||||
@State
|
@State
|
||||||
ArrayList<CommentData> comments;
|
ArrayList<Comment> comments;
|
||||||
@State
|
@State
|
||||||
ArrayList<String> children;
|
ArrayList<String> children;
|
||||||
@State
|
@State
|
||||||
@ -648,7 +648,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
ParseComment.parseComment(response.body(), new ArrayList<>(), mLocale,
|
ParseComment.parseComment(response.body(), new ArrayList<>(), mLocale,
|
||||||
mExpandChildren, new ParseComment.ParseCommentListener() {
|
mExpandChildren, new ParseComment.ParseCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentSuccess(ArrayList<CommentData> expandedComments, String parentId, ArrayList<String> moreChildrenFullnames) {
|
public void onParseCommentSuccess(ArrayList<Comment> expandedComments, String parentId, ArrayList<String> moreChildrenFullnames) {
|
||||||
ViewPostDetailActivity.this.children = moreChildrenFullnames;
|
ViewPostDetailActivity.this.children = moreChildrenFullnames;
|
||||||
|
|
||||||
hasMoreChildren = children.size() != 0;
|
hasMoreChildren = children.size() != 0;
|
||||||
@ -738,7 +738,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
FetchComment.fetchComments(retrofit, mAccessToken, mPost.getId(), commentId, sortType, mExpandChildren,
|
FetchComment.fetchComments(retrofit, mAccessToken, mPost.getId(), commentId, sortType, mExpandChildren,
|
||||||
mLocale, new FetchComment.FetchCommentListener() {
|
mLocale, new FetchComment.FetchCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchCommentSuccess(ArrayList<CommentData> expandedComments,
|
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments,
|
||||||
String parentId, ArrayList<String> children) {
|
String parentId, ArrayList<String> children) {
|
||||||
if (checkSortState && isSortingComments) {
|
if (checkSortState && isSortingComments) {
|
||||||
if (changeRefreshState) {
|
if (changeRefreshState) {
|
||||||
@ -840,7 +840,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
FetchComment.fetchMoreComment(retrofit, mAccessToken, children, mChildrenStartingIndex,
|
FetchComment.fetchMoreComment(retrofit, mAccessToken, children, mChildrenStartingIndex,
|
||||||
0, mExpandChildren, mLocale, new FetchComment.FetchMoreCommentListener() {
|
0, mExpandChildren, mLocale, new FetchComment.FetchMoreCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchMoreCommentSuccess(ArrayList<CommentData> expandedComments, int childrenStartingIndex) {
|
public void onFetchMoreCommentSuccess(ArrayList<Comment> expandedComments, int childrenStartingIndex) {
|
||||||
hasMoreChildren = childrenStartingIndex < children.size();
|
hasMoreChildren = childrenStartingIndex < children.size();
|
||||||
mAdapter.addComments(expandedComments, hasMoreChildren);
|
mAdapter.addComments(expandedComments, hasMoreChildren);
|
||||||
mChildrenStartingIndex = childrenStartingIndex;
|
mChildrenStartingIndex = childrenStartingIndex;
|
||||||
@ -1091,14 +1091,14 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showRemovedComment(CommentData comment, int position) {
|
public void showRemovedComment(Comment comment, int position) {
|
||||||
Toast.makeText(ViewPostDetailActivity.this, R.string.fetching_removed_comment, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewPostDetailActivity.this, R.string.fetching_removed_comment, Toast.LENGTH_SHORT).show();
|
||||||
FetchRemovedComment.fetchRemovedComment(
|
FetchRemovedComment.fetchRemovedComment(
|
||||||
pushshiftRetrofit,
|
pushshiftRetrofit,
|
||||||
comment,
|
comment,
|
||||||
new FetchRemovedComment.FetchRemovedCommentListener() {
|
new FetchRemovedComment.FetchRemovedCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void fetchSuccess(CommentData comment) {
|
public void fetchSuccess(Comment comment) {
|
||||||
mAdapter.editComment(comment.getAuthor(), comment.getCommentMarkdown(), position);
|
mAdapter.editComment(comment.getAuthor(), comment.getCommentMarkdown(), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1451,7 +1451,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
if (requestCode == WRITE_COMMENT_REQUEST_CODE) {
|
if (requestCode == WRITE_COMMENT_REQUEST_CODE) {
|
||||||
if (data != null && resultCode == RESULT_OK) {
|
if (data != null && resultCode == RESULT_OK) {
|
||||||
if (data.hasExtra(RETURN_EXTRA_COMMENT_DATA_KEY)) {
|
if (data.hasExtra(RETURN_EXTRA_COMMENT_DATA_KEY)) {
|
||||||
CommentData comment = data.getParcelableExtra(RETURN_EXTRA_COMMENT_DATA_KEY);
|
Comment comment = data.getParcelableExtra(RETURN_EXTRA_COMMENT_DATA_KEY);
|
||||||
if (comment != null && comment.getDepth() == 0) {
|
if (comment != null && comment.getDepth() == 0) {
|
||||||
mAdapter.addComment(comment);
|
mAdapter.addComment(comment);
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,11 +39,11 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
|
|||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Event.RepliedToPrivateMessageEvent;
|
import ml.docilealligator.infinityforreddit.Event.RepliedToPrivateMessageEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.Message;
|
import ml.docilealligator.infinityforreddit.Message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.ReplyMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReplyMessage;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
|
@ -70,7 +70,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
|
@ -69,6 +69,7 @@ import im.ene.toro.widget.Container;
|
|||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
@ -91,11 +92,11 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
|
|||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.CommentData;
|
import ml.docilealligator.infinityforreddit.Comment.Comment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Comment.FetchComment;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
|
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
|
||||||
import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager;
|
import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager;
|
||||||
import ml.docilealligator.infinityforreddit.FetchComment;
|
|
||||||
import ml.docilealligator.infinityforreddit.Post.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
@ -138,7 +139,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private Post mPost;
|
private Post mPost;
|
||||||
private ArrayList<CommentData> mVisibleComments;
|
private ArrayList<Comment> mVisibleComments;
|
||||||
private String mSubredditNamePrefixed;
|
private String mSubredditNamePrefixed;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private String mSingleCommentId;
|
private String mSingleCommentId;
|
||||||
@ -205,6 +206,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
private int mButtonTextColor;
|
private int mButtonTextColor;
|
||||||
private int mPostIconAndInfoColor;
|
private int mPostIconAndInfoColor;
|
||||||
private int mCommentIconAndInfoColor;
|
private int mCommentIconAndInfoColor;
|
||||||
|
private int mFullyCollapsedCommentBackgroundColor;
|
||||||
|
private int mAwardedCommentBackgroundColor;
|
||||||
|
|
||||||
private Drawable mCommentIcon;
|
private Drawable mCommentIcon;
|
||||||
private float mScale;
|
private float mScale;
|
||||||
@ -226,6 +229,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mGlide = glide;
|
mGlide = glide;
|
||||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
int markdownColor = customThemeWrapper.getPostContentColor();
|
int markdownColor = customThemeWrapper.getPostContentColor();
|
||||||
|
int linkColor = customThemeWrapper.getLinkColor();
|
||||||
mPostDetailMarkwon = Markwon.builder(mActivity)
|
mPostDetailMarkwon = Markwon.builder(mActivity)
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
@ -254,6 +258,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
|
}).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||||
|
builder.linkColor(linkColor);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
@ -280,6 +289,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
|
}).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||||
|
builder.linkColor(linkColor);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
@ -373,6 +387,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor();
|
mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor();
|
||||||
mCommentIconAndInfoColor = customThemeWrapper.getCommentIconAndInfoColor();
|
mCommentIconAndInfoColor = customThemeWrapper.getCommentIconAndInfoColor();
|
||||||
|
mFullyCollapsedCommentBackgroundColor = customThemeWrapper.getFullyCollapsedCommentBackgroundColor();
|
||||||
|
mAwardedCommentBackgroundColor = customThemeWrapper.getAwardedCommentBackgroundColor();
|
||||||
|
|
||||||
mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp);
|
mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp);
|
||||||
if (mCommentIcon != null) {
|
if (mCommentIcon != null) {
|
||||||
@ -443,7 +459,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = mVisibleComments.get(position - 2);
|
Comment comment = mVisibleComments.get(position - 2);
|
||||||
if (!comment.isPlaceHolder()) {
|
if (!comment.isPlaceHolder()) {
|
||||||
if (mFullyCollapseComment && comment.hasReply() && !comment.isExpanded() && comment.hasExpandedBefore()) {
|
if (mFullyCollapseComment && comment.hasReply() && !comment.isExpanded() && comment.hasExpandedBefore()) {
|
||||||
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
|
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
|
||||||
@ -461,7 +477,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = mVisibleComments.get(position - 1);
|
Comment comment = mVisibleComments.get(position - 1);
|
||||||
if (!comment.isPlaceHolder()) {
|
if (!comment.isPlaceHolder()) {
|
||||||
if (mFullyCollapseComment && comment.hasReply() && !comment.isExpanded() && comment.hasExpandedBefore()) {
|
if (mFullyCollapseComment && comment.hasReply() && !comment.isExpanded() && comment.hasExpandedBefore()) {
|
||||||
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
|
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
|
||||||
@ -743,7 +759,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (holder instanceof CommentViewHolder) {
|
} else if (holder instanceof CommentViewHolder) {
|
||||||
CommentData comment;
|
Comment comment;
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
||||||
} else {
|
} else {
|
||||||
@ -752,6 +768,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
if (mIsSingleCommentThreadMode && comment.getId().equals(mSingleCommentId)) {
|
if (mIsSingleCommentThreadMode && comment.getId().equals(mSingleCommentId)) {
|
||||||
((CommentViewHolder) holder).itemView.setBackgroundColor(mSingleCommentThreadBackgroundColor);
|
((CommentViewHolder) holder).itemView.setBackgroundColor(mSingleCommentThreadBackgroundColor);
|
||||||
|
} else if (comment.getAwards() != null && !comment.getAwards().equals("")) {
|
||||||
|
((CommentViewHolder) holder).itemView.setBackgroundColor(mAwardedCommentBackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
String authorPrefixed = "u/" + comment.getAuthor();
|
String authorPrefixed = "u/" + comment.getAuthor();
|
||||||
@ -859,12 +877,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case CommentData.VOTE_TYPE_UPVOTE:
|
case Comment.VOTE_TYPE_UPVOTE:
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
break;
|
break;
|
||||||
case CommentData.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
@ -895,7 +913,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
|
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
|
||||||
CommentData comment;
|
Comment comment;
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
||||||
} else {
|
} else {
|
||||||
@ -904,10 +922,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
String authorWithPrefix = "u/" + comment.getAuthor();
|
String authorWithPrefix = "u/" + comment.getAuthor();
|
||||||
((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
|
((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
|
||||||
if (comment.getMoreChildrenFullnames() != null) {
|
if (mShowElapsedTime) {
|
||||||
((CommentFullyCollapsedViewHolder) holder).nMoreRepliesTextView.setText(Integer.toString(1 + comment.getMoreChildrenFullnames().size()));
|
((CommentFullyCollapsedViewHolder) holder).commentTimeTextView.setText(Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((CommentFullyCollapsedViewHolder) holder).nMoreRepliesTextView.setText(Integer.toString(1));
|
((CommentFullyCollapsedViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore()));
|
((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore()));
|
||||||
|
|
||||||
@ -948,7 +966,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((CommentFullyCollapsedViewHolder) holder).verticalBlock.setLayoutParams(params);
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
||||||
CommentData placeholder;
|
Comment placeholder;
|
||||||
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
|
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
|
||||||
: mVisibleComments.get(holder.getAdapterPosition() - 1);
|
: mVisibleComments.get(holder.getAdapterPosition() - 1);
|
||||||
|
|
||||||
@ -1002,7 +1020,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
|
int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
|
||||||
int parentPosition = getParentPosition(commentPosition);
|
int parentPosition = getParentPosition(commentPosition);
|
||||||
if (parentPosition >= 0) {
|
if (parentPosition >= 0) {
|
||||||
CommentData parentComment = mVisibleComments.get(parentPosition);
|
Comment parentComment = mVisibleComments.get(parentPosition);
|
||||||
|
|
||||||
mVisibleComments.get(commentPosition).setLoadingMoreChildren(true);
|
mVisibleComments.get(commentPosition).setLoadingMoreChildren(true);
|
||||||
mVisibleComments.get(commentPosition).setLoadMoreChildrenFailed(false);
|
mVisibleComments.get(commentPosition).setLoadMoreChildrenFailed(false);
|
||||||
@ -1014,7 +1032,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mExpandChildren, mLocale,
|
mExpandChildren, mLocale,
|
||||||
new FetchComment.FetchMoreCommentListener() {
|
new FetchComment.FetchMoreCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchMoreCommentSuccess(ArrayList<CommentData> expandedComments,
|
public void onFetchMoreCommentSuccess(ArrayList<Comment> expandedComments,
|
||||||
int childrenStartingIndex) {
|
int childrenStartingIndex) {
|
||||||
if (mVisibleComments.size() > parentPosition
|
if (mVisibleComments.size() > parentPosition
|
||||||
&& parentComment.getFullName().equals(mVisibleComments.get(parentPosition).getFullName())) {
|
&& parentComment.getFullName().equals(mVisibleComments.get(parentPosition).getFullName())) {
|
||||||
@ -1287,7 +1305,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expandChildren(ArrayList<CommentData> comments, ArrayList<CommentData> newList, int position) {
|
private void expandChildren(ArrayList<Comment> comments, ArrayList<Comment> newList, int position) {
|
||||||
if (comments != null && comments.size() > 0) {
|
if (comments != null && comments.size() > 0) {
|
||||||
newList.addAll(position, comments);
|
newList.addAll(position, comments);
|
||||||
for (int i = 0; i < comments.size(); i++) {
|
for (int i = 0; i < comments.size(); i++) {
|
||||||
@ -1327,7 +1345,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComments(@NonNull ArrayList<CommentData> comments, boolean hasMoreComments) {
|
public void addComments(@NonNull ArrayList<Comment> comments, boolean hasMoreComments) {
|
||||||
if (mVisibleComments.size() == 0) {
|
if (mVisibleComments.size() == 0) {
|
||||||
isInitiallyLoading = false;
|
isInitiallyLoading = false;
|
||||||
isInitiallyLoadingFailed = false;
|
isInitiallyLoadingFailed = false;
|
||||||
@ -1364,7 +1382,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mHasMoreComments = hasMoreComments;
|
mHasMoreComments = hasMoreComments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComment(CommentData comment) {
|
public void addComment(Comment comment) {
|
||||||
if (mVisibleComments.size() == 0 || isInitiallyLoadingFailed) {
|
if (mVisibleComments.size() == 0 || isInitiallyLoadingFailed) {
|
||||||
notifyItemRemoved(1);
|
notifyItemRemoved(1);
|
||||||
}
|
}
|
||||||
@ -1378,7 +1396,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildComment(CommentData comment, String parentFullname, int parentPosition) {
|
public void addChildComment(Comment comment, String parentFullname, int parentPosition) {
|
||||||
if (!parentFullname.equals(mVisibleComments.get(parentPosition).getFullName())) {
|
if (!parentFullname.equals(mVisibleComments.get(parentPosition).getFullName())) {
|
||||||
for (int i = 0; i < mVisibleComments.size(); i++) {
|
for (int i = 0; i < mVisibleComments.size(); i++) {
|
||||||
if (parentFullname.equals(mVisibleComments.get(i).getFullName())) {
|
if (parentFullname.equals(mVisibleComments.get(i).getFullName())) {
|
||||||
@ -1391,7 +1409,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mVisibleComments.get(parentPosition).addChild(comment);
|
mVisibleComments.get(parentPosition).addChild(comment);
|
||||||
mVisibleComments.get(parentPosition).setHasReply(true);
|
mVisibleComments.get(parentPosition).setHasReply(true);
|
||||||
if (!mVisibleComments.get(parentPosition).isExpanded()) {
|
if (!mVisibleComments.get(parentPosition).isExpanded()) {
|
||||||
ArrayList<CommentData> newList = new ArrayList<>();
|
ArrayList<Comment> newList = new ArrayList<>();
|
||||||
expandChildren(mVisibleComments.get(parentPosition).getChildren(), newList, 0);
|
expandChildren(mVisibleComments.get(parentPosition).getChildren(), newList, 0);
|
||||||
mVisibleComments.get(parentPosition).setExpanded(true);
|
mVisibleComments.get(parentPosition).setExpanded(true);
|
||||||
mVisibleComments.addAll(parentPosition + 1, newList);
|
mVisibleComments.addAll(parentPosition + 1, newList);
|
||||||
@ -1417,7 +1435,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
|
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<CommentData> getVisibleComments() {
|
public ArrayList<Comment> getVisibleComments() {
|
||||||
return mVisibleComments;
|
return mVisibleComments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2799,7 +2817,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
||||||
|
|
||||||
moreButton.setOnClickListener(view -> {
|
moreButton.setOnClickListener(view -> {
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
|
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
|
||||||
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
@ -2831,7 +2849,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
|
|
||||||
Intent intent = new Intent(mActivity, CommentActivity.class);
|
Intent intent = new Intent(mActivity, CommentActivity.class);
|
||||||
intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, comment.getDepth() + 1);
|
intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, comment.getDepth() + 1);
|
||||||
@ -2856,21 +2874,21 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = APIUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
@ -2885,11 +2903,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position) {
|
||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -2918,21 +2936,21 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = APIUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
@ -2947,11 +2965,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -2970,7 +2988,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
});
|
});
|
||||||
|
|
||||||
saveButton.setOnClickListener(view -> {
|
saveButton.setOnClickListener(view -> {
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
||||||
@ -3018,13 +3036,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if (expandButton.getVisibility() == View.VISIBLE) {
|
if (expandButton.getVisibility() == View.VISIBLE) {
|
||||||
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
||||||
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
||||||
collapseChildren(commentPosition);
|
collapseChildren(commentPosition);
|
||||||
expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
|
expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
|
||||||
} else {
|
} else {
|
||||||
comment.setExpanded(true);
|
comment.setExpanded(true);
|
||||||
ArrayList<CommentData> newList = new ArrayList<>();
|
ArrayList<Comment> newList = new ArrayList<>();
|
||||||
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
||||||
mVisibleComments.get(commentPosition).setExpanded(true);
|
mVisibleComments.get(commentPosition).setExpanded(true);
|
||||||
mVisibleComments.addAll(commentPosition + 1, newList);
|
mVisibleComments.addAll(commentPosition + 1, newList);
|
||||||
@ -3082,8 +3100,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommentData getCurrentComment(RecyclerView.ViewHolder holder) {
|
private Comment getCurrentComment(RecyclerView.ViewHolder holder) {
|
||||||
CommentData comment;
|
Comment comment;
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
||||||
} else {
|
} else {
|
||||||
@ -3100,8 +3118,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
TextView usernameTextView;
|
TextView usernameTextView;
|
||||||
@BindView(R.id.score_text_view_item_comment_fully_collapsed)
|
@BindView(R.id.score_text_view_item_comment_fully_collapsed)
|
||||||
TextView scoreTextView;
|
TextView scoreTextView;
|
||||||
@BindView(R.id.more_count_text_view_item_comment_fully_collapsed)
|
@BindView(R.id.time_text_view_item_comment_fully_collapsed)
|
||||||
TextView nMoreRepliesTextView;
|
TextView commentTimeTextView;
|
||||||
@BindView(R.id.divider_item_load_comment_fully_collapsed)
|
@BindView(R.id.divider_item_load_comment_fully_collapsed)
|
||||||
View commentDivider;
|
View commentDivider;
|
||||||
|
|
||||||
@ -3109,6 +3127,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
|
|
||||||
|
itemView.setBackgroundColor(mFullyCollapsedCommentBackgroundColor);
|
||||||
|
usernameTextView.setTextColor(mUsernameColor);
|
||||||
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
|
||||||
if (mShowCommentDivider) {
|
if (mShowCommentDivider) {
|
||||||
commentDivider.setBackgroundColor(mDividerColor);
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
commentDivider.setVisibility(View.VISIBLE);
|
commentDivider.setVisibility(View.VISIBLE);
|
||||||
@ -3117,9 +3140,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
itemView.setOnClickListener(view -> {
|
itemView.setOnClickListener(view -> {
|
||||||
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
||||||
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
||||||
CommentData comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
comment.setExpanded(true);
|
comment.setExpanded(true);
|
||||||
ArrayList<CommentData> newList = new ArrayList<>();
|
ArrayList<Comment> newList = new ArrayList<>();
|
||||||
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
||||||
mVisibleComments.get(commentPosition).setExpanded(true);
|
mVisibleComments.get(commentPosition).setExpanded(true);
|
||||||
mVisibleComments.addAll(commentPosition + 1, newList);
|
mVisibleComments.addAll(commentPosition + 1, newList);
|
||||||
|
@ -33,6 +33,7 @@ import butterknife.ButterKnife;
|
|||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||||
@ -41,7 +42,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.CommentData;
|
import ml.docilealligator.infinityforreddit.Comment.Comment;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
@ -52,19 +53,19 @@ import ml.docilealligator.infinityforreddit.Utils.Utils;
|
|||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, RecyclerView.ViewHolder> {
|
public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment, RecyclerView.ViewHolder> {
|
||||||
private static final int VIEW_TYPE_DATA = 0;
|
private static final int VIEW_TYPE_DATA = 0;
|
||||||
private static final int VIEW_TYPE_ERROR = 1;
|
private static final int VIEW_TYPE_ERROR = 1;
|
||||||
private static final int VIEW_TYPE_LOADING = 2;
|
private static final int VIEW_TYPE_LOADING = 2;
|
||||||
private static final DiffUtil.ItemCallback<CommentData> DIFF_CALLBACK = new DiffUtil.ItemCallback<CommentData>() {
|
private static final DiffUtil.ItemCallback<Comment> DIFF_CALLBACK = new DiffUtil.ItemCallback<Comment>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean areItemsTheSame(@NonNull CommentData commentData, @NonNull CommentData t1) {
|
public boolean areItemsTheSame(@NonNull Comment comment, @NonNull Comment t1) {
|
||||||
return commentData.getId().equals(t1.getId());
|
return comment.getId().equals(t1.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areContentsTheSame(@NonNull CommentData commentData, @NonNull CommentData t1) {
|
public boolean areContentsTheSame(@NonNull Comment comment, @NonNull Comment t1) {
|
||||||
return commentData.getCommentMarkdown().equals(t1.getCommentMarkdown());
|
return comment.getCommentMarkdown().equals(t1.getCommentMarkdown());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -103,6 +104,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
mOauthRetrofit = oauthRetrofit;
|
mOauthRetrofit = oauthRetrofit;
|
||||||
mMarkwon = Markwon.builder(mContext)
|
mMarkwon = Markwon.builder(mContext)
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@Override
|
||||||
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||||
|
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
@ -115,6 +121,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
}
|
}
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
@ -165,7 +172,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof CommentViewHolder) {
|
if (holder instanceof CommentViewHolder) {
|
||||||
CommentData comment = getItem(holder.getAdapterPosition());
|
Comment comment = getItem(holder.getAdapterPosition());
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
|
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
|
||||||
((CommentViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor());
|
((CommentViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor());
|
||||||
@ -210,12 +217,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case CommentData.VOTE_TYPE_UPVOTE:
|
case Comment.VOTE_TYPE_UPVOTE:
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
break;
|
break;
|
||||||
case CommentData.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
@ -259,16 +266,16 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = APIUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
@ -281,11 +288,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position) {
|
||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -312,15 +319,15 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = APIUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
@ -333,11 +340,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.FetchMessages;
|
import ml.docilealligator.infinityforreddit.Message.FetchMessage;
|
||||||
import ml.docilealligator.infinityforreddit.Message;
|
import ml.docilealligator.infinityforreddit.Message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
||||||
@ -104,10 +104,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
if (where.equals(FetchMessages.WHERE_MESSAGES)) {
|
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||||
mMessageType = FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE;
|
mMessageType = FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE;
|
||||||
} else {
|
} else {
|
||||||
mMessageType = FetchMessages.MESSAGE_TYPE_INBOX;
|
mMessageType = FetchMessage.MESSAGE_TYPE_INBOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
mColorAccent = customThemeWrapper.getColorAccent();
|
mColorAccent = customThemeWrapper.getColorAccent();
|
||||||
@ -161,13 +161,13 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, displayedMessage.getBody());
|
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, displayedMessage.getBody());
|
||||||
|
|
||||||
((DataViewHolder) holder).itemView.setOnClickListener(view -> {
|
((DataViewHolder) holder).itemView.setOnClickListener(view -> {
|
||||||
if (mMessageType == FetchMessages.MESSAGE_TYPE_INBOX
|
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
|
||||||
&& message.getContext() != null && !message.getContext().equals("")) {
|
&& message.getContext() != null && !message.getContext().equals("")) {
|
||||||
Uri uri = LinkResolverActivity.getRedditUriByPath(message.getContext());
|
Uri uri = LinkResolverActivity.getRedditUriByPath(message.getContext());
|
||||||
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
} else if (mMessageType == FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE) {
|
} else if (mMessageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE) {
|
||||||
Intent intent = new Intent(mContext, ViewPrivateMessagesActivity.class);
|
Intent intent = new Intent(mContext, ViewPrivateMessagesActivity.class);
|
||||||
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message);
|
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message);
|
||||||
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_MESSAGE_POSITION, holder.getAdapterPosition());
|
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_MESSAGE_POSITION, holder.getAdapterPosition());
|
||||||
|
@ -34,7 +34,7 @@ import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Message;
|
import ml.docilealligator.infinityforreddit.Message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
|
@ -20,6 +20,7 @@ import butterknife.ButterKnife;
|
|||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||||
@ -50,6 +51,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||||
|
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
|
@ -25,7 +25,7 @@ import ml.docilealligator.infinityforreddit.Activity.EditCommentActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ReportActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ReportActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.CommentData;
|
import ml.docilealligator.infinityforreddit.Comment.Comment;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
CommentData commentData = bundle.getParcelable(EXTRA_COMMENT);
|
Comment comment = bundle.getParcelable(EXTRA_COMMENT);
|
||||||
if (commentData == null) {
|
if (comment == null) {
|
||||||
dismiss();
|
dismiss();
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
@ -81,8 +81,8 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
|
|||||||
editTextView.setOnClickListener(view -> {
|
editTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(activity, EditCommentActivity.class);
|
Intent intent = new Intent(activity, EditCommentActivity.class);
|
||||||
intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken);
|
intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken);
|
||||||
intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, commentData.getFullName());
|
intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, comment.getFullName());
|
||||||
intent.putExtra(EditCommentActivity.EXTRA_CONTENT, commentData.getCommentMarkdown());
|
intent.putExtra(EditCommentActivity.EXTRA_CONTENT, comment.getCommentMarkdown());
|
||||||
intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION));
|
intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION));
|
||||||
if (activity instanceof ViewPostDetailActivity) {
|
if (activity instanceof ViewPostDetailActivity) {
|
||||||
activity.startActivityForResult(intent, ViewPostDetailActivity.EDIT_COMMENT_REQUEST_CODE);
|
activity.startActivityForResult(intent, ViewPostDetailActivity.EDIT_COMMENT_REQUEST_CODE);
|
||||||
@ -96,9 +96,9 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
|
|||||||
deleteTextView.setOnClickListener(view -> {
|
deleteTextView.setOnClickListener(view -> {
|
||||||
dismiss();
|
dismiss();
|
||||||
if (activity instanceof ViewPostDetailActivity) {
|
if (activity instanceof ViewPostDetailActivity) {
|
||||||
((ViewPostDetailActivity) activity).deleteComment(commentData.getFullName(), bundle.getInt(EXTRA_POSITION));
|
((ViewPostDetailActivity) activity).deleteComment(comment.getFullName(), bundle.getInt(EXTRA_POSITION));
|
||||||
} else if (activity instanceof ViewUserDetailActivity) {
|
} else if (activity instanceof ViewUserDetailActivity) {
|
||||||
((ViewUserDetailActivity) activity).deleteComment(commentData.getFullName());
|
((ViewUserDetailActivity) activity).deleteComment(comment.getFullName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
|
|||||||
try {
|
try {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, commentData.getPermalink());
|
intent.putExtra(Intent.EXTRA_TEXT, comment.getPermalink());
|
||||||
activity.startActivity(Intent.createChooser(intent, getString(R.string.share)));
|
activity.startActivity(Intent.createChooser(intent, getString(R.string.share)));
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
|
||||||
@ -119,31 +119,31 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
|
|||||||
dismiss();
|
dismiss();
|
||||||
CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
|
CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
|
||||||
Bundle copyBundle = new Bundle();
|
Bundle copyBundle = new Bundle();
|
||||||
copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, commentData.getCommentMarkdown());
|
copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, comment.getCommentMarkdown());
|
||||||
copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, commentData.getCommentRawText());
|
copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, comment.getCommentRawText());
|
||||||
copyTextBottomSheetFragment.setArguments(copyBundle);
|
copyTextBottomSheetFragment.setArguments(copyBundle);
|
||||||
copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
|
copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
|
||||||
});
|
});
|
||||||
|
|
||||||
reportTextView.setOnClickListener(view -> {
|
reportTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(activity, ReportActivity.class);
|
Intent intent = new Intent(activity, ReportActivity.class);
|
||||||
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, commentData.getSubredditName());
|
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getSubredditName());
|
||||||
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, commentData.getFullName());
|
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
|
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
if ("[deleted]".equals(commentData.getAuthor()) ||
|
if ("[deleted]".equals(comment.getAuthor()) ||
|
||||||
"[deleted]".equals(commentData.getCommentRawText()) ||
|
"[deleted]".equals(comment.getCommentRawText()) ||
|
||||||
"[removed]".equals(commentData.getCommentRawText())
|
"[removed]".equals(comment.getCommentRawText())
|
||||||
) {
|
) {
|
||||||
seeRemovedTextView.setVisibility(View.VISIBLE);
|
seeRemovedTextView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
seeRemovedTextView.setOnClickListener(view -> {
|
seeRemovedTextView.setOnClickListener(view -> {
|
||||||
dismiss();
|
dismiss();
|
||||||
if (activity instanceof ViewPostDetailActivity) {
|
if (activity instanceof ViewPostDetailActivity) {
|
||||||
((ViewPostDetailActivity) activity).showRemovedComment(commentData, bundle.getInt(EXTRA_POSITION));
|
((ViewPostDetailActivity) activity).showRemovedComment(comment, bundle.getInt(EXTRA_POSITION));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@ -7,19 +7,19 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
|
|
||||||
public class CommentData implements Parcelable {
|
public class Comment implements Parcelable {
|
||||||
public static final int VOTE_TYPE_NO_VOTE = 0;
|
public static final int VOTE_TYPE_NO_VOTE = 0;
|
||||||
public static final int VOTE_TYPE_UPVOTE = 1;
|
public static final int VOTE_TYPE_UPVOTE = 1;
|
||||||
public static final int VOTE_TYPE_DOWNVOTE = -1;
|
public static final int VOTE_TYPE_DOWNVOTE = -1;
|
||||||
public static final Creator<CommentData> CREATOR = new Creator<CommentData>() {
|
public static final Creator<Comment> CREATOR = new Creator<Comment>() {
|
||||||
@Override
|
@Override
|
||||||
public CommentData createFromParcel(Parcel in) {
|
public Comment createFromParcel(Parcel in) {
|
||||||
return new CommentData(in);
|
return new Comment(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommentData[] newArray(int size) {
|
public Comment[] newArray(int size) {
|
||||||
return new CommentData[size];
|
return new Comment[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private String id;
|
private String id;
|
||||||
@ -47,20 +47,20 @@ public class CommentData implements Parcelable {
|
|||||||
private boolean saved;
|
private boolean saved;
|
||||||
private boolean isExpanded;
|
private boolean isExpanded;
|
||||||
private boolean hasExpandedBefore;
|
private boolean hasExpandedBefore;
|
||||||
private ArrayList<CommentData> children;
|
private ArrayList<Comment> children;
|
||||||
private ArrayList<String> moreChildrenFullnames;
|
private ArrayList<String> moreChildrenFullnames;
|
||||||
private int moreChildrenStartingIndex;
|
private int moreChildrenStartingIndex;
|
||||||
private boolean isPlaceHolder;
|
private boolean isPlaceHolder;
|
||||||
private boolean isLoadingMoreChildren;
|
private boolean isLoadingMoreChildren;
|
||||||
private boolean loadMoreChildrenFailed;
|
private boolean loadMoreChildrenFailed;
|
||||||
|
|
||||||
public CommentData(String id, String fullName, String author, String authorFlair,
|
public Comment(String id, String fullName, String author, String authorFlair,
|
||||||
String authorFlairHTML, String linkAuthor,
|
String authorFlairHTML, String linkAuthor,
|
||||||
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
||||||
String linkId, String subredditName, String parentId, int score,
|
String linkId, String subredditName, String parentId, int score,
|
||||||
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
||||||
String awards, int depth, boolean collapsed, boolean hasReply,
|
String awards, int depth, boolean collapsed, boolean hasReply,
|
||||||
boolean scoreHidden, boolean saved) {
|
boolean scoreHidden, boolean saved) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
@ -90,7 +90,7 @@ public class CommentData implements Parcelable {
|
|||||||
isPlaceHolder = false;
|
isPlaceHolder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommentData(String parentFullName, int depth) {
|
public Comment(String parentFullName, int depth) {
|
||||||
this.fullName = parentFullName;
|
this.fullName = parentFullName;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
isPlaceHolder = true;
|
isPlaceHolder = true;
|
||||||
@ -98,7 +98,7 @@ public class CommentData implements Parcelable {
|
|||||||
loadMoreChildrenFailed = false;
|
loadMoreChildrenFailed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommentData(Parcel in) {
|
protected Comment(Parcel in) {
|
||||||
id = in.readString();
|
id = in.readString();
|
||||||
fullName = in.readString();
|
fullName = in.readString();
|
||||||
author = in.readString();
|
author = in.readString();
|
||||||
@ -123,8 +123,8 @@ public class CommentData implements Parcelable {
|
|||||||
scoreHidden = in.readByte() != 0;
|
scoreHidden = in.readByte() != 0;
|
||||||
isExpanded = in.readByte() != 0;
|
isExpanded = in.readByte() != 0;
|
||||||
hasExpandedBefore = in.readByte() != 0;
|
hasExpandedBefore = in.readByte() != 0;
|
||||||
children = in.readArrayList(CommentData.class.getClassLoader());
|
children = in.readArrayList(Comment.class.getClassLoader());
|
||||||
moreChildrenFullnames = in.readArrayList(CommentData.class.getClassLoader());
|
moreChildrenFullnames = in.readArrayList(Comment.class.getClassLoader());
|
||||||
moreChildrenStartingIndex = in.readInt();
|
moreChildrenStartingIndex = in.readInt();
|
||||||
isPlaceHolder = in.readByte() != 0;
|
isPlaceHolder = in.readByte() != 0;
|
||||||
isLoadingMoreChildren = in.readByte() != 0;
|
isLoadingMoreChildren = in.readByte() != 0;
|
||||||
@ -270,15 +270,15 @@ public class CommentData implements Parcelable {
|
|||||||
this.voteType = voteType;
|
this.voteType = voteType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<CommentData> getChildren() {
|
public ArrayList<Comment> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChildren(ArrayList<CommentData> children) {
|
public void setChildren(ArrayList<Comment> children) {
|
||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildren(ArrayList<CommentData> moreChildren) {
|
public void addChildren(ArrayList<Comment> moreChildren) {
|
||||||
if (children == null || children.size() == 0) {
|
if (children == null || children.size() == 0) {
|
||||||
setChildren(moreChildren);
|
setChildren(moreChildren);
|
||||||
} else {
|
} else {
|
||||||
@ -290,11 +290,11 @@ public class CommentData implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(CommentData comment) {
|
public void addChild(Comment comment) {
|
||||||
addChild(comment, 0);
|
addChild(comment, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(CommentData comment, int position) {
|
public void addChild(Comment comment, int position) {
|
||||||
if (children == null) {
|
if (children == null) {
|
||||||
children = new ArrayList<>();
|
children = new ArrayList<>();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
@ -15,7 +15,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@ -23,7 +25,7 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class CommentDataSource extends PageKeyedDataSource<String, CommentData> {
|
public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||||
|
|
||||||
private Retrofit retrofit;
|
private Retrofit retrofit;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
@ -38,7 +40,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
private MutableLiveData<Boolean> hasPostLiveData;
|
private MutableLiveData<Boolean> hasPostLiveData;
|
||||||
|
|
||||||
private LoadParams<String> params;
|
private LoadParams<String> params;
|
||||||
private LoadCallback<String, CommentData> callback;
|
private LoadCallback<String, Comment> callback;
|
||||||
|
|
||||||
CommentDataSource(Retrofit retrofit, Locale locale, @Nullable String accessToken, String username, SortType sortType,
|
CommentDataSource(Retrofit retrofit, Locale locale, @Nullable String accessToken, String username, SortType sortType,
|
||||||
boolean areSavedComments) {
|
boolean areSavedComments) {
|
||||||
@ -70,7 +72,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull LoadInitialCallback<String, CommentData> callback) {
|
public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull LoadInitialCallback<String, Comment> callback) {
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADING);
|
initialLoadStateLiveData.postValue(NetworkState.LOADING);
|
||||||
|
|
||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
@ -108,7 +110,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
|
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
|
||||||
@Override
|
@Override
|
||||||
public void parseSuccessful(ArrayList<CommentData> comments, String after) {
|
public void parseSuccessful(ArrayList<Comment> comments, String after) {
|
||||||
if (comments.size() == 0) {
|
if (comments.size() == 0) {
|
||||||
hasPostLiveData.postValue(false);
|
hasPostLiveData.postValue(false);
|
||||||
} else {
|
} else {
|
||||||
@ -141,12 +143,12 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadBefore(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, CommentData> callback) {
|
public void loadBefore(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, Comment> callback) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadAfter(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, CommentData> callback) {
|
public void loadAfter(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, Comment> callback) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|
||||||
@ -186,7 +188,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
|
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
|
||||||
@Override
|
@Override
|
||||||
public void parseSuccessful(ArrayList<CommentData> comments, String after) {
|
public void parseSuccessful(ArrayList<Comment> comments, String after) {
|
||||||
if (after == null || after.equals("") || after.equals("null")) {
|
if (after == null || after.equals("") || after.equals("null")) {
|
||||||
callback.onResult(comments, null);
|
callback.onResult(comments, null);
|
||||||
} else {
|
} else {
|
||||||
@ -212,7 +214,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ParseCommentAsyncTask extends AsyncTask<Void, ArrayList<CommentData>, ArrayList<CommentData>> {
|
private static class ParseCommentAsyncTask extends AsyncTask<Void, ArrayList<Comment>, ArrayList<Comment>> {
|
||||||
private String after;
|
private String after;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private JSONArray commentsJSONArray;
|
private JSONArray commentsJSONArray;
|
||||||
@ -234,12 +236,12 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ArrayList<CommentData> doInBackground(Void... voids) {
|
protected ArrayList<Comment> doInBackground(Void... voids) {
|
||||||
if (parseFailed) {
|
if (parseFailed) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<CommentData> comments = new ArrayList<>();
|
ArrayList<Comment> comments = new ArrayList<>();
|
||||||
for (int i = 0; i < commentsJSONArray.length(); i++) {
|
for (int i = 0; i < commentsJSONArray.length(); i++) {
|
||||||
try {
|
try {
|
||||||
JSONObject commentJSON = commentsJSONArray.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
JSONObject commentJSON = commentsJSONArray.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
@ -251,7 +253,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(ArrayList<CommentData> commentData) {
|
protected void onPostExecute(ArrayList<Comment> commentData) {
|
||||||
super.onPostExecute(commentData);
|
super.onPostExecute(commentData);
|
||||||
if (commentData != null) {
|
if (commentData != null) {
|
||||||
parseCommentAsyncTaskListener.parseSuccessful(commentData, after);
|
parseCommentAsyncTaskListener.parseSuccessful(commentData, after);
|
||||||
@ -261,7 +263,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ParseCommentAsyncTaskListener {
|
interface ParseCommentAsyncTaskListener {
|
||||||
void parseSuccessful(ArrayList<CommentData> comments, String after);
|
void parseSuccessful(ArrayList<Comment> comments, String after);
|
||||||
|
|
||||||
void parseFailed();
|
void parseFailed();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -7,6 +7,7 @@ import androidx.paging.DataSource;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
class CommentDataSourceFactory extends DataSource.Factory {
|
class CommentDataSourceFactory extends DataSource.Factory {
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
@ -11,6 +11,8 @@ import androidx.paging.PagedList;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class CommentViewModel extends ViewModel {
|
public class CommentViewModel extends ViewModel {
|
||||||
@ -18,7 +20,7 @@ public class CommentViewModel extends ViewModel {
|
|||||||
private LiveData<NetworkState> paginationNetworkState;
|
private LiveData<NetworkState> paginationNetworkState;
|
||||||
private LiveData<NetworkState> initialLoadingState;
|
private LiveData<NetworkState> initialLoadingState;
|
||||||
private LiveData<Boolean> hasCommentLiveData;
|
private LiveData<Boolean> hasCommentLiveData;
|
||||||
private LiveData<PagedList<CommentData>> comments;
|
private LiveData<PagedList<Comment>> comments;
|
||||||
private MutableLiveData<SortType> sortTypeLiveData;
|
private MutableLiveData<SortType> sortTypeLiveData;
|
||||||
|
|
||||||
public CommentViewModel(Retrofit retrofit, Locale locale, String accessToken, String username, SortType sortType,
|
public CommentViewModel(Retrofit retrofit, Locale locale, String accessToken, String username, SortType sortType,
|
||||||
@ -48,7 +50,7 @@ public class CommentViewModel extends ViewModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<PagedList<CommentData>> getComments() {
|
public LiveData<PagedList<Comment>> getComments() {
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -41,7 +41,7 @@ public class FetchComment {
|
|||||||
ParseComment.parseComment(response.body(), new ArrayList<>(),
|
ParseComment.parseComment(response.body(), new ArrayList<>(),
|
||||||
locale, expandChildren, new ParseComment.ParseCommentListener() {
|
locale, expandChildren, new ParseComment.ParseCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentSuccess(ArrayList<CommentData> expandedComments,
|
public void onParseCommentSuccess(ArrayList<Comment> expandedComments,
|
||||||
String parentId, ArrayList<String> moreChildrenFullnames) {
|
String parentId, ArrayList<String> moreChildrenFullnames) {
|
||||||
fetchCommentListener.onFetchCommentSuccess(expandedComments, parentId,
|
fetchCommentListener.onFetchCommentSuccess(expandedComments, parentId,
|
||||||
moreChildrenFullnames);
|
moreChildrenFullnames);
|
||||||
@ -101,7 +101,7 @@ public class FetchComment {
|
|||||||
ParseComment.parseMoreComment(response.body(), new ArrayList<>(), locale,
|
ParseComment.parseMoreComment(response.body(), new ArrayList<>(), locale,
|
||||||
depth, expandChildren, new ParseComment.ParseCommentListener() {
|
depth, expandChildren, new ParseComment.ParseCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentSuccess(ArrayList<CommentData> expandedComments,
|
public void onParseCommentSuccess(ArrayList<Comment> expandedComments,
|
||||||
String parentId, ArrayList<String> moreChildrenFullnames) {
|
String parentId, ArrayList<String> moreChildrenFullnames) {
|
||||||
fetchMoreCommentListener.onFetchMoreCommentSuccess(expandedComments,
|
fetchMoreCommentListener.onFetchMoreCommentSuccess(expandedComments,
|
||||||
startingIndex + 100);
|
startingIndex + 100);
|
||||||
@ -125,13 +125,13 @@ public class FetchComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface FetchCommentListener {
|
public interface FetchCommentListener {
|
||||||
void onFetchCommentSuccess(ArrayList<CommentData> expandedComments, String parentId, ArrayList<String> children);
|
void onFetchCommentSuccess(ArrayList<Comment> expandedComments, String parentId, ArrayList<String> children);
|
||||||
|
|
||||||
void onFetchCommentFailed();
|
void onFetchCommentFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface FetchMoreCommentListener {
|
public interface FetchMoreCommentListener {
|
||||||
void onFetchMoreCommentSuccess(ArrayList<CommentData> expandedComments, int childrenStartingIndex);
|
void onFetchMoreCommentSuccess(ArrayList<Comment> expandedComments, int childrenStartingIndex);
|
||||||
|
|
||||||
void onFetchMoreCommentFailed();
|
void onFetchMoreCommentFailed();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
@ -15,12 +15,12 @@ import java.util.Locale;
|
|||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
|
|
||||||
import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_DOWNVOTE;
|
import static ml.docilealligator.infinityforreddit.Comment.Comment.VOTE_TYPE_DOWNVOTE;
|
||||||
import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_NO_VOTE;
|
import static ml.docilealligator.infinityforreddit.Comment.Comment.VOTE_TYPE_NO_VOTE;
|
||||||
import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_UPVOTE;
|
import static ml.docilealligator.infinityforreddit.Comment.Comment.VOTE_TYPE_UPVOTE;
|
||||||
|
|
||||||
public class ParseComment {
|
public class ParseComment {
|
||||||
public static void parseComment(String response, ArrayList<CommentData> commentData, Locale locale,
|
public static void parseComment(String response, ArrayList<Comment> commentData, Locale locale,
|
||||||
boolean expandChildren, ParseCommentListener parseCommentListener) {
|
boolean expandChildren, ParseCommentListener parseCommentListener) {
|
||||||
try {
|
try {
|
||||||
JSONArray childrenArray = new JSONArray(response);
|
JSONArray childrenArray = new JSONArray(response);
|
||||||
@ -35,7 +35,7 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseMoreComment(String response, ArrayList<CommentData> commentData, Locale locale,
|
static void parseMoreComment(String response, ArrayList<Comment> commentData, Locale locale,
|
||||||
int depth, boolean expandChildren, ParseCommentListener parseCommentListener) {
|
int depth, boolean expandChildren, ParseCommentListener parseCommentListener) {
|
||||||
try {
|
try {
|
||||||
JSONArray childrenArray = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
JSONArray childrenArray = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||||
@ -51,7 +51,7 @@ public class ParseComment {
|
|||||||
new ParseSentCommentAsyncTask(response, depth, locale, parseSentCommentListener).execute();
|
new ParseSentCommentAsyncTask(response, depth, locale, parseSentCommentListener).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseCommentRecursion(JSONArray comments, ArrayList<CommentData> newCommentData,
|
private static void parseCommentRecursion(JSONArray comments, ArrayList<Comment> newCommentData,
|
||||||
ArrayList<String> moreChildrenFullnames, int depth, Locale locale) throws JSONException {
|
ArrayList<String> moreChildrenFullnames, int depth, Locale locale) throws JSONException {
|
||||||
int actualCommentLength;
|
int actualCommentLength;
|
||||||
|
|
||||||
@ -76,12 +76,12 @@ public class ParseComment {
|
|||||||
|
|
||||||
for (int i = 0; i < actualCommentLength; i++) {
|
for (int i = 0; i < actualCommentLength; i++) {
|
||||||
JSONObject data = comments.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
JSONObject data = comments.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
CommentData singleComment = parseSingleComment(data, depth, locale);
|
Comment singleComment = parseSingleComment(data, depth, locale);
|
||||||
|
|
||||||
if (data.get(JSONUtils.REPLIES_KEY) instanceof JSONObject) {
|
if (data.get(JSONUtils.REPLIES_KEY) instanceof JSONObject) {
|
||||||
JSONArray childrenArray = data.getJSONObject(JSONUtils.REPLIES_KEY)
|
JSONArray childrenArray = data.getJSONObject(JSONUtils.REPLIES_KEY)
|
||||||
.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||||
ArrayList<CommentData> children = new ArrayList<>();
|
ArrayList<Comment> children = new ArrayList<>();
|
||||||
ArrayList<String> nextMoreChildrenFullnames = new ArrayList<>();
|
ArrayList<String> nextMoreChildrenFullnames = new ArrayList<>();
|
||||||
parseCommentRecursion(childrenArray, children, nextMoreChildrenFullnames, singleComment.getDepth(),
|
parseCommentRecursion(childrenArray, children, nextMoreChildrenFullnames, singleComment.getDepth(),
|
||||||
locale);
|
locale);
|
||||||
@ -93,9 +93,9 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void expandChildren(ArrayList<CommentData> comments, ArrayList<CommentData> visibleComments,
|
private static void expandChildren(ArrayList<Comment> comments, ArrayList<Comment> visibleComments,
|
||||||
boolean setExpanded) {
|
boolean setExpanded) {
|
||||||
for (CommentData c : comments) {
|
for (Comment c : comments) {
|
||||||
visibleComments.add(c);
|
visibleComments.add(c);
|
||||||
if (c.hasReply()) {
|
if (c.hasReply()) {
|
||||||
if (setExpanded) {
|
if (setExpanded) {
|
||||||
@ -105,14 +105,14 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
if (c.hasMoreChildrenFullnames() && c.getMoreChildrenFullnames().size() > c.getMoreChildrenStartingIndex()) {
|
if (c.hasMoreChildrenFullnames() && c.getMoreChildrenFullnames().size() > c.getMoreChildrenStartingIndex()) {
|
||||||
//Add a load more placeholder
|
//Add a load more placeholder
|
||||||
CommentData placeholder = new CommentData(c.getFullName(), c.getDepth() + 1);
|
Comment placeholder = new Comment(c.getFullName(), c.getDepth() + 1);
|
||||||
visibleComments.add(placeholder);
|
visibleComments.add(placeholder);
|
||||||
c.addChild(placeholder, c.getChildren().size());
|
c.addChild(placeholder, c.getChildren().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CommentData parseSingleComment(JSONObject singleCommentData, int depth, Locale locale) throws JSONException {
|
static Comment parseSingleComment(JSONObject singleCommentData, int depth, Locale locale) throws JSONException {
|
||||||
String id = singleCommentData.getString(JSONUtils.ID_KEY);
|
String id = singleCommentData.getString(JSONUtils.ID_KEY);
|
||||||
String fullName = singleCommentData.getString(JSONUtils.NAME_KEY);
|
String fullName = singleCommentData.getString(JSONUtils.NAME_KEY);
|
||||||
String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY);
|
String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY);
|
||||||
@ -176,7 +176,7 @@ public class ParseComment {
|
|||||||
boolean collapsed = singleCommentData.getBoolean(JSONUtils.COLLAPSED_KEY);
|
boolean collapsed = singleCommentData.getBoolean(JSONUtils.COLLAPSED_KEY);
|
||||||
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
|
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
|
||||||
|
|
||||||
return new CommentData(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(),
|
return new Comment(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(),
|
||||||
linkAuthor, submitTime, commentMarkdown, commentRawText,
|
linkAuthor, submitTime, commentMarkdown, commentRawText,
|
||||||
linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished,
|
linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished,
|
||||||
permalink, awardingsBuilder.toString(),depth, collapsed, hasReply, scoreHidden, saved);
|
permalink, awardingsBuilder.toString(),depth, collapsed, hasReply, scoreHidden, saved);
|
||||||
@ -212,23 +212,23 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface ParseCommentListener {
|
public interface ParseCommentListener {
|
||||||
void onParseCommentSuccess(ArrayList<CommentData> expandedComments, String parentId,
|
void onParseCommentSuccess(ArrayList<Comment> expandedComments, String parentId,
|
||||||
ArrayList<String> moreChildrenFullnames);
|
ArrayList<String> moreChildrenFullnames);
|
||||||
|
|
||||||
void onParseCommentFailed();
|
void onParseCommentFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParseSentCommentListener {
|
interface ParseSentCommentListener {
|
||||||
void onParseSentCommentSuccess(CommentData commentData);
|
void onParseSentCommentSuccess(Comment comment);
|
||||||
|
|
||||||
void onParseSentCommentFailed(@Nullable String errorMessage);
|
void onParseSentCommentFailed(@Nullable String errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ParseCommentAsyncTask extends AsyncTask<Void, Void, Void> {
|
private static class ParseCommentAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
private JSONArray commentsJSONArray;
|
private JSONArray commentsJSONArray;
|
||||||
private ArrayList<CommentData> comments;
|
private ArrayList<Comment> comments;
|
||||||
private ArrayList<CommentData> newComments;
|
private ArrayList<Comment> newComments;
|
||||||
private ArrayList<CommentData> expandedNewComments;
|
private ArrayList<Comment> expandedNewComments;
|
||||||
private ArrayList<String> moreChildrenFullnames;
|
private ArrayList<String> moreChildrenFullnames;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private String parentId;
|
private String parentId;
|
||||||
@ -237,7 +237,7 @@ public class ParseComment {
|
|||||||
private ParseCommentListener parseCommentListener;
|
private ParseCommentListener parseCommentListener;
|
||||||
private boolean parseFailed;
|
private boolean parseFailed;
|
||||||
|
|
||||||
ParseCommentAsyncTask(JSONArray commentsJSONArray, ArrayList<CommentData> comments, Locale locale,
|
ParseCommentAsyncTask(JSONArray commentsJSONArray, ArrayList<Comment> comments, Locale locale,
|
||||||
@Nullable String parentId, int depth, boolean expandChildren,
|
@Nullable String parentId, int depth, boolean expandChildren,
|
||||||
ParseCommentListener parseCommentListener) {
|
ParseCommentListener parseCommentListener) {
|
||||||
this.commentsJSONArray = commentsJSONArray;
|
this.commentsJSONArray = commentsJSONArray;
|
||||||
@ -286,7 +286,7 @@ public class ParseComment {
|
|||||||
private ParseSentCommentListener parseSentCommentListener;
|
private ParseSentCommentListener parseSentCommentListener;
|
||||||
private boolean parseFailed;
|
private boolean parseFailed;
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
private CommentData commentData;
|
private Comment comment;
|
||||||
|
|
||||||
ParseSentCommentAsyncTask(String response, int depth, Locale locale, ParseSentCommentListener parseSentCommentListener) {
|
ParseSentCommentAsyncTask(String response, int depth, Locale locale, ParseSentCommentListener parseSentCommentListener) {
|
||||||
this.response = response;
|
this.response = response;
|
||||||
@ -300,7 +300,7 @@ public class ParseComment {
|
|||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
try {
|
try {
|
||||||
JSONObject sentCommentData = new JSONObject(response);
|
JSONObject sentCommentData = new JSONObject(response);
|
||||||
commentData = parseSingleComment(sentCommentData, depth, locale);
|
comment = parseSingleComment(sentCommentData, depth, locale);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
errorMessage = parseSentCommentErrorMessage(response);
|
errorMessage = parseSentCommentErrorMessage(response);
|
||||||
@ -315,7 +315,7 @@ public class ParseComment {
|
|||||||
if (parseFailed) {
|
if (parseFailed) {
|
||||||
parseSentCommentListener.onParseSentCommentFailed(errorMessage);
|
parseSentCommentListener.onParseSentCommentFailed(errorMessage);
|
||||||
} else {
|
} else {
|
||||||
parseSentCommentListener.onParseSentCommentSuccess(commentData);
|
parseSentCommentListener.onParseSentCommentSuccess(comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Comment;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -35,8 +35,8 @@ public class SendComment {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
ParseComment.parseSentComment(response.body(), parentDepth, locale, new ParseComment.ParseSentCommentListener() {
|
ParseComment.parseSentComment(response.body(), parentDepth, locale, new ParseComment.ParseSentCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParseSentCommentSuccess(CommentData commentData) {
|
public void onParseSentCommentSuccess(Comment comment) {
|
||||||
sendCommentListener.sendCommentSuccess(commentData);
|
sendCommentListener.sendCommentSuccess(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,7 +57,7 @@ public class SendComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface SendCommentListener {
|
public interface SendCommentListener {
|
||||||
void sendCommentSuccess(CommentData commentData);
|
void sendCommentSuccess(Comment comment);
|
||||||
|
|
||||||
void sendCommentFailed(String errorMessage);
|
void sendCommentFailed(String errorMessage);
|
||||||
}
|
}
|
@ -151,6 +151,22 @@ public class CustomTheme {
|
|||||||
public int fabIconColor;
|
public int fabIconColor;
|
||||||
@ColumnInfo(name = "chip_text_color")
|
@ColumnInfo(name = "chip_text_color")
|
||||||
public int chipTextColor;
|
public int chipTextColor;
|
||||||
|
@ColumnInfo(name = "link_color")
|
||||||
|
public int linkColor;
|
||||||
|
@ColumnInfo(name = "received_message_text_color")
|
||||||
|
public int receivedMessageTextColor;
|
||||||
|
@ColumnInfo(name = "sent_message_text_color")
|
||||||
|
public int sentMessageTextColor;
|
||||||
|
@ColumnInfo(name = "received_message_background_color")
|
||||||
|
public int receivedMessageBackgroundColor;
|
||||||
|
@ColumnInfo(name = "sent_message_background_color")
|
||||||
|
public int sentMessageBackgroundColor;
|
||||||
|
@ColumnInfo(name = "send_message_icon_color")
|
||||||
|
public int sendMessageIconColor;
|
||||||
|
@ColumnInfo(name = "fully_collapsed_comment_background_color")
|
||||||
|
public int fullyCollapsedCommentBackgroundColor;
|
||||||
|
@ColumnInfo(name = "awarded_comment_background_color")
|
||||||
|
public int awardedCommentBackgroundColor;
|
||||||
@ColumnInfo(name = "is_light_status_bar")
|
@ColumnInfo(name = "is_light_status_bar")
|
||||||
public boolean isLightStatusBar;
|
public boolean isLightStatusBar;
|
||||||
@ColumnInfo(name = "is_light_nav_bar")
|
@ColumnInfo(name = "is_light_nav_bar")
|
||||||
@ -190,63 +206,71 @@ public class CustomTheme {
|
|||||||
customTheme.commentColor = customThemeSettingsItems.get(11).colorValue;
|
customTheme.commentColor = customThemeSettingsItems.get(11).colorValue;
|
||||||
customTheme.buttonTextColor = customThemeSettingsItems.get(12).colorValue;
|
customTheme.buttonTextColor = customThemeSettingsItems.get(12).colorValue;
|
||||||
customTheme.chipTextColor = customThemeSettingsItems.get(13).colorValue;
|
customTheme.chipTextColor = customThemeSettingsItems.get(13).colorValue;
|
||||||
customTheme.backgroundColor = customThemeSettingsItems.get(14).colorValue;
|
customTheme.linkColor = customThemeSettingsItems.get(14).colorValue;
|
||||||
customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(15).colorValue;
|
customTheme.receivedMessageTextColor = customThemeSettingsItems.get(15).colorValue;
|
||||||
customTheme.commentBackgroundColor = customThemeSettingsItems.get(16).colorValue;
|
customTheme.sentMessageTextColor = customThemeSettingsItems.get(16).colorValue;
|
||||||
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(17).colorValue;
|
customTheme.backgroundColor = customThemeSettingsItems.get(17).colorValue;
|
||||||
customTheme.primaryIconColor = customThemeSettingsItems.get(18).colorValue;
|
customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(18).colorValue;
|
||||||
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(19).colorValue;
|
customTheme.commentBackgroundColor = customThemeSettingsItems.get(19).colorValue;
|
||||||
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(20).colorValue;
|
customTheme.fullyCollapsedCommentBackgroundColor = customThemeSettingsItems.get(20).colorValue;
|
||||||
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(21).colorValue;
|
customTheme.awardedCommentBackgroundColor = customThemeSettingsItems.get(21).colorValue;
|
||||||
customTheme.fabIconColor = customThemeSettingsItems.get(22).colorValue;
|
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(22).colorValue;
|
||||||
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(23).colorValue;
|
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(23).colorValue;
|
||||||
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(24).colorValue;
|
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(24).colorValue;
|
||||||
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(25).colorValue;
|
customTheme.primaryIconColor = customThemeSettingsItems.get(25).colorValue;
|
||||||
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(26).colorValue;
|
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(26).colorValue;
|
||||||
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(27).colorValue;
|
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(27).colorValue;
|
||||||
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(28).colorValue;
|
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(28).colorValue;
|
||||||
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(29).colorValue;
|
customTheme.fabIconColor = customThemeSettingsItems.get(29).colorValue;
|
||||||
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(30).colorValue;
|
customTheme.sendMessageIconColor = customThemeSettingsItems.get(30).colorValue;
|
||||||
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(31).colorValue;
|
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(31).colorValue;
|
||||||
customTheme.upvoted = customThemeSettingsItems.get(32).colorValue;
|
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(32).colorValue;
|
||||||
customTheme.downvoted = customThemeSettingsItems.get(33).colorValue;
|
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(33).colorValue;
|
||||||
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(34).colorValue;
|
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(34).colorValue;
|
||||||
customTheme.postTypeTextColor = customThemeSettingsItems.get(35).colorValue;
|
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(35).colorValue;
|
||||||
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(36).colorValue;
|
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(36).colorValue;
|
||||||
customTheme.spoilerTextColor = customThemeSettingsItems.get(37).colorValue;
|
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(37).colorValue;
|
||||||
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(38).colorValue;
|
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(38).colorValue;
|
||||||
customTheme.nsfwTextColor = customThemeSettingsItems.get(39).colorValue;
|
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(39).colorValue;
|
||||||
customTheme.flairBackgroundColor = customThemeSettingsItems.get(40).colorValue;
|
customTheme.upvoted = customThemeSettingsItems.get(40).colorValue;
|
||||||
customTheme.flairTextColor = customThemeSettingsItems.get(41).colorValue;
|
customTheme.downvoted = customThemeSettingsItems.get(41).colorValue;
|
||||||
customTheme.awardsBackgroundColor = customThemeSettingsItems.get(42).colorValue;
|
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(42).colorValue;
|
||||||
customTheme.awardsTextColor = customThemeSettingsItems.get(43).colorValue;
|
customTheme.postTypeTextColor = customThemeSettingsItems.get(43).colorValue;
|
||||||
customTheme.archivedTint = customThemeSettingsItems.get(44).colorValue;
|
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(44).colorValue;
|
||||||
customTheme.lockedIconTint = customThemeSettingsItems.get(45).colorValue;
|
customTheme.spoilerTextColor = customThemeSettingsItems.get(45).colorValue;
|
||||||
customTheme.crosspostIconTint = customThemeSettingsItems.get(46).colorValue;
|
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(46).colorValue;
|
||||||
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(47).colorValue;
|
customTheme.nsfwTextColor = customThemeSettingsItems.get(47).colorValue;
|
||||||
customTheme.subscribed = customThemeSettingsItems.get(48).colorValue;
|
customTheme.flairBackgroundColor = customThemeSettingsItems.get(48).colorValue;
|
||||||
customTheme.unsubscribed = customThemeSettingsItems.get(49).colorValue;
|
customTheme.flairTextColor = customThemeSettingsItems.get(49).colorValue;
|
||||||
customTheme.username = customThemeSettingsItems.get(50).colorValue;
|
customTheme.awardsBackgroundColor = customThemeSettingsItems.get(50).colorValue;
|
||||||
customTheme.subreddit = customThemeSettingsItems.get(51).colorValue;
|
customTheme.awardsTextColor = customThemeSettingsItems.get(51).colorValue;
|
||||||
customTheme.authorFlairTextColor = customThemeSettingsItems.get(52).colorValue;
|
customTheme.archivedTint = customThemeSettingsItems.get(52).colorValue;
|
||||||
customTheme.submitter = customThemeSettingsItems.get(53).colorValue;
|
customTheme.lockedIconTint = customThemeSettingsItems.get(53).colorValue;
|
||||||
customTheme.moderator = customThemeSettingsItems.get(54).colorValue;
|
customTheme.crosspostIconTint = customThemeSettingsItems.get(54).colorValue;
|
||||||
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(55).colorValue;
|
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(55).colorValue;
|
||||||
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(56).colorValue;
|
customTheme.subscribed = customThemeSettingsItems.get(56).colorValue;
|
||||||
customTheme.dividerColor = customThemeSettingsItems.get(57).colorValue;
|
customTheme.unsubscribed = customThemeSettingsItems.get(57).colorValue;
|
||||||
customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(58).colorValue;
|
customTheme.username = customThemeSettingsItems.get(58).colorValue;
|
||||||
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(59).colorValue;
|
customTheme.subreddit = customThemeSettingsItems.get(59).colorValue;
|
||||||
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(60).colorValue;
|
customTheme.authorFlairTextColor = customThemeSettingsItems.get(60).colorValue;
|
||||||
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(61).colorValue;
|
customTheme.submitter = customThemeSettingsItems.get(61).colorValue;
|
||||||
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(62).colorValue;
|
customTheme.moderator = customThemeSettingsItems.get(62).colorValue;
|
||||||
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(63).colorValue;
|
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(63).colorValue;
|
||||||
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(64).colorValue;
|
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(64).colorValue;
|
||||||
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(65).colorValue;
|
customTheme.dividerColor = customThemeSettingsItems.get(65).colorValue;
|
||||||
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(66).colorValue;
|
customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(66).colorValue;
|
||||||
customTheme.navBarColor = customThemeSettingsItems.get(67).colorValue;
|
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(67).colorValue;
|
||||||
customTheme.isLightStatusBar = customThemeSettingsItems.get(68).isEnabled;
|
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(68).colorValue;
|
||||||
customTheme.isLightNavBar = customThemeSettingsItems.get(69).isEnabled;
|
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(69).colorValue;
|
||||||
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(70).isEnabled;
|
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(70).colorValue;
|
||||||
|
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(71).colorValue;
|
||||||
|
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(72).colorValue;
|
||||||
|
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(73).colorValue;
|
||||||
|
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(74).colorValue;
|
||||||
|
customTheme.navBarColor = customThemeSettingsItems.get(75).colorValue;
|
||||||
|
customTheme.isLightStatusBar = customThemeSettingsItems.get(76).isEnabled;
|
||||||
|
customTheme.isLightNavBar = customThemeSettingsItems.get(77).isEnabled;
|
||||||
|
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(78).isEnabled;
|
||||||
|
|
||||||
return customTheme;
|
return customTheme;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,18 @@ public class CustomThemeSettingsItem implements Parcelable {
|
|||||||
context.getString(R.string.theme_item_chip_text_color),
|
context.getString(R.string.theme_item_chip_text_color),
|
||||||
context.getString(R.string.theme_item_chip_text_color_detail),
|
context.getString(R.string.theme_item_chip_text_color_detail),
|
||||||
customTheme.chipTextColor));
|
customTheme.chipTextColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_link_color),
|
||||||
|
context.getString(R.string.theme_item_link_color_detail),
|
||||||
|
customTheme.linkColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_received_message_text_color),
|
||||||
|
context.getString(R.string.theme_item_received_message_text_color_detail),
|
||||||
|
customTheme.receivedMessageTextColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_sent_message_text_color),
|
||||||
|
context.getString(R.string.theme_item_sent_message_text_color_detail),
|
||||||
|
customTheme.sentMessageTextColor));
|
||||||
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
context.getString(R.string.theme_item_background_color),
|
context.getString(R.string.theme_item_background_color),
|
||||||
context.getString(R.string.theme_item_background_color_detail),
|
context.getString(R.string.theme_item_background_color_detail),
|
||||||
@ -122,6 +134,22 @@ public class CustomThemeSettingsItem implements Parcelable {
|
|||||||
context.getString(R.string.theme_item_comment_background_color),
|
context.getString(R.string.theme_item_comment_background_color),
|
||||||
context.getString(R.string.theme_item_comment_background_color_detail),
|
context.getString(R.string.theme_item_comment_background_color_detail),
|
||||||
customTheme.commentBackgroundColor));
|
customTheme.commentBackgroundColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_fully_collapsed_comment_background_color),
|
||||||
|
context.getString(R.string.theme_item_fully_collapsed_comment_background_color_detail),
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_awarded_comment_background_color),
|
||||||
|
context.getString(R.string.theme_item_awarded_comment_background_color_detail),
|
||||||
|
customTheme.awardedCommentBackgroundColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_received_message_background_color),
|
||||||
|
context.getString(R.string.theme_item_received_message_background_color_detail),
|
||||||
|
customTheme.receivedMessageBackgroundColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_sent_message_background_color),
|
||||||
|
context.getString(R.string.theme_item_sent_message_background_color_detail),
|
||||||
|
customTheme.sentMessageBackgroundColor));
|
||||||
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
context.getString(R.string.theme_item_bottom_app_bar_background_color),
|
context.getString(R.string.theme_item_bottom_app_bar_background_color),
|
||||||
context.getString(R.string.theme_item_bottom_app_bar_background_color_detail),
|
context.getString(R.string.theme_item_bottom_app_bar_background_color_detail),
|
||||||
@ -146,6 +174,10 @@ public class CustomThemeSettingsItem implements Parcelable {
|
|||||||
context.getString(R.string.theme_item_fab_icon_color),
|
context.getString(R.string.theme_item_fab_icon_color),
|
||||||
context.getString(R.string.theme_item_fab_icon_color_detail),
|
context.getString(R.string.theme_item_fab_icon_color_detail),
|
||||||
customTheme.fabIconColor));
|
customTheme.fabIconColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_send_message_icon_color),
|
||||||
|
context.getString(R.string.theme_item_send_message_icon_color_detail),
|
||||||
|
customTheme.sendMessageIconColor));
|
||||||
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
context.getString(R.string.theme_item_toolbar_primary_text_and_icon_color),
|
context.getString(R.string.theme_item_toolbar_primary_text_and_icon_color),
|
||||||
context.getString(R.string.theme_item_toolbar_primary_text_and_icon_color_detail),
|
context.getString(R.string.theme_item_toolbar_primary_text_and_icon_color_detail),
|
||||||
|
@ -372,6 +372,46 @@ public class CustomThemeWrapper {
|
|||||||
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
|
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLinkColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.LINK_COLOR,
|
||||||
|
getDefaultColor("#FF4081", "#FF4081", "#FF4081"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReceivedMessageTextColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.RECEIVED_MESSAGE_TEXT_COLOR,
|
||||||
|
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSentMessageTextColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SENT_MESSAGE_TEXT_COLOR,
|
||||||
|
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReceivedMessageBackgroundColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.RECEIVED_MESSAGE_BACKROUND_COLOR,
|
||||||
|
getDefaultColor("#4185F4", "#4185F4", "#4185F4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSentMessageBackgroundColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SENT_MESSAGE_BACKGROUND_COLOR,
|
||||||
|
getDefaultColor("#31BF7D", "#31BF7D", "#31BF7D"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSendMessageIconColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SEND_MESSAGE_ICON_COLOR,
|
||||||
|
getDefaultColor("#4185F4", "#4185F4", "#4185F4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFullyCollapsedCommentBackgroundColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FULLY_COLLAPSED_COMMENT_BACKGROUND_COLOR,
|
||||||
|
getDefaultColor("#4185F4", "#4185F4", "#4185F4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAwardedCommentBackgroundColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR,
|
||||||
|
getDefaultColor("#EEAB02", "#EEAB02", "#EEAB02"));
|
||||||
|
}
|
||||||
|
|
||||||
public int getNavBarColor() {
|
public int getNavBarColor() {
|
||||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR,
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR,
|
||||||
getDefaultColor("#FFFFFF", "#121212", "#000000"));
|
getDefaultColor("#FFFFFF", "#121212", "#000000"));
|
||||||
@ -503,6 +543,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#FFFFFF");
|
customTheme.navBarColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = true;
|
customTheme.isLightNavBar = true;
|
||||||
@ -580,6 +628,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#121212");
|
customTheme.navBarColor = Color.parseColor("#121212");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -657,6 +713,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#000000");
|
customTheme.navBarColor = Color.parseColor("#000000");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -734,6 +798,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#000000");
|
customTheme.fabIconColor = Color.parseColor("#000000");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#FFFFFF");
|
customTheme.navBarColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.isLightStatusBar = true;
|
customTheme.isLightStatusBar = true;
|
||||||
customTheme.isLightNavBar = true;
|
customTheme.isLightNavBar = true;
|
||||||
@ -811,6 +883,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#121212");
|
customTheme.navBarColor = Color.parseColor("#121212");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -888,6 +968,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#000000");
|
customTheme.navBarColor = Color.parseColor("#000000");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -965,6 +1053,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#FFFFFF");
|
customTheme.navBarColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = true;
|
customTheme.isLightNavBar = true;
|
||||||
@ -1042,6 +1138,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#121212");
|
customTheme.navBarColor = Color.parseColor("#121212");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -1119,6 +1223,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#000000");
|
customTheme.navBarColor = Color.parseColor("#000000");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -1196,6 +1308,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#F1FA8C");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#F1FA8C");
|
||||||
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
customTheme.fabIconColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#393A59");
|
customTheme.navBarColor = Color.parseColor("#393A59");
|
||||||
customTheme.isLightStatusBar = false;
|
customTheme.isLightStatusBar = false;
|
||||||
customTheme.isLightNavBar = false;
|
customTheme.isLightNavBar = false;
|
||||||
@ -1273,6 +1393,14 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602");
|
||||||
customTheme.fabIconColor = Color.parseColor("#000000");
|
customTheme.fabIconColor = Color.parseColor("#000000");
|
||||||
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.linkColor = Color.parseColor("#FF4081");
|
||||||
|
customTheme.receivedMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.sentMessageTextColor = Color.parseColor("#FFFFFF");
|
||||||
|
customTheme.receivedMessageBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
|
||||||
|
customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#4185F4");
|
||||||
|
customTheme.awardedCommentBackgroundColor = Color.parseColor("#EEAB02");
|
||||||
customTheme.navBarColor = Color.parseColor("#D48AE0");
|
customTheme.navBarColor = Color.parseColor("#D48AE0");
|
||||||
customTheme.isLightStatusBar = true;
|
customTheme.isLightStatusBar = true;
|
||||||
customTheme.isLightNavBar = true;
|
customTheme.isLightNavBar = true;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Event;
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Message;
|
import ml.docilealligator.infinityforreddit.Message.Message;
|
||||||
|
|
||||||
public class RepliedToPrivateMessageEvent {
|
public class RepliedToPrivateMessageEvent {
|
||||||
public Message newReply;
|
public Message newReply;
|
||||||
|
@ -8,6 +8,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.API.PushshiftAPI;
|
import ml.docilealligator.infinityforreddit.API.PushshiftAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Comment.Comment;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@ -17,7 +18,7 @@ import retrofit2.Retrofit;
|
|||||||
|
|
||||||
public class FetchRemovedComment {
|
public class FetchRemovedComment {
|
||||||
|
|
||||||
public static void fetchRemovedComment(Retrofit retrofit, CommentData comment, FetchRemovedCommentListener listener) {
|
public static void fetchRemovedComment(Retrofit retrofit, Comment comment, FetchRemovedCommentListener listener) {
|
||||||
retrofit.create(PushshiftAPI.class).getRemovedComment(comment.getId())
|
retrofit.create(PushshiftAPI.class).getRemovedComment(comment.getId())
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
@ -37,7 +38,7 @@ public class FetchRemovedComment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CommentData parseRemovedComment(JSONObject result, CommentData comment) throws JSONException {
|
private static Comment parseRemovedComment(JSONObject result, Comment comment) throws JSONException {
|
||||||
String id = result.getString(JSONUtils.ID_KEY);
|
String id = result.getString(JSONUtils.ID_KEY);
|
||||||
String author = result.getString(JSONUtils.AUTHOR_KEY);
|
String author = result.getString(JSONUtils.AUTHOR_KEY);
|
||||||
String body = Utils.modifyMarkdown(result.optString(JSONUtils.BODY_KEY).trim());
|
String body = Utils.modifyMarkdown(result.optString(JSONUtils.BODY_KEY).trim());
|
||||||
@ -56,7 +57,7 @@ public class FetchRemovedComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface FetchRemovedCommentListener {
|
public interface FetchRemovedCommentListener {
|
||||||
void fetchSuccess(CommentData comment);
|
void fetchSuccess(Comment comment);
|
||||||
|
|
||||||
void fetchFailed();
|
void fetchFailed();
|
||||||
}
|
}
|
||||||
@ -65,9 +66,9 @@ public class FetchRemovedComment {
|
|||||||
|
|
||||||
private String responseBody;
|
private String responseBody;
|
||||||
private FetchRemovedCommentListener listener;
|
private FetchRemovedCommentListener listener;
|
||||||
CommentData comment;
|
Comment comment;
|
||||||
|
|
||||||
public ParseCommentAsyncTask(String responseBody, CommentData comment, FetchRemovedCommentListener listener) {
|
public ParseCommentAsyncTask(String responseBody, Comment comment, FetchRemovedCommentListener listener) {
|
||||||
this.responseBody = responseBody;
|
this.responseBody = responseBody;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -33,7 +33,7 @@ import butterknife.ButterKnife;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Adapter.CommentsListingRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.Adapter.CommentsListingRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.CommentViewModel;
|
import ml.docilealligator.infinityforreddit.Comment.CommentViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
|
@ -33,10 +33,10 @@ import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Adapter.MessageRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.Adapter.MessageRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Event.RepliedToPrivateMessageEvent;
|
import ml.docilealligator.infinityforreddit.Event.RepliedToPrivateMessageEvent;
|
||||||
import ml.docilealligator.infinityforreddit.FetchMessages;
|
import ml.docilealligator.infinityforreddit.Message.FetchMessage;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.MessageViewModel;
|
import ml.docilealligator.infinityforreddit.Message.MessageViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
@ -102,7 +102,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
|||||||
mRecyclerView.setPadding(0, 0, 0, mActivity.getNavBarHeight());
|
mRecyclerView.setPadding(0, 0, 0, mActivity.getNavBarHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
mWhere = arguments.getString(EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_INBOX);
|
mWhere = arguments.getString(EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
|
||||||
mAdapter = new MessageRecyclerViewAdapter(mActivity, mOauthRetrofit, mCustomThemeWrapper,
|
mAdapter = new MessageRecyclerViewAdapter(mActivity, mOauthRetrofit, mCustomThemeWrapper,
|
||||||
mAccessToken, mWhere, () -> mMessageViewModel.retryLoadingMore());
|
mAccessToken, mWhere, () -> mMessageViewModel.retryLoadingMore());
|
||||||
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
||||||
@ -190,7 +190,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onRepliedToPrivateMessageEvent(RepliedToPrivateMessageEvent repliedToPrivateMessageEvent) {
|
public void onRepliedToPrivateMessageEvent(RepliedToPrivateMessageEvent repliedToPrivateMessageEvent) {
|
||||||
if (mAdapter != null && mWhere.equals(FetchMessages.WHERE_MESSAGES)) {
|
if (mAdapter != null && mWhere.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||||
mAdapter.updateMessageReply(repliedToPrivateMessageEvent.newReply, repliedToPrivateMessageEvent.messagePosition);
|
mAdapter.updateMessageReply(repliedToPrivateMessageEvent.newReply, repliedToPrivateMessageEvent.messagePosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import butterknife.ButterKnife;
|
|||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
@ -101,6 +102,11 @@ public class SidebarFragment extends Fragment {
|
|||||||
textView.setTextColor(markdownColor);
|
textView.setTextColor(markdownColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||||
|
builder.linkColor(mCustomThemeWrapper.getLinkColor());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
@ -113,6 +119,7 @@ public class SidebarFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
|
}).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -13,7 +13,7 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class FetchMessages {
|
public class FetchMessage {
|
||||||
|
|
||||||
public static final String WHERE_INBOX = "inbox";
|
public static final String WHERE_INBOX = "inbox";
|
||||||
public static final String WHERE_UNREAD = "unread";
|
public static final String WHERE_UNREAD = "unread";
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@ -6,11 +6,11 @@ import android.os.Parcelable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Message implements Parcelable {
|
public class Message implements Parcelable {
|
||||||
static final String TYPE_COMMENT = "t1";
|
public static final String TYPE_COMMENT = "t1";
|
||||||
static final String TYPE_ACCOUNT = "t2";
|
public static final String TYPE_ACCOUNT = "t2";
|
||||||
static final String TYPE_LINK = "t3";
|
public static final String TYPE_LINK = "t3";
|
||||||
static final String TYPE_MESSAGE = "t4";
|
public static final String TYPE_MESSAGE = "t4";
|
||||||
static final String TYPE_SUBREDDIT = "t5";
|
public static final String TYPE_SUBREDDIT = "t5";
|
||||||
static final String TYPE_AWARD = "t6";
|
static final String TYPE_AWARD = "t6";
|
||||||
|
|
||||||
private String kind;
|
private String kind;
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -8,6 +8,7 @@ import androidx.paging.PageKeyedDataSource;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
||||||
@ -29,10 +30,10 @@ class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
|||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.where = where;
|
this.where = where;
|
||||||
if (where.equals(FetchMessages.WHERE_MESSAGES)) {
|
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||||
messageType = FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE;
|
messageType = FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE;
|
||||||
} else {
|
} else {
|
||||||
messageType = FetchMessages.MESSAGE_TYPE_INBOX;
|
messageType = FetchMessage.MESSAGE_TYPE_INBOX;
|
||||||
}
|
}
|
||||||
paginationNetworkStateLiveData = new MutableLiveData<>();
|
paginationNetworkStateLiveData = new MutableLiveData<>();
|
||||||
initialLoadStateLiveData = new MutableLiveData<>();
|
initialLoadStateLiveData = new MutableLiveData<>();
|
||||||
@ -59,8 +60,8 @@ class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
|||||||
public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull LoadInitialCallback<String, Message> callback) {
|
public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull LoadInitialCallback<String, Message> callback) {
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADING);
|
initialLoadStateLiveData.postValue(NetworkState.LOADING);
|
||||||
|
|
||||||
FetchMessages.fetchInbox(oauthRetrofit, locale, accessToken, where, null, messageType,
|
FetchMessage.fetchInbox(oauthRetrofit, locale, accessToken, where, null, messageType,
|
||||||
new FetchMessages.FetchMessagesListener() {
|
new FetchMessage.FetchMessagesListener() {
|
||||||
@Override
|
@Override
|
||||||
public void fetchSuccess(ArrayList<Message> messages, @Nullable String after) {
|
public void fetchSuccess(ArrayList<Message> messages, @Nullable String after) {
|
||||||
if (messages.size() == 0) {
|
if (messages.size() == 0) {
|
||||||
@ -96,8 +97,8 @@ class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
|||||||
|
|
||||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADING);
|
paginationNetworkStateLiveData.postValue(NetworkState.LOADING);
|
||||||
|
|
||||||
FetchMessages.fetchInbox(oauthRetrofit, locale, accessToken, where, params.key, messageType,
|
FetchMessage.fetchInbox(oauthRetrofit, locale, accessToken, where, params.key, messageType,
|
||||||
new FetchMessages.FetchMessagesListener() {
|
new FetchMessage.FetchMessagesListener() {
|
||||||
@Override
|
@Override
|
||||||
public void fetchSuccess(ArrayList<Message> messages, @Nullable String after) {
|
public void fetchSuccess(ArrayList<Message> messages, @Nullable String after) {
|
||||||
if (after == null || after.equals("") || after.equals("null")) {
|
if (after == null || after.equals("") || after.equals("null")) {
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
@ -11,6 +11,7 @@ import androidx.paging.PagedList;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MessageViewModel extends ViewModel {
|
public class MessageViewModel extends ViewModel {
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ public class ParseMessage {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private static Message parseSingleMessage(JSONObject messageJSON, Locale locale, int messageType) throws JSONException {
|
private static Message parseSingleMessage(JSONObject messageJSON, Locale locale, int messageType) throws JSONException {
|
||||||
String kind = messageJSON.getString(JSONUtils.KIND_KEY);
|
String kind = messageJSON.getString(JSONUtils.KIND_KEY);
|
||||||
if ((messageType == FetchMessages.MESSAGE_TYPE_INBOX && kind.equals("t4")) ||
|
if ((messageType == FetchMessage.MESSAGE_TYPE_INBOX && kind.equals("t4")) ||
|
||||||
(messageType == FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE && !kind.equals("t4"))) {
|
(messageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE && !kind.equals("t4"))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public class ParseMessage {
|
|||||||
try {
|
try {
|
||||||
JSONObject messageJSON = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY)
|
JSONObject messageJSON = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY)
|
||||||
.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.THINGS_KEY).getJSONObject(0);
|
.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.THINGS_KEY).getJSONObject(0);
|
||||||
message = parseSingleMessage(messageJSON, locale, FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE);
|
message = parseSingleMessage(messageJSON, locale, FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
errorMessage = parseRepliedMessageErrorMessage(response);
|
errorMessage = parseRepliedMessageErrorMessage(response);
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Message;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -31,6 +31,9 @@ import ml.docilealligator.infinityforreddit.Account.Account;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.InboxActivity;
|
import ml.docilealligator.infinityforreddit.Activity.InboxActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
|
import ml.docilealligator.infinityforreddit.Message.FetchMessage;
|
||||||
|
import ml.docilealligator.infinityforreddit.Message.Message;
|
||||||
|
import ml.docilealligator.infinityforreddit.Message.ParseMessage;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
@ -85,7 +88,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
String responseBody = response.body();
|
String responseBody = response.body();
|
||||||
JSONArray messageArray = new JSONObject(responseBody).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
JSONArray messageArray = new JSONObject(responseBody).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||||
ArrayList<Message> messages = ParseMessage.parseMessages(messageArray,
|
ArrayList<Message> messages = ParseMessage.parseMessages(messageArray,
|
||||||
context.getResources().getConfiguration().locale, FetchMessages.MESSAGE_TYPE_NOTIFICATION);
|
context.getResources().getConfiguration().locale, FetchMessage.MESSAGE_TYPE_NOTIFICATION);
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
NotificationManagerCompat notificationManager = NotificationUtils.getNotificationManager(context);
|
NotificationManagerCompat notificationManager = NotificationUtils.getNotificationManager(context);
|
||||||
@ -218,7 +221,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
|
|
||||||
Call<String> call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
|
Call<String> call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
|
||||||
.getMessages(APIUtils.getOAuthHeader(account.getAccessToken()),
|
.getMessages(APIUtils.getOAuthHeader(account.getAccessToken()),
|
||||||
FetchMessages.WHERE_UNREAD, null);
|
FetchMessage.WHERE_UNREAD, null);
|
||||||
Response<String> response = call.execute();
|
Response<String> response = call.execute();
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -26,7 +26,7 @@ import ml.docilealligator.infinityforreddit.User.UserDao;
|
|||||||
import ml.docilealligator.infinityforreddit.User.UserData;
|
import ml.docilealligator.infinityforreddit.User.UserData;
|
||||||
|
|
||||||
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
||||||
SubscribedUserData.class, MultiReddit.class, CustomTheme.class}, version = 8)
|
SubscribedUserData.class, MultiReddit.class, CustomTheme.class}, version = 9)
|
||||||
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||||
private static RedditDataRoomDatabase INSTANCE;
|
private static RedditDataRoomDatabase INSTANCE;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
|
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
|
||||||
RedditDataRoomDatabase.class, "reddit_data")
|
RedditDataRoomDatabase.class, "reddit_data")
|
||||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
|
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
|
||||||
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8)
|
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,4 +186,27 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
+ " ADD COLUMN bottom_app_bar_icon_color INTEGER DEFAULT " + Color.parseColor("#000000") + " NOT NULL");
|
+ " ADD COLUMN bottom_app_bar_icon_color INTEGER DEFAULT " + Color.parseColor("#000000") + " NOT NULL");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_8_9 = new Migration(8, 9) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN link_color INTEGER DEFAULT " + Color.parseColor("#FF4081") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN received_message_text_color INTEGER DEFAULT " + Color.parseColor("#FFFFFF") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN sent_message_text_color INTEGER DEFAULT " + Color.parseColor("#FFFFFF") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN received_message_background_color INTEGER DEFAULT " + Color.parseColor("#4185F4") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN sent_message_background_color INTEGER DEFAULT " + Color.parseColor("#31BF7D") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN send_message_icon_color INTEGER DEFAULT " + Color.parseColor("#4185F4") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN fully_collapsed_comment_background_color INTEGER DEFAULT " + Color.parseColor("#4185F4") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes"
|
||||||
|
+ " ADD COLUMN awarded_comment_background_color INTEGER DEFAULT " + Color.parseColor("#EEAB02") + " NOT NULL");
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,14 @@ public class CustomThemeSharedPreferencesUtils {
|
|||||||
public static final String COMMENT_VERTICAL_BAR_COLOR_7 = "commentVerticalBarColor7";
|
public static final String COMMENT_VERTICAL_BAR_COLOR_7 = "commentVerticalBarColor7";
|
||||||
public static final String FAB_ICON_COLOR = "fabIconColor";
|
public static final String FAB_ICON_COLOR = "fabIconColor";
|
||||||
public static final String CHIP_TEXT_COLOR = "chipTextColor";
|
public static final String CHIP_TEXT_COLOR = "chipTextColor";
|
||||||
|
public static final String LINK_COLOR = "linkColor";
|
||||||
|
public static final String RECEIVED_MESSAGE_TEXT_COLOR = "receivedMessageTextColor";
|
||||||
|
public static final String SENT_MESSAGE_TEXT_COLOR = "sentMessageTextColor";
|
||||||
|
public static final String RECEIVED_MESSAGE_BACKROUND_COLOR = "receivedMessageBackgroundColor";
|
||||||
|
public static final String SENT_MESSAGE_BACKGROUND_COLOR = "sentMessageBackgroundColor";
|
||||||
|
public static final String SEND_MESSAGE_ICON_COLOR = "sentMessageIconColor";
|
||||||
|
public static final String FULLY_COLLAPSED_COMMENT_BACKGROUND_COLOR = "fullyCollapsedCommentBackgroundColor";
|
||||||
|
public static final String AWARDED_COMMENT_BACKGROUND_COLOR = "awardedCommentBackgroundColor";
|
||||||
|
|
||||||
public static void insertThemeToSharedPreferences(CustomTheme customTheme, SharedPreferences themeSharedPreferences) {
|
public static void insertThemeToSharedPreferences(CustomTheme customTheme, SharedPreferences themeSharedPreferences) {
|
||||||
SharedPreferences.Editor editor = themeSharedPreferences.edit();
|
SharedPreferences.Editor editor = themeSharedPreferences.edit();
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
android:fontFamily="?attr/font_family" />
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/more_count_text_view_item_comment_fully_collapsed"
|
android:id="@+id/time_text_view_item_comment_fully_collapsed"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
|
@ -569,12 +569,26 @@
|
|||||||
<string name="theme_item_button_text_color_detail">Applied to: Text on button</string>
|
<string name="theme_item_button_text_color_detail">Applied to: Text on button</string>
|
||||||
<string name="theme_item_chip_text_color">Chip Text Color</string>
|
<string name="theme_item_chip_text_color">Chip Text Color</string>
|
||||||
<string name="theme_item_chip_text_color_detail">Applied to: Subscribe Button</string>
|
<string name="theme_item_chip_text_color_detail">Applied to: Subscribe Button</string>
|
||||||
|
<string name="theme_item_link_color">Link Color</string>
|
||||||
|
<string name="theme_item_link_color_detail">Applied to: URL</string>
|
||||||
|
<string name="theme_item_received_message_text_color">Received Message Text Color</string>
|
||||||
|
<string name="theme_item_received_message_text_color_detail">Applied to: Received Private Messages</string>
|
||||||
|
<string name="theme_item_sent_message_text_color">Sent Message Text Color</string>
|
||||||
|
<string name="theme_item_sent_message_text_color_detail">Applied to: Sent Private Messages</string>
|
||||||
<string name="theme_item_background_color">Background Color</string>
|
<string name="theme_item_background_color">Background Color</string>
|
||||||
<string name="theme_item_background_color_detail">Applied to: Background of every page and navigation drawer</string>
|
<string name="theme_item_background_color_detail">Applied to: Background of every page and navigation drawer</string>
|
||||||
<string name="theme_item_card_view_background_color">Card View Background Color</string>
|
<string name="theme_item_card_view_background_color">Card View Background Color</string>
|
||||||
<string name="theme_item_card_view_background_color_detail">Applied to: Post background and message background</string>
|
<string name="theme_item_card_view_background_color_detail">Applied to: Post background and message background</string>
|
||||||
<string name="theme_item_comment_background_color">Comment Background Color</string>
|
<string name="theme_item_comment_background_color">Comment Background Color</string>
|
||||||
<string name="theme_item_comment_background_color_detail">Applied to: Comment background</string>
|
<string name="theme_item_comment_background_color_detail">Applied to: Comment background</string>
|
||||||
|
<string name="theme_item_fully_collapsed_comment_background_color">Fully-Collapsed Comment Background Color</string>
|
||||||
|
<string name="theme_item_fully_collapsed_comment_background_color_detail">Applied to: Background of fully-collapsed comments</string>
|
||||||
|
<string name="theme_item_awarded_comment_background_color">Awarded Comment Background Color</string>
|
||||||
|
<string name="theme_item_awarded_comment_background_color_detail">Applied to: Background of awarded comments</string>
|
||||||
|
<string name="theme_item_received_message_background_color">Received Message Background Color</string>
|
||||||
|
<string name="theme_item_received_message_background_color_detail">Applied to: Background of received private messages</string>
|
||||||
|
<string name="theme_item_sent_message_background_color">Sent Message Background Color</string>
|
||||||
|
<string name="theme_item_sent_message_background_color_detail">Applied to: Background of sent private messages</string>
|
||||||
<string name="theme_item_bottom_app_bar_background_color">Bottom Navigation Bar Color</string>
|
<string name="theme_item_bottom_app_bar_background_color">Bottom Navigation Bar Color</string>
|
||||||
<string name="theme_item_bottom_app_bar_background_color_detail">Applied to: Bottom navigation bar</string>
|
<string name="theme_item_bottom_app_bar_background_color_detail">Applied to: Bottom navigation bar</string>
|
||||||
<string name="theme_item_primary_icon_color">Primary Icon Color</string>
|
<string name="theme_item_primary_icon_color">Primary Icon Color</string>
|
||||||
@ -587,6 +601,8 @@
|
|||||||
<string name="theme_item_comment_icon_and_info_color_detail">Applied to: Icons and score in comments</string>
|
<string name="theme_item_comment_icon_and_info_color_detail">Applied to: Icons and score in comments</string>
|
||||||
<string name="theme_item_fab_icon_color">Floating Action Button Icon Color</string>
|
<string name="theme_item_fab_icon_color">Floating Action Button Icon Color</string>
|
||||||
<string name="theme_item_fab_icon_color_detail">Applied to: Floating action button icon</string>
|
<string name="theme_item_fab_icon_color_detail">Applied to: Floating action button icon</string>
|
||||||
|
<string name="theme_item_send_message_icon_color">Send Message Icon Color</string>
|
||||||
|
<string name="theme_item_send_message_icon_color_detail">Applied to: send private message icon</string>
|
||||||
<string name="theme_item_toolbar_primary_text_and_icon_color">Toolbar Primary Text and Icon Color</string>
|
<string name="theme_item_toolbar_primary_text_and_icon_color">Toolbar Primary Text and Icon Color</string>
|
||||||
<string name="theme_item_toolbar_primary_text_and_icon_color_detail">Applied to: Primary texts and icons in toolbars</string>
|
<string name="theme_item_toolbar_primary_text_and_icon_color_detail">Applied to: Primary texts and icons in toolbars</string>
|
||||||
<string name="theme_item_toolbar_secondary_text_color">Toolbar Secondary Text Color</string>
|
<string name="theme_item_toolbar_secondary_text_color">Toolbar Secondary Text Color</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user