Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a14cd9f0 authored by Vincent Breitmoser's avatar Vincent Breitmoser Committed by GitHub
Browse files

Merge pull request #2047 from k9mail/apg-deprecation-warning

show warning about APG being deprecated if still selected
parents 0dd7a4aa 330aef85
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ public class Account implements BaseAccount, StoreConfig {
    private boolean mStripSignature;
    private boolean mSyncRemoteDeletions;
    private String mCryptoApp;
    private boolean mCryptoAppIsDeprecatedApg;
    private long mCryptoKey;
    private boolean mCryptoSupportSignOnly;
    private boolean mMarkMessageAsReadOnView;
@@ -1607,13 +1608,19 @@ public class Account implements BaseAccount, StoreConfig {
    }

    public void setCryptoApp(String cryptoApp) {
        if (cryptoApp == null || cryptoApp.equals("apg")) {
        boolean isApgCryptoProvider = "apg".equals(cryptoApp);
        if (cryptoApp == null || isApgCryptoProvider) {
            mCryptoAppIsDeprecatedApg = isApgCryptoProvider;
            mCryptoApp = NO_OPENPGP_PROVIDER;
        } else {
            mCryptoApp = cryptoApp;
        }
    }

    public boolean isCryptoAppDeprecatedApg() {
        return mCryptoAppIsDeprecatedApg;
    }

    public long getCryptoKey() {
        return mCryptoKey;
    }
+27 −3
Original line number Diff line number Diff line

package com.fsck.k9.activity.setup;


import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -8,6 +9,8 @@ import java.util.Map;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
@@ -45,7 +48,7 @@ import com.fsck.k9.mail.Store;
import com.fsck.k9.mailstore.LocalFolder;
import com.fsck.k9.mailstore.StorageManager;
import com.fsck.k9.service.MailService;

import com.fsck.k9.ui.dialog.ApgDeprecationWarningDialog;
import org.openintents.openpgp.util.OpenPgpAppPreference;
import org.openintents.openpgp.util.OpenPgpKeyPreference;
import org.openintents.openpgp.util.OpenPgpUtils;
@@ -56,6 +59,7 @@ public class AccountSettings extends K9PreferenceActivity {

    private static final int DIALOG_COLOR_PICKER_ACCOUNT = 1;
    private static final int DIALOG_COLOR_PICKER_LED = 2;
    private static final int DIALOG_APG_DEPRECATION_WARNING = 3;

    private static final int SELECT_AUTO_EXPAND_FOLDER = 1;

@@ -127,6 +131,7 @@ public class AccountSettings extends K9PreferenceActivity {
    private static final String PREFERENCE_SPAM_FOLDER = "spam_folder";
    private static final String PREFERENCE_TRASH_FOLDER = "trash_folder";
    private static final String PREFERENCE_ALWAYS_SHOW_CC_BCC = "always_show_cc_bcc";
    public static final String APG_PROVIDER_PLACEHOLDER = "apg-placeholder";


    private Account mAccount;
@@ -703,12 +708,21 @@ public class AccountSettings extends K9PreferenceActivity {
            mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY);

            mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp()));
            if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) {
                mCryptoApp.addLegacyProvider(APG_PROVIDER_PLACEHOLDER, getString(R.string.apg), R.drawable.ic_apg_small);
            }
            mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    String value = newValue.toString();
                    if (APG_PROVIDER_PLACEHOLDER.equals(value)) {
                        mCryptoApp.setValue("");
                        mCryptoKey.setOpenPgpProvider("");
                        showDialog(DIALOG_APG_DEPRECATION_WARNING);
                    } else {
                        mCryptoApp.setValue(value);

                        mCryptoKey.setOpenPgpProvider(value);
                    }

                    return false;
                }
            });
@@ -939,6 +953,16 @@ public class AccountSettings extends K9PreferenceActivity {

                break;
            }
            case DIALOG_APG_DEPRECATION_WARNING: {
                dialog = new ApgDeprecationWarningDialog(this);
                dialog.setOnCancelListener(new OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        mCryptoApp.show();
                    }
                });
                break;
            }
        }

        return dialog;
+43 −0
Original line number Diff line number Diff line
package com.fsck.k9.ui.dialog;


import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.fsck.k9.R;


public class ApgDeprecationWarningDialog extends AlertDialog {
    public ApgDeprecationWarningDialog(Context context) {
        super(context);

        LayoutInflater inflater = LayoutInflater.from(context);

        @SuppressLint("InflateParams")
        View contentView = inflater.inflate(R.layout.dialog_apg_deprecated, null);

        TextView textViewLearnMore = (TextView) contentView.findViewById(R.id.apg_learn_more);
        makeTextViewLinksClickable(textViewLearnMore);

        setIcon(R.drawable.ic_apg_small);
        setTitle(R.string.apg_deprecated_title);
        setView(contentView);
        setButton(Dialog.BUTTON_NEUTRAL, context.getString(R.string.apg_deprecated_ok), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                cancel();
            }
        });
    }

    private void makeTextViewLinksClickable(TextView textView) {
        textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
+4.43 KiB
Loading image diff...
+2.51 KiB
Loading image diff...
Loading