From 42497bb2475bbd0edaff79a6f1aaf99104e1b84b Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 17 Jul 2019 21:33:16 +0800 Subject: Display spoiler and flair info in posts. --- .../CommentRecyclerViewAdapter.java | 21 ++++++ .../infinityforreddit/JSONUtils.java | 1 + .../infinityforreddit/ParsePost.java | 35 +++++---- .../ml/docilealligator/infinityforreddit/Post.java | 87 ++++++++++++++-------- .../infinityforreddit/PostImageActivity.java | 8 +- .../infinityforreddit/PostLinkActivity.java | 8 +- .../infinityforreddit/PostRecyclerViewAdapter.java | 24 ++++++ .../infinityforreddit/PostTextActivity.java | 8 +- .../infinityforreddit/PostVideoActivity.java | 8 +- app/src/main/res/layout/item_post.xml | 44 ++++++++++- app/src/main/res/layout/item_post_detail.xml | 44 ++++++++++- 11 files changed, 223 insertions(+), 65 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java index 46987335..32b023be 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java @@ -32,6 +32,7 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import com.google.android.material.chip.Chip; +import com.libRG.CustomTextView; import com.santalu.aspectratioimageview.AspectRatioImageView; import java.util.ArrayList; @@ -271,6 +272,23 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter { if(!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); @@ -428,7 +428,7 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS public void flairSelected(String flair) { this.flair = flair; flairTextView.setText(flair); - flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairSelectionBottomSheetFragment.dismiss(); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java index 829e3261..7260c5af 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java @@ -119,10 +119,10 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh if(flair != null) { flairTextView.setText(flair); - flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); } if(isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); } if(isNSFW) { nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); @@ -166,7 +166,7 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh spoilerTextView.setOnClickListener(view -> { if(!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); @@ -306,7 +306,7 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh public void flairSelected(String flair) { this.flair = flair; flairTextView.setText(flair); - flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairSelectionBottomSheetFragment.dismiss(); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index 3abc176a..4536c60b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -37,6 +37,7 @@ import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import com.google.android.material.card.MaterialCardView; import com.google.android.material.chip.Chip; +import com.libRG.CustomTextView; import org.greenrobot.eventbus.EventBus; @@ -139,6 +140,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter { if(canStartActivity) { @@ -300,6 +303,21 @@ class PostRecyclerViewAdapter extends PagedListAdapter { if(!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); @@ -311,7 +311,7 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh public void flairSelected(String flair) { this.flair = flair; flairTextView.setText(flair); - flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairSelectionBottomSheetFragment.dismiss(); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java index 6c1b4b07..7432a0b7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java @@ -154,10 +154,10 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS if(flair != null) { flairTextView.setText(flair); - flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); } if(isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); } if(isNSFW) { nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); @@ -200,7 +200,7 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS spoilerTextView.setOnClickListener(view -> { if(!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); @@ -409,7 +409,7 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS public void flairSelected(String flair) { this.flair = flair; flairTextView.setText(flair); - flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); + flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairSelectionBottomSheetFragment.dismiss(); } } diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml index fbaf0d87..e6e41b81 100644 --- a/app/src/main/res/layout/item_post.xml +++ b/app/src/main/res/layout/item_post.xml @@ -142,10 +142,53 @@ + + + + + + + + + + + + + + + +