mirror of https://github.com/M66B/FairEmail.git
Addd manage private keys
This commit is contained in:
parent
8dd9c62365
commit
dc1e6ae733
|
@ -23,9 +23,11 @@ import android.app.Dialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.security.KeyChain;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -74,6 +76,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
private Spinner spBiometricsTimeout;
|
||||
private Button btnManageCertificates;
|
||||
private Button btnImportKey;
|
||||
private Button btnManageKeys;
|
||||
private TextView tvKeySize;
|
||||
|
||||
private List<String> openPgpProvider = new ArrayList<>();
|
||||
|
@ -91,6 +94,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
setSubtitle(R.string.title_setup);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
View view = inflater.inflate(R.layout.fragment_options_privacy, container, false);
|
||||
|
||||
// Get controls
|
||||
|
@ -108,10 +112,11 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
|
||||
btnManageCertificates = view.findViewById(R.id.btnManageCertificates);
|
||||
btnImportKey = view.findViewById(R.id.btnImportKey);
|
||||
btnManageKeys = view.findViewById(R.id.btnManageKeys);
|
||||
tvKeySize = view.findViewById(R.id.tvKeySize);
|
||||
|
||||
Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2);
|
||||
List<ResolveInfo> ris = getContext().getPackageManager().queryIntentServices(intent, 0);
|
||||
List<ResolveInfo> ris = pm.queryIntentServices(intent, 0);
|
||||
for (ResolveInfo ri : ris)
|
||||
if (ri.serviceInfo != null)
|
||||
openPgpProvider.add(ri.serviceInfo.packageName);
|
||||
|
@ -254,7 +259,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
});
|
||||
|
||||
final Intent importKey = KeyChain.createInstallIntent();
|
||||
btnImportKey.setEnabled(importKey.resolveActivity(getContext().getPackageManager()) != null);
|
||||
btnImportKey.setEnabled(importKey.resolveActivity(pm) != null);
|
||||
btnImportKey.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -262,6 +267,15 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
final Intent security = new Intent(Settings.ACTION_SECURITY_SETTINGS);
|
||||
btnImportKey.setEnabled(security.resolveActivity(pm) != null);
|
||||
btnManageKeys.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(security);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
int maxKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength("AES");
|
||||
tvKeySize.setText(getString(R.string.title_advanced_aes_key_size, maxKeySize));
|
||||
|
|
|
@ -253,6 +253,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnManageCertificates" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnManageKeys"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"
|
||||
android:text="@string/title_advanced_manage_keys"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnImportKey" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvKeySize"
|
||||
android:layout_width="0dp"
|
||||
|
@ -261,6 +273,6 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnImportKey" />
|
||||
app:layout_constraintTop_toBottomOf="@id/btnManageKeys" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -340,6 +340,7 @@
|
|||
<string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string>
|
||||
<string name="title_advanced_manage_certificates">Manage public keys</string>
|
||||
<string name="title_advanced_import_key">Import private key</string>
|
||||
<string name="title_advanced_manage_keys">Manage private keys</string>
|
||||
<string name="title_advanced_aes_key_size" translatable="false">Max AES key size: %1$d</string>
|
||||
|
||||
<string name="title_advanced_english">Force English language</string>
|
||||
|
|
Loading…
Reference in New Issue