aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorscria1000 <91804886+scria1000@users.noreply.github.com>2021-11-27 17:04:45 +0000
committerscria1000 <91804886+scria1000@users.noreply.github.com>2021-11-27 17:04:45 +0000
commit90a9b1033f36087ce302e06304cbf3581921748b (patch)
tree3b6ebb9ad3833445d8b8d6506207d9fd42a9de0a /app/src/main
parent17df9d41ca298a86203da9a5f097109229cd58f7 (diff)
downloadinfinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.tar
infinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.tar.gz
infinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.tar.bz2
infinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.tar.lz
infinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.tar.xz
infinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.tar.zst
infinity-for-reddit-90a9b1033f36087ce302e06304cbf3581921748b.zip
Make caption text copyable with long press
Use native way to theme ViewRedditGalleryActivity
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java51
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java47
-rw-r--r--app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml3
6 files changed, 87 insertions, 49 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index 636e4615..13f40f63 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -59,7 +59,6 @@ public abstract class BaseActivity extends AppCompatActivity {
private int systemVisibilityToolbarExpanded = 0;
private int systemVisibilityToolbarCollapsed = 0;
private CustomThemeWrapper customThemeWrapper;
- private int appliedTheme;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -99,18 +98,15 @@ public abstract class BaseActivity extends AppCompatActivity {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
getTheme().applyStyle(R.style.Theme_Normal, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT);
- setAppliedTheme(R.style.Theme_Normal);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED);
- setAppliedTheme(R.style.Theme_Normal_AmoledDark);
} else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK);
- setAppliedTheme(R.style.Theme_Normal_NormalDark);
}
break;
case 2:
@@ -121,17 +117,14 @@ public abstract class BaseActivity extends AppCompatActivity {
}
if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
getTheme().applyStyle(R.style.Theme_Normal, true);
- setAppliedTheme(R.style.Theme_Normal);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT);
} else {
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED);
- setAppliedTheme(R.style.Theme_Normal_AmoledDark);
} else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK);
- setAppliedTheme(R.style.Theme_Normal_NormalDark);
}
}
}
@@ -234,8 +227,6 @@ public abstract class BaseActivity extends AppCompatActivity {
return systemVisibilityToolbarCollapsed;
}
- public int getAppliedTheme() { return appliedTheme; }
-
public boolean isImmersiveInterface() {
return immersiveInterface;
}
@@ -306,8 +297,6 @@ public abstract class BaseActivity extends AppCompatActivity {
isImmersiveInterfaceApplicable = false;
}
- public void setAppliedTheme(int appliedStyle) { this.appliedTheme = appliedStyle; }
-
protected void applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(AppBarLayout appBarLayout, @Nullable CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar) {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, true);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
index 3c016a2c..aadf344d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
@@ -1,8 +1,15 @@
package ml.docilealligator.infinityforreddit.activities;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
+
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
@@ -13,6 +20,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
@@ -32,6 +40,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
import ml.docilealligator.infinityforreddit.WallpaperSetter;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.ViewPagerBugFixed;
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
@@ -48,21 +57,20 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
public static final String EXTRA_REDDIT_GALLERY = "ERG";
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
- public static final String EXTRA_APPLIED_THEME = "EAS";
@BindView(R.id.hauler_view_view_reddit_gallery_activity)
HaulerView haulerView;
@BindView(R.id.view_pager_view_reddit_gallery_activity)
ViewPagerBugFixed viewPager;
- private SectionsPagerAdapter sectionsPagerAdapter;
- private ArrayList<Post.Gallery> gallery;
- private String subredditName;
- private boolean useBottomAppBar;
@Inject
@Named("default")
SharedPreferences sharedPreferences;
@Inject
Executor executor;
+ private SectionsPagerAdapter sectionsPagerAdapter;
+ private ArrayList<Post.Gallery> gallery;
+ private String subredditName;
+ private boolean useBottomAppBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -70,8 +78,37 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
((Infinity) getApplication()).getAppComponent().inject(this);
- int theme = getIntent().getIntExtra(EXTRA_APPLIED_THEME, R.style.Theme_Normal);
- getTheme().applyStyle(theme <= 0 ? R.style.Theme_Normal : theme, true);
+ boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+ int systemThemeType = Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
+ switch (systemThemeType) {
+ case 0:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
+ getTheme().applyStyle(R.style.Theme_Normal, true);
+ break;
+ case 1:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
+ if (sharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
+ } else {
+ getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
+ }
+ break;
+ case 2:
+ if (systemDefault) {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
+ } else {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
+ }
+ if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
+ getTheme().applyStyle(R.style.Theme_Normal, true);
+ } else {
+ if (sharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
+ } else {
+ getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
+ }
+ }
+ }
getTheme().applyStyle(FontStyle.valueOf(sharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index dba26de7..d99db605 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -87,7 +87,6 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing;
-import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
@@ -124,7 +123,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6;
private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7;
private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8;
-
+ private final MarkwonAdapter mMarkwonAdapter;
private AppCompatActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
@@ -135,7 +134,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private RequestManager mGlide;
private Markwon mPostDetailMarkwon;
- private final MarkwonAdapter mMarkwonAdapter;
private int mImageViewWidth;
private String mAccessToken;
private String mAccountName;
@@ -196,6 +194,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private int mDownvotedColor;
private int mVoteAndReplyUnavailableVoteButtonColor;
private int mPostIconAndInfoColor;
+ private int mCommentColor;
private Drawable mCommentIcon;
private float mScale;
@@ -264,6 +263,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
ClickableSpan clickableSpan = new ClickableSpan() {
private boolean isShowing = false;
+
@Override
public void updateDrawState(@NonNull TextPaint ds) {
if (isShowing) {
@@ -422,6 +422,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mDownvotedColor = customThemeWrapper.getDownvoted();
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor();
+ mCommentColor = customThemeWrapper.getCommentColor();
mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp);
if (mCommentIcon != null) {
@@ -819,15 +820,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
String previewCaptionUrl = preview.getPreviewCaptionUrl();
boolean previewCaptionIsEmpty = android.text.TextUtils.isEmpty(previewCaption);
boolean previewCaptionUrlIsEmpty = android.text.TextUtils.isEmpty(previewCaptionUrl);
- if(!previewCaptionIsEmpty || !previewCaptionUrlIsEmpty){
+ if (!previewCaptionIsEmpty || !previewCaptionUrlIsEmpty) {
+ ((PostDetailGalleryViewHolder) holder).mCaptionConstraintLayout.setBackgroundColor(mCardViewColor & 0x0D000000); // Make 10% darker than CardViewColor
((PostDetailGalleryViewHolder) holder).mCaptionConstraintLayout.setVisibility(View.VISIBLE);
}
- if(!previewCaptionIsEmpty) {
+ if (!previewCaptionIsEmpty) {
+ ((PostDetailGalleryViewHolder) holder).mCaption.setTextColor(mCommentColor);
((PostDetailGalleryViewHolder) holder).mCaption.setText(previewCaption);
((PostDetailGalleryViewHolder) holder).mCaption.setSelected(true);
}
- if(!previewCaptionUrlIsEmpty)
- {
+ if (!previewCaptionUrlIsEmpty) {
String domain = Uri.parse(previewCaptionUrl).getHost();
domain = domain.startsWith("www.") ? domain.substring(4) : domain;
mPostDetailMarkwon.setMarkdown(((PostDetailGalleryViewHolder) holder).mCaptionUrl, String.format("[%s](%s)", domain, previewCaptionUrl));
@@ -1583,6 +1585,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
class PostDetailVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer {
+ public FetchGfycatOrRedgifsVideoLinks fetchGfycatOrRedgifsVideoLinks;
@BindView(R.id.icon_gif_image_view_item_post_detail_video_autoplay)
AspectRatioGifImageView mIconGifImageView;
@BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay)
@@ -1639,12 +1642,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
ImageView mSaveButton;
@BindView(R.id.share_button_item_post_detail_video_autoplay)
ImageView mShareButton;
-
@Nullable
ExoPlayerViewHelper helper;
private Uri mediaUri;
private float volume;
- public FetchGfycatOrRedgifsVideoLinks fetchGfycatOrRedgifsVideoLinks;
public PostDetailVideoAutoplayViewHolder(@NonNull View itemView) {
super(itemView);
@@ -2251,7 +2252,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, mPost.getTitle());
intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, mPost.getSubredditName());
mActivity.startActivity(intent);
- } else if (mPost.getPostType() == Post.GIF_TYPE){
+ } else if (mPost.getPostType() == Post.GIF_TYPE) {
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mPost.getSubredditName()
+ "-" + mPost.getId() + ".gif");
@@ -2269,7 +2270,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, mPost.getGallery());
intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_APPLIED_THEME, ((BaseActivity)mActivity).getAppliedTheme());
mActivity.startActivity(intent);
}
}
@@ -2380,7 +2380,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, mPost.getGallery());
intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_APPLIED_THEME, ((BaseActivity)mActivity).getAppliedTheme());
mActivity.startActivity(intent);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index bc9931a7..0c7f4590 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -1972,7 +1972,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, post.getSubredditName());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_APPLIED_THEME, ((BaseActivity)mActivity).getAppliedTheme());
mActivity.startActivity(intent);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
index 9c652a51..60f48523 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
@@ -4,13 +4,13 @@ import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.text.TextUtils;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -62,10 +62,12 @@ import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity;
import ml.docilealligator.infinityforreddit.asynctasks.SaveBitmapImageToFile;
import ml.docilealligator.infinityforreddit.asynctasks.SaveGIFToFile;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SetAsWallpaperBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
+import ml.docilealligator.infinityforreddit.utils.Utils;
public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@@ -249,39 +251,50 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
String caption = media.caption;
String captionUrl = media.captionUrl;
- boolean captionIsEmpty = android.text.TextUtils.isEmpty(caption);
- boolean captionUrlIsEmpty = android.text.TextUtils.isEmpty(captionUrl);
- if(!captionIsEmpty || !captionUrlIsEmpty){
+ boolean captionIsEmpty = TextUtils.isEmpty(caption);
+ boolean captionUrlIsEmpty = TextUtils.isEmpty(captionUrl);
+ if (!captionIsEmpty || !captionUrlIsEmpty) {
isUseBottomCaption = true;
if (!activity.isUseBottomAppBar()) {
bottomAppBar.setVisibility(View.VISIBLE);
bottomAppBarMenu.setVisibility(View.GONE);
- //Add bottom margin so that caption doesn't disappear to the bottom in some screens with rounded corners
- //I couldn't get binding expressions to work so I did it here
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)captionLayout.getLayoutParams();
- layoutParams.setMargins(0, 0, 0, (int) (16 * getResources().getDisplayMetrics().density));
+
+ captionLayout.setPadding(0, captionLayout.getPaddingTop(), 0, (int) Utils.convertDpToPixel(16, activity));
}
captionLayout.setVisibility(View.VISIBLE);
- if(!captionIsEmpty) {
+ if (!captionIsEmpty) {
captionTextView.setVisibility(View.VISIBLE);
captionTextView.setText(caption);
+ captionTextView.setOnLongClickListener(view -> {
+ if (activity != null
+ && !activity.isDestroyed()
+ && !activity.isFinishing()
+ && captionTextView.getSelectionStart() == -1
+ && captionTextView.getSelectionEnd() == -1) {
+ Bundle bundle = new Bundle();
+ bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, caption);
+ CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
+ copyTextBottomSheetFragment.setArguments(bundle);
+ copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ }
+ return true;
+ });
}
- if(!captionUrlIsEmpty)
- {
+ if (!captionUrlIsEmpty) {
captionUrlTextView.setText(captionUrl);
- if (!activity.isDestroyed() && !activity.isFinishing()) {
- BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, captionUrlTextView).setOnLinkLongClickListener((textView, url) -> {
+ BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, captionUrlTextView).setOnLinkLongClickListener((textView, url) -> {
+ if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
urlMenuBottomSheetFragment.setArguments(bundle);
urlMenuBottomSheetFragment.show(activity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
- return true;
- });
- }
+ }
+ return true;
+ });
captionUrlTextView.setVisibility(View.VISIBLE);
}
}
@@ -348,7 +361,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
Intent intent = new Intent(activity, DownloadMediaService.class);
intent.putExtra(DownloadMediaService.EXTRA_URL, media.url);
- intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, media.mediaType == Post.Gallery.TYPE_GIF ? DownloadMediaService.EXTRA_MEDIA_TYPE_GIF: DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE);
+ intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, media.mediaType == Post.Gallery.TYPE_GIF ? DownloadMediaService.EXTRA_MEDIA_TYPE_GIF : DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE);
intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, media.fileName);
intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
ContextCompat.startForegroundService(activity, intent);
diff --git a/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml b/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml
index 23fc50b0..54d64069 100644
--- a/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml
+++ b/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml
@@ -59,7 +59,8 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical"
- android:visibility="gone">
+ android:visibility="gone"
+ android:paddingTop="8dp">
<TextView
android:id="@+id/caption_text_view_view_reddit_gallery_image_or_gif_fragment"