Added key import

This commit is contained in:
M66B 2019-12-02 09:17:33 +01:00
parent a5de71cb6a
commit c049958263
2 changed files with 27 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import android.content.SharedPreferences;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.security.KeyChain;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -66,8 +67,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private SwitchCompat swAutoDecrypt; private SwitchCompat swAutoDecrypt;
private SwitchCompat swSecure; private SwitchCompat swSecure;
private Button btnBiometrics; private Button btnBiometrics;
private Spinner spBiometricsTimeout;
private Button btnPin; private Button btnPin;
private Spinner spBiometricsTimeout;
private Button btnImportKey;
private List<String> openPgpProvider = new ArrayList<>(); private List<String> openPgpProvider = new ArrayList<>();
@ -96,8 +98,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt); swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt);
swSecure = view.findViewById(R.id.swSecure); swSecure = view.findViewById(R.id.swSecure);
btnBiometrics = view.findViewById(R.id.btnBiometrics); btnBiometrics = view.findViewById(R.id.btnBiometrics);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
btnPin = view.findViewById(R.id.btnPin); 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); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2);
List<ResolveInfo> ris = getContext().getPackageManager().queryIntentServices(intent, 0); List<ResolveInfo> 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); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view; return view;

View File

@ -206,5 +206,17 @@
android:entries="@array/biometricsTimeoutNames" android:entries="@array/biometricsTimeoutNames"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" /> app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<Button
android:id="@+id/btnImportKey"
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_import_encrypt_key"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>