aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java7
7 files changed, 31 insertions, 39 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index bd6a9791..9bec2c5b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -199,7 +199,6 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
Intent intent = getIntent();
String parentTextMarkdown = intent.getStringExtra(EXTRA_COMMENT_PARENT_TEXT_MARKDOWN_KEY);
String parentText = intent.getStringExtra(EXTRA_COMMENT_PARENT_TEXT_KEY);
- CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
int linkColor = mCustomThemeWrapper.getLinkColor();
Markwon markwon = Markwon.builder(this)
@@ -242,15 +241,13 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
if (parentTextMarkdown != null) {
commentParentMarkwonView.setOnLongClickListener(view -> {
Utils.hideKeyboard(CommentActivity.this);
- Bundle bundle = new Bundle();
if (parentText == null) {
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, parentTextMarkdown);
+ CopyTextBottomSheetFragment.show(getSupportFragmentManager(),
+ parentTextMarkdown, null);
} else {
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, parentText);
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, parentTextMarkdown);
+ CopyTextBottomSheetFragment.show(getSupportFragmentManager(),
+ parentText, parentTextMarkdown);
}
- copyTextBottomSheetFragment.setArguments(bundle);
- copyTextBottomSheetFragment.show(getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
return true;
});
markwon.setMarkdown(commentParentMarkwonView, parentTextMarkdown);
@@ -285,11 +282,8 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
textView.setTextColor(markdownColor);
textView.setOnLongClickListener(view -> {
Utils.hideKeyboard(CommentActivity.this);
- Bundle bundle = new Bundle();
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, parentBody);
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, parentBodyMarkdown);
- copyTextBottomSheetFragment.setArguments(bundle);
- copyTextBottomSheetFragment.show(getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ CopyTextBottomSheetFragment.show(getSupportFragmentManager(),
+ parentBody, parentBodyMarkdown);
return true;
});
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 4e1188fc..64501048 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -404,11 +404,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
descriptionTextView.setOnLongClickListener(view -> {
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
- Bundle bundle = new Bundle();
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, description);
- CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
- copyTextBottomSheetFragment.setArguments(bundle);
- copyTextBottomSheetFragment.show(getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ CopyTextBottomSheetFragment.show(getSupportFragmentManager(), description, null);
}
return true;
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index c30a86e2..d07b8244 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -400,11 +400,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
descriptionTextView.setOnLongClickListener(view -> {
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
- Bundle bundle = new Bundle();
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, description);
- CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
- copyTextBottomSheetFragment.setArguments(bundle);
- copyTextBottomSheetFragment.show(getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ CopyTextBottomSheetFragment.show(getSupportFragmentManager(), description, null);
}
return 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 6e374626..c1a15eee 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -269,12 +269,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
textView.setTextColor(markdownColor);
textView.setOnLongClickListener(view -> {
if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) {
- Bundle bundle = new Bundle();
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, mPost.getSelfTextPlain());
- bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, mPost.getSelfText());
- CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
- copyTextBottomSheetFragment.setArguments(bundle);
- copyTextBottomSheetFragment.show(mActivity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ CopyTextBottomSheetFragment.show(
+ mActivity.getSupportFragmentManager(),
+ mPost.getSelfTextPlain(), mPost.getSelfText()
+ );
}
return true;
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
index 1e16f010..a8e91634 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
@@ -181,12 +181,8 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
copyTextView.setOnClickListener(view -> {
dismiss();
- CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
- Bundle copyBundle = new Bundle();
- copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, comment.getCommentMarkdown());
- copyBundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, comment.getCommentRawText());
- copyTextBottomSheetFragment.setArguments(copyBundle);
- copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ CopyTextBottomSheetFragment.show(activity.getSupportFragmentManager(),
+ comment.getCommentRawText(), comment.getCommentMarkdown());
});
reportTextView.setOnClickListener(view -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
index a3680bd1..c30fdddb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
@@ -12,8 +12,10 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@@ -49,6 +51,19 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
// Required empty public constructor
}
+ /**
+ * Convenience method for creating the dialog, creating and setting arguments bundle
+ * and displaying the dialog
+ */
+ public static void show(@NonNull FragmentManager fragmentManager,
+ @Nullable String rawText, @Nullable String markdown) {
+ Bundle bundle = new Bundle();
+ bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, rawText);
+ bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, markdown);
+ CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
+ copyTextBottomSheetFragment.setArguments(bundle);
+ copyTextBottomSheetFragment.show(fragmentManager, null);
+ }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
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 e7f6fa33..db4cfeb0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
@@ -286,11 +286,8 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
&& !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());
+ CopyTextBottomSheetFragment.show(
+ activity.getSupportFragmentManager(), caption, null);
}
return true;
});