From 108bd1159a9520a05bd85731bce39a77c676ba0d Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 5 Sep 2018 16:18:46 +0000 Subject: [PATCH] Fixed reply to self, layout improvements --- .../eu/faircode/email/FragmentCompose.java | 21 +++++++++---------- app/src/main/res/layout/item_account.xml | 2 +- app/src/main/res/layout/item_folder.xml | 2 +- app/src/main/res/layout/item_identity.xml | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index cafe3b5e06..dc700afaf0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -683,22 +683,21 @@ public class FragmentCompose extends FragmentEx { account = ref.account; // Reply to recipient, not to known self - String from = (ref.from == null || ref.from.length == 0 ? null : ((InternetAddress) ref.from[0]).getAddress()); - String replyto = (ref.reply == null || ref.reply.length == 0 ? null : ((InternetAddress) ref.reply[0]).getAddress()); - List identities = db.identity().getIdentities(); - for (EntityIdentity identity : identities) - if (replyto == null) { - if (from != null && from.equals(identity.email)) { + if (ref.from != null && ref.from.length > 0) { + String from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress()); + List identities = db.identity().getIdentities(); + for (EntityIdentity identity : identities) { + String email = Helper.canonicalAddress(identity.email); + if (from.equals(email)) { + Log.i(Helper.TAG, "Swapping from/to"); Address[] tmp = ref.to; ref.to = ref.from; ref.reply = null; ref.from = tmp; break; } - } else if (replyto.equals(identity.email)) { - ref.reply = ref.to; - break; } + } } EntityFolder drafts; @@ -881,9 +880,9 @@ public class FragmentCompose extends FragmentEx { // Select identity matching from address if (!found && draft.from != null && draft.from.length > 0) { String from = Helper.canonicalAddress(((InternetAddress) draft.from[0]).getAddress()); - for (int pos = 0; pos < identities.size(); pos++) { - if (Helper.canonicalAddress(identities.get(pos).email).equals(from)) { + String email = Helper.canonicalAddress(identities.get(pos).email); + if (email.equals(from)) { spFrom.setSelection(pos); found = true; break; diff --git a/app/src/main/res/layout/item_account.xml b/app/src/main/res/layout/item_account.xml index 17a83421ef..c1e806a128 100644 --- a/app/src/main/res/layout/item_account.xml +++ b/app/src/main/res/layout/item_account.xml @@ -84,7 +84,7 @@ android:layout_marginStart="6dp" android:text="error" android:textAppearance="@style/TextAppearance.AppCompat.Small" - android:textStyle="bold" + android:textColor="?attr/colorWarning" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvHost" /> diff --git a/app/src/main/res/layout/item_folder.xml b/app/src/main/res/layout/item_folder.xml index f6bf6232a5..ee71f3f830 100644 --- a/app/src/main/res/layout/item_folder.xml +++ b/app/src/main/res/layout/item_folder.xml @@ -109,7 +109,7 @@ android:layout_marginStart="6dp" android:text="error" android:textAppearance="@style/TextAppearance.AppCompat.Small" - android:textStyle="bold" + android:textColor="?attr/colorWarning" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/ivState" /> diff --git a/app/src/main/res/layout/item_identity.xml b/app/src/main/res/layout/item_identity.xml index f632338a4d..d12af22a5d 100644 --- a/app/src/main/res/layout/item_identity.xml +++ b/app/src/main/res/layout/item_identity.xml @@ -96,7 +96,7 @@ android:layout_marginStart="6dp" android:text="error" android:textAppearance="@style/TextAppearance.AppCompat.Small" - android:textStyle="bold" + android:textColor="?attr/colorWarning" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvHost" />