fix NPE in EncryptModeAsymmetricFragment
This commit is contained in:
@@ -28,6 +28,7 @@ import android.arch.lifecycle.ViewModelProviders;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -53,7 +54,7 @@ import timber.log.Timber;
|
|||||||
|
|
||||||
|
|
||||||
public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
||||||
KeyRepository mKeyRepository;
|
KeyRepository keyRepository;
|
||||||
|
|
||||||
private KeySpinner mSignKeySpinner;
|
private KeySpinner mSignKeySpinner;
|
||||||
private ChipsInput mEncryptKeyView;
|
private ChipsInput mEncryptKeyView;
|
||||||
@@ -73,6 +74,13 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
|||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
keyRepository = KeyRepository.create(requireContext());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inflate the layout for this fragment
|
* Inflate the layout for this fragment
|
||||||
*/
|
*/
|
||||||
@@ -184,7 +192,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
|||||||
*/
|
*/
|
||||||
private void preselectKeys(Long signatureKeyId, long[] encryptionKeyIds) {
|
private void preselectKeys(Long signatureKeyId, long[] encryptionKeyIds) {
|
||||||
if (signatureKeyId != null) {
|
if (signatureKeyId != null) {
|
||||||
UnifiedKeyInfo unifiedKeyInfo = mKeyRepository.getUnifiedKeyInfo(signatureKeyId);
|
UnifiedKeyInfo unifiedKeyInfo = keyRepository.getUnifiedKeyInfo(signatureKeyId);
|
||||||
if (unifiedKeyInfo == null) {
|
if (unifiedKeyInfo == null) {
|
||||||
String beautifyKeyId = KeyFormattingUtils.beautifyKeyId(signatureKeyId);
|
String beautifyKeyId = KeyFormattingUtils.beautifyKeyId(signatureKeyId);
|
||||||
Notify.create(getActivity(), getString(R.string.error_preselect_sign_key, beautifyKeyId), Style.ERROR).show();
|
Notify.create(getActivity(), getString(R.string.error_preselect_sign_key, beautifyKeyId), Style.ERROR).show();
|
||||||
@@ -197,7 +205,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
|||||||
for (long preselectedId : encryptionKeyIds) {
|
for (long preselectedId : encryptionKeyIds) {
|
||||||
try {
|
try {
|
||||||
CanonicalizedPublicKeyRing ring =
|
CanonicalizedPublicKeyRing ring =
|
||||||
mKeyRepository.getCanonicalizedPublicKeyRing(preselectedId);
|
keyRepository.getCanonicalizedPublicKeyRing(preselectedId);
|
||||||
Chip infooo = new Chip(ring.getMasterKeyId(), ring.getPrimaryUserIdWithFallback(), "infooo");
|
Chip infooo = new Chip(ring.getMasterKeyId(), ring.getPrimaryUserIdWithFallback(), "infooo");
|
||||||
mEncryptKeyView.addChip(infooo);
|
mEncryptKeyView.addChip(infooo);
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user