From 6595af849e1834ee27af23da053947481f7108d0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 5 Feb 2023 11:55:19 +0100 Subject: [PATCH] Fix forward tags in replies --- .../mastodon/ui/drawer/ComposeAdapter.java | 27 +++++++++++++++++++ .../metadata/android/en/changelogs/477.txt | 1 + 2 files changed, 28 insertions(+) diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index a500e1af6..d3076c01b 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -1311,6 +1311,8 @@ public class ComposeAdapter extends RecyclerView.Adapter 0 && statusDraft.text != null && !statusDraft.text.contains("#")) { + Status status = statusList.get(position - 1).reblog == null ? statusList.get(position - 1) : statusList.get(position - 1).reblog; + if (status.tags != null && status.tags.size() > 0) { + statusDraft.text += "\n\n"; + int lenght = 0; + for (Tag tag : status.tags) { + statusDraft.text += "#" + tag.name + " "; + lenght += ("#" + tag.name + " ").length(); + } + holder.binding.content.setText(statusDraft.text); + statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3; + statusDraft.setCursorToEnd = false; + holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3); + } + } else if (forwardTag && position > 0 && statusDraft.text != null && statusDraft.text.contains("#")) { + Status status = statusList.get(position - 1).reblog == null ? statusList.get(position - 1) : statusList.get(position - 1).reblog; + int lenght = 0; + for (Tag tag : status.tags) { + lenght += ("#" + tag.name + " ").length(); + } + statusDraft.cursorPosition = statusDraft.text.length() - lenght - 3; + statusDraft.setCursorToEnd = false; + holder.binding.content.setSelection(statusDraft.text.length() - lenght - 3); + } + if (statusDraft.spoiler_text != null) { holder.binding.contentSpoiler.setText(statusDraft.spoiler_text); holder.binding.contentSpoiler.setSelection(holder.binding.contentSpoiler.getText().length()); diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt index e86d194e4..ee3ae0d22 100644 --- a/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt @@ -11,4 +11,5 @@ Fixed: - Dynamic color for Android 12+ - Fix a crash when replying - Fix button size not changed +- Forward tags in replies - Some crashes