mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
parent
a7c2a67d0c
commit
2704ff0ecf
@ -554,9 +554,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
.into(((PostBaseViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
if (holder.getBindingAdapterPosition() >= 0) {
|
||||
post.setSubredditIconUrl(iconUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||
@ -1082,9 +1079,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
if (holder.getBindingAdapterPosition() >= 0) {
|
||||
post.setSubredditIconUrl(iconUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||
|
@ -172,6 +172,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
private boolean mHideUpvoteRatio;
|
||||
private boolean mHideTheNumberOfAwards;
|
||||
private boolean mHideSubredditAndUserPrefix;
|
||||
|
||||
private boolean mShowDisplayNames;
|
||||
private boolean mHideTheNumberOfVotes;
|
||||
|
||||
private boolean mSeperateUpvoteAndDownvote;
|
||||
@ -345,6 +347,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mHideUpvoteRatio = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_UPVOTE_RATIO, false);
|
||||
mHideTheNumberOfAwards = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
|
||||
mHideSubredditAndUserPrefix = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
|
||||
mShowDisplayNames = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
|
||||
mHideTheNumberOfVotes = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
|
||||
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
|
||||
mSeperateUpvoteAndDownvote = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
|
||||
@ -528,8 +531,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostDetailBaseViewHolder) holder).mIconGifImageView);
|
||||
}
|
||||
|
||||
mPost.setSubredditIconUrl(iconImageUrl);
|
||||
});
|
||||
} else if (!mPost.getSubredditIconUrl().equals("")) {
|
||||
mGlide.load(mPost.getSubredditIconUrl())
|
||||
@ -580,13 +581,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
((PostDetailBaseViewHolder) holder).mCrosspostImageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText((mShowDisplayNames) ? mPost.getAuthor() : mPost.getAuthorInfo().getUsername());
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText((mShowDisplayNames) ? mPost.getSubredditName() : mPost.getCommunityInfo().getName());
|
||||
if (mHideSubredditAndUserPrefix) {
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditName());
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthor());
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText((mShowDisplayNames) ? mPost.getAuthor() : mPost.getAuthorInfo().getUsername());
|
||||
} else {
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditName());
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText((mShowDisplayNames) ? mPost.getSubredditName() : mPost.getCommunityInfo().getName());
|
||||
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setText('@' + mPost.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthor());
|
||||
|
||||
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setText('@' + mPost.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
|
||||
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() || mPost.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
|
||||
|
@ -227,6 +227,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
private boolean mHidePostFlair;
|
||||
private boolean mHideTheNumberOfAwards;
|
||||
private boolean mHideSubredditAndUserPrefix;
|
||||
private boolean mShowDisplayNames;
|
||||
private boolean mHideTheNumberOfVotes;
|
||||
|
||||
private boolean mSeparateUpandDownVotes;
|
||||
@ -313,6 +314,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
mHidePostFlair = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_FLAIR, false);
|
||||
mHideTheNumberOfAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
|
||||
mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
|
||||
mShowDisplayNames = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
|
||||
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
|
||||
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
|
||||
mSeparateUpandDownVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
|
||||
@ -536,13 +538,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
String authorPrefixed = post.getAuthorNamePrefixed();
|
||||
|
||||
if (mHideSubredditAndUserPrefix) {
|
||||
((PostBaseViewHolder) holder).subredditTextView.setText(post.getSubredditName());
|
||||
((PostBaseViewHolder) holder).userTextView.setText(post.getAuthor());
|
||||
} else {
|
||||
((PostBaseViewHolder) holder).subredditTextView.setText(post.getSubredditName());
|
||||
((PostBaseViewHolder) holder).userTextView.setText((mShowDisplayNames) ? post.getAuthor() : post.getAuthorInfo().getUsername());
|
||||
((PostBaseViewHolder) holder).subredditTextView.setText((mShowDisplayNames) ? post.getSubredditName() : post.getCommunityInfo().getName());
|
||||
if (!mHideSubredditAndUserPrefix) {
|
||||
((PostBaseViewHolder) holder).communityInstanceTextView.setText('@' + post.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
((PostBaseViewHolder) holder).userTextView.setText(post.getAuthor());
|
||||
((PostBaseViewHolder) holder).userInstanceTextView.setText('@' + post.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
((PostBaseViewHolder) holder).communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
|
||||
((PostBaseViewHolder) holder).userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(post.isModerator() || post.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
|
||||
@ -599,10 +598,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostBaseViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
if (holder.getBindingAdapterPosition() >= 0) {
|
||||
post.setSubredditIconUrl(iconUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||
@ -1191,9 +1186,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
if (holder.getBindingAdapterPosition() >= 0) {
|
||||
post.setSubredditIconUrl(iconUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||
@ -1210,10 +1202,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mSubredditColor);
|
||||
if (mHideSubredditAndUserPrefix) {
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getSubredditName());
|
||||
} else {
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getSubredditName());
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setText((mShowDisplayNames) ? post.getAuthor() : post.getAuthorInfo().getUsername());
|
||||
if (!mHideSubredditAndUserPrefix) {
|
||||
((PostCompactBaseViewHolder) holder).instanceTextView.setText('@' + post.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
((PostCompactBaseViewHolder) holder).instanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
|
||||
}
|
||||
|
@ -33,7 +33,9 @@ import java.util.concurrent.Executor;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.toldi.infinityforlemmy.community.BasicCommunityInfo;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
@ -188,25 +190,25 @@ public class ParsePost {
|
||||
boolean saved = data.getBoolean("saved");
|
||||
String distinguished = (creator.getBoolean("admin") ? "admin" : "");
|
||||
String suggestedSort = "";
|
||||
ArrayList <Post.Preview> previews = new ArrayList<>();
|
||||
if(!post.isNull("thumbnail_url")) {
|
||||
ArrayList<Post.Preview> previews = new ArrayList<>();
|
||||
if (!post.isNull("thumbnail_url")) {
|
||||
String thumbnail = post.getString("thumbnail_url");
|
||||
//int[] wh_array = getImageDimension(thumbnail);
|
||||
previews.add(new Post.Preview(thumbnail, 0, 0, "", ""));
|
||||
}
|
||||
BasicUserInfo authorInfo = new BasicUserInfo(creator.getInt("id"), author, authorFull, creator.optString("avatar", ""), creator.optString("display_name", author));
|
||||
BasicCommunityInfo communityInfo = new BasicCommunityInfo(community.getInt("id"), subredditName, subredditNamePrefixed, community.optString("icon", ""), community.optString("title", subredditName));
|
||||
|
||||
|
||||
return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
|
||||
author,authorFull, postTimeMillis, title, previews,
|
||||
downvotes,upvotes, voteType, nComments, upvoteRatio, nsfw, locked, saved,
|
||||
distinguished, suggestedSort);
|
||||
return parseData(data, permalink, id, communityInfo,
|
||||
authorInfo, postTimeMillis, title, previews,
|
||||
downvotes, upvotes, voteType, nComments, upvoteRatio, nsfw, locked, saved,
|
||||
distinguished, suggestedSort);
|
||||
|
||||
}
|
||||
|
||||
private static Post parseData(JSONObject data, String permalink, int id, String fullName,
|
||||
String subredditName, String subredditNamePrefixed, String author, String authorFull,
|
||||
private static Post parseData(JSONObject data, String permalink, int id, BasicCommunityInfo communityInfo, BasicUserInfo author,
|
||||
long postTimeMillis, String title, ArrayList<Post.Preview> previews,
|
||||
int downvotes,int upvotes, int voteType, int nComments, int upvoteRatio,
|
||||
int downvotes, int upvotes, int voteType, int nComments, int upvoteRatio,
|
||||
boolean nsfw, boolean locked,
|
||||
boolean saved,
|
||||
String distinguished, String suggestedSort) throws JSONException {
|
||||
@ -228,7 +230,7 @@ public class ParsePost {
|
||||
if (!data.getJSONObject("post").isNull("body") && url.equals("")) {
|
||||
//Text post
|
||||
int postType = Post.TEXT_TYPE;
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw,
|
||||
locked, saved, distinguished, suggestedSort);
|
||||
@ -241,9 +243,9 @@ public class ParsePost {
|
||||
//Image post
|
||||
int postType = Post.IMAGE_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
|
||||
if (previews.isEmpty()) {
|
||||
previews.add(new Post.Preview(url, 0, 0, "", ""));
|
||||
@ -254,7 +256,7 @@ public class ParsePost {
|
||||
//No preview video post
|
||||
int postType = Post.VIDEO_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull, postTimeMillis, title, permalink, downvotes,upvotes, postType, voteType,
|
||||
post = new Post(id, communityInfo, author, postTimeMillis, title, permalink, downvotes, upvotes, postType, voteType,
|
||||
nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
|
||||
post.setVideoUrl(url);
|
||||
@ -262,7 +264,7 @@ public class ParsePost {
|
||||
} else if (!url.equals("")) {
|
||||
//No preview link post
|
||||
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||
@ -296,7 +298,7 @@ public class ParsePost {
|
||||
}
|
||||
} else {
|
||||
int postType = Post.TEXT_TYPE;
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw,
|
||||
locked, saved, distinguished, suggestedSort);
|
||||
@ -335,7 +337,7 @@ public class ParsePost {
|
||||
String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString();
|
||||
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull, postTimeMillis, title, permalink, downvotes, upvotes, postType, voteType,
|
||||
post = new Post(id, communityInfo, author, postTimeMillis, title, permalink, downvotes, upvotes, postType, voteType,
|
||||
nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
|
||||
post.setPreviews(previews);
|
||||
@ -346,8 +348,8 @@ public class ParsePost {
|
||||
//Image post
|
||||
int postType = Post.IMAGE_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||
authorFull, postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved,
|
||||
distinguished, suggestedSort);
|
||||
|
||||
@ -358,7 +360,7 @@ public class ParsePost {
|
||||
} else if (path.endsWith(".gif")) {
|
||||
//Gif post
|
||||
int postType = Post.GIF_TYPE;
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio,
|
||||
nsfw, locked, saved,
|
||||
@ -374,7 +376,7 @@ public class ParsePost {
|
||||
url = url.substring(0, url.length() - 5) + ".mp4";
|
||||
}
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio,
|
||||
nsfw, locked, saved,
|
||||
@ -387,7 +389,7 @@ public class ParsePost {
|
||||
//Video post
|
||||
int postType = Post.VIDEO_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved,
|
||||
distinguished, suggestedSort);
|
||||
@ -398,7 +400,7 @@ public class ParsePost {
|
||||
//Link post
|
||||
int postType = Post.LINK_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved,
|
||||
distinguished, suggestedSort);
|
||||
@ -439,7 +441,7 @@ public class ParsePost {
|
||||
//Image post
|
||||
int postType = Post.IMAGE_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
|
||||
@ -451,7 +453,7 @@ public class ParsePost {
|
||||
//Video post
|
||||
int postType = Post.VIDEO_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
post.setPreviews(previews);
|
||||
@ -461,9 +463,9 @@ public class ParsePost {
|
||||
//CP No Preview Link post
|
||||
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,authorFull,
|
||||
post = new Post(id, communityInfo, author,
|
||||
postTimeMillis, title, url, permalink, downvotes, upvotes,
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
//Need attention
|
||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||
post.setSelfText("");
|
||||
@ -579,7 +581,7 @@ public class ParsePost {
|
||||
singleGalleryObject.getJSONObject(JSONUtils.S_KEY).getInt(JSONUtils.Y_KEY), galleryItemCaption, galleryItemCaptionUrl));
|
||||
}
|
||||
|
||||
Post.Gallery postGalleryItem = new Post.Gallery(mimeType, galleryItemUrl, "", subredditName + "-" + galleryId + "." + mimeType.substring(mimeType.lastIndexOf("/") + 1), galleryItemCaption, galleryItemCaptionUrl);
|
||||
Post.Gallery postGalleryItem = new Post.Gallery(mimeType, galleryItemUrl, "", communityInfo.getDisplayName() + "-" + galleryId + "." + mimeType.substring(mimeType.lastIndexOf("/") + 1), galleryItemCaption, galleryItemCaptionUrl);
|
||||
|
||||
// For issue #558
|
||||
// Construct a fallback image url
|
||||
@ -675,8 +677,8 @@ public class ParsePost {
|
||||
if (data.getJSONObject("post").getBoolean("featured_local")) {
|
||||
post.setFeaturedOnInstance(true);
|
||||
}
|
||||
post.setAuthorIconUrl(authorAvatar);
|
||||
post.setSubredditIconUrl(communityURL);
|
||||
|
||||
|
||||
return post;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,9 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import eu.toldi.infinityforlemmy.community.BasicCommunityInfo;
|
||||
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||
|
||||
/**
|
||||
* Created by alex on 3/1/18.
|
||||
*/
|
||||
@ -33,13 +36,8 @@ public class Post implements Parcelable {
|
||||
}
|
||||
};
|
||||
private int id;
|
||||
private String fullName;
|
||||
private String subredditName;
|
||||
private String subredditNamePrefixed;
|
||||
private String subredditIconUrl;
|
||||
private String author;
|
||||
private String authorNamePrefixed;
|
||||
private String authorIconUrl;
|
||||
private BasicCommunityInfo communityInfo;
|
||||
private BasicUserInfo author;
|
||||
private String title;
|
||||
private String selfText;
|
||||
private String selfTextPlain;
|
||||
@ -80,18 +78,15 @@ public class Post implements Parcelable {
|
||||
private ArrayList<Preview> previews = new ArrayList<>();
|
||||
private ArrayList<Gallery> gallery = new ArrayList<>();
|
||||
|
||||
public Post(int id, String fullName, String subredditName, String subredditNamePrefixed,
|
||||
String author,String authorNamePrefixed, long postTimeMillis,
|
||||
String title, String permalink, int downvotes,int upvotes, int postType, int voteType, int nComments,
|
||||
public Post(int id, BasicCommunityInfo communityInfo,
|
||||
BasicUserInfo userInfo, long postTimeMillis,
|
||||
String title, String permalink, int downvotes, int upvotes, int postType, int voteType, int nComments,
|
||||
int upvoteRatio,
|
||||
boolean nsfw, boolean locked, boolean saved,
|
||||
String distinguished, String suggestedSort) {
|
||||
this.id = id;
|
||||
this.fullName = fullName;
|
||||
this.subredditName = subredditName;
|
||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||
this.author = author;
|
||||
this.authorNamePrefixed = authorNamePrefixed;
|
||||
this.communityInfo = communityInfo;
|
||||
this.author = userInfo;
|
||||
this.postTimeMillis = postTimeMillis;
|
||||
this.title = title;
|
||||
this.permalink = permalink;
|
||||
@ -112,17 +107,14 @@ public class Post implements Parcelable {
|
||||
isRead = false;
|
||||
}
|
||||
|
||||
public Post(int id, String fullName, String subredditName, String subredditNamePrefixed,
|
||||
String author, String authorNamePrefixed, long postTimeMillis, String title,
|
||||
String url, String permalink, int downvotes,int upvotes, int postType, int voteType, int nComments,
|
||||
public Post(int id, BasicCommunityInfo communityInfo,
|
||||
BasicUserInfo author, long postTimeMillis, String title,
|
||||
String url, String permalink, int downvotes, int upvotes, int postType, int voteType, int nComments,
|
||||
int upvoteRatio,
|
||||
boolean nsfw, boolean locked, boolean saved, String distinguished, String suggestedSort) {
|
||||
boolean nsfw, boolean locked, boolean saved, String distinguished, String suggestedSort) {
|
||||
this.id = id;
|
||||
this.fullName = fullName;
|
||||
this.subredditName = subredditName;
|
||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||
this.communityInfo = communityInfo;
|
||||
this.author = author;
|
||||
this.authorNamePrefixed = authorNamePrefixed;
|
||||
this.postTimeMillis = postTimeMillis;
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
@ -146,13 +138,8 @@ public class Post implements Parcelable {
|
||||
|
||||
protected Post(Parcel in) {
|
||||
id = in.readInt();
|
||||
fullName = in.readString();
|
||||
subredditName = in.readString();
|
||||
subredditNamePrefixed = in.readString();
|
||||
subredditIconUrl = in.readString();
|
||||
author = in.readString();
|
||||
authorNamePrefixed = in.readString();
|
||||
authorIconUrl = in.readString();
|
||||
communityInfo = in.readParcelable(BasicCommunityInfo.class.getClassLoader());
|
||||
author = in.readParcelable(BasicUserInfo.class.getClassLoader());
|
||||
postTimeMillis = in.readLong();
|
||||
title = in.readString();
|
||||
selfText = in.readString();
|
||||
@ -195,27 +182,24 @@ public class Post implements Parcelable {
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
return communityInfo.getQualifiedName();
|
||||
}
|
||||
|
||||
public String getSubredditName() {
|
||||
return subredditName;
|
||||
return communityInfo.getDisplayName();
|
||||
}
|
||||
|
||||
public String getSubredditNamePrefixed() {
|
||||
return subredditNamePrefixed;
|
||||
return communityInfo.getQualifiedName();
|
||||
}
|
||||
|
||||
public String getSubredditIconUrl() {
|
||||
return subredditIconUrl;
|
||||
return communityInfo.getIcon();
|
||||
}
|
||||
|
||||
public void setSubredditIconUrl(String subredditIconUrl) {
|
||||
this.subredditIconUrl = subredditIconUrl;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
return author.getDisplayName();
|
||||
}
|
||||
|
||||
public boolean isAuthorDeleted() {
|
||||
@ -223,20 +207,19 @@ public class Post implements Parcelable {
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
this.authorNamePrefixed = "u/" + author;
|
||||
|
||||
}
|
||||
|
||||
public String getAuthorNamePrefixed() {
|
||||
return authorNamePrefixed;
|
||||
return author.getQualifiedName();
|
||||
}
|
||||
|
||||
public String getAuthorIconUrl() {
|
||||
return authorIconUrl;
|
||||
return (author.getAvatar() == null) ? "" : author.getAvatar();
|
||||
}
|
||||
|
||||
public void setAuthorIconUrl(String authorIconUrl) {
|
||||
this.authorIconUrl = authorIconUrl;
|
||||
|
||||
}
|
||||
|
||||
public long getPostTimeMillis() {
|
||||
@ -512,16 +495,19 @@ public class Post implements Parcelable {
|
||||
this.gallery = gallery;
|
||||
}
|
||||
|
||||
public BasicCommunityInfo getCommunityInfo() {
|
||||
return communityInfo;
|
||||
}
|
||||
|
||||
public BasicUserInfo getAuthorInfo() {
|
||||
return author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeInt(id);
|
||||
parcel.writeString(fullName);
|
||||
parcel.writeString(subredditName);
|
||||
parcel.writeString(subredditNamePrefixed);
|
||||
parcel.writeString(subredditIconUrl);
|
||||
parcel.writeString(author);
|
||||
parcel.writeString(authorNamePrefixed);
|
||||
parcel.writeString(authorIconUrl);
|
||||
parcel.writeParcelable(communityInfo, i);
|
||||
parcel.writeParcelable(author, i);
|
||||
parcel.writeLong(postTimeMillis);
|
||||
parcel.writeString(title);
|
||||
parcel.writeString(selfText);
|
||||
|
@ -54,6 +54,10 @@ public class SharedPreferencesUtils {
|
||||
|
||||
public static final String COMMENT_SEPARATE_UP_AND_DOWN_VOTES = "comment_separate_down_and_up_votes";
|
||||
|
||||
public static final String POST_DISPLAY_NAME_INSTEAD_OF_USERNAME = "post_display_name_instead_of_user_name";
|
||||
|
||||
public static final String POST_DETAIL_DISPLAY_NAME_INSTEAD_OF_USERNAME = "post_detail_display_name_instead_of_user_name";
|
||||
|
||||
public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "eu.toldi.infinityforlemmy.sort_type";
|
||||
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
|
||||
public static final String SORT_TIME_BEST_POST = "sort_time_best_post";
|
||||
|
@ -0,0 +1,43 @@
|
||||
package eu.toldi.infinityforlemmy.community
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
data class BasicCommunityInfo(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val qualifiedName: String,
|
||||
val icon: String?,
|
||||
val displayName: String
|
||||
) : Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
parcel.readString()!!,
|
||||
parcel.readString()!!,
|
||||
parcel.readString(),
|
||||
parcel.readString()!!
|
||||
) {
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeInt(id)
|
||||
parcel.writeString(name)
|
||||
parcel.writeString(qualifiedName)
|
||||
parcel.writeString(icon)
|
||||
parcel.writeString(displayName)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<BasicCommunityInfo> {
|
||||
override fun createFromParcel(parcel: Parcel): BasicCommunityInfo {
|
||||
return BasicCommunityInfo(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<BasicCommunityInfo?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package eu.toldi.infinityforlemmy.user
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
data class BasicUserInfo(
|
||||
val id: Int,
|
||||
val username: String,
|
||||
val qualifiedName: String,
|
||||
val avatar: String?,
|
||||
val displayName: String
|
||||
) : Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
parcel.readString()!!,
|
||||
parcel.readString()!!,
|
||||
parcel.readString(),
|
||||
parcel.readString()!!
|
||||
) {
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeInt(id)
|
||||
parcel.writeString(username)
|
||||
parcel.writeString(qualifiedName)
|
||||
parcel.writeString(avatar)
|
||||
parcel.writeString(displayName)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<BasicUserInfo> {
|
||||
override fun createFromParcel(parcel: Parcel): BasicUserInfo {
|
||||
return BasicUserInfo(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<BasicUserInfo?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
@ -1365,4 +1365,6 @@
|
||||
<string name="action_unblock_user">Unblock User</string>
|
||||
<string name="unblock_user_success">Unblocked</string>
|
||||
<string name="unblock_user_failed">Failed to unblock user</string>
|
||||
<string name="settings_hide_community_and_user_instance">Hide community and user instance</string>
|
||||
<string name="settings_show_display_name_instead_of_user_name">Show community and user display names</string>
|
||||
</resources>
|
||||
|
@ -25,7 +25,13 @@
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="hide_subreddit_and_user_prefix"
|
||||
app:title="@string/settings_hide_community_and_user_prefix" />
|
||||
app:title="@string/settings_hide_community_and_user_instance" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="true"
|
||||
app:key="post_detail_display_name_instead_of_user_name"
|
||||
app:title="@string/settings_show_display_name_instead_of_user_name" />
|
||||
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="false"
|
||||
|
@ -31,7 +31,12 @@
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="hide_subreddit_and_user_prefix"
|
||||
app:title="@string/settings_hide_community_and_user_prefix" />
|
||||
app:title="@string/settings_hide_community_and_user_instance" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="true"
|
||||
app:key="post_display_name_instead_of_user_name"
|
||||
app:title="@string/settings_show_display_name_instead_of_user_name" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
|
||||
app:defaultValue="false"
|
||||
|
Loading…
Reference in New Issue
Block a user