mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Make it easier to check if a crypto provider is configured
This commit is contained in:
parent
cac1f1ca0d
commit
132ede425b
@ -466,7 +466,8 @@ public class Account implements BaseAccount, StoreConfig {
|
||||
mIsSignatureBeforeQuotedText = prefs.getBoolean(mUuid + ".signatureBeforeQuotedText", false);
|
||||
identities = loadIdentities(prefs);
|
||||
|
||||
mCryptoApp = prefs.getString(mUuid + ".cryptoApp", NO_OPENPGP_PROVIDER);
|
||||
String cryptoApp = prefs.getString(mUuid + ".cryptoApp", NO_OPENPGP_PROVIDER);
|
||||
setCryptoApp(cryptoApp);
|
||||
mAllowRemoteSearch = prefs.getBoolean(mUuid + ".allowRemoteSearch", false);
|
||||
mRemoteSearchFullText = prefs.getBoolean(mUuid + ".remoteSearchFullText", false);
|
||||
mRemoteSearchNumResults = prefs.getInt(mUuid + ".remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS);
|
||||
@ -1615,7 +1616,11 @@ public class Account implements BaseAccount, StoreConfig {
|
||||
}
|
||||
|
||||
public void setCryptoApp(String cryptoApp) {
|
||||
mCryptoApp = cryptoApp;
|
||||
if (cryptoApp == null || cryptoApp.equals("apg")) {
|
||||
mCryptoApp = NO_OPENPGP_PROVIDER;
|
||||
} else {
|
||||
mCryptoApp = cryptoApp;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean allowRemoteSearch() {
|
||||
@ -1659,13 +1664,16 @@ public class Account implements BaseAccount, StoreConfig {
|
||||
}
|
||||
|
||||
public synchronized String getOpenPgpProvider() {
|
||||
// return null if set to "APG" or "None"
|
||||
if (getCryptoApp().equals("apg") || getCryptoApp().equals("")) {
|
||||
if (!isOpenPgpProviderConfigured()) {
|
||||
return null;
|
||||
}
|
||||
return getCryptoApp();
|
||||
}
|
||||
|
||||
public synchronized boolean isOpenPgpProviderConfigured() {
|
||||
return !NO_OPENPGP_PROVIDER.equals(getCryptoApp());
|
||||
}
|
||||
|
||||
public synchronized NotificationSetting getNotificationSetting() {
|
||||
return mNotificationSetting;
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
initializeCrypto();
|
||||
|
||||
mOpenPgpProvider = mAccount.getOpenPgpProvider();
|
||||
if (mOpenPgpProvider != null) {
|
||||
if (isCryptoProviderEnabled()) {
|
||||
mCryptoSignatureCheckbox = (CheckBox)findViewById(R.id.cb_crypto_signature);
|
||||
final OnCheckedChangeListener updateListener = new OnCheckedChangeListener() {
|
||||
@Override
|
||||
@ -1682,7 +1682,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
}
|
||||
|
||||
private void performSend() {
|
||||
if (mOpenPgpProvider != null) {
|
||||
if (isCryptoProviderEnabled()) {
|
||||
// OpenPGP Provider API
|
||||
|
||||
// If not already encrypted but user wants to encrypt...
|
||||
@ -1894,7 +1894,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
*/
|
||||
@SuppressLint("InlinedApi")
|
||||
private void onAddAttachment2(final String mime_type) {
|
||||
if (mAccount.getOpenPgpProvider() != null) {
|
||||
if (isCryptoProviderEnabled()) {
|
||||
Toast.makeText(this, R.string.attachment_encryption_unsupported, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
|
@ -76,7 +76,7 @@ public class MessageCryptoHelper {
|
||||
public void decryptOrVerifyMessagePartsIfNecessary(LocalMessage message) {
|
||||
this.message = message;
|
||||
|
||||
if (!isCryptoProviderConfigured()) {
|
||||
if (!account.isOpenPgpProviderConfigured()) {
|
||||
returnResultToFragment();
|
||||
return;
|
||||
}
|
||||
@ -95,10 +95,6 @@ public class MessageCryptoHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCryptoProviderConfigured() {
|
||||
return !TextUtils.isEmpty(account.getCryptoApp());
|
||||
}
|
||||
|
||||
private void decryptOrVerifyNextPart() {
|
||||
if (partsToDecryptOrVerify.isEmpty()) {
|
||||
returnResultToFragment();
|
||||
|
@ -88,7 +88,7 @@ public class MessageTopView extends LinearLayout implements ShowPicturesControll
|
||||
|
||||
for (MessageViewContainer container : messageViewInfo.containers) {
|
||||
MessageContainerView view = (MessageContainerView) mInflater.inflate(R.layout.message_container, null);
|
||||
boolean displayPgpHeader = !Account.NO_OPENPGP_PROVIDER.equals(account.getOpenPgpProvider());
|
||||
boolean displayPgpHeader = account.isOpenPgpProviderConfigured();
|
||||
view.displayMessageViewContainer(container, automaticallyLoadPictures, this, attachmentCallback,
|
||||
openPgpHeaderViewCallback, displayPgpHeader);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user