Skip to content

Commit 4c18d11

Browse files
committed
Added an ability to reply from the address it was received on. (Using Gmail sendAs)| Close #81.
1 parent 35706ff commit 4c18d11

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/base/CreateMessageFragment.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ public void handleSuccessLoaderResult(int loaderId, Object result) {
385385
fromAddressesArrayAdapter.clear();
386386
fromAddressesArrayAdapter.addAll(aliases);
387387

388+
prepareAliasForReplyIfNeed(aliases);
389+
388390
if (fromAddressesArrayAdapter.getCount() > 1) {
389391
editTextFrom.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.mipmap.ic_arrow_drop_down_grey, 0);
390392
} else {
@@ -507,6 +509,40 @@ public boolean isMessageSendingNow() {
507509
return isMessageSendingNow;
508510
}
509511

512+
/**
513+
* Prepare an alias for the reply. Will be used the email address that the email was received. Will be used the
514+
* first found matched email.
515+
*
516+
* @param aliases A list of Gmail aliases.
517+
*/
518+
private void prepareAliasForReplyIfNeed(List<String> aliases) {
519+
if (incomingMessageInfo != null) {
520+
ArrayList<String> toAddresses = incomingMessageInfo.getTo();
521+
if (toAddresses != null) {
522+
String firstFoundedAlias = null;
523+
for (String toAddress : toAddresses) {
524+
if (firstFoundedAlias == null) {
525+
for (String alias : aliases) {
526+
if (alias.equalsIgnoreCase(toAddress)) {
527+
firstFoundedAlias = alias;
528+
break;
529+
}
530+
}
531+
} else {
532+
break;
533+
}
534+
}
535+
536+
if (firstFoundedAlias != null) {
537+
int position = fromAddressesArrayAdapter.getPosition(firstFoundedAlias);
538+
if (position != -1) {
539+
spinnerFrom.setSelection(position);
540+
}
541+
}
542+
}
543+
}
544+
}
545+
510546
/**
511547
* Remove not valid emails from the recipients list.
512548
*

0 commit comments

Comments
 (0)