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