1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 03:32:16 -05:00

Show new decrypt/verify error conditions in crypto header

This commit is contained in:
cketti 2015-02-21 04:31:44 +01:00
parent bcb668300f
commit e7f706b78d
25 changed files with 106 additions and 48 deletions

View File

@ -1815,7 +1815,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
Log.e(K9.LOG_TAG, "OpenPGP Error Message:" + error.getMessage());
Toast.makeText(MessageCompose.this,
getString(R.string.openpgp_error) + " " + error.getMessage(),
getString(R.string.openpgp_error, error.getMessage()),
Toast.LENGTH_LONG).show();
}
});

View File

@ -412,12 +412,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
OpenPgpHeaderView openPgpHeaderView = (OpenPgpHeaderView) openPgpHeaderStub.inflate();
OpenPgpResultAnnotation cryptoAnnotation = messageViewContainer.cryptoAnnotation;
if (cryptoAnnotation == null) {
openPgpHeaderView.setOpenPgpData(null, false, null);
} else {
openPgpHeaderView.setOpenPgpData(cryptoAnnotation.getSignatureResult(), cryptoAnnotation.wasEncrypted(),
cryptoAnnotation.getPendingIntent());
}
openPgpHeaderView.setOpenPgpData(cryptoAnnotation);
openPgpHeaderView.setCallback(openPgpHeaderViewCallback);
mSidebar.setVisibility(View.VISIBLE);
} else {
@ -447,8 +442,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
return wrapStatusMessage(cryptoAnnotation.getError().getMessage());
}
case ENCRYPTED_BUT_INCOMPLETE: {
//FIXME
return wrapStatusMessage("You need to download the complete message to be able to decrypt it.");
return wrapStatusMessage(getContext().getString(R.string.crypto_download_complete_message_to_decrypt));
}
case NONE:
case SIGNED_BUT_INCOMPLETE: {

View File

@ -18,6 +18,8 @@ import android.widget.TextView;
import com.fsck.k9.R;
import com.fsck.k9.mailstore.OpenPgpResultAnnotation;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpUtils;
@ -26,9 +28,7 @@ public class OpenPgpHeaderView extends LinearLayout {
private Context context;
private OpenPgpHeaderViewCallback callback;
private OpenPgpSignatureResult signatureResult;
private boolean encrypted;
private PendingIntent pendingIntent;
private OpenPgpResultAnnotation cryptoAnnotation;
private ImageView resultEncryptionIcon;
private TextView resultEncryptionText;
@ -61,28 +61,105 @@ public class OpenPgpHeaderView extends LinearLayout {
this.callback = callback;
}
public void setOpenPgpData(OpenPgpSignatureResult signatureResult, boolean encrypted, PendingIntent pendingIntent) {
this.signatureResult = signatureResult;
this.encrypted = encrypted;
this.pendingIntent = pendingIntent;
public void setOpenPgpData(OpenPgpResultAnnotation cryptoAnnotation) {
this.cryptoAnnotation = cryptoAnnotation;
initializeEncryptionHeader();
initializeSignatureHeader();
}
private void initializeEncryptionHeader() {
if (encrypted) {
setEncryptionImageAndTextColor(CryptoState.ENCRYPTED);
resultEncryptionText.setText(R.string.openpgp_result_encrypted);
} else {
setEncryptionImageAndTextColor(CryptoState.NOT_ENCRYPTED);
resultEncryptionText.setText(R.string.openpgp_result_not_encrypted);
if (noCryptoAnnotationFound()) {
displayNotEncrypted();
return;
}
switch (cryptoAnnotation.getErrorType()) {
case NONE: {
if (cryptoAnnotation.wasEncrypted()) {
displayEncrypted();
} else {
displayNotEncrypted();
}
break;
}
case CRYPTO_API_RETURNED_ERROR: {
displayEncryptionError();
break;
}
case ENCRYPTED_BUT_INCOMPLETE: {
displayIncompleteEncryptedPart();
break;
}
case SIGNED_BUT_INCOMPLETE: {
displayNotEncrypted();
break;
}
}
}
private boolean noCryptoAnnotationFound() {
return cryptoAnnotation == null;
}
private void displayEncrypted() {
setEncryptionImageAndTextColor(CryptoState.ENCRYPTED);
resultEncryptionText.setText(R.string.openpgp_result_encrypted);
}
private void displayNotEncrypted() {
setEncryptionImageAndTextColor(CryptoState.NOT_ENCRYPTED);
resultEncryptionText.setText(R.string.openpgp_result_not_encrypted);
}
private void displayEncryptionError() {
setEncryptionImageAndTextColor(CryptoState.INVALID);
OpenPgpError error = cryptoAnnotation.getError();
String text;
if (error == null) {
text = context.getString(R.string.openpgp_unknown_error);
} else {
text = context.getString(R.string.openpgp_error, error.getMessage());
}
resultEncryptionText.setText(text);
}
private void displayIncompleteEncryptedPart() {
setEncryptionImageAndTextColor(CryptoState.UNAVAILABLE);
resultEncryptionText.setText(R.string.crypto_incomplete_message);
}
private void initializeSignatureHeader() {
initializeSignatureButton();
if (noCryptoAnnotationFound()) {
displayNotSigned();
return;
}
switch (cryptoAnnotation.getErrorType()) {
case CRYPTO_API_RETURNED_ERROR:
case NONE: {
displayVerificationResult();
break;
}
case ENCRYPTED_BUT_INCOMPLETE:
case SIGNED_BUT_INCOMPLETE: {
displayIncompleteSignedPart();
break;
}
}
}
private void displayIncompleteSignedPart() {
setSignatureImageAndTextColor(CryptoState.UNAVAILABLE);
resultSignatureText.setText(R.string.crypto_incomplete_message);
hideSignatureLayout();
}
private void displayVerificationResult() {
OpenPgpSignatureResult signatureResult = cryptoAnnotation.getSignatureResult();
if (signatureResult == null) {
displayNotSigned();
return;
@ -117,7 +194,9 @@ public class OpenPgpHeaderView extends LinearLayout {
}
private void initializeSignatureButton() {
if (isSignatureButtonUsed()) {
if (noCryptoAnnotationFound()) {
hideSignatureButton();
} else if (isSignatureButtonUsed()) {
setSignatureButtonClickListener();
} else {
hideSignatureButton();
@ -125,10 +204,11 @@ public class OpenPgpHeaderView extends LinearLayout {
}
private boolean isSignatureButtonUsed() {
return pendingIntent != null;
return cryptoAnnotation.getPendingIntent() != null;
}
private void setSignatureButtonClickListener() {
final PendingIntent pendingIntent = cryptoAnnotation.getPendingIntent();
resultSignatureButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@ -172,7 +252,7 @@ public class OpenPgpHeaderView extends LinearLayout {
setSignatureImageAndTextColor(CryptoState.UNKNOWN_KEY);
resultSignatureText.setText(R.string.openpgp_result_signature_missing_key);
setUserId(signatureResult);
setUserId(cryptoAnnotation.getSignatureResult());
showSignatureButtonWithTextIfNecessary(R.string.openpgp_result_action_lookup);
showSignatureLayout();
}
@ -199,7 +279,7 @@ public class OpenPgpHeaderView extends LinearLayout {
}
private void displayUserIdAndSignatureButton() {
setUserId(signatureResult);
setUserId(cryptoAnnotation.getSignatureResult());
showSignatureButtonWithTextIfNecessary(R.string.openpgp_result_action_show);
showSignatureLayout();
}

View File

@ -912,7 +912,6 @@ Posílejte prosím chybová hlášení, přispívejte novými funkcemi a ptejte
<string name="openpgp_successful_decryption_valid_signature_uncertified">Úspěšné dešifrování a platný podpis ale bez certifikátu</string>
<string name="openpgp_successful_decryption_unknown_signature">Úspěšné dešifrování, ale chybí veřejný klíč</string>
<string name="openpgp_get_key">Vyhledávám chybějící klíč</string>
<string name="openpgp_error">Chyba OpenPGP:</string>
<string name="openpgp_user_id">Id uživatele</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Použít klientský certifikát</string>

View File

@ -906,7 +906,6 @@ Um Fehler zu melden, neue Funktionen vorzuschlagen oder Fragen zu stellen, besuc
<string name="openpgp_successful_decryption_valid_signature_uncertified">Erfolgreiche Entschlüsselung und gültige, aber nicht beglaubigte Signatur</string>
<string name="openpgp_successful_decryption_unknown_signature">Erfolgreiche Entschlüsselung, aber fehlender öffentlicher Schlüssel</string>
<string name="openpgp_get_key">Schlage fehlenden Schlüssel nach</string>
<string name="openpgp_error">OpenPGP Fehler:</string>
<string name="openpgp_user_id">Benutzer-ID</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Client-Zertifikat verwenden</string>

View File

@ -870,7 +870,6 @@
<string name="openpgp_successful_decryption_valid_signature_uncertified">Επιτυχής αποκρυπτογράφηση και έγκυρη υπογραφή αλλά χωρίς πιστοποίηση</string>
<string name="openpgp_successful_decryption_unknown_signature">Επιτυχής αποκρυπτογράφηση αλλά απόν δημόσιο κλειδί</string>
<string name="openpgp_get_key">Εύρεση κλειδιού που λείπει</string>
<string name="openpgp_error">Σφάλμα OpenPGP:</string>
<string name="openpgp_user_id">Ταυτότητα χρήστη</string>
<!--=== Client certificates specific ==================================================================-->
</resources>

View File

@ -895,7 +895,6 @@ Por favor, envía los errores detectados, contribuye con nuevas funcionalidades
<string name="openpgp_successful_decryption_valid_signature_uncertified">Descifrado correctamente y firma válida pero sin certificar</string>
<string name="openpgp_successful_decryption_unknown_signature">Descifrado correctamente pero no se encuentra la clave pública</string>
<string name="openpgp_get_key">Buscar la clave no encontrada</string>
<string name="openpgp_error">Error OpenPGP:</string>
<string name="openpgp_user_id">Id de usuario</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Usar certificado de cliente</string>

View File

@ -845,7 +845,6 @@ Palun saada infot probleemidest, soovitavatest lisafunktsioonidest ja küsi küs
<string name="openpgp_successful_decryption_valid_signature_uncertified">Edukalt dekrüpteeritud ja kehtiv allkiri kuid sertifitseerimata</string>
<string name="openpgp_successful_decryption_unknown_signature">Edukalt dekrüpteeritud kuid puudub avalik võti</string>
<string name="openpgp_get_key">Otsi puuduvat võtit</string>
<string name="openpgp_error">OpenPGP viga:</string>
<string name="openpgp_user_id">Kasutaja Id</string>
<!--=== Client certificates specific ==================================================================-->
</resources>

View File

@ -906,7 +906,6 @@ Virheraportit, osallistuminen projektiin ja kysymykset: Mene osoitteeseen
<string name="openpgp_successful_decryption_valid_signature_uncertified">Salauksen purku onnistui ja kelvollinen, mutta varmentamaton allekirjoitus</string>
<string name="openpgp_successful_decryption_unknown_signature">Salauksen purku onnistui, mutta julkinen avain puuttuu</string>
<string name="openpgp_get_key">Etsi puuttuva avain</string>
<string name="openpgp_error">OpenPGP-virhe:</string>
<string name="openpgp_user_id">Käyttäjätunniste</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Käytä asiakasvarmennetta</string>

View File

@ -904,7 +904,6 @@ jusqu\'à <xliff:g id="messages_to_load">%d</xliff:g> de plus</string>
<string name="openpgp_successful_decryption_valid_signature_uncertified">Déchiffrement réussi et signature valide mais non certifiée</string>
<string name="openpgp_successful_decryption_unknown_signature">Déchiffrement réussi mais clef publique manquante</string>
<string name="openpgp_get_key">Rechercher la clef manquante </string>
<string name="openpgp_error">Erreur OpenPGP :</string>
<string name="openpgp_user_id">ID utilisateur</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Utiliser le certificat client</string>

View File

@ -902,7 +902,6 @@ Molimo vas pošaljite izvještaj o manama, učestvujte u novim značajkama i pos
<string name="openpgp_successful_decryption_valid_signature_uncertified">Uspješna dekripcija i važeći potpis ali ne certificiran</string>
<string name="openpgp_successful_decryption_unknown_signature">Uspješna dekripcija ali nedostaje javni kjuč</string>
<string name="openpgp_get_key">Potraži nedostajući ključ</string>
<string name="openpgp_error">OpenPGP Greška:</string>
<string name="openpgp_user_id">Korisnički ID</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Koristi certifikat klijenta</string>

View File

@ -882,7 +882,6 @@ Hibajelentéseivel hozzájárul az újabb verziók tökéletesítéséhez, kérd
<string name="openpgp_successful_decryption_valid_signature_uncertified">Titkosítás sikeresen feloldva és az aláírás érvényes, de nem tanúsított</string>
<string name="openpgp_successful_decryption_unknown_signature">Titkosítás sikeresen feloldva, de hiányzik a nyilvános kulcs</string>
<string name="openpgp_get_key">Hiányzó kulcs keresése</string>
<string name="openpgp_error">OpenPGP hiba:</string>
<string name="openpgp_user_id">Felhasználói Id</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Ügyfél tanúsítvány használata</string>

View File

@ -903,7 +903,6 @@ Invia le tue segnalazioni, suggerisci nuove funzionalità e chiedi informazioni
<string name="openpgp_successful_decryption_valid_signature_uncertified">Decifratura avvenuta e firma valida ma non certificata</string>
<string name="openpgp_successful_decryption_unknown_signature">Decifratura avvenuta ma chiave pubblica mancante</string>
<string name="openpgp_get_key">Cerca chiave mancante</string>
<string name="openpgp_error">Errore OpenPGP:</string>
<string name="openpgp_user_id">ID utente</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Usa certificato client</string>

View File

@ -886,7 +886,6 @@ K-9 は大多数のメールクライアントと同様に、ほとんどのフ
<string name="openpgp_successful_decryption_valid_signature_uncertified">解読と署名確認(証明書なし)成功</string>
<string name="openpgp_successful_decryption_unknown_signature">解読成功。ただし、公開鍵なし</string>
<string name="openpgp_get_key">公開鍵調査</string>
<string name="openpgp_error">OpenPGP エラー:</string>
<string name="openpgp_user_id">ユーザID</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">クライアント証明書を使う</string>

View File

@ -902,7 +902,6 @@ pat <xliff:g id="messages_to_load">%d</xliff:g> vairāk</string>
<string name="openpgp_successful_decryption_valid_signature_uncertified">Atkodēšana sekmīga un paraksts derīgs, bet nesertificēts</string>
<string name="openpgp_successful_decryption_unknown_signature">Atkodēšana sekmīga bet trūkst publiskās atslēgas</string>
<string name="openpgp_get_key">Meklēt trūkstošo atslēgu</string>
<string name="openpgp_error">OpenPGP kļūda:</string>
<string name="openpgp_user_id">Lietotāja ID</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Izmantot klienta sertifikātu</string>

View File

@ -899,7 +899,6 @@ Vis neste melding som standard etter meldingssletting</string>
<string name="openpgp_successful_decryption_valid_signature_uncertified">Vellykket dekryptering og gyldig signatur, men ikke sertifisert</string>
<string name="openpgp_successful_decryption_unknown_signature">Vellykket dekryptering, men mangler offentlig nøkkel</string>
<string name="openpgp_get_key">Se etter manglende nøkkel</string>
<string name="openpgp_error">OpenPGP feil:</string>
<string name="openpgp_user_id">BrukerID</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Bruk klientsertifikat</string>

View File

@ -893,7 +893,6 @@ Graag foutrapporten, bijdrage nieuwe functies en vragen stellen op
<string name="openpgp_signature_invalid">Ongeldige pgp handtekening</string>
<string name="openpgp_signature_unknown_text">Geen publieke sleutel voor deze handtekening</string>
<string name="openpgp_get_key">Zoek de missende sleutel</string>
<string name="openpgp_error">OpenPGP Fout:</string>
<string name="openpgp_user_id">Gebruikers-id</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Gebruik cliënt certificaat</string>

View File

@ -857,7 +857,6 @@ Wszelkie zgłoszenia usterek, zapytania oraz nowe pomysły prosimy przesyłać z
<string name="fetching_attachment_dialog_title_save">Zapisywanie szkicu</string>
<string name="fetching_attachment_dialog_message">Pobieranie załącznika…</string>
<!--=== OpenPGP specific ==================================================================-->
<string name="openpgp_error">Błąd OpenPGP:</string>
<string name="openpgp_user_id">ID użytkownika</string>
<!--=== Client certificates specific ==================================================================-->
<string name="client_certificate_advanced_options">Zaawansowane ustawienia</string>

View File

@ -874,7 +874,6 @@ Por favor, nos envie relatórios de bugs, contribua para novas melhorias e faça
<string name="openpgp_successful_decryption_valid_signature_uncertified">Desencriptação realizada com sucesso e assinatura válida mas não certificada</string>
<string name="openpgp_successful_decryption_unknown_signature">Desencriptação realizada mas falta chave pública</string>
<string name="openpgp_get_key">Procurar chave faltando</string>
<string name="openpgp_error">Error do OpenPGP</string>
<string name="openpgp_user_id">User Id</string>
<!--=== Client certificates specific ==================================================================-->
</resources>

View File

@ -900,7 +900,6 @@ K-9 Mail — почтовый клиент для Android.
<string name="openpgp_successful_decryption_valid_signature_uncertified">Дешифрование выполнено, подпись действительна, но не проверена</string>
<string name="openpgp_successful_decryption_unknown_signature">Дешифрование выполнено, но отсутствует открытый ключ</string>
<string name="openpgp_get_key">Поиск отсутствующего ключа</string>
<string name="openpgp_error">Ошибка OpenPGP:</string>
<string name="openpgp_user_id">ID пользователя</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Использовать сертификат клиента</string>

View File

@ -889,7 +889,6 @@ Prosím, nahlasujte prípadné chyby, prispievajte novými funkciami a pýtajte
<string name="openpgp_successful_decryption_valid_signature_uncertified">Úspešne dešifrované a platný podpis, ale necertifikovaný</string>
<string name="openpgp_successful_decryption_unknown_signature">Úspešne dešifrované, ale chýbajúci verejný kľúč</string>
<string name="openpgp_get_key">Vyhľadať chýbajúci kľúč</string>
<string name="openpgp_error">Chyba OpenPGP:</string>
<string name="openpgp_user_id">ID používateľa</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">Použiť klientský certifikát</string>

View File

@ -873,7 +873,6 @@ Anmäl fel, hjälp till med nya funktioner och ställ frågor på
<string name="openpgp_successful_decryption_valid_signature_uncertified">Lyckad dekryptering och giltig signatur men ocertifierad</string>
<string name="openpgp_successful_decryption_unknown_signature">Lyckad dekryptering men offentlig nyckel saknas</string>
<string name="openpgp_get_key">Sök nyckel som saknas</string>
<string name="openpgp_error">OpenPGP Error:</string>
<string name="openpgp_user_id">Användar-ID</string>
<!--=== Client certificates specific ==================================================================-->
</resources>

View File

@ -896,7 +896,6 @@ Lütfen hata raporlarınızı, istediğiniz yeni özellikleri ve sorularınızı
<string name="openpgp_successful_decryption_valid_signature_uncertified">Şifre çözme başarılı ve imza geçerli ancak sertifikalı değil</string>
<string name="openpgp_successful_decryption_unknown_signature">Şifre çözme başarılı ancak kamusal anahtar eksik</string>
<string name="openpgp_get_key">Kayıp anahtarı bul</string>
<string name="openpgp_error">OpenPGP Hatası:</string>
<string name="openpgp_user_id">Kullanıcı Kimliği</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">İstemci sertifikası kullan</string>

View File

@ -890,7 +890,6 @@ K-9改进的功能包括
<string name="openpgp_successful_decryption_valid_signature_uncertified">已成功解密且签名有效,但未验证</string>
<string name="openpgp_successful_decryption_unknown_signature">已成功解密,但没有公钥</string>
<string name="openpgp_get_key">查找缺失的公钥</string>
<string name="openpgp_error">OpenPGP 错误:</string>
<string name="openpgp_user_id">用户标识</string>
<!--=== Client certificates specific ==================================================================-->
<string name="account_setup_basics_client_certificate">使用客户端证书</string>

View File

@ -1114,7 +1114,8 @@ Please submit bug reports, contribute new features and ask questions at
<string name="openpgp_successful_decryption_valid_signature_uncertified">Successful decryption and valid signature but uncertified</string>
<string name="openpgp_successful_decryption_unknown_signature">Successful decryption but missing public key</string>
<string name="openpgp_get_key">Lookup missing key</string>
<string name="openpgp_error">OpenPGP Error:</string>
<string name="openpgp_error">OpenPGP Error: %s</string>
<string name="openpgp_unknown_error">Unknown OpenPGP Error</string>
<string name="openpgp_user_id">User Id</string>
<string name="openpgp_result_no_signature">"Not Signed"</string>
@ -1141,4 +1142,8 @@ Please submit bug reports, contribute new features and ask questions at
<string name="preview_inner_message">"Includes message titled \"%s\" containing: "</string>
<string name="preview_untitled_inner_message">"Includes untitled message containing: "</string>
<string name="crypto_incomplete_message">Incomplete message</string>
<!-- Note: This references message_view_download_remainder -->
<string name="crypto_download_complete_message_to_decrypt">Click \'Download complete message\' to allow decryption.</string>
</resources>