add screen to display when no crypto provider is configured
This commit is contained in:
parent
8ee9b2c591
commit
e2186058bc
7 changed files with 83 additions and 8 deletions
|
@ -159,5 +159,6 @@ public final class CryptoResultAnnotation {
|
|||
OPENPGP_ENCRYPTED_BUT_INCOMPLETE,
|
||||
SIGNED_BUT_UNSUPPORTED,
|
||||
ENCRYPTED_BUT_UNSUPPORTED,
|
||||
OPENPGP_ENCRYPTED_NO_PROVIDER,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.fsck.k9.crypto.MessageDecryptVerifier;
|
|||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.Part;
|
||||
import com.fsck.k9.mailstore.CryptoResultAnnotation;
|
||||
import com.fsck.k9.mailstore.CryptoResultAnnotation.CryptoError;
|
||||
|
||||
|
||||
public class MessageCryptoSplitter {
|
||||
|
@ -19,20 +20,21 @@ public class MessageCryptoSplitter {
|
|||
|
||||
@Nullable
|
||||
public static CryptoMessageParts split(@NonNull Message message, @Nullable MessageCryptoAnnotations annotations) {
|
||||
if (annotations == null) {
|
||||
ArrayList<Part> extraParts = new ArrayList<>();
|
||||
Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts);
|
||||
if (primaryPart == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<Part> extraParts = new ArrayList<>();
|
||||
Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts);
|
||||
|
||||
if (!annotations.has(primaryPart)) {
|
||||
return null;
|
||||
if (annotations == null) {
|
||||
CryptoResultAnnotation rootPartAnnotation =
|
||||
CryptoResultAnnotation.createErrorAnnotation(CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null);
|
||||
return new CryptoMessageParts(primaryPart, rootPartAnnotation, extraParts);
|
||||
}
|
||||
|
||||
CryptoResultAnnotation rootPartAnnotation = annotations.get(primaryPart);
|
||||
Part rootPart;
|
||||
if (rootPartAnnotation.hasReplacementData()) {
|
||||
if (rootPartAnnotation != null && rootPartAnnotation.hasReplacementData()) {
|
||||
rootPart = rootPartAnnotation.getReplacementData();
|
||||
} else {
|
||||
rootPart = primaryPart;
|
||||
|
@ -43,11 +45,12 @@ public class MessageCryptoSplitter {
|
|||
|
||||
public static class CryptoMessageParts {
|
||||
public final Part contentPart;
|
||||
@Nullable
|
||||
public final CryptoResultAnnotation contentCryptoAnnotation;
|
||||
|
||||
public final List<Part> extraParts;
|
||||
|
||||
CryptoMessageParts(Part contentPart, CryptoResultAnnotation contentCryptoAnnotation, List<Part> extraParts) {
|
||||
CryptoMessageParts(Part contentPart, @Nullable CryptoResultAnnotation contentCryptoAnnotation, List<Part> extraParts) {
|
||||
this.contentPart = contentPart;
|
||||
this.contentCryptoAnnotation = contentCryptoAnnotation;
|
||||
this.extraParts = Collections.unmodifiableList(extraParts);
|
||||
|
|
|
@ -116,6 +116,11 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
|
|||
break;
|
||||
}
|
||||
|
||||
case ENCRYPTED_NO_PROVIDER: {
|
||||
messageView.showNoCryptoProviderConfigured(messageViewInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
case INCOMPLETE_SIGNED:
|
||||
case UNSUPPORTED_SIGNED:
|
||||
default: {
|
||||
|
|
|
@ -189,6 +189,21 @@ public class MessageTopView extends LinearLayout {
|
|||
displayViewOnLoadFinished(false);
|
||||
}
|
||||
|
||||
public void showNoCryptoProviderConfigured(MessageViewInfo messageViewInfo) {
|
||||
resetAndPrepareMessageView(messageViewInfo);
|
||||
View view = mInflater.inflate(R.layout.message_content_crypto_no_provider, containerView, false);
|
||||
|
||||
view.findViewById(R.id.crypto_settings).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
|
||||
containerView.addView(view);
|
||||
displayViewOnLoadFinished(false);
|
||||
}
|
||||
|
||||
private void setCryptoProviderIcon(Drawable openPgpApiProviderIcon, View view) {
|
||||
ImageView cryptoProviderIcon = (ImageView) view.findViewById(R.id.crypto_error_icon);
|
||||
if (openPgpApiProviderIcon != null) {
|
||||
|
|
|
@ -136,6 +136,12 @@ public enum MessageCryptoDisplayStatus {
|
|||
R.string.crypto_msg_signed_unencrypted, R.string.crypto_msg_sign_incomplete
|
||||
),
|
||||
|
||||
ENCRYPTED_NO_PROVIDER (
|
||||
R.attr.openpgp_red,
|
||||
R.drawable.status_lock_error,
|
||||
R.string.crypto_msg_unsupported_encrypted
|
||||
),
|
||||
|
||||
UNSUPPORTED_ENCRYPTED (
|
||||
R.attr.openpgp_red,
|
||||
R.drawable.status_lock_error,
|
||||
|
@ -214,6 +220,9 @@ public enum MessageCryptoDisplayStatus {
|
|||
|
||||
case OPENPGP_ENCRYPTED_API_ERROR:
|
||||
return ENCRYPTED_ERROR;
|
||||
|
||||
case OPENPGP_ENCRYPTED_NO_PROVIDER:
|
||||
return ENCRYPTED_NO_PROVIDER;
|
||||
}
|
||||
throw new IllegalStateException("Unhandled case!");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:id="@+id/crypto_error_title"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/crypto_no_provider_title"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:text="@string/crypto_no_provider_message"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/crypto_settings"
|
||||
android:text="@string/crypto_no_provider_button"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1163,6 +1163,7 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
|
||||
<string name="crypto_msg_encrypted_error">Message is encrypted, but there was a decryption error.</string>
|
||||
<string name="crypto_msg_signed_error">Message is signed, but the signature could not be verified.</string>
|
||||
<string name="crypto_msg_encrypted_no_provider">Message is encrypted, but no crypto app is configured.</string>
|
||||
<string name="crypto_msg_unsupported_encrypted">Message is encrypted, but in an unsupported format.</string>
|
||||
<string name="crypto_msg_unsupported_signed">Message is signed, but in an unsupported format.</string>
|
||||
<string name="crypto_msg_incomplete_encrypted">Message is encrypted, but must be fully downloaded for decryption.</string>
|
||||
|
@ -1217,5 +1218,8 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="apg_deprecated_ok">Got it!</string>
|
||||
<string name="apg">APG</string>
|
||||
<string name="no_crypto_provider_see_global">No OpenPGP app configured, see global settings!</string>
|
||||
<string name="crypto_no_provider_title">This email is encrypted</string>
|
||||
<string name="crypto_no_provider_message">This email has been encrypted with OpenPGP.\nTo read it, you need to install and configure a compatible OpenPGP App.</string>
|
||||
<string name="crypto_no_provider_button">Choose OpenPGP App</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue