diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java index 1fce40cff8..f13ed072fa 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java @@ -26,6 +26,7 @@ import android.content.SharedPreferences; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.Handler; +import android.security.KeyChain; import android.text.TextUtils; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -66,8 +67,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer private SwitchCompat swAutoDecrypt; private SwitchCompat swSecure; private Button btnBiometrics; - private Spinner spBiometricsTimeout; private Button btnPin; + private Spinner spBiometricsTimeout; + private Button btnImportKey; private List openPgpProvider = new ArrayList<>(); @@ -96,8 +98,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt); swSecure = view.findViewById(R.id.swSecure); btnBiometrics = view.findViewById(R.id.btnBiometrics); - spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); btnPin = view.findViewById(R.id.btnPin); + spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); + btnImportKey = view.findViewById(R.id.btnImportKey); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2); List ris = getContext().getPackageManager().queryIntentServices(intent, 0); @@ -219,6 +222,16 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer } }); + final Intent importKey = KeyChain.createInstallIntent(); + btnImportKey.setEnabled(importKey.resolveActivity(getContext().getPackageManager()) != null); + btnImportKey.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE); + btnImportKey.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(importKey); + } + }); + PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); return view; diff --git a/app/src/main/res/layout/fragment_options_privacy.xml b/app/src/main/res/layout/fragment_options_privacy.xml index f88bdae824..ccdcfbfc6b 100644 --- a/app/src/main/res/layout/fragment_options_privacy.xml +++ b/app/src/main/res/layout/fragment_options_privacy.xml @@ -206,5 +206,17 @@ android:entries="@array/biometricsTimeoutNames" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" /> + +