diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java index c87fd263..8eeb0a07 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java @@ -49,14 +49,14 @@ import io.noties.markwon.recycler.table.TableEntryPlugin; import io.noties.markwon.simple.ext.SimpleExtPlugin; import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute; 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.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; 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.Utils; import retrofit2.Retrofit; @@ -330,13 +330,13 @@ public class CommentActivity extends BaseActivity { mAccessToken, new SendComment.SendCommentListener() { @Override - public void sendCommentSuccess(CommentData commentData) { + public void sendCommentSuccess(Comment comment) { isSubmitting = false; item.setEnabled(true); item.getIcon().setAlpha(255); Toast.makeText(CommentActivity.this, R.string.send_comment_success, Toast.LENGTH_SHORT).show(); 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); if (isReplying) { returnIntent.putExtra(EXTRA_PARENT_POSITION_KEY, parentPosition); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/InboxActivity.java index 66072a2b..fa62c47c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/InboxActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/InboxActivity.java @@ -38,7 +38,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; 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.Infinity; import ml.docilealligator.infinityforreddit.R; @@ -280,14 +280,14 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf InboxFragment fragment = new InboxFragment(); Bundle bundle = new Bundle(); 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); return fragment; } else { InboxFragment fragment = new InboxFragment(); Bundle bundle = new Bundle(); 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); return fragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 04c1ff41..824a686d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -82,7 +82,7 @@ import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.PullNotificationWorker; 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.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 6586dd08..000e677d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -62,7 +62,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; 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.CustomView.CustomToroContainer; 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.PostUpdateEventToPostList; 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.FetchRemovedPost; import ml.docilealligator.infinityforreddit.Flair; 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.HidePost; import ml.docilealligator.infinityforreddit.Post.ParsePost; import ml.docilealligator.infinityforreddit.Post.Post; 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.SaveThing; import ml.docilealligator.infinityforreddit.SortType; @@ -126,7 +126,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @State boolean isSingleCommentThreadMode = false; @State - ArrayList comments; + ArrayList comments; @State ArrayList children; @State @@ -648,7 +648,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS ParseComment.parseComment(response.body(), new ArrayList<>(), mLocale, mExpandChildren, new ParseComment.ParseCommentListener() { @Override - public void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenFullnames) { + public void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenFullnames) { ViewPostDetailActivity.this.children = moreChildrenFullnames; hasMoreChildren = children.size() != 0; @@ -738,7 +738,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS FetchComment.fetchComments(retrofit, mAccessToken, mPost.getId(), commentId, sortType, mExpandChildren, mLocale, new FetchComment.FetchCommentListener() { @Override - public void onFetchCommentSuccess(ArrayList expandedComments, + public void onFetchCommentSuccess(ArrayList expandedComments, String parentId, ArrayList children) { if (checkSortState && isSortingComments) { if (changeRefreshState) { @@ -840,7 +840,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS FetchComment.fetchMoreComment(retrofit, mAccessToken, children, mChildrenStartingIndex, 0, mExpandChildren, mLocale, new FetchComment.FetchMoreCommentListener() { @Override - public void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex) { + public void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex) { hasMoreChildren = childrenStartingIndex < children.size(); mAdapter.addComments(expandedComments, hasMoreChildren); mChildrenStartingIndex = childrenStartingIndex; @@ -1091,14 +1091,14 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS .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(); FetchRemovedComment.fetchRemovedComment( pushshiftRetrofit, comment, new FetchRemovedComment.FetchRemovedCommentListener() { @Override - public void fetchSuccess(CommentData comment) { + public void fetchSuccess(Comment comment) { 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 (data != null && resultCode == RESULT_OK) { 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) { mAdapter.addComment(comment); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java index b75f9e8b..e78cdc47 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java @@ -39,11 +39,11 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.RepliedToPrivateMessageEvent; 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.ReadMessage; +import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.ReplyMessage; +import ml.docilealligator.infinityforreddit.Message.ReplyMessage; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index 2b516549..aa42d49a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -73,7 +73,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Post.PostDataSource; 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.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index cbcd54be..8134ebcf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -70,7 +70,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Post.PostDataSource; 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.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index cb3bc599..f815b3c6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -69,6 +69,7 @@ import im.ene.toro.widget.Container; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; +import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.ext.strikethrough.StrikethroughPlugin; import io.noties.markwon.linkify.LinkifyPlugin; 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.CopyTextBottomSheetFragment; 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.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager; -import ml.docilealligator.infinityforreddit.FetchComment; import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; @@ -138,7 +139,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter mVisibleComments; + private ArrayList mVisibleComments; private String mSubredditNamePrefixed; private Locale mLocale; private String mSingleCommentId; @@ -205,6 +206,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter= 0) { - CommentData parentComment = mVisibleComments.get(parentPosition); + Comment parentComment = mVisibleComments.get(parentPosition); mVisibleComments.get(commentPosition).setLoadingMoreChildren(true); mVisibleComments.get(commentPosition).setLoadMoreChildrenFailed(false); @@ -1014,7 +1032,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter expandedComments, + public void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex) { if (mVisibleComments.size() > parentPosition && parentComment.getFullName().equals(mVisibleComments.get(parentPosition).getFullName())) { @@ -1287,7 +1305,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter comments, ArrayList newList, int position) { + private void expandChildren(ArrayList comments, ArrayList newList, int position) { if (comments != null && comments.size() > 0) { newList.addAll(position, comments); for (int i = 0; i < comments.size(); i++) { @@ -1327,7 +1345,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter comments, boolean hasMoreComments) { + public void addComments(@NonNull ArrayList comments, boolean hasMoreComments) { if (mVisibleComments.size() == 0) { isInitiallyLoading = false; isInitiallyLoadingFailed = false; @@ -1364,7 +1382,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter newList = new ArrayList<>(); + ArrayList newList = new ArrayList<>(); expandChildren(mVisibleComments.get(parentPosition).getChildren(), newList, 0); mVisibleComments.get(parentPosition).setExpanded(true); mVisibleComments.addAll(parentPosition + 1, newList); @@ -1417,7 +1435,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter getVisibleComments() { + public ArrayList getVisibleComments() { return mVisibleComments; } @@ -2799,7 +2817,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter authorTextView.performClick()); moreButton.setOnClickListener(view -> { - CommentData comment = getCurrentComment(this); + Comment comment = getCurrentComment(this); Bundle bundle = new Bundle(); if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) { bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken); @@ -2831,7 +2849,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { - CommentData comment = getCurrentComment(this); + Comment comment = getCurrentComment(this); if (comment.isSaved()) { comment.setSaved(false); SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() { @@ -3018,13 +3036,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter= 0 && commentPosition < mVisibleComments.size()) { - CommentData comment = getCurrentComment(this); + Comment comment = getCurrentComment(this); if (mVisibleComments.get(commentPosition).isExpanded()) { collapseChildren(commentPosition); expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp); } else { comment.setExpanded(true); - ArrayList newList = new ArrayList<>(); + ArrayList newList = new ArrayList<>(); expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0); mVisibleComments.get(commentPosition).setExpanded(true); mVisibleComments.addAll(commentPosition + 1, newList); @@ -3082,8 +3100,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1; if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) { - CommentData comment = getCurrentComment(this); + Comment comment = getCurrentComment(this); comment.setExpanded(true); - ArrayList newList = new ArrayList<>(); + ArrayList newList = new ArrayList<>(); expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0); mVisibleComments.get(commentPosition).setExpanded(true); mVisibleComments.addAll(commentPosition + 1, newList); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java index f58da947..eb3ef3f2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java @@ -33,6 +33,7 @@ import butterknife.ButterKnife; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; +import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.ext.strikethrough.StrikethroughPlugin; import io.noties.markwon.linkify.LinkifyPlugin; 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.ViewUserDetailActivity; 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.NetworkState; import ml.docilealligator.infinityforreddit.R; @@ -52,19 +53,19 @@ import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.VoteThing; import retrofit2.Retrofit; -public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { +public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { private static final int VIEW_TYPE_DATA = 0; private static final int VIEW_TYPE_ERROR = 1; private static final int VIEW_TYPE_LOADING = 2; - private static final DiffUtil.ItemCallback DIFF_CALLBACK = new DiffUtil.ItemCallback() { + private static final DiffUtil.ItemCallback DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override - public boolean areItemsTheSame(@NonNull CommentData commentData, @NonNull CommentData t1) { - return commentData.getId().equals(t1.getId()); + public boolean areItemsTheSame(@NonNull Comment comment, @NonNull Comment t1) { + return comment.getId().equals(t1.getId()); } @Override - public boolean areContentsTheSame(@NonNull CommentData commentData, @NonNull CommentData t1) { - return commentData.getCommentMarkdown().equals(t1.getCommentMarkdown()); + public boolean areContentsTheSame(@NonNull Comment comment, @NonNull Comment t1) { + return comment.getCommentMarkdown().equals(t1.getCommentMarkdown()); } }; private Context mContext; @@ -103,6 +104,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { @@ -115,6 +121,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { @@ -104,10 +104,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter { - if (mMessageType == FetchMessages.MESSAGE_TYPE_INBOX + if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX && message.getContext() != null && !message.getContext().equals("")) { Uri uri = LinkResolverActivity.getRedditUriByPath(message.getContext()); Intent intent = new Intent(mContext, LinkResolverActivity.class); intent.setData(uri); 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.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message); intent.putExtra(ViewPrivateMessagesActivity.EXTRA_MESSAGE_POSITION, holder.getAdapterPosition()); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java index 7cbf73a1..5bcbba8a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java @@ -34,7 +34,7 @@ import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity; import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity; 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.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java index 5d23975d..2b5e62df 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java @@ -20,6 +20,7 @@ import butterknife.ButterKnife; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; +import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.ext.strikethrough.StrikethroughPlugin; import io.noties.markwon.linkify.LinkifyPlugin; import io.noties.markwon.simple.ext.SimpleExtPlugin; @@ -50,6 +51,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter { Intent intent = new Intent(activity, EditCommentActivity.class); intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken); - intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, commentData.getFullName()); - intent.putExtra(EditCommentActivity.EXTRA_CONTENT, commentData.getCommentMarkdown()); + intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, comment.getFullName()); + intent.putExtra(EditCommentActivity.EXTRA_CONTENT, comment.getCommentMarkdown()); intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION)); if (activity instanceof ViewPostDetailActivity) { activity.startActivityForResult(intent, ViewPostDetailActivity.EDIT_COMMENT_REQUEST_CODE); @@ -96,9 +96,9 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag deleteTextView.setOnClickListener(view -> { dismiss(); 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) { - ((ViewUserDetailActivity) activity).deleteComment(commentData.getFullName()); + ((ViewUserDetailActivity) activity).deleteComment(comment.getFullName()); } }); } @@ -108,7 +108,7 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag try { Intent intent = new Intent(Intent.ACTION_SEND); 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))); } catch (ActivityNotFoundException e) { Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show(); @@ -119,31 +119,31 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag dismiss(); CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment(); Bundle copyBundle = new Bundle(); - copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, commentData.getCommentMarkdown()); - copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, commentData.getCommentRawText()); + copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, comment.getCommentMarkdown()); + copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, comment.getCommentRawText()); copyTextBottomSheetFragment.setArguments(copyBundle); copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag()); }); reportTextView.setOnClickListener(view -> { Intent intent = new Intent(activity, ReportActivity.class); - intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, commentData.getSubredditName()); - intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, commentData.getFullName()); + intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getSubredditName()); + intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName()); activity.startActivity(intent); dismiss(); }); - if ("[deleted]".equals(commentData.getAuthor()) || - "[deleted]".equals(commentData.getCommentRawText()) || - "[removed]".equals(commentData.getCommentRawText()) + if ("[deleted]".equals(comment.getAuthor()) || + "[deleted]".equals(comment.getCommentRawText()) || + "[removed]".equals(comment.getCommentRawText()) ) { seeRemovedTextView.setVisibility(View.VISIBLE); seeRemovedTextView.setOnClickListener(view -> { dismiss(); if (activity instanceof ViewPostDetailActivity) { - ((ViewPostDetailActivity) activity).showRemovedComment(commentData, bundle.getInt(EXTRA_POSITION)); + ((ViewPostDetailActivity) activity).showRemovedComment(comment, bundle.getInt(EXTRA_POSITION)); } }); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/Comment.java similarity index 86% rename from app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/Comment.java index 0880e19a..5d27a3a1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/Comment.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import android.os.Parcel; import android.os.Parcelable; @@ -7,19 +7,19 @@ import java.util.ArrayList; 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_UPVOTE = 1; public static final int VOTE_TYPE_DOWNVOTE = -1; - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = new Creator() { @Override - public CommentData createFromParcel(Parcel in) { - return new CommentData(in); + public Comment createFromParcel(Parcel in) { + return new Comment(in); } @Override - public CommentData[] newArray(int size) { - return new CommentData[size]; + public Comment[] newArray(int size) { + return new Comment[size]; } }; private String id; @@ -47,20 +47,20 @@ public class CommentData implements Parcelable { private boolean saved; private boolean isExpanded; private boolean hasExpandedBefore; - private ArrayList children; + private ArrayList children; private ArrayList moreChildrenFullnames; private int moreChildrenStartingIndex; private boolean isPlaceHolder; private boolean isLoadingMoreChildren; private boolean loadMoreChildrenFailed; - public CommentData(String id, String fullName, String author, String authorFlair, - String authorFlairHTML, String linkAuthor, - long commentTimeMillis, String commentMarkdown, String commentRawText, - String linkId, String subredditName, String parentId, int score, - int voteType, boolean isSubmitter, String distinguished, String permalink, - String awards, int depth, boolean collapsed, boolean hasReply, - boolean scoreHidden, boolean saved) { + public Comment(String id, String fullName, String author, String authorFlair, + String authorFlairHTML, String linkAuthor, + long commentTimeMillis, String commentMarkdown, String commentRawText, + String linkId, String subredditName, String parentId, int score, + int voteType, boolean isSubmitter, String distinguished, String permalink, + String awards, int depth, boolean collapsed, boolean hasReply, + boolean scoreHidden, boolean saved) { this.id = id; this.fullName = fullName; this.author = author; @@ -90,7 +90,7 @@ public class CommentData implements Parcelable { isPlaceHolder = false; } - public CommentData(String parentFullName, int depth) { + public Comment(String parentFullName, int depth) { this.fullName = parentFullName; this.depth = depth; isPlaceHolder = true; @@ -98,7 +98,7 @@ public class CommentData implements Parcelable { loadMoreChildrenFailed = false; } - protected CommentData(Parcel in) { + protected Comment(Parcel in) { id = in.readString(); fullName = in.readString(); author = in.readString(); @@ -123,8 +123,8 @@ public class CommentData implements Parcelable { scoreHidden = in.readByte() != 0; isExpanded = in.readByte() != 0; hasExpandedBefore = in.readByte() != 0; - children = in.readArrayList(CommentData.class.getClassLoader()); - moreChildrenFullnames = in.readArrayList(CommentData.class.getClassLoader()); + children = in.readArrayList(Comment.class.getClassLoader()); + moreChildrenFullnames = in.readArrayList(Comment.class.getClassLoader()); moreChildrenStartingIndex = in.readInt(); isPlaceHolder = in.readByte() != 0; isLoadingMoreChildren = in.readByte() != 0; @@ -270,15 +270,15 @@ public class CommentData implements Parcelable { this.voteType = voteType; } - public ArrayList getChildren() { + public ArrayList getChildren() { return children; } - public void setChildren(ArrayList children) { + public void setChildren(ArrayList children) { this.children = children; } - public void addChildren(ArrayList moreChildren) { + public void addChildren(ArrayList moreChildren) { if (children == null || children.size() == 0) { setChildren(moreChildren); } else { @@ -290,11 +290,11 @@ public class CommentData implements Parcelable { } } - public void addChild(CommentData comment) { + public void addChild(Comment comment) { addChild(comment, 0); } - public void addChild(CommentData comment, int position) { + public void addChild(Comment comment, int position) { if (children == null) { children = new ArrayList<>(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentDataSource.java similarity index 93% rename from app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentDataSource.java index 598579df..35a8ddd2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentDataSource.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import android.os.AsyncTask; @@ -15,7 +15,9 @@ import java.util.ArrayList; import java.util.Locale; import ml.docilealligator.infinityforreddit.API.RedditAPI; +import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.Post.PostDataSource; +import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import retrofit2.Call; @@ -23,7 +25,7 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; -public class CommentDataSource extends PageKeyedDataSource { +public class CommentDataSource extends PageKeyedDataSource { private Retrofit retrofit; private Locale locale; @@ -38,7 +40,7 @@ public class CommentDataSource extends PageKeyedDataSource private MutableLiveData hasPostLiveData; private LoadParams params; - private LoadCallback callback; + private LoadCallback callback; CommentDataSource(Retrofit retrofit, Locale locale, @Nullable String accessToken, String username, SortType sortType, boolean areSavedComments) { @@ -70,7 +72,7 @@ public class CommentDataSource extends PageKeyedDataSource } @Override - public void loadInitial(@NonNull LoadInitialParams params, @NonNull LoadInitialCallback callback) { + public void loadInitial(@NonNull LoadInitialParams params, @NonNull LoadInitialCallback callback) { initialLoadStateLiveData.postValue(NetworkState.LOADING); RedditAPI api = retrofit.create(RedditAPI.class); @@ -108,7 +110,7 @@ public class CommentDataSource extends PageKeyedDataSource if (response.isSuccessful()) { new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() { @Override - public void parseSuccessful(ArrayList comments, String after) { + public void parseSuccessful(ArrayList comments, String after) { if (comments.size() == 0) { hasPostLiveData.postValue(false); } else { @@ -141,12 +143,12 @@ public class CommentDataSource extends PageKeyedDataSource } @Override - public void loadBefore(@NonNull LoadParams params, @NonNull LoadCallback callback) { + public void loadBefore(@NonNull LoadParams params, @NonNull LoadCallback callback) { } @Override - public void loadAfter(@NonNull LoadParams params, @NonNull LoadCallback callback) { + public void loadAfter(@NonNull LoadParams params, @NonNull LoadCallback callback) { this.params = params; this.callback = callback; @@ -186,7 +188,7 @@ public class CommentDataSource extends PageKeyedDataSource if (response.isSuccessful()) { new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() { @Override - public void parseSuccessful(ArrayList comments, String after) { + public void parseSuccessful(ArrayList comments, String after) { if (after == null || after.equals("") || after.equals("null")) { callback.onResult(comments, null); } else { @@ -212,7 +214,7 @@ public class CommentDataSource extends PageKeyedDataSource }); } - private static class ParseCommentAsyncTask extends AsyncTask, ArrayList> { + private static class ParseCommentAsyncTask extends AsyncTask, ArrayList> { private String after; private Locale locale; private JSONArray commentsJSONArray; @@ -234,12 +236,12 @@ public class CommentDataSource extends PageKeyedDataSource } @Override - protected ArrayList doInBackground(Void... voids) { + protected ArrayList doInBackground(Void... voids) { if (parseFailed) { return null; } - ArrayList comments = new ArrayList<>(); + ArrayList comments = new ArrayList<>(); for (int i = 0; i < commentsJSONArray.length(); i++) { try { JSONObject commentJSON = commentsJSONArray.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY); @@ -251,7 +253,7 @@ public class CommentDataSource extends PageKeyedDataSource } @Override - protected void onPostExecute(ArrayList commentData) { + protected void onPostExecute(ArrayList commentData) { super.onPostExecute(commentData); if (commentData != null) { parseCommentAsyncTaskListener.parseSuccessful(commentData, after); @@ -261,7 +263,7 @@ public class CommentDataSource extends PageKeyedDataSource } interface ParseCommentAsyncTaskListener { - void parseSuccessful(ArrayList comments, String after); + void parseSuccessful(ArrayList comments, String after); void parseFailed(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentDataSourceFactory.java similarity index 93% rename from app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSourceFactory.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentDataSourceFactory.java index 34d24b8a..bd7e5831 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentDataSourceFactory.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -7,6 +7,7 @@ import androidx.paging.DataSource; import java.util.Locale; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; class CommentDataSourceFactory extends DataSource.Factory { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentViewModel.java similarity index 93% rename from app/src/main/java/ml/docilealligator/infinityforreddit/CommentViewModel.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentViewModel.java index 3753ba9f..99832054 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/CommentViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import androidx.annotation.NonNull; import androidx.lifecycle.LiveData; @@ -11,6 +11,8 @@ import androidx.paging.PagedList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class CommentViewModel extends ViewModel { @@ -18,7 +20,7 @@ public class CommentViewModel extends ViewModel { private LiveData paginationNetworkState; private LiveData initialLoadingState; private LiveData hasCommentLiveData; - private LiveData> comments; + private LiveData> comments; private MutableLiveData sortTypeLiveData; public CommentViewModel(Retrofit retrofit, Locale locale, String accessToken, String username, SortType sortType, @@ -48,7 +50,7 @@ public class CommentViewModel extends ViewModel { }); } - public LiveData> getComments() { + public LiveData> getComments() { return comments; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/FetchComment.java similarity index 94% rename from app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/FetchComment.java index b6b16c1b..361a5746 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/FetchComment.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -41,7 +41,7 @@ public class FetchComment { ParseComment.parseComment(response.body(), new ArrayList<>(), locale, expandChildren, new ParseComment.ParseCommentListener() { @Override - public void onParseCommentSuccess(ArrayList expandedComments, + public void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenFullnames) { fetchCommentListener.onFetchCommentSuccess(expandedComments, parentId, moreChildrenFullnames); @@ -101,7 +101,7 @@ public class FetchComment { ParseComment.parseMoreComment(response.body(), new ArrayList<>(), locale, depth, expandChildren, new ParseComment.ParseCommentListener() { @Override - public void onParseCommentSuccess(ArrayList expandedComments, + public void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenFullnames) { fetchMoreCommentListener.onFetchMoreCommentSuccess(expandedComments, startingIndex + 100); @@ -125,13 +125,13 @@ public class FetchComment { } public interface FetchCommentListener { - void onFetchCommentSuccess(ArrayList expandedComments, String parentId, ArrayList children); + void onFetchCommentSuccess(ArrayList expandedComments, String parentId, ArrayList children); void onFetchCommentFailed(); } public interface FetchMoreCommentListener { - void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex); + void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex); void onFetchMoreCommentFailed(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/ParseComment.java similarity index 90% rename from app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/ParseComment.java index 272294ba..fc318e7d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/ParseComment.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import android.os.AsyncTask; import android.text.Html; @@ -15,12 +15,12 @@ import java.util.Locale; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; -import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_DOWNVOTE; -import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_NO_VOTE; -import static ml.docilealligator.infinityforreddit.CommentData.VOTE_TYPE_UPVOTE; +import static ml.docilealligator.infinityforreddit.Comment.Comment.VOTE_TYPE_DOWNVOTE; +import static ml.docilealligator.infinityforreddit.Comment.Comment.VOTE_TYPE_NO_VOTE; +import static ml.docilealligator.infinityforreddit.Comment.Comment.VOTE_TYPE_UPVOTE; public class ParseComment { - public static void parseComment(String response, ArrayList commentData, Locale locale, + public static void parseComment(String response, ArrayList commentData, Locale locale, boolean expandChildren, ParseCommentListener parseCommentListener) { try { JSONArray childrenArray = new JSONArray(response); @@ -35,7 +35,7 @@ public class ParseComment { } } - static void parseMoreComment(String response, ArrayList commentData, Locale locale, + static void parseMoreComment(String response, ArrayList commentData, Locale locale, int depth, boolean expandChildren, ParseCommentListener parseCommentListener) { try { 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(); } - private static void parseCommentRecursion(JSONArray comments, ArrayList newCommentData, + private static void parseCommentRecursion(JSONArray comments, ArrayList newCommentData, ArrayList moreChildrenFullnames, int depth, Locale locale) throws JSONException { int actualCommentLength; @@ -76,12 +76,12 @@ public class ParseComment { for (int i = 0; i < actualCommentLength; i++) { 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) { JSONArray childrenArray = data.getJSONObject(JSONUtils.REPLIES_KEY) .getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY); - ArrayList children = new ArrayList<>(); + ArrayList children = new ArrayList<>(); ArrayList nextMoreChildrenFullnames = new ArrayList<>(); parseCommentRecursion(childrenArray, children, nextMoreChildrenFullnames, singleComment.getDepth(), locale); @@ -93,9 +93,9 @@ public class ParseComment { } } - private static void expandChildren(ArrayList comments, ArrayList visibleComments, + private static void expandChildren(ArrayList comments, ArrayList visibleComments, boolean setExpanded) { - for (CommentData c : comments) { + for (Comment c : comments) { visibleComments.add(c); if (c.hasReply()) { if (setExpanded) { @@ -105,14 +105,14 @@ public class ParseComment { } if (c.hasMoreChildrenFullnames() && c.getMoreChildrenFullnames().size() > c.getMoreChildrenStartingIndex()) { //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); 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 fullName = singleCommentData.getString(JSONUtils.NAME_KEY); String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY); @@ -176,7 +176,7 @@ public class ParseComment { boolean collapsed = singleCommentData.getBoolean(JSONUtils.COLLAPSED_KEY); 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, linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished, permalink, awardingsBuilder.toString(),depth, collapsed, hasReply, scoreHidden, saved); @@ -212,23 +212,23 @@ public class ParseComment { } public interface ParseCommentListener { - void onParseCommentSuccess(ArrayList expandedComments, String parentId, + void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenFullnames); void onParseCommentFailed(); } interface ParseSentCommentListener { - void onParseSentCommentSuccess(CommentData commentData); + void onParseSentCommentSuccess(Comment comment); void onParseSentCommentFailed(@Nullable String errorMessage); } private static class ParseCommentAsyncTask extends AsyncTask { private JSONArray commentsJSONArray; - private ArrayList comments; - private ArrayList newComments; - private ArrayList expandedNewComments; + private ArrayList comments; + private ArrayList newComments; + private ArrayList expandedNewComments; private ArrayList moreChildrenFullnames; private Locale locale; private String parentId; @@ -237,7 +237,7 @@ public class ParseComment { private ParseCommentListener parseCommentListener; private boolean parseFailed; - ParseCommentAsyncTask(JSONArray commentsJSONArray, ArrayList comments, Locale locale, + ParseCommentAsyncTask(JSONArray commentsJSONArray, ArrayList comments, Locale locale, @Nullable String parentId, int depth, boolean expandChildren, ParseCommentListener parseCommentListener) { this.commentsJSONArray = commentsJSONArray; @@ -286,7 +286,7 @@ public class ParseComment { private ParseSentCommentListener parseSentCommentListener; private boolean parseFailed; private String errorMessage; - private CommentData commentData; + private Comment comment; ParseSentCommentAsyncTask(String response, int depth, Locale locale, ParseSentCommentListener parseSentCommentListener) { this.response = response; @@ -300,7 +300,7 @@ public class ParseComment { protected Void doInBackground(Void... voids) { try { JSONObject sentCommentData = new JSONObject(response); - commentData = parseSingleComment(sentCommentData, depth, locale); + comment = parseSingleComment(sentCommentData, depth, locale); } catch (JSONException e) { e.printStackTrace(); errorMessage = parseSentCommentErrorMessage(response); @@ -315,7 +315,7 @@ public class ParseComment { if (parseFailed) { parseSentCommentListener.onParseSentCommentFailed(errorMessage); } else { - parseSentCommentListener.onParseSentCommentSuccess(commentData); + parseSentCommentListener.onParseSentCommentSuccess(comment); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/SendComment.java similarity index 94% rename from app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Comment/SendComment.java index d35d07c7..1ce8fac5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SendComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/SendComment.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -35,8 +35,8 @@ public class SendComment { if (response.isSuccessful()) { ParseComment.parseSentComment(response.body(), parentDepth, locale, new ParseComment.ParseSentCommentListener() { @Override - public void onParseSentCommentSuccess(CommentData commentData) { - sendCommentListener.sendCommentSuccess(commentData); + public void onParseSentCommentSuccess(Comment comment) { + sendCommentListener.sendCommentSuccess(comment); } @Override @@ -57,7 +57,7 @@ public class SendComment { } public interface SendCommentListener { - void sendCommentSuccess(CommentData commentData); + void sendCommentSuccess(Comment comment); void sendCommentFailed(String errorMessage); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java index 7fbd3359..45c12d6f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java @@ -151,6 +151,22 @@ public class CustomTheme { public int fabIconColor; @ColumnInfo(name = "chip_text_color") 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") public boolean isLightStatusBar; @ColumnInfo(name = "is_light_nav_bar") @@ -190,63 +206,71 @@ public class CustomTheme { customTheme.commentColor = customThemeSettingsItems.get(11).colorValue; customTheme.buttonTextColor = customThemeSettingsItems.get(12).colorValue; customTheme.chipTextColor = customThemeSettingsItems.get(13).colorValue; - customTheme.backgroundColor = customThemeSettingsItems.get(14).colorValue; - customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(15).colorValue; - customTheme.commentBackgroundColor = customThemeSettingsItems.get(16).colorValue; - customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(17).colorValue; - customTheme.primaryIconColor = customThemeSettingsItems.get(18).colorValue; - customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(19).colorValue; - customTheme.postIconAndInfoColor = customThemeSettingsItems.get(20).colorValue; - customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(21).colorValue; - customTheme.fabIconColor = customThemeSettingsItems.get(22).colorValue; - customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(23).colorValue; - customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(24).colorValue; - customTheme.circularProgressBarBackground = customThemeSettingsItems.get(25).colorValue; - customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(26).colorValue; - customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(27).colorValue; - customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(28).colorValue; - customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(29).colorValue; - customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(30).colorValue; - customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(31).colorValue; - customTheme.upvoted = customThemeSettingsItems.get(32).colorValue; - customTheme.downvoted = customThemeSettingsItems.get(33).colorValue; - customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(34).colorValue; - customTheme.postTypeTextColor = customThemeSettingsItems.get(35).colorValue; - customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(36).colorValue; - customTheme.spoilerTextColor = customThemeSettingsItems.get(37).colorValue; - customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(38).colorValue; - customTheme.nsfwTextColor = customThemeSettingsItems.get(39).colorValue; - customTheme.flairBackgroundColor = customThemeSettingsItems.get(40).colorValue; - customTheme.flairTextColor = customThemeSettingsItems.get(41).colorValue; - customTheme.awardsBackgroundColor = customThemeSettingsItems.get(42).colorValue; - customTheme.awardsTextColor = customThemeSettingsItems.get(43).colorValue; - customTheme.archivedTint = customThemeSettingsItems.get(44).colorValue; - customTheme.lockedIconTint = customThemeSettingsItems.get(45).colorValue; - customTheme.crosspostIconTint = customThemeSettingsItems.get(46).colorValue; - customTheme.stickiedPostIconTint = customThemeSettingsItems.get(47).colorValue; - customTheme.subscribed = customThemeSettingsItems.get(48).colorValue; - customTheme.unsubscribed = customThemeSettingsItems.get(49).colorValue; - customTheme.username = customThemeSettingsItems.get(50).colorValue; - customTheme.subreddit = customThemeSettingsItems.get(51).colorValue; - customTheme.authorFlairTextColor = customThemeSettingsItems.get(52).colorValue; - customTheme.submitter = customThemeSettingsItems.get(53).colorValue; - customTheme.moderator = customThemeSettingsItems.get(54).colorValue; - customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(55).colorValue; - customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(56).colorValue; - customTheme.dividerColor = customThemeSettingsItems.get(57).colorValue; - customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(58).colorValue; - customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(59).colorValue; - customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(60).colorValue; - customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(61).colorValue; - customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(62).colorValue; - customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(63).colorValue; - customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(64).colorValue; - customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(65).colorValue; - customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(66).colorValue; - customTheme.navBarColor = customThemeSettingsItems.get(67).colorValue; - customTheme.isLightStatusBar = customThemeSettingsItems.get(68).isEnabled; - customTheme.isLightNavBar = customThemeSettingsItems.get(69).isEnabled; - customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(70).isEnabled; + customTheme.linkColor = customThemeSettingsItems.get(14).colorValue; + customTheme.receivedMessageTextColor = customThemeSettingsItems.get(15).colorValue; + customTheme.sentMessageTextColor = customThemeSettingsItems.get(16).colorValue; + customTheme.backgroundColor = customThemeSettingsItems.get(17).colorValue; + customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(18).colorValue; + customTheme.commentBackgroundColor = customThemeSettingsItems.get(19).colorValue; + customTheme.fullyCollapsedCommentBackgroundColor = customThemeSettingsItems.get(20).colorValue; + customTheme.awardedCommentBackgroundColor = customThemeSettingsItems.get(21).colorValue; + customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(22).colorValue; + customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(23).colorValue; + customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(24).colorValue; + customTheme.primaryIconColor = customThemeSettingsItems.get(25).colorValue; + customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(26).colorValue; + customTheme.postIconAndInfoColor = customThemeSettingsItems.get(27).colorValue; + customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(28).colorValue; + customTheme.fabIconColor = customThemeSettingsItems.get(29).colorValue; + customTheme.sendMessageIconColor = customThemeSettingsItems.get(30).colorValue; + customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(31).colorValue; + customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(32).colorValue; + customTheme.circularProgressBarBackground = customThemeSettingsItems.get(33).colorValue; + customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(34).colorValue; + customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(35).colorValue; + customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(36).colorValue; + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(37).colorValue; + customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(38).colorValue; + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(39).colorValue; + customTheme.upvoted = customThemeSettingsItems.get(40).colorValue; + customTheme.downvoted = customThemeSettingsItems.get(41).colorValue; + customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(42).colorValue; + customTheme.postTypeTextColor = customThemeSettingsItems.get(43).colorValue; + customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(44).colorValue; + customTheme.spoilerTextColor = customThemeSettingsItems.get(45).colorValue; + customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(46).colorValue; + customTheme.nsfwTextColor = customThemeSettingsItems.get(47).colorValue; + customTheme.flairBackgroundColor = customThemeSettingsItems.get(48).colorValue; + customTheme.flairTextColor = customThemeSettingsItems.get(49).colorValue; + customTheme.awardsBackgroundColor = customThemeSettingsItems.get(50).colorValue; + customTheme.awardsTextColor = customThemeSettingsItems.get(51).colorValue; + customTheme.archivedTint = customThemeSettingsItems.get(52).colorValue; + customTheme.lockedIconTint = customThemeSettingsItems.get(53).colorValue; + customTheme.crosspostIconTint = customThemeSettingsItems.get(54).colorValue; + customTheme.stickiedPostIconTint = customThemeSettingsItems.get(55).colorValue; + customTheme.subscribed = customThemeSettingsItems.get(56).colorValue; + customTheme.unsubscribed = customThemeSettingsItems.get(57).colorValue; + customTheme.username = customThemeSettingsItems.get(58).colorValue; + customTheme.subreddit = customThemeSettingsItems.get(59).colorValue; + customTheme.authorFlairTextColor = customThemeSettingsItems.get(60).colorValue; + customTheme.submitter = customThemeSettingsItems.get(61).colorValue; + customTheme.moderator = customThemeSettingsItems.get(62).colorValue; + customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(63).colorValue; + customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(64).colorValue; + customTheme.dividerColor = customThemeSettingsItems.get(65).colorValue; + customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(66).colorValue; + customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(67).colorValue; + customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(68).colorValue; + customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(69).colorValue; + 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; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java index b32fcf1a..616446a4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java @@ -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_detail), 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( context.getString(R.string.theme_item_background_color), 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_detail), 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( context.getString(R.string.theme_item_bottom_app_bar_background_color), 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_detail), 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( 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), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java index aef072c9..7f137eed 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java @@ -372,6 +372,46 @@ public class CustomThemeWrapper { 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() { return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR, getDefaultColor("#FFFFFF", "#121212", "#000000")); @@ -503,6 +543,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = true; @@ -580,6 +628,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -657,6 +713,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -734,6 +798,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = Color.parseColor("#000000"); 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.isLightStatusBar = true; customTheme.isLightNavBar = true; @@ -811,6 +883,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -888,6 +968,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -965,6 +1053,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = true; @@ -1042,6 +1138,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1119,6 +1223,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1196,6 +1308,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#F1FA8C"); customTheme.fabIconColor = 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.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1273,6 +1393,14 @@ public class CustomThemeWrapper { customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); customTheme.fabIconColor = Color.parseColor("#000000"); 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.isLightStatusBar = true; customTheme.isLightNavBar = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/RepliedToPrivateMessageEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/RepliedToPrivateMessageEvent.java index 4e89b4ec..59d82f3c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/RepliedToPrivateMessageEvent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/RepliedToPrivateMessageEvent.java @@ -1,6 +1,6 @@ package ml.docilealligator.infinityforreddit.Event; -import ml.docilealligator.infinityforreddit.Message; +import ml.docilealligator.infinityforreddit.Message.Message; public class RepliedToPrivateMessageEvent { public Message newReply; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java index d012342e..658ddc88 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java @@ -8,6 +8,7 @@ import org.json.JSONException; import org.json.JSONObject; import ml.docilealligator.infinityforreddit.API.PushshiftAPI; +import ml.docilealligator.infinityforreddit.Comment.Comment; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Call; @@ -17,7 +18,7 @@ import retrofit2.Retrofit; 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()) .enqueue(new Callback() { @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 author = result.getString(JSONUtils.AUTHOR_KEY); String body = Utils.modifyMarkdown(result.optString(JSONUtils.BODY_KEY).trim()); @@ -56,7 +57,7 @@ public class FetchRemovedComment { } public interface FetchRemovedCommentListener { - void fetchSuccess(CommentData comment); + void fetchSuccess(Comment comment); void fetchFailed(); } @@ -65,9 +66,9 @@ public class FetchRemovedComment { private String responseBody; 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.comment = comment; this.listener = listener; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java index 015d56eb..6a866fef 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java @@ -33,7 +33,7 @@ import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.Activity.BaseActivity; import ml.docilealligator.infinityforreddit.Adapter.CommentsListingRecyclerViewAdapter; 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.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/InboxFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/InboxFragment.java index 9129bec2..56f4c2a0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/InboxFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/InboxFragment.java @@ -33,10 +33,10 @@ import ml.docilealligator.infinityforreddit.Activity.BaseActivity; import ml.docilealligator.infinityforreddit.Adapter.MessageRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; 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.Infinity; -import ml.docilealligator.infinityforreddit.MessageViewModel; +import ml.docilealligator.infinityforreddit.Message.MessageViewModel; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; @@ -102,7 +102,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator { 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, mAccessToken, mWhere, () -> mMessageViewModel.retryLoadingMore()); mLinearLayoutManager = new LinearLayoutManager(mActivity); @@ -190,7 +190,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator { @Subscribe 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); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java index 9d9aa9b7..6e070c5e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java @@ -31,6 +31,7 @@ import butterknife.ButterKnife; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; +import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.ext.strikethrough.StrikethroughPlugin; import io.noties.markwon.linkify.LinkifyPlugin; import io.noties.markwon.recycler.MarkwonAdapter; @@ -101,6 +102,11 @@ public class SidebarFragment extends Fragment { textView.setTextColor(markdownColor); } + @Override + public void configureTheme(@NonNull MarkwonTheme.Builder builder) { + builder.linkColor(mCustomThemeWrapper.getLinkColor()); + } + @Override public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) { builder.linkResolver((view, link) -> { @@ -113,6 +119,7 @@ public class SidebarFragment extends Fragment { } startActivity(intent); }).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com")); + } }) .usePlugin(StrikethroughPlugin.create()) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/FetchMessage.java similarity index 96% rename from app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/FetchMessage.java index a1a6552c..1322d7c0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMessages.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/FetchMessage.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -13,7 +13,7 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; -public class FetchMessages { +public class FetchMessage { public static final String WHERE_INBOX = "inbox"; public static final String WHERE_UNREAD = "unread"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Message.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/Message.java similarity index 94% rename from app/src/main/java/ml/docilealligator/infinityforreddit/Message.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/Message.java index 9f3131e0..a53b11f2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Message.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/Message.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import android.os.Parcel; import android.os.Parcelable; @@ -6,11 +6,11 @@ import android.os.Parcelable; import java.util.ArrayList; public class Message implements Parcelable { - static final String TYPE_COMMENT = "t1"; - static final String TYPE_ACCOUNT = "t2"; - static final String TYPE_LINK = "t3"; - static final String TYPE_MESSAGE = "t4"; - static final String TYPE_SUBREDDIT = "t5"; + public static final String TYPE_COMMENT = "t1"; + public static final String TYPE_ACCOUNT = "t2"; + public static final String TYPE_LINK = "t3"; + public static final String TYPE_MESSAGE = "t4"; + public static final String TYPE_SUBREDDIT = "t5"; static final String TYPE_AWARD = "t6"; private String kind; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageDataSource.java similarity index 86% rename from app/src/main/java/ml/docilealligator/infinityforreddit/MessageDataSource.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageDataSource.java index f81d1894..e3f8cc18 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageDataSource.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -8,6 +8,7 @@ import androidx.paging.PageKeyedDataSource; import java.util.ArrayList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.NetworkState; import retrofit2.Retrofit; class MessageDataSource extends PageKeyedDataSource { @@ -29,10 +30,10 @@ class MessageDataSource extends PageKeyedDataSource { this.locale = locale; this.accessToken = accessToken; this.where = where; - if (where.equals(FetchMessages.WHERE_MESSAGES)) { - messageType = FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE; + if (where.equals(FetchMessage.WHERE_MESSAGES)) { + messageType = FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE; } else { - messageType = FetchMessages.MESSAGE_TYPE_INBOX; + messageType = FetchMessage.MESSAGE_TYPE_INBOX; } paginationNetworkStateLiveData = new MutableLiveData<>(); initialLoadStateLiveData = new MutableLiveData<>(); @@ -59,8 +60,8 @@ class MessageDataSource extends PageKeyedDataSource { public void loadInitial(@NonNull LoadInitialParams params, @NonNull LoadInitialCallback callback) { initialLoadStateLiveData.postValue(NetworkState.LOADING); - FetchMessages.fetchInbox(oauthRetrofit, locale, accessToken, where, null, messageType, - new FetchMessages.FetchMessagesListener() { + FetchMessage.fetchInbox(oauthRetrofit, locale, accessToken, where, null, messageType, + new FetchMessage.FetchMessagesListener() { @Override public void fetchSuccess(ArrayList messages, @Nullable String after) { if (messages.size() == 0) { @@ -96,8 +97,8 @@ class MessageDataSource extends PageKeyedDataSource { paginationNetworkStateLiveData.postValue(NetworkState.LOADING); - FetchMessages.fetchInbox(oauthRetrofit, locale, accessToken, where, params.key, messageType, - new FetchMessages.FetchMessagesListener() { + FetchMessage.fetchInbox(oauthRetrofit, locale, accessToken, where, params.key, messageType, + new FetchMessage.FetchMessagesListener() { @Override public void fetchSuccess(ArrayList messages, @Nullable String after) { if (after == null || after.equals("") || after.equals("null")) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageDataSourceFactory.java similarity index 96% rename from app/src/main/java/ml/docilealligator/infinityforreddit/MessageDataSourceFactory.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageDataSourceFactory.java index b1470bf7..db717ce5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageDataSourceFactory.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageViewModel.java similarity index 96% rename from app/src/main/java/ml/docilealligator/infinityforreddit/MessageViewModel.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageViewModel.java index e02c4296..3af6b708 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MessageViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/MessageViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import androidx.annotation.NonNull; import androidx.lifecycle.LiveData; @@ -11,6 +11,7 @@ import androidx.paging.PagedList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.NetworkState; import retrofit2.Retrofit; public class MessageViewModel extends ViewModel { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseMessage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/ParseMessage.java similarity index 96% rename from app/src/main/java/ml/docilealligator/infinityforreddit/ParseMessage.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/ParseMessage.java index c605a5f3..6b4048e4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseMessage.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/ParseMessage.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import android.os.AsyncTask; @@ -44,8 +44,8 @@ public class ParseMessage { @Nullable private static Message parseSingleMessage(JSONObject messageJSON, Locale locale, int messageType) throws JSONException { String kind = messageJSON.getString(JSONUtils.KIND_KEY); - if ((messageType == FetchMessages.MESSAGE_TYPE_INBOX && kind.equals("t4")) || - (messageType == FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE && !kind.equals("t4"))) { + if ((messageType == FetchMessage.MESSAGE_TYPE_INBOX && kind.equals("t4")) || + (messageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE && !kind.equals("t4"))) { return null; } @@ -145,7 +145,7 @@ public class ParseMessage { try { JSONObject messageJSON = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY) .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) { e.printStackTrace(); errorMessage = parseRepliedMessageErrorMessage(response); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/ReadMessage.java similarity index 96% rename from app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/ReadMessage.java index 1b039178..bb8b4030 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ReadMessage.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/ReadMessage.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import androidx.annotation.NonNull; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ReplyMessage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/ReplyMessage.java similarity index 97% rename from app/src/main/java/ml/docilealligator/infinityforreddit/ReplyMessage.java rename to app/src/main/java/ml/docilealligator/infinityforreddit/Message/ReplyMessage.java index 1b60d05b..ca8edcd2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ReplyMessage.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Message/ReplyMessage.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Message; import androidx.annotation.NonNull; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java index 52886ecb..246f9119 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java @@ -31,6 +31,9 @@ import ml.docilealligator.infinityforreddit.Account.Account; import ml.docilealligator.infinityforreddit.Activity.InboxActivity; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; 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.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -85,7 +88,7 @@ public class PullNotificationWorker extends Worker { String responseBody = response.body(); JSONArray messageArray = new JSONObject(responseBody).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY); ArrayList messages = ParseMessage.parseMessages(messageArray, - context.getResources().getConfiguration().locale, FetchMessages.MESSAGE_TYPE_NOTIFICATION); + context.getResources().getConfiguration().locale, FetchMessage.MESSAGE_TYPE_NOTIFICATION); if (!messages.isEmpty()) { NotificationManagerCompat notificationManager = NotificationUtils.getNotificationManager(context); @@ -218,7 +221,7 @@ public class PullNotificationWorker extends Worker { Call call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class) .getMessages(APIUtils.getOAuthHeader(account.getAccessToken()), - FetchMessages.WHERE_UNREAD, null); + FetchMessage.WHERE_UNREAD, null); Response response = call.execute(); if (response.isSuccessful()) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java index 8743c4c9..3bac4b1b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java @@ -26,7 +26,7 @@ import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.User.UserData; @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 { private static RedditDataRoomDatabase INSTANCE; @@ -37,7 +37,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { INSTANCE = Room.databaseBuilder(context.getApplicationContext(), RedditDataRoomDatabase.class, "reddit_data") .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(); } } @@ -186,4 +186,27 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { + " 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"); + + } + }; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java index 295013f1..3ed4951b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java @@ -79,6 +79,14 @@ public class CustomThemeSharedPreferencesUtils { public static final String COMMENT_VERTICAL_BAR_COLOR_7 = "commentVerticalBarColor7"; public static final String FAB_ICON_COLOR = "fabIconColor"; 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) { SharedPreferences.Editor editor = themeSharedPreferences.edit(); diff --git a/app/src/main/res/layout/item_comment_fully_collapsed.xml b/app/src/main/res/layout/item_comment_fully_collapsed.xml index f77b683c..c11085c5 100644 --- a/app/src/main/res/layout/item_comment_fully_collapsed.xml +++ b/app/src/main/res/layout/item_comment_fully_collapsed.xml @@ -34,7 +34,7 @@ android:fontFamily="?attr/font_family" /> Applied to: Text on button Chip Text Color Applied to: Subscribe Button + Link Color + Applied to: URL + Received Message Text Color + Applied to: Received Private Messages + Sent Message Text Color + Applied to: Sent Private Messages Background Color Applied to: Background of every page and navigation drawer Card View Background Color Applied to: Post background and message background Comment Background Color Applied to: Comment background + Fully-Collapsed Comment Background Color + Applied to: Background of fully-collapsed comments + Awarded Comment Background Color + Applied to: Background of awarded comments + Received Message Background Color + Applied to: Background of received private messages + Sent Message Background Color + Applied to: Background of sent private messages Bottom Navigation Bar Color Applied to: Bottom navigation bar Primary Icon Color @@ -587,6 +601,8 @@ Applied to: Icons and score in comments Floating Action Button Icon Color Applied to: Floating action button icon + Send Message Icon Color + Applied to: send private message icon Toolbar Primary Text and Icon Color Applied to: Primary texts and icons in toolbars Toolbar Secondary Text Color