From c815a66be3fe5378f34abe86bce76a864ef3dec3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 27 Feb 2023 10:51:11 +0100 Subject: [PATCH] Fix visibility with cross replies --- .../mastodon/activities/ComposeActivity.java | 15 +++++++++------ .../metadata/android/en/changelogs/481.txt | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java index 40f016d34..85be9c6a1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java @@ -180,10 +180,10 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana return "public"; } - public static String getVisibility(String defaultVisibility) { + public static String getVisibility(BaseAccount account, String defaultVisibility) { int tootVisibility = visibilityToNumber(defaultVisibility); - if (currentAccount != null && currentAccount.mastodon_account != null && currentAccount.mastodon_account.source != null) { - int userVisibility = visibilityToNumber(currentAccount.mastodon_account.source.privacy); + if (account != null && account.mastodon_account != null && account.mastodon_account.source != null) { + int userVisibility = visibilityToNumber(account.mastodon_account.source.privacy); if (tootVisibility > userVisibility) { return visibilityToString(userVisibility); } else { @@ -475,12 +475,15 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana statusReplyId = b.getString(Helper.ARG_STATUS_REPLY_ID); statusMention = (Status) b.getSerializable(Helper.ARG_STATUS_MENTION); account = (BaseAccount) b.getSerializable(Helper.ARG_ACCOUNT); + if (account == null) { + account = currentAccount; + } editMessageId = b.getString(Helper.ARG_EDIT_STATUS_ID, null); instance = b.getString(Helper.ARG_INSTANCE, null); token = b.getString(Helper.ARG_TOKEN, null); visibility = b.getString(Helper.ARG_VISIBILITY, null); if (visibility == null && statusReply != null) { - visibility = getVisibility(statusReply.visibility); + visibility = getVisibility(account, statusReply.visibility); } else if (visibility == null && currentAccount != null && currentAccount.mastodon_account != null && currentAccount.mastodon_account.source != null) { visibility = currentAccount.mastodon_account.source.privacy; } @@ -606,7 +609,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana //We change order for mentions //At first place the account that has been mentioned if it's not our statusDraftList.get(0).mentions = new ArrayList<>(); - if (statusReply.account.acct != null && currentAccount.mastodon_account != null && !statusReply.account.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) { + if (statusReply.account.acct != null && account.mastodon_account != null && !statusReply.account.acct.equalsIgnoreCase(account.mastodon_account.acct)) { Mention mention = new Mention(); mention.acct = "@" + statusReply.account.acct; mention.url = statusReply.account.url; @@ -618,7 +621,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana //There are other mentions to if (statusReply.mentions != null && statusReply.mentions.size() > 0) { for (Mention mentionTmp : statusReply.mentions) { - if (statusReply.account.acct != null && !mentionTmp.acct.equalsIgnoreCase(statusReply.account.acct) && currentAccount.mastodon_account != null && !mentionTmp.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) { + if (statusReply.account.acct != null && !mentionTmp.acct.equalsIgnoreCase(statusReply.account.acct) && account.mastodon_account != null && !mentionTmp.acct.equalsIgnoreCase(account.mastodon_account.acct)) { statusDraftList.get(0).mentions.add(mentionTmp); } } diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/481.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/481.txt index 75b968ea5..1c9936219 100644 --- a/src/fdroid/fastlane/metadata/android/en/changelogs/481.txt +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/481.txt @@ -5,4 +5,5 @@ Changed: Fixed: - Media previews remain the same when sharing +- Cross replies: Wrong visibility with the selected account - Several crashes \ No newline at end of file