Commit f1fd4b0a authored by Hussein's avatar Hussein

Merge branch 'P4A-776' into develop

parents 8e3b0209 a80b8884
......@@ -1739,14 +1739,13 @@ public class MessagingController implements Sync.MessageToSendCallback, KeyImpor
|| message.getFrom().length > 0 && message.getFrom()[0].getAddress() == null))
) {
MimeMessage decryptedMessage = alreadyDecrypted ? ((MimeMessage) message) : result.msg;
if (message.getFolder().getName().equals(account.getSentFolderName())
|| message.getFolder().getName().equals(account.getDraftsFolderName())) {
decryptedMessage.setHeader(MimeHeader.HEADER_PEP_RATING, PEpUtils.ratingToString(pEpProvider.getRating(message)));
} else {
decryptedMessage.setHeader(MimeHeader.HEADER_PEP_RATING, PEpUtils.ratingToString(result.rating));
}
// sync UID so we know our mail
decryptedMessage.setUid(message.getUid());
decryptedMessage.setUid(message.getUid()); // sync UID so we know our mail...
Rating ratingToSave = PEpUtils.shouldUseOutgoingRating(message, account, result.rating)
? pEpProvider.getRating(message)
: result.rating;
decryptedMessage.setHeader(MimeHeader.HEADER_PEP_RATING, PEpUtils.ratingToString(ratingToSave));
// Store the updated message locally
final LocalMessage localMessage = localFolder.storeSmallMessage(decryptedMessage, new Runnable() {
......
......@@ -472,6 +472,10 @@ public class PEpUtils {
|| message.getFolder().getName().equals(account.getOutboxFolderName());
}
public static boolean shouldUseOutgoingRating(Message message, Account account, Rating rating) {
return isMessageOnOutgoingFolder(message, account) && !isRatingUnsecure(rating);
}
public static Message generateKeyImportRequest(Context context, PEpProvider pEp, Account account,
boolean ispEp, boolean encrypted) throws MessagingException {
foundation.pEp.jniadapter.Message result;
......@@ -561,5 +565,9 @@ public class PEpUtils {
public static boolean isPepStatusClickable(ArrayList<Identity> recipients ,Rating rating) {
return recipients.size() > 0 && rating.value >= Rating.pEpRatingReliable.value;
}
public static boolean isRatingUnsecure(Rating rating){
return rating.value != Rating.pEpRatingMistrust.value && rating.value < Rating.pEpRatingReliable.value;
}
}
......@@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable
import android.view.View
import androidx.core.content.ContextCompat
import com.fsck.k9.R
import com.fsck.k9.pEp.PEpUtils.isRatingUnsecure
import foundation.pEp.jniadapter.Rating
object PEpUIUtils {
......@@ -21,7 +22,7 @@ object PEpUIUtils {
return when {
rating == null ->
ContextCompat.getDrawable(context, R.drawable.pep_status_gray)
isUnsecure(rating) ->
isRatingUnsecure(rating) ->
ContextCompat.getDrawable(context, R.drawable.pep_status_gray)
rating.value == Rating.pEpRatingMistrust.value ->
ContextCompat.getDrawable(context, R.drawable.pep_status_red)
......@@ -39,7 +40,7 @@ object PEpUIUtils {
return when {
rating == null ->
ContextCompat.getDrawable(context, R.drawable.pep_status_gray_bordered)
isUnsecure(rating) ->
isRatingUnsecure(rating) ->
ContextCompat.getDrawable(context, R.drawable.pep_status_gray_bordered)
rating.value == Rating.pEpRatingMistrust.value ->
ContextCompat.getDrawable(context, R.drawable.pep_status_red_bordered)
......@@ -57,7 +58,7 @@ object PEpUIUtils {
return when {
rating == null ->
ContextCompat.getDrawable(context, R.drawable.pep_status_gray_white)
isUnsecure(rating) ->
isRatingUnsecure(rating) ->
ContextCompat.getDrawable(context, R.drawable.pep_status_gray_white)
rating.value == Rating.pEpRatingMistrust.value ->
ContextCompat.getDrawable(context, R.drawable.pep_status_red_white)
......@@ -75,7 +76,7 @@ object PEpUIUtils {
return when {
rating == null ->
ColorDrawable(Color.TRANSPARENT)
isUnsecure(rating) ->
isRatingUnsecure(rating) ->
ColorDrawable(Color.TRANSPARENT)
rating.value == Rating.pEpRatingMistrust.value ->
ContextCompat.getDrawable(context, R.drawable.pep_status_red)
......@@ -93,7 +94,7 @@ object PEpUIUtils {
return when {
rating == null ->
null
isUnsecure(rating) ->
isRatingUnsecure(rating) ->
null
rating.value == Rating.pEpRatingMistrust.value ->
ContextCompat.getDrawable(context, R.drawable.pep_status_red)
......@@ -110,7 +111,7 @@ object PEpUIUtils {
fun getToolbarRatingVisibility(rating: Rating?, encrypt: Boolean = true): Int {
return when {
rating == null ||
isUnsecure(rating) ->
isRatingUnsecure(rating) ->
View.GONE
!encrypt ->
View.VISIBLE
......@@ -166,9 +167,4 @@ object PEpUIUtils {
}
}
private fun isUnsecure(rating: Rating) =
rating.value != Rating.pEpRatingMistrust.value && rating.value < Rating.pEpRatingReliable.value
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment