nicer errors if key cannot be found in preselect

This commit is contained in:
Vincent Breitmoser 2017-02-27 15:13:15 +01:00
parent 05e4cf1ab6
commit 3f674f8bbe
2 changed files with 13 additions and 2 deletions

View file

@ -38,6 +38,9 @@ import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter.KeyItem;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView;
import org.sufficientlysecure.keychain.ui.widget.KeySpinner;
import org.sufficientlysecure.keychain.ui.widget.KeySpinner.OnKeyChangedListener;
@ -141,7 +144,10 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
mSignKeySpinner.setPreSelectedKeyId(signatureKeyId);
}
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
Log.e(Constants.TAG, "key not found for signing!", e);
Notify.create(getActivity(), getString(R.string.error_preselect_sign_key,
KeyFormattingUtils.beautifyKeyId(signatureKeyId)),
Style.ERROR).show();
}
}
@ -152,7 +158,10 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
mKeyRepository.getCanonicalizedPublicKeyRing(preselectedId);
mEncryptKeyView.addObject(new KeyItem(ring));
} catch (NotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
Log.e(Constants.TAG, "key not found for encryption!", e);
Notify.create(getActivity(), getString(R.string.error_preselect_encrypt_key,
KeyFormattingUtils.beautifyKeyId(preselectedId)),
Style.ERROR).show();
}
}
// This is to work-around a rendering bug in TokenCompleteTextView

View file

@ -1805,4 +1805,6 @@
<string name="button_allow">Allow</string>
<string name="button_cancel">Cancel</string>
<string name="requested_key_label">Requested key:</string>
<string name="error_preselect_sign_key">Error selecting key %s for signing!</string>
<string name="error_preselect_encrypt_key">Error selecting key %s for encryption!</string>
</resources>