From 4e52fa0c708c8f1c45830ffd1338d61e7de64f9d Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 6 Jun 2022 15:46:45 +0200 Subject: [PATCH] Fix issue #136 - Mentions are lost when replying to a own message --- app/src/main/AndroidManifest.xml | 3 +- .../android/activities/ComposeActivity.java | 38 +++++++++---------- .../imageeditor/EditImageActivity.java | 2 - .../android/ui/drawer/ComposeAdapter.java | 20 +++------- 4 files changed, 25 insertions(+), 38 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 07a2a763..40873aea 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,8 +62,7 @@ android:configChanges="keyboardHidden|orientation|screenSize" /> (); + if (!statusReply.account.acct.equalsIgnoreCase(MainActivity.accountWeakReference.get().mastodon_account.acct)) { + Mention mention = new Mention(); + mention.acct = "@" + statusReply.account.acct; + mention.url = statusReply.account.url; + mention.username = statusReply.account.username; + statusDraftList.get(0).mentions.add(mention); } - if (statusDraftList.get(0).mentions == null) { - statusDraftList.get(0).mentions = new ArrayList<>(); - } - //We will add the mentioned account in mention if not the current user nor if it is already mentioned - if (statusReply.account != null && statusReply.account.acct != null && !statusReply.account.id.equals(BaseMainActivity.currentUserID)) { - boolean canBeAdded = true; - for (Mention mention : statusDraftList.get(0).mentions) { - if (mention.acct.compareToIgnoreCase(statusReply.account.acct) == 0) { - mention.id = null; - canBeAdded = false; + + //There are other mentions to + if (statusReply.mentions != null && statusReply.mentions.size() > 0) { + for (Mention mentionTmp : statusReply.mentions) { + if (!mentionTmp.acct.equalsIgnoreCase(statusReply.account.acct) && !mentionTmp.acct.equalsIgnoreCase(MainActivity.accountWeakReference.get().mastodon_account.acct)) { + statusDraftList.get(0).mentions.add(mentionTmp); } } - if (canBeAdded) { - Mention mention = new Mention(); - mention.acct = "@" + statusReply.account.acct; - mention.url = statusReply.account.url; - mention.username = statusReply.account.username; - statusDraftList.get(0).mentions.add(mention); - } + } + if (statusReply.spoiler_text != null) { + statusDraftList.get(0).spoiler_text = statusReply.spoiler_text; } //StatusDraftList at this point should only have one element statusList.addAll(statusDraftList); diff --git a/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java b/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java index a4cffadd..034417ce 100644 --- a/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java +++ b/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java @@ -9,7 +9,6 @@ import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; -import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.animation.AnticipateOvershootInterpolator; @@ -413,7 +412,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList mPropertiesBSFragment.show(getSupportFragmentManager(), mPropertiesBSFragment.getTag()); break; case CROP: - Log.v(Helper.TAG, "crop! " + uri); CropImage.activity(uri) .start(this); break; diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java index 8caa77c7..e85540bf 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java @@ -187,13 +187,7 @@ public class ComposeAdapter extends RecyclerView.Adapter 1) { statusDraft.text += "\n"; - for (Mention mention : statusDraft.mentions) { - if (mention.id != null && mention.acct != null && !mention.id.equals(BaseMainActivity.currentUserID)) { - String tootTemp = String.format("@%s ", mention.acct); - statusDraft.text = String.format("%s ", (statusDraft.text + tootTemp.trim())); - } + for (int i = 1; i < statusDraft.mentions.size(); i++) { + String tootTemp = String.format("@%s ", statusDraft.mentions.get(i).acct); + statusDraft.text = String.format("%s ", (statusDraft.text + tootTemp.trim())); } } holder.binding.content.setText(statusDraft.text);