From 7a6a43818d10a0c5ebeebea42bcf040da194941b Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 30 Oct 2022 07:54:44 +0100 Subject: [PATCH] Link to OpenKeychain app only when relevant --- .../eu/faircode/email/FragmentCompose.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 8ed77a6011..07a81f66dd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -7759,18 +7759,6 @@ public class FragmentCompose extends FragmentBase { } }); - if (Helper.isOpenKeychainInstalled(context)) { - tvEncrypt.setPaintFlags(tvEncrypt.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); - tvEncrypt.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String pkg = Helper.getOpenKeychainPackage(v.getContext()); - PackageManager pm = v.getContext().getPackageManager(); - v.getContext().startActivity(pm.getLaunchIntentForPackage(pkg)); - } - }); - } - spEncrypt.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { @@ -7778,6 +7766,23 @@ public class FragmentCompose extends FragmentBase { if (last != position) { spEncrypt.setTag(position); setEncrypt(encryptValues[position]); + + if ((encryptValues[position] == EntityMessage.PGP_SIGNONLY || + encryptValues[position] == EntityMessage.PGP_SIGNENCRYPT) && + Helper.isOpenKeychainInstalled(context)) { + tvEncrypt.setPaintFlags(tvEncrypt.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); + tvEncrypt.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String pkg = Helper.getOpenKeychainPackage(v.getContext()); + PackageManager pm = v.getContext().getPackageManager(); + v.getContext().startActivity(pm.getLaunchIntentForPackage(pkg)); + } + }); + } else { + tvEncrypt.setPaintFlags(tvEncrypt.getPaintFlags() & ~Paint.UNDERLINE_TEXT_FLAG); + tvEncrypt.setOnClickListener(null); + } } }