Sharing and copying post links and media links are available.

This commit is contained in:
Alex Ning 2020-01-06 17:19:41 +08:00
parent 35acef9f8d
commit b04ad8956d
16 changed files with 535 additions and 259 deletions

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.ColorFilter;
@ -76,6 +75,7 @@ import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.FetchComment;
import ml.docilealligator.infinityforreddit.Fragment.ModifyCommentBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.ShareLinkBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
import ml.docilealligator.infinityforreddit.R;
@ -99,7 +99,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 7;
private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 8;
private Activity mActivity;
private AppCompatActivity mActivity;
private Retrofit mRetrofit;
private Retrofit mOauthRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
@ -125,8 +125,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mHasMoreComments;
private boolean loadMoreCommentsFailed;
private int mCommentBackgroundColor;
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
public CommentAndPostRecyclerViewAdapter(Activity activity, Retrofit retrofit, Retrofit oauthRetrofit,
public CommentAndPostRecyclerViewAdapter(AppCompatActivity activity, Retrofit retrofit, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
String accessToken, String accountName, Post post, Locale locale,
String singleCommentId, boolean isSingleCommentThreadMode,
@ -222,6 +223,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
TypedValue typedValue = new TypedValue();
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
mCommentBackgroundColor = typedValue.data;
mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment();
}
@Override
@ -1635,8 +1638,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
TextView mPostTimeTextView;
@BindView(R.id.title_text_view_item_post_detail)
TextView mTitleTextView;
/*@BindView(R.id.content_markdown_view_item_post_detail)
TextView mContentMarkdownView;*/
@BindView(R.id.content_markdown_view_item_post_detail)
RecyclerView mContentMarkdownView;
@BindView(R.id.type_text_view_item_post_detail)
@ -1712,14 +1713,24 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
});
mShareButton.setOnClickListener(view -> {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mPost.getPermalink());
mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.share)));
} catch (ActivityNotFoundException e) {
Toast.makeText(mActivity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
Bundle bundle = new Bundle();
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, mPost.getPermalink());
if (mPost.getPostType() != Post.TEXT_TYPE) {
bundle.putInt(ShareLinkBottomSheetFragment.EXTRA_MEDIA_TYPE, mPost.getPostType());
switch (mPost.getPostType()) {
case Post.IMAGE_TYPE:
case Post.GIF_TYPE:
case Post.LINK_TYPE:
case Post.NO_PREVIEW_LINK_TYPE:
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_MEDIA_LINK, mPost.getUrl());
break;
case Post.VIDEO_TYPE:
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_MEDIA_LINK, mPost.getVideoDownloadUrl());
break;
}
}
mShareLinkBottomSheetFragment.setArguments(bundle);
mShareLinkBottomSheetFragment.show(mActivity.getSupportFragmentManager(), mShareLinkBottomSheetFragment.getTag());
});
mUpvoteButton.setOnClickListener(view -> {

View File

@ -1,11 +1,10 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -18,6 +17,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.content.ContextCompat;
@ -54,6 +54,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask
import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
import ml.docilealligator.infinityforreddit.Fragment.ShareLinkBottomSheetFragment;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
@ -86,7 +87,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
return false;
}
};
private Context mContext;
private AppCompatActivity mActivity;
private Retrofit mOauthRetrofit;
private Retrofit mRetrofit;
private String mAccessToken;
@ -103,15 +104,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mShowElapsedTime;
private NetworkState networkState;
private Callback mCallback;
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
public PostRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
public PostRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit, Retrofit retrofit,
RedditDataRoomDatabase redditDataRoomDatabase, String accessToken,
int postType, int postLayout, boolean displaySubredditName,
boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
boolean showElapsedTime, Callback callback) {
super(DIFF_CALLBACK);
if (context != null) {
mContext = context;
if (activity != null) {
mActivity = activity;
mOauthRetrofit = oauthRetrofit;
mRetrofit = retrofit;
mAccessToken = accessToken;
@ -122,10 +124,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
mShowElapsedTime = showElapsedTime;
mPostLayout = postLayout;
mGlide = Glide.with(mContext.getApplicationContext());
mGlide = Glide.with(mActivity.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase;
mUserDao = redditDataRoomDatabase.userDao();
mCallback = callback;
mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment();
}
}
@ -177,10 +180,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (canStartActivity) {
canStartActivity = false;
Intent intent = new Intent(mContext, ViewPostDetailActivity.class);
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
});
@ -189,9 +192,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).userTextView.setOnClickListener(view -> {
if (canStartActivity) {
canStartActivity = false;
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
});
@ -199,7 +202,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (authorPrefixed.equals(subredditNamePrefixed)) {
if (post.getAuthorIconUrl() == null) {
new LoadUserDataAsyncTask(mUserDao, post.getAuthor(), mRetrofit, iconImageUrl -> {
if (mContext != null && getItemCount() > 0) {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@ -232,7 +235,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (post.getSubredditIconUrl() == null) {
new LoadSubredditIconAsyncTask(mRedditDataRoomDatabase, subredditName, mRetrofit,
iconImageUrl -> {
if (mContext != null && getItemCount() > 0) {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@ -267,15 +270,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (canStartActivity) {
canStartActivity = false;
if (post.getSubredditNamePrefixed().startsWith("u/")) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
post.getSubredditNamePrefixed().substring(2));
mContext.startActivity(intent);
mActivity.startActivity(intent);
} else {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
post.getSubredditName());
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
}
});
@ -286,7 +289,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (post.getAuthorIconUrl() == null) {
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor();
new LoadUserDataAsyncTask(mUserDao, authorName, mRetrofit, iconImageUrl -> {
if (mContext != null && getItemCount() > 0) {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@ -320,14 +323,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (canStartActivity) {
canStartActivity = false;
if (post.getSubredditNamePrefixed().startsWith("u/")) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
mContext.startActivity(intent);
mActivity.startActivity(intent);
} else {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
post.getSubredditName());
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
}
});
@ -338,7 +341,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (mShowElapsedTime) {
((PostViewHolder) holder).postTimeTextView.setText(
Utils.getElapsedTime(mContext, post.getPostTimeMillis()));
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
} else {
((PostViewHolder) holder).postTimeTextView.setText(postTime);
}
@ -348,7 +351,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (gilded > 0) {
((PostViewHolder) holder).gildedNumberTextView.setVisibility(View.VISIBLE);
String gildedNumber = mContext.getResources().getString(R.string.gilded_count, gilded);
String gildedNumber = mActivity.getResources().getString(R.string.gilded_count, gilded);
((PostViewHolder) holder).gildedNumberTextView.setText(gildedNumber);
}
@ -357,13 +360,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (nsfw) {
if (!(mContext instanceof FilteredThingActivity)) {
if (!(mActivity instanceof FilteredThingActivity)) {
((PostViewHolder) holder).nsfwTextView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, FilteredThingActivity.class);
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
}
((PostViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE);
@ -381,13 +384,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
switch (voteType) {
case 1:
//Upvoted
((PostViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted));
((PostViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted));
break;
case -1:
//Downvoted
((PostViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted));
((PostViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted));
break;
}
@ -409,16 +412,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE);
((PostViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mActivity, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mActivity, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
}
if (post.isCrosspost()) {
((PostViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE);
}
if (!(mContext instanceof FilteredThingActivity)) {
if (!(mActivity instanceof FilteredThingActivity)) {
((PostViewHolder) holder).typeTextView.setOnClickListener(view -> mCallback.typeChipClicked(post.getPostType()));
}
@ -428,11 +431,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final String imageUrl = post.getUrl();
((PostViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewImageActivity.class);
Intent intent = new Intent(mActivity, ViewImageActivity.class);
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl);
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName
+ "-" + id + ".jpg");
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
break;
case Post.LINK_TYPE:
@ -443,14 +446,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).linkTextView.setText(domain);
((PostViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, LinkResolverActivity.class);
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
Uri uri = Uri.parse(post.getUrl());
if (uri.getScheme() == null && uri.getHost() == null) {
intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
} else {
intent.setData(uri);
}
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
break;
case Post.GIF_TYPE:
@ -458,12 +461,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
((PostViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewGIFActivity.class);
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
intent.setData(gifVideoUri);
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
+ "-" + id + ".gif");
intent.putExtra(ViewGIFActivity.IMAGE_URL_KEY, post.getVideoUrl());
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
((PostViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
@ -473,12 +476,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final Uri videoUri = Uri.parse(post.getVideoUrl());
((PostViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewVideoActivity.class);
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
intent.setData(videoUri);
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName);
intent.putExtra(ViewVideoActivity.EXTRA_ID, fullName);
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
((PostViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
@ -492,14 +495,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).linkTextView.setText(noPreviewLinkDomain);
((PostViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
((PostViewHolder) holder).noPreviewLinkImageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, LinkResolverActivity.class);
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
Uri uri = Uri.parse(post.getUrl());
if (uri.getScheme() == null && uri.getHost() == null) {
intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
} else {
intent.setData(uri);
}
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
break;
case Post.TEXT_TYPE:
@ -513,12 +516,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).upvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
if (isArchived) {
Toast.makeText(mContext, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
return;
}
@ -536,14 +539,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE;
((PostViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted));
} else {
//Upvoted before
post.setVoteType(0);
newVoteType = RedditUtils.DIR_UNVOTE;
((PostViewHolder) holder).upvoteButton.clearColorFilter();
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
@ -554,12 +557,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
post.setVoteType(1);
((PostViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted));
} else {
post.setVoteType(0);
((PostViewHolder) holder).upvoteButton.clearColorFilter();
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostViewHolder) holder).downvoteButton.clearColorFilter();
@ -570,7 +573,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void onVoteThingFail(int position1) {
Toast.makeText(mContext, R.string.vote_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
((PostViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + previousVoteType));
((PostViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
@ -584,12 +587,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).downvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
if (isArchived) {
Toast.makeText(mContext, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
return;
}
@ -607,14 +610,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(-1);
newVoteType = RedditUtils.DIR_DOWNVOTE;
((PostViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted));
} else {
//Downvoted before
post.setVoteType(0);
newVoteType = RedditUtils.DIR_UNVOTE;
((PostViewHolder) holder).downvoteButton.clearColorFilter();
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
@ -625,12 +628,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
post.setVoteType(-1);
((PostViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted));
} else {
post.setVoteType(0);
((PostViewHolder) holder).downvoteButton.clearColorFilter();
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostViewHolder) holder).upvoteButton.clearColorFilter();
@ -641,7 +644,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void onVoteThingFail(int position1) {
Toast.makeText(mContext, R.string.vote_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
((PostViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + previousVoteType));
((PostViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
@ -663,7 +666,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).saveButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
@ -675,7 +678,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void success() {
post.setSaved(false);
((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@ -683,7 +686,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void failed() {
post.setSaved(true);
((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
});
@ -695,7 +698,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void success() {
post.setSaved(true);
((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@ -703,23 +706,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void failed() {
post.setSaved(false);
((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
});
}
});
((PostViewHolder) holder).shareButton.setOnClickListener(view -> {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, permalink);
mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.share)));
} catch (ActivityNotFoundException e) {
Toast.makeText(mContext, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
}
});
((PostViewHolder) holder).shareButton.setOnClickListener(view -> shareLink(post));
}
} else if (holder instanceof PostCompactViewHolder) {
Post post = getItem(position);
@ -743,10 +737,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (canStartActivity) {
canStartActivity = false;
Intent intent = new Intent(mContext, ViewPostDetailActivity.class);
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
});
@ -754,7 +748,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (authorPrefixed.equals(subredditNamePrefixed)) {
if (post.getAuthorIconUrl() == null) {
new LoadUserDataAsyncTask(mUserDao, post.getAuthor(), mRetrofit, iconImageUrl -> {
if (mContext != null && getItemCount() > 0) {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@ -787,7 +781,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (post.getSubredditIconUrl() == null) {
new LoadSubredditIconAsyncTask(mRedditDataRoomDatabase, subredditName, mRetrofit,
iconImageUrl -> {
if (mContext != null && getItemCount() > 0) {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@ -818,22 +812,22 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
}
((PostCompactViewHolder) holder).nameTextView.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
((PostCompactViewHolder) holder).nameTextView.setTextColor(mActivity.getResources().getColor(R.color.colorAccent));
((PostCompactViewHolder) holder).nameTextView.setText(subredditNamePrefixed);
((PostCompactViewHolder) holder).nameTextView.setOnClickListener(view -> {
if (canStartActivity) {
canStartActivity = false;
if (post.getSubredditNamePrefixed().startsWith("u/")) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
post.getSubredditNamePrefixed().substring(2));
mContext.startActivity(intent);
mActivity.startActivity(intent);
} else {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
post.getSubredditNamePrefixed().substring(2));
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
}
});
@ -844,7 +838,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (post.getAuthorIconUrl() == null) {
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor();
new LoadUserDataAsyncTask(mUserDao, authorName, mRetrofit, iconImageUrl -> {
if (mContext != null && getItemCount() > 0) {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@ -874,15 +868,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.into(((PostCompactViewHolder) holder).iconGifImageView);
}
((PostCompactViewHolder) holder).nameTextView.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme));
((PostCompactViewHolder) holder).nameTextView.setTextColor(mActivity.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme));
((PostCompactViewHolder) holder).nameTextView.setText(authorPrefixed);
((PostCompactViewHolder) holder).nameTextView.setOnClickListener(view -> {
if (canStartActivity) {
canStartActivity = false;
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
mContext.startActivity(intent);
mActivity.startActivity(intent);
}
});
@ -892,7 +886,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (mShowElapsedTime) {
((PostCompactViewHolder) holder).postTimeTextView.setText(
Utils.getElapsedTime(mContext, post.getPostTimeMillis()));
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
} else {
((PostCompactViewHolder) holder).postTimeTextView.setText(postTime);
}
@ -902,7 +896,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (gilded > 0) {
((PostCompactViewHolder) holder).gildedNumberTextView.setVisibility(View.VISIBLE);
String gildedNumber = mContext.getResources().getString(R.string.gilded_count, gilded);
String gildedNumber = mActivity.getResources().getString(R.string.gilded_count, gilded);
((PostCompactViewHolder) holder).gildedNumberTextView.setText(gildedNumber);
}
@ -911,13 +905,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (nsfw) {
if (!(mContext instanceof FilteredThingActivity)) {
if (!(mActivity instanceof FilteredThingActivity)) {
((PostCompactViewHolder) holder).nsfwTextView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, FilteredThingActivity.class);
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
}
((PostCompactViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE);
@ -935,13 +929,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
switch (voteType) {
case 1:
//Upvoted
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted));
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted));
break;
case -1:
//Downvoted
((PostCompactViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted));
((PostCompactViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted));
break;
}
@ -963,16 +957,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE);
((PostCompactViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mActivity, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mActivity, R.color.voteAndReplyUnavailableVoteButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
}
if (post.isCrosspost()) {
((PostCompactViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE);
}
if (!(mContext instanceof FilteredThingActivity)) {
if (!(mActivity instanceof FilteredThingActivity)) {
((PostCompactViewHolder) holder).typeTextView.setOnClickListener(view -> mCallback.typeChipClicked(post.getPostType()));
}
@ -982,11 +976,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final String imageUrl = post.getUrl();
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewImageActivity.class);
Intent intent = new Intent(mActivity, ViewImageActivity.class);
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl);
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName
+ "-" + id + ".jpg");
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
break;
case Post.LINK_TYPE:
@ -997,14 +991,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).linkTextView.setText(domain);
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, LinkResolverActivity.class);
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
Uri uri = Uri.parse(post.getUrl());
if (uri.getScheme() == null && uri.getHost() == null) {
intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
} else {
intent.setData(uri);
}
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
break;
case Post.GIF_TYPE:
@ -1012,12 +1006,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewGIFActivity.class);
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
intent.setData(gifVideoUri);
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
+ "-" + id + ".gif");
intent.putExtra(ViewGIFActivity.IMAGE_URL_KEY, post.getVideoUrl());
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
((PostCompactViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
@ -1027,12 +1021,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final Uri videoUri = Uri.parse(post.getVideoUrl());
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewVideoActivity.class);
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
intent.setData(videoUri);
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName);
intent.putExtra(ViewVideoActivity.EXTRA_ID, fullName);
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
((PostCompactViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
@ -1046,14 +1040,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).linkTextView.setText(noPreviewLinkDomain);
((PostCompactViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
((PostCompactViewHolder) holder).noPreviewLinkImageView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, LinkResolverActivity.class);
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
Uri uri = Uri.parse(post.getUrl());
if (uri.getScheme() == null && uri.getHost() == null) {
intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
} else {
intent.setData(uri);
}
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
break;
case Post.TEXT_TYPE:
@ -1063,12 +1057,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).upvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
if (isArchived) {
Toast.makeText(mContext, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
return;
}
@ -1086,14 +1080,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE;
((PostCompactViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted));
} else {
//Upvoted before
post.setVoteType(0);
newVoteType = RedditUtils.DIR_UNVOTE;
((PostCompactViewHolder) holder).upvoteButton.clearColorFilter();
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
@ -1104,12 +1098,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
post.setVoteType(1);
((PostCompactViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted));
} else {
post.setVoteType(0);
((PostCompactViewHolder) holder).upvoteButton.clearColorFilter();
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostCompactViewHolder) holder).downvoteButton.clearColorFilter();
@ -1120,7 +1114,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void onVoteThingFail(int position1) {
Toast.makeText(mContext, R.string.vote_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + previousVoteType));
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
@ -1134,12 +1128,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).downvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
if (isArchived) {
Toast.makeText(mContext, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
return;
}
@ -1157,14 +1151,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(-1);
newVoteType = RedditUtils.DIR_DOWNVOTE;
((PostCompactViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted));
} else {
//Downvoted before
post.setVoteType(0);
newVoteType = RedditUtils.DIR_UNVOTE;
((PostCompactViewHolder) holder).downvoteButton.clearColorFilter();
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
@ -1175,12 +1169,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
post.setVoteType(-1);
((PostCompactViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted));
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted));
} else {
post.setVoteType(0);
((PostCompactViewHolder) holder).downvoteButton.clearColorFilter();
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
}
((PostCompactViewHolder) holder).upvoteButton.clearColorFilter();
@ -1191,7 +1185,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void onVoteThingFail(int position1) {
Toast.makeText(mContext, R.string.vote_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + previousVoteType));
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
@ -1213,7 +1207,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).saveButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
@ -1225,7 +1219,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void success() {
post.setSaved(false);
((PostCompactViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@ -1233,7 +1227,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void failed() {
post.setSaved(true);
((PostCompactViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
});
@ -1245,7 +1239,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void success() {
post.setSaved(true);
((PostCompactViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@ -1253,23 +1247,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void failed() {
post.setSaved(false);
((PostCompactViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
});
}
});
((PostCompactViewHolder) holder).shareButton.setOnClickListener(view -> {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, permalink);
mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.share)));
} catch (ActivityNotFoundException e) {
Toast.makeText(mContext, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
}
});
((PostCompactViewHolder) holder).shareButton.setOnClickListener(view -> shareLink(post));
}
}
}
@ -1329,6 +1314,27 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
}
private void shareLink(Post post) {
Bundle bundle = new Bundle();
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, post.getPermalink());
if (post.getPostType() != Post.TEXT_TYPE) {
bundle.putInt(ShareLinkBottomSheetFragment.EXTRA_MEDIA_TYPE, post.getPostType());
switch (post.getPostType()) {
case Post.IMAGE_TYPE:
case Post.GIF_TYPE:
case Post.LINK_TYPE:
case Post.NO_PREVIEW_LINK_TYPE:
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_MEDIA_LINK, post.getUrl());
break;
case Post.VIDEO_TYPE:
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_MEDIA_LINK, post.getVideoDownloadUrl());
break;
}
}
mShareLinkBottomSheetFragment.setArguments(bundle);
mShareLinkBottomSheetFragment.show(mActivity.getSupportFragmentManager(), mShareLinkBottomSheetFragment.getTag());
}
@Override
public int getItemViewType(int position) {
// Reached at the end
@ -1421,7 +1427,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE);
((PostViewHolder) holder).contentTextView.setVisibility(View.GONE);
((PostViewHolder) holder).upvoteButton.clearColorFilter();
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
((PostViewHolder) holder).downvoteButton.clearColorFilter();
} else if (holder instanceof PostCompactViewHolder) {
mGlide.clear(((PostCompactViewHolder) holder).imageView);
@ -1441,7 +1447,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).playButtonImageView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).upvoteButton.clearColorFilter();
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor));
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
((PostCompactViewHolder) holder).downvoteButton.clearColorFilter();
}
}

View File

@ -26,6 +26,7 @@ import android.widget.Toast;
import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
@ -108,7 +109,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Inject
SharedPreferences mSharedPreferences;
private RequestManager mGlide;
private Activity activity;
private AppCompatActivity activity;
private LinearLayoutManager mLinearLayoutManager;
private StaggeredGridLayoutManager mStaggeredGridLayoutManager;
private boolean isInLazyMode = false;
@ -597,7 +598,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.activity = (Activity) context;
this.activity = (AppCompatActivity) context;
}
@Override

View File

@ -9,7 +9,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
@ -31,13 +31,13 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
public static final int TYPE_IMAGE = 2;
public static final int TYPE_VIDEO = 3;
@BindView(R.id.text_type_linear_layout_post_type_bottom_sheet_fragment)
LinearLayout textTypeLinearLayout;
TextView textTypeTextView;
@BindView(R.id.link_type_linear_layout_post_type_bottom_sheet_fragment)
LinearLayout linkTypeLinearLayout;
TextView linkTypeTextView;
@BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment)
LinearLayout imageTypeLinearLayout;
TextView imageTypeTextView;
@BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment)
LinearLayout videoTypeLinearLayout;
TextView videoTypeTextView;
private Activity activity;
public PostTypeBottomSheetFragment() {
// Required empty public constructor
@ -54,22 +54,22 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
textTypeLinearLayout.setOnClickListener(view -> {
textTypeTextView.setOnClickListener(view -> {
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_TEXT);
dismiss();
});
linkTypeLinearLayout.setOnClickListener(view -> {
linkTypeTextView.setOnClickListener(view -> {
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_LINK);
dismiss();
});
imageTypeLinearLayout.setOnClickListener(view -> {
imageTypeTextView.setOnClickListener(view -> {
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_IMAGE);
dismiss();
});
videoTypeLinearLayout.setOnClickListener(view -> {
videoTypeTextView.setOnClickListener(view -> {
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO);
dismiss();
});

View File

@ -0,0 +1,142 @@
package ml.docilealligator.infinityforreddit.Fragment;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.R;
/**
* A simple {@link Fragment} subclass.
*/
public class ShareLinkBottomSheetFragment extends RoundedBottomSheetDialogFragment {
public static final String EXTRA_POST_LINK = "EPL";
public static final String EXTRA_MEDIA_LINK = "EML";
public static final String EXTRA_MEDIA_TYPE = "EMT";
@BindView(R.id.share_post_link_text_view_share_link_bottom_sheet_fragment)
TextView sharePostLinkTextView;
@BindView(R.id.share_media_link_text_view_share_link_bottom_sheet_fragment)
TextView shareMediaLinkTextView;
@BindView(R.id.copy_post_link_text_view_share_link_bottom_sheet_fragment)
TextView copyPostLinkTextView;
@BindView(R.id.copy_media_link_text_view_share_link_bottom_sheet_fragment)
TextView copyMediaLinkTextView;
private Activity activity;
public ShareLinkBottomSheetFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_share_link_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
String postLink = getArguments().getString(EXTRA_POST_LINK);
String mediaLink = getArguments().containsKey(EXTRA_MEDIA_LINK) ? getArguments().getString(EXTRA_MEDIA_LINK) : null;
if (mediaLink != null) {
shareMediaLinkTextView.setVisibility(View.VISIBLE);
copyMediaLinkTextView.setVisibility(View.VISIBLE);
int mediaType = getArguments().getInt(EXTRA_MEDIA_TYPE);
switch (mediaType) {
case Post.IMAGE_TYPE:
shareMediaLinkTextView.setText(R.string.share_image_link);
copyMediaLinkTextView.setText(R.string.copy_image_link);
shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds(
activity.getDrawable(R.drawable.ic_image_24dp), null, null, null);
break;
case Post.GIF_TYPE:
shareMediaLinkTextView.setText(R.string.share_gif_link);
copyMediaLinkTextView.setText(R.string.copy_gif_link);
shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds(
activity.getDrawable(R.drawable.ic_image_24dp), null, null, null);
break;
case Post.VIDEO_TYPE:
shareMediaLinkTextView.setText(R.string.share_video_link);
copyMediaLinkTextView.setText(R.string.copy_video_link);
shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds(
activity.getDrawable(R.drawable.ic_outline_video_24dp), null, null, null);
break;
case Post.LINK_TYPE:
case Post.NO_PREVIEW_LINK_TYPE:
shareMediaLinkTextView.setText(R.string.share_link);
copyMediaLinkTextView.setText(R.string.copy_link);
break;
}
shareMediaLinkTextView.setOnClickListener(view -> {
shareLink(mediaLink);
dismiss();
});
copyMediaLinkTextView.setOnClickListener(view -> {
copyLink(mediaLink);
dismiss();
});
}
sharePostLinkTextView.setOnClickListener(view -> {
shareLink(postLink);
dismiss();
});
copyPostLinkTextView.setOnClickListener(view -> {
copyLink(postLink);
dismiss();
});
return rootView;
}
private void shareLink(String link) {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, link);
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();
}
}
private void copyLink(String link) {
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) {
ClipData clip = ClipData.newPlainText("simple text", link);
clipboard.setPrimaryClip(clip);
Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(activity, R.string.copy_failed, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.activity = (AppCompatActivity) context;
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M17,7h-4v2h4c1.65,0 3,1.35 3,3s-1.35,3 -3,3h-4v2h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5zM11,15L7,15c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-2zM8,11h8v2L8,13z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v18l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,16L6,16l-2,2L4,4h16v12zM7,9h2v2L7,11zM11,9h2v2h-2zM15,9h2v2h-2z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M21,3L3,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM21,16L3,16L3,5h18v11z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
</vector>

View File

@ -10,125 +10,77 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
<TextView
android:id="@+id/text_type_linear_layout_post_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" >
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="48dp"
android:src="@drawable/ic_outline_text_24px"
android:tint="@color/primaryTextColor" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_text"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" />
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_outline_text_24px"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
</LinearLayout>
<LinearLayout
<TextView
android:id="@+id/link_type_linear_layout_post_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" >
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="48dp"
android:src="@drawable/ic_link"
android:tint="@color/primaryTextColor" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_link"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" />
</LinearLayout>
<LinearLayout
android:id="@+id/image_type_linear_layout_post_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_link"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" >
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="48dp"
android:src="@drawable/ic_menu_gallery"
android:tint="@color/primaryTextColor" />
android:background="?attr/selectableItemBackground" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_image"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" />
</LinearLayout>
<LinearLayout
android:id="@+id/video_type_linear_layout_post_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/bottom_sheet_post_link"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_outline_video_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" >
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginEnd="48dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_outline_video_label_24px"
android:tint="@color/primaryTextColor" />
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/image_type_linear_layout_post_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/bottom_sheet_post_video"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" />
</LinearLayout>
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_image_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
</LinearLayout>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/share_post_link_text_view_share_link_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/share_post_link"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_link"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/copy_post_link_text_view_share_link_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/copy_post_link"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_copy_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/share_media_link_text_view_share_link_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_link"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"
android:visibility="gone" />
<TextView
android:id="@+id/copy_media_link_text_view_share_link_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_copy_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"
android:visibility="gone" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -389,4 +389,18 @@
<string name="share_this_app">Check out Infinity for Reddit, an awesome Reddit client!\nhttps://play.google.com/store/apps/details?id=ml.docilealligator.infinityforreddit</string>
<string name="error_getting_subreddit_name">Error getting subreddit name</string>
<string name="share_post_link">Share Post Link</string>
<string name="share_image_link">Share Image Link</string>
<string name="share_gif_link">Share Gif Link</string>
<string name="share_video_link">Share Video Link</string>
<string name="share_link">Share Link</string>
<string name="copy_post_link">Copy Post Link</string>
<string name="copy_image_link">Copy Image Link</string>
<string name="copy_gif_link">Copy Gif Link</string>
<string name="copy_video_link">Copy Video Link</string>
<string name="copy_link">Copy Link</string>
<string name="copy_success">Copied</string>
<string name="copy_failed">Cannot copy the link</string>
</resources>