mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-07 00:20:08 +02:00
Fix contact not added when composing
This commit is contained in:
parent
2c32113476
commit
bd8d3405b2
3 changed files with 25 additions and 12 deletions
|
@ -402,8 +402,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRetrieveContact(PopupContactBinding binding, List<app.fedilab.android.client.entities.api.Account> accounts) {
|
private void onRetrieveContact(PopupContactBinding popupContactBinding, List<app.fedilab.android.client.entities.api.Account> accounts) {
|
||||||
binding.loader.setVisibility(View.GONE);
|
popupContactBinding.loader.setVisibility(View.GONE);
|
||||||
if (accounts == null) {
|
if (accounts == null) {
|
||||||
accounts = new ArrayList<>();
|
accounts = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -413,8 +413,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
checkedValues.add(composeAdapter.getLastComposeContent().contains("@" + account.acct));
|
checkedValues.add(composeAdapter.getLastComposeContent().contains("@" + account.acct));
|
||||||
}
|
}
|
||||||
AccountsReplyAdapter contactAdapter = new AccountsReplyAdapter(contacts, checkedValues);
|
AccountsReplyAdapter contactAdapter = new AccountsReplyAdapter(contacts, checkedValues);
|
||||||
binding.lvAccountsSearch.setAdapter(contactAdapter);
|
contactAdapter.actionDone = ComposeActivity.this;
|
||||||
binding.lvAccountsSearch.setLayoutManager(new LinearLayoutManager(ComposeActivity.this));
|
popupContactBinding.lvAccountsSearch.setAdapter(contactAdapter);
|
||||||
|
popupContactBinding.lvAccountsSearch.setLayoutManager(new LinearLayoutManager(ComposeActivity.this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,6 @@ public class AccountsReplyAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
private final boolean[] checked;
|
private final boolean[] checked;
|
||||||
public ActionDone actionDone;
|
public ActionDone actionDone;
|
||||||
|
|
||||||
|
|
||||||
public AccountsReplyAdapter(List<Account> accounts, List<Boolean> checked) {
|
public AccountsReplyAdapter(List<Account> accounts, List<Boolean> checked) {
|
||||||
this.accounts = accounts;
|
this.accounts = accounts;
|
||||||
this.checked = new boolean[checked.size()];
|
this.checked = new boolean[checked.size()];
|
||||||
|
|
|
@ -142,6 +142,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
private List<Emoji> emojisList = new ArrayList<>();
|
private List<Emoji> emojisList = new ArrayList<>();
|
||||||
public promptDraftListener promptDraftListener;
|
public promptDraftListener promptDraftListener;
|
||||||
private boolean unlisted_changed = false;
|
private boolean unlisted_changed = false;
|
||||||
|
public static int currentCursorPosition;
|
||||||
|
|
||||||
public ComposeAdapter(List<Status> statusList, int statusCount, BaseAccount account, app.fedilab.android.client.entities.api.Account mentionedAccount, String visibility, String editMessageId) {
|
public ComposeAdapter(List<Status> statusList, int statusCount, BaseAccount account, app.fedilab.android.client.entities.api.Account mentionedAccount, String visibility, String editMessageId) {
|
||||||
this.statusList = statusList;
|
this.statusList = statusList;
|
||||||
|
@ -298,6 +299,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
} else {
|
} else {
|
||||||
holder.binding.content.requestFocus();
|
holder.binding.content.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusCount(int count) {
|
public void setStatusCount(int count) {
|
||||||
|
@ -852,19 +854,25 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
//It only targets last message in a thread
|
//It only targets last message in a thread
|
||||||
//Return content of last compose message
|
//Return content of last compose message
|
||||||
public String getLastComposeContent() {
|
public String getLastComposeContent() {
|
||||||
return statusList.get(statusList.size() - 1).text != null ? statusList.get(statusList.size() - 1).text : "";
|
return statusList.get(currentCursorPosition).text != null ? statusList.get(currentCursorPosition).text : "";
|
||||||
}
|
}
|
||||||
//------- end contact ----->
|
//------- end contact ----->
|
||||||
|
|
||||||
//Used to write contact when composing
|
//Used to write contact when composing
|
||||||
public void updateContent(boolean checked, String acct) {
|
public void updateContent(boolean checked, String acct) {
|
||||||
if (checked) {
|
if (currentCursorPosition < statusList.size()) {
|
||||||
if (!statusList.get(statusList.size() - 1).text.contains(acct))
|
if (checked) {
|
||||||
statusList.get(statusList.size() - 1).text = String.format("%s %s", acct, statusList.get(statusList.size() - 1).text);
|
if (statusList.get(currentCursorPosition).text == null) {
|
||||||
} else {
|
statusList.get(currentCursorPosition).text = "";
|
||||||
statusList.get(statusList.size() - 1).text = statusList.get(statusList.size() - 1).text.replaceAll("\\s*" + acct, "");
|
}
|
||||||
|
if (!statusList.get(currentCursorPosition).text.contains(acct)) {
|
||||||
|
statusList.get(currentCursorPosition).text = String.format("@%s %s", acct, statusList.get(currentCursorPosition).text);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
statusList.get(currentCursorPosition).text = statusList.get(currentCursorPosition).text.replaceAll("\\b@" + acct, "");
|
||||||
|
}
|
||||||
|
notifyItemChanged(currentCursorPosition);
|
||||||
}
|
}
|
||||||
notifyItemChanged(statusList.size() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Put cursor to the end after changing contacts
|
//Put cursor to the end after changing contacts
|
||||||
|
@ -1316,6 +1324,11 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
addAttachment(position, uris);
|
addAttachment(position, uris);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
holder.binding.content.setOnFocusChangeListener((view, focused) -> {
|
||||||
|
if (focused) {
|
||||||
|
currentCursorPosition = position;
|
||||||
|
}
|
||||||
|
});
|
||||||
if (statusDraft.cursorPosition <= holder.binding.content.length()) {
|
if (statusDraft.cursorPosition <= holder.binding.content.length()) {
|
||||||
holder.binding.content.setSelection(statusDraft.cursorPosition);
|
holder.binding.content.setSelection(statusDraft.cursorPosition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue