From de744fedfab09204d1c965f42ff1e62441dd7ae9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 8 May 2022 16:06:22 +0200 Subject: [PATCH] Fix #36 - CW automatically expanded does not work --- .../android/ui/drawer/StatusAdapter.java | 31 ++++++++++++------- .../timeline/FragmentMastodonContext.java | 5 +-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 1601e32e..0d4b4f0d 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -16,6 +16,7 @@ package app.fedilab.android.ui.drawer; import static app.fedilab.android.activities.ContextActivity.displayCW; +import static app.fedilab.android.activities.ContextActivity.expand; import android.annotation.SuppressLint; import android.app.Activity; @@ -681,19 +682,27 @@ public class StatusAdapter extends RecyclerView.Adapter //---- SPOILER TEXT ----- if (statusToDeal.spoiler_text != null && !statusToDeal.spoiler_text.trim().isEmpty()) { - if (!expand_cw && context instanceof ContextActivity && statusToDeal.sensitive) { - statusToDeal.isExpended = displayCW; - status.isMediaDisplayed = displayCW; + if (expand_cw || expand) { + holder.binding.spoilerExpand.setVisibility(View.VISIBLE); + holder.binding.spoiler.setVisibility(View.VISIBLE); + holder.binding.spoiler.setText(statusToDeal.span_spoiler_text, TextView.BufferType.SPANNABLE); + statusToDeal.isExpended = true; + statusToDeal.isMediaDisplayed = true; + } else { + if (context instanceof ContextActivity && statusToDeal.sensitive) { + statusToDeal.isExpended = displayCW; + status.isMediaDisplayed = displayCW; + } + holder.binding.spoilerExpand.setOnClickListener(v -> { + statusToDeal.isExpended = !status.isExpended; + statusToDeal.isMediaDisplayed = !status.isMediaDisplayed; + adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal)); + }); + holder.binding.spoilerExpand.setVisibility(View.VISIBLE); + holder.binding.spoiler.setVisibility(View.VISIBLE); + holder.binding.spoiler.setText(statusToDeal.span_spoiler_text, TextView.BufferType.SPANNABLE); } - holder.binding.spoilerExpand.setOnClickListener(v -> { - statusToDeal.isExpended = !status.isExpended; - statusToDeal.isMediaDisplayed = !status.isMediaDisplayed; - adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal)); - }); - holder.binding.spoilerExpand.setVisibility(View.VISIBLE); - holder.binding.spoiler.setVisibility(View.VISIBLE); - holder.binding.spoiler.setText(statusToDeal.span_spoiler_text, TextView.BufferType.SPANNABLE); } else { holder.binding.spoiler.setVisibility(View.GONE); holder.binding.spoilerExpand.setVisibility(View.GONE); diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java index a9dfa19b..f7e2e4ba 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java @@ -201,10 +201,11 @@ public class FragmentMastodonContext extends Fragment { if (statusAdapter != null && firstStatus != null) { pullToRefresh = true; String id; - if (expand) + if (expand) { id = firstStatus.id; - else + } else { id = focusedStatus.id; + } statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, id) .observe(FragmentMastodonContext.this, this::initializeContextView); }