10000 Message compose: support completion of list of recipients by ruuzia · Pull Request #8994 · thunderbird/thunderbird-android · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Message compose: support completion of list of recipients #8994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
Expand Down Expand Up @@ -167,21 +168,33 @@ private void bindObjectView(Recipient recipient, View view) {
holder.showCryptoState(isAvailable, showCryptoEnabled);
}

@Override
protected Recipient defaultObject(String completionText) {
private List<Recipient> parseRecipients(String text) {
try {
List<Address> parsedAddresses = emailAddressParser.parse(completionText);
List<Address> parsedAddresses = emailAddressParser.parse(text);

if (parsedAddresses.isEmpty()) {
setError(getContext().getString(R.string.recipient_error_parse_failed));
return null;
return List.of();
}

return new Recipient(parsedAddresses.get(0));
List<Recipient> recipients = new ArrayList<>();
for (Address a : parsedAddresses) {
recipients.add(new Recipient(a));
}
return recipients;
} catch (NonAsciiEmailAddressException e) {
setError(getContext().getString(R.string.recipient_error_non_ascii));
return null;
return List.of();
}
}

@Override
protected Recipient defaultObject(String completionText) {
List<Recipient> recipients = parseRecipients(completionText);
if (!recipients.isEmpty()) {
return recipients.get(0);
}
return null;
}

public void setLoaderManager(@Nullable LoaderManager loaderManager) {
Expand Down Expand Up @@ -245,9 +258,12 @@ public void showDropDown() {
@Override
public void performCompletion() {
if (getListSelection() == ListView.INVALID_POSITION && enoughToFilter()) {
Object recipientText = defaultObject(currentCompletionText());
if (recipientText != null) {
replaceText(convertSelectionToString(recipientText));
List<Recipient> recipients = parseRecipients(currentCompletionText());
if (!recipients.isEmpty()) {
clearCompletionText();
for (Recipient r : recipients) {
addObjectSync(r);
}
}
} else {
super.performCompletion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public CharSequence filter(CharSequence source, int start, int end,
}

//Detect split characters, remove them and complete the current token instead
if (tokenizer.containsTokenTerminator(source)) {
// We only want to handle the case where the user inputs a single split character here
if (source.length() == 1 && tokenizer.containsTokenTerminator(source)) {
performCompletion();
return "";
}
Expand Down Expand Up @@ -392,16 +393,10 @@ private Range getCurrentCandidateTokenRange() {
candidateStringEnd = spanStart;
}
}

List<Range> tokenRanges = tokenizer.findTokenRanges(editable, candidateStringStart, candidateStringEnd);

for (Range range: tokenRanges) {
if (range.start <= cursorEndPosition && cursorEndPosition <= range.end) {
return range;
}
if (candidateStringEnd < candidateStringStart) {
return new Range(cursorEndPosition, cursorEndPosition);
}

return new Range(cursorEndPosition, cursorEndPosition);
return new Range(candidateStringStart, candidateStringEnd);
}

/**
Expand Down
0