aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-11 18:01:22 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-11 18:01:22 +0000
commit707aec6b2dc7a03a4dc5835ade7ede3aeef8a158 (patch)
tree367ef5122ffa662e851ba8074295344319732d2b /app/src
parent747f5f1a239925958ba1e7dce3c422d4b42a6767 (diff)
downloadinfinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.tar
infinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.tar.gz
infinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.tar.bz2
infinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.tar.lz
infinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.tar.xz
infinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.tar.zst
infinity-for-reddit-707aec6b2dc7a03a4dc5835ade7ede3aeef8a158.zip
Continue implementing PostOptionsBottomSheetFragment.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java104
-rw-r--r--app/src/main/res/layout/fragment_post_options_bottom_sheet.xml3
2 files changed, 105 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java
index 4e2f9ca2..de834388 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java
@@ -1,13 +1,26 @@
package ml.docilealligator.infinityforreddit.bottomsheetfragments;
+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 androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
+import ml.docilealligator.infinityforreddit.activities.CommentActivity;
+import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
+import ml.docilealligator.infinityforreddit.activities.ReportActivity;
+import ml.docilealligator.infinityforreddit.activities.SubmitCrosspostActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import ml.docilealligator.infinityforreddit.databinding.FragmentPostOptionsBottomSheetBinding;
import ml.docilealligator.infinityforreddit.post.Post;
@@ -21,6 +34,7 @@ public class PostOptionsBottomSheetFragment extends LandscapeExpandedRoundedBott
private static final String EXTRA_POST = "EP";
+ private BaseActivity mBaseActivity;
private Post mPost;
private FragmentPostOptionsBottomSheetBinding binding;
@@ -58,6 +72,96 @@ public class PostOptionsBottomSheetFragment extends LandscapeExpandedRoundedBott
Bundle savedInstanceState) {
// Inflate the layout for this fragment
binding = FragmentPostOptionsBottomSheetBinding.inflate(inflater, container, false);
+
+ if (mPost != null) {
+ switch (mPost.getPostType()) {
+ case Post.IMAGE_TYPE:
+ break;
+ case Post.GIF_TYPE:
+ break;
+ case Post.VIDEO_TYPE:
+ break;
+ case Post.GALLERY_TYPE:
+ break;
+ }
+
+ binding.addToPostFilterTextViewPostOptionsBottomSheetFragment.setOnClickListener(view -> {
+ Intent intent = new Intent(mBaseActivity, PostFilterPreferenceActivity.class);
+ intent.putExtra(PostFilterPreferenceActivity.EXTRA_POST, mPost);
+ startActivity(intent);
+
+ dismiss();
+ });
+
+ if (mBaseActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ binding.commentTextViewPostOptionsBottomSheetFragment.setVisibility(View.GONE);
+ binding.hidePostTextViewPostOptionsBottomSheetFragment.setVisibility(View.GONE);
+ binding.crosspostTextViewPostOptionsBottomSheetFragment.setVisibility(View.GONE);
+ binding.reportTextViewPostOptionsBottomSheetFragment.setVisibility(View.GONE);
+ } else {
+ binding.commentTextViewPostOptionsBottomSheetFragment.setOnClickListener(view -> {
+ Intent intent = new Intent(mBaseActivity, CommentActivity.class);
+ intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, mPost.getFullName());
+ intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TITLE_KEY, mPost.getTitle());
+ intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_BODY_MARKDOWN_KEY, mPost.getSelfText());
+ intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_BODY_KEY, mPost.getSelfTextPlain());
+ intent.putExtra(CommentActivity.EXTRA_SUBREDDIT_NAME_KEY, mPost.getSubredditName());
+ intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, false);
+ intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, 0);
+ mBaseActivity.startActivity(intent);
+
+ dismiss();
+ });
+
+ if (mPost.isHidden()) {
+ binding.hidePostTextViewPostOptionsBottomSheetFragment.setText(R.string.action_unhide_post);
+ } else {
+ binding.hidePostTextViewPostOptionsBottomSheetFragment.setText(R.string.action_hide_post);
+ }
+
+ binding.hidePostTextViewPostOptionsBottomSheetFragment.setOnClickListener(view -> {
+ if (mBaseActivity instanceof PostOptionsCallback) {
+ ((PostOptionsCallback) mBaseActivity).onOptionClicked(mPost, mPost.isHidden() ? POST_OPTION.UNHIDE_POST : POST_OPTION.HIDE_POST);
+ }
+
+ dismiss();
+ });
+
+ binding.crosspostTextViewPostOptionsBottomSheetFragment.setOnClickListener(view -> {
+ Intent submitCrosspostIntent = new Intent(mBaseActivity, SubmitCrosspostActivity.class);
+ submitCrosspostIntent.putExtra(SubmitCrosspostActivity.EXTRA_POST, mPost);
+ startActivity(submitCrosspostIntent);
+
+ dismiss();
+ });
+
+ binding.reportTextViewPostOptionsBottomSheetFragment.setOnClickListener(view -> {
+ Intent intent = new Intent(mBaseActivity, ReportActivity.class);
+ intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
+ intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName());
+ startActivity(intent);
+ });
+ }
+ }
+
return binding.getRoot();
}
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ mBaseActivity = (BaseActivity) context;
+ }
+
+ public interface PostOptionsCallback {
+ void onOptionClicked(Post post, @POST_OPTION int option);
+ }
+
+ @IntDef({POST_OPTION.HIDE_POST, POST_OPTION.UNHIDE_POST})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface POST_OPTION {
+ int HIDE_POST = 0;
+ int UNHIDE_POST = 1;
+ int DOWNLOAD_MEDIA = 2;
+ }
} \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml
index c84f7402..cf5074b3 100644
--- a/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml
@@ -32,7 +32,7 @@
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
- android:id="@+id/at_to_post_filter_text_view_post_options_bottom_sheet_fragment"
+ android:id="@+id/add_to_post_filter_text_view_post_options_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@@ -66,7 +66,6 @@
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
- android:text="@string/action_hide_post"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />