From d55baa92af841bba83614b29887fed07a1fb4b4d Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 30 Dec 2022 12:10:52 +0100 Subject: [PATCH] comment #702 - Improve reactions and quotes --- .../fedilab/android/jobs/ComposeWorker.java | 6 ++--- .../android/ui/drawer/ReactionAdapter.java | 2 ++ .../android/ui/drawer/StatusAdapter.java | 26 +++++++++++++++---- .../main/res/layout/drawer_status_simple.xml | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java b/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java index 776130e91..37a04e3c1 100644 --- a/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java +++ b/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java @@ -221,10 +221,10 @@ public class ComposeWorker extends Worker { if (dataPost.scheduledDate == null) { if (dataPost.statusEditId == null) { statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in, - poll_multiple, poll_hide_totals, in_reply_to_status, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language, statuses.get(i).quote_id); + poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language, statuses.get(i).quote_id); } else { //Status is edited statusCall = mastodonStatusesService.updateStatus(null, dataPost.token, dataPost.statusEditId, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in, - poll_multiple, poll_hide_totals, in_reply_to_status, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language); + poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language); } try { Response statusResponse = statusCall.execute(); @@ -285,7 +285,7 @@ public class ComposeWorker extends Worker { } } else { Call scheduledStatusCall = mastodonStatusesService.createScheduledStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in, - poll_multiple, poll_hide_totals, in_reply_to_status, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), dataPost.scheduledDate, statuses.get(i).language); + poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), dataPost.scheduledDate, statuses.get(i).language); try { Response statusResponse = scheduledStatusCall.execute(); diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ReactionAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ReactionAdapter.java index 19bdec57a..91048d2db 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ReactionAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ReactionAdapter.java @@ -32,6 +32,7 @@ import app.fedilab.android.R; import app.fedilab.android.client.entities.api.Reaction; import app.fedilab.android.databinding.DrawerReactionBinding; import app.fedilab.android.helper.Helper; +import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.viewmodel.mastodon.AnnouncementsVM; import app.fedilab.android.viewmodel.pleroma.ActionsVM; @@ -74,6 +75,7 @@ public class ReactionAdapter extends RecyclerView.Adapter String loadMediaType = sharedpreferences.getString(context.getString(R.string.SET_LOAD_MEDIA_TYPE), "ALWAYS"); if (statusToDeal.quote != null) { - holder.binding.quotedMessage.cardviewContainer.setCardElevation(5); + holder.binding.quotedMessage.cardviewContainer.setCardElevation((int) Helper.convertDpToPixel(5, context)); holder.binding.quotedMessage.dividerCard.setVisibility(View.GONE); - holder.binding.quotedMessage.cardviewContainer.setStrokeWidth(1); - holder.binding.quotedMessage.cardviewContainer.setOnClickListener(v -> { + holder.binding.quotedMessage.cardviewContainer.setStrokeWidth((int) Helper.convertDpToPixel(1, context)); + holder.binding.quotedMessage.cardviewContainer.setOnClickListener(v -> holder.binding.quotedMessage.statusContent.callOnClick()); + holder.binding.quotedMessage.statusContent.setOnTouchListener((view, motionEvent) -> { + if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { + try { + view.requestFocus(); + } catch (Exception ignored) { + } + } + return false; + }); + holder.binding.quotedMessage.statusContent.setOnClickListener(v -> { + if (status.isFocused || v.getTag() == SpannableHelper.CLICKABLE_SPAN) { + if (v.getTag() == SpannableHelper.CLICKABLE_SPAN) { + v.setTag(null); + } + return; + } Intent intent = new Intent(context, ContextActivity.class); intent.putExtra(Helper.ARG_STATUS, statusToDeal.quote); context.startActivity(intent); @@ -651,7 +667,7 @@ public class StatusAdapter extends RecyclerView.Adapter } } - if (statusToDeal.card != null && (display_card || statusToDeal.isFocused)) { + if (statusToDeal.card != null && (display_card || statusToDeal.isFocused) && statusToDeal.quote_id == null) { if (statusToDeal.card.width > statusToDeal.card.height) { holder.binding.cardImageHorizontal.setVisibility(View.VISIBLE); holder.binding.cardImageVertical.setVisibility(View.GONE); @@ -1217,7 +1233,7 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.mediaContainer.setVisibility(View.GONE); } else { holder.binding.statusContent.setVisibility(View.VISIBLE); - if (statusToDeal.card != null && (display_card || statusToDeal.isFocused)) { + if (statusToDeal.card != null && statusToDeal.quote_id == null && (display_card || statusToDeal.isFocused)) { holder.binding.card.setVisibility(View.VISIBLE); } else { holder.binding.card.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/drawer_status_simple.xml b/app/src/main/res/layout/drawer_status_simple.xml index baa53c424..33ee579fb 100644 --- a/app/src/main/res/layout/drawer_status_simple.xml +++ b/app/src/main/res/layout/drawer_status_simple.xml @@ -34,6 +34,7 @@ android:background="?colorOutline" />