forked from mirrors/Fedilab
Fix issue #136 - Mentions are lost when replying to a own message
This commit is contained in:
parent
0c19da62c0
commit
4e52fa0c70
4 changed files with 25 additions and 38 deletions
|
@ -62,8 +62,7 @@
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ComposeActivity"
|
android:name=".activities.ComposeActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:windowSoftInputMode="adjustPan|adjustResize"
|
|
||||||
android:label="@string/compose" />
|
android:label="@string/compose" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.StatusInfoActivity"
|
android:name=".activities.StatusInfoActivity"
|
||||||
|
|
|
@ -247,29 +247,27 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
statusList.add(statusReply);
|
statusList.add(statusReply);
|
||||||
int statusCount = statusList.size();
|
int statusCount = statusList.size();
|
||||||
statusDraftList.get(0).in_reply_to_id = statusReply.id;
|
statusDraftList.get(0).in_reply_to_id = statusReply.id;
|
||||||
statusDraftList.get(0).mentions = statusReply.mentions;
|
//We change order for mentions
|
||||||
if (statusReply.spoiler_text != null) {
|
//At first place the account that has been mentioned if it's not our
|
||||||
statusDraftList.get(0).spoiler_text = statusReply.spoiler_text;
|
|
||||||
}
|
|
||||||
if (statusDraftList.get(0).mentions == null) {
|
|
||||||
statusDraftList.get(0).mentions = new ArrayList<>();
|
statusDraftList.get(0).mentions = new ArrayList<>();
|
||||||
}
|
if (!statusReply.account.acct.equalsIgnoreCase(MainActivity.accountWeakReference.get().mastodon_account.acct)) {
|
||||||
//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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (canBeAdded) {
|
|
||||||
Mention mention = new Mention();
|
Mention mention = new Mention();
|
||||||
mention.acct = "@" + statusReply.account.acct;
|
mention.acct = "@" + statusReply.account.acct;
|
||||||
mention.url = statusReply.account.url;
|
mention.url = statusReply.account.url;
|
||||||
mention.username = statusReply.account.username;
|
mention.username = statusReply.account.username;
|
||||||
statusDraftList.get(0).mentions.add(mention);
|
statusDraftList.get(0).mentions.add(mention);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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 (statusReply.spoiler_text != null) {
|
||||||
|
statusDraftList.get(0).spoiler_text = statusReply.spoiler_text;
|
||||||
}
|
}
|
||||||
//StatusDraftList at this point should only have one element
|
//StatusDraftList at this point should only have one element
|
||||||
statusList.addAll(statusDraftList);
|
statusList.addAll(statusDraftList);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AnticipateOvershootInterpolator;
|
import android.view.animation.AnticipateOvershootInterpolator;
|
||||||
|
@ -413,7 +412,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
|
||||||
mPropertiesBSFragment.show(getSupportFragmentManager(), mPropertiesBSFragment.getTag());
|
mPropertiesBSFragment.show(getSupportFragmentManager(), mPropertiesBSFragment.getTag());
|
||||||
break;
|
break;
|
||||||
case CROP:
|
case CROP:
|
||||||
Log.v(Helper.TAG, "crop! " + uri);
|
|
||||||
CropImage.activity(uri)
|
CropImage.activity(uri)
|
||||||
.start(this);
|
.start(this);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -187,13 +187,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
|
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
|
||||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
Mention inReplyToUser = null;
|
Mention inReplyToUser = null;
|
||||||
for (Mention mention : statusDraft.mentions) {
|
inReplyToUser = statusDraft.mentions.get(0);
|
||||||
//Mentioned account has a null id
|
|
||||||
if (mention.id == null) {
|
|
||||||
inReplyToUser = mention;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (statusDraft.text == null) {
|
if (statusDraft.text == null) {
|
||||||
statusDraft.text = "";
|
statusDraft.text = "";
|
||||||
}
|
}
|
||||||
|
@ -201,22 +195,20 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
boolean capitalize = sharedpreferences.getBoolean(context.getString(R.string.SET_CAPITALIZE), true);
|
boolean capitalize = sharedpreferences.getBoolean(context.getString(R.string.SET_CAPITALIZE), true);
|
||||||
if (inReplyToUser != null) {
|
if (inReplyToUser != null) {
|
||||||
if (capitalize) {
|
if (capitalize) {
|
||||||
statusDraft.text = inReplyToUser.acct + "\n";
|
statusDraft.text = inReplyToUser.acct.startsWith("@") ? inReplyToUser.acct + "\n" : "@" + inReplyToUser.acct + "\n";
|
||||||
} else {
|
} else {
|
||||||
statusDraft.text = inReplyToUser.acct + " ";
|
statusDraft.text = inReplyToUser.acct.startsWith("@") ? inReplyToUser.acct + " " : "@" + inReplyToUser.acct + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
holder.binding.content.setText(statusDraft.text);
|
holder.binding.content.setText(statusDraft.text);
|
||||||
statusDraft.cursorPosition = statusDraft.text.length();
|
statusDraft.cursorPosition = statusDraft.text.length();
|
||||||
if (statusDraft.mentions.size() > 1) {
|
if (statusDraft.mentions.size() > 1) {
|
||||||
statusDraft.text += "\n";
|
statusDraft.text += "\n";
|
||||||
for (Mention mention : statusDraft.mentions) {
|
for (int i = 1; i < statusDraft.mentions.size(); i++) {
|
||||||
if (mention.id != null && mention.acct != null && !mention.id.equals(BaseMainActivity.currentUserID)) {
|
String tootTemp = String.format("@%s ", statusDraft.mentions.get(i).acct);
|
||||||
String tootTemp = String.format("@%s ", mention.acct);
|
|
||||||
statusDraft.text = String.format("%s ", (statusDraft.text + tootTemp.trim()));
|
statusDraft.text = String.format("%s ", (statusDraft.text + tootTemp.trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
holder.binding.content.setText(statusDraft.text);
|
holder.binding.content.setText(statusDraft.text);
|
||||||
updateCharacterCount(holder);
|
updateCharacterCount(holder);
|
||||||
holder.binding.content.requestFocus();
|
holder.binding.content.requestFocus();
|
||||||
|
|
Loading…
Reference in a new issue