consistently name openpgp provider setting

This commit is contained in:
Vincent Breitmoser 2017-01-24 18:17:29 +01:00
parent 6e982690d2
commit 884b12a48b
12 changed files with 62 additions and 62 deletions

View file

@ -242,8 +242,8 @@ public class K9 extends Application {
private static boolean mHideUserAgent = false;
private static boolean mHideTimeZone = false;
private static String sCryptoProvider = "";
private static boolean sCryptoSupportSignOnly = false;
private static String sOpenPgpProvider = "";
private static boolean sOpenPgpSupportSignOnly = false;
private static SortType mSortType;
private static Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
@ -314,7 +314,7 @@ public class K9 extends Application {
public static final int BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 60000;
public static final String NO_CRYPTO_PROVIDER = "";
public static final String NO_OPENPGP_PROVIDER = "";
public static class Intents {
@ -469,8 +469,8 @@ public class K9 extends Application {
editor.putBoolean("hideUserAgent", mHideUserAgent);
editor.putBoolean("hideTimeZone", mHideTimeZone);
editor.putString("cryptoProvider", sCryptoProvider);
editor.putBoolean("cryptoSupportSignOnly", sCryptoSupportSignOnly);
editor.putString("openPgpProvider", sOpenPgpProvider);
editor.putBoolean("openPgpSupportSignOnly", sOpenPgpSupportSignOnly);
editor.putString("language", language);
editor.putInt("theme", theme.ordinal());
@ -690,8 +690,8 @@ public class K9 extends Application {
mHideUserAgent = storage.getBoolean("hideUserAgent", false);
mHideTimeZone = storage.getBoolean("hideTimeZone", false);
sCryptoProvider = storage.getString("cryptoProvider", NO_CRYPTO_PROVIDER);
sCryptoSupportSignOnly = storage.getBoolean("cryptoSupportSignOnly", false);
sOpenPgpProvider = storage.getString("openPgpProvider", NO_OPENPGP_PROVIDER);
sOpenPgpSupportSignOnly = storage.getBoolean("openPgpSupportSignOnly", false);
mConfirmDelete = storage.getBoolean("confirmDelete", false);
mConfirmDiscardMessage = storage.getBoolean("confirmDiscardMessage", true);
@ -1238,24 +1238,24 @@ public class K9 extends Application {
mHideTimeZone = state;
}
public static boolean isCryptoProviderConfigured() {
return !NO_CRYPTO_PROVIDER.equals(sCryptoProvider);
public static boolean isOpenPgpProviderConfigured() {
return !NO_OPENPGP_PROVIDER.equals(sOpenPgpProvider);
}
public static String getCryptoProvider() {
return sCryptoProvider;
public static String getOpenPgpProvider() {
return sOpenPgpProvider;
}
public static void setCryptoProvider(String cryptoProvider) {
sCryptoProvider = cryptoProvider;
public static void setOpenPgpProvider(String openPgpProvider) {
sOpenPgpProvider = openPgpProvider;
}
public static boolean getCryptoSupportSignOnly() {
return sCryptoSupportSignOnly;
public static boolean getOpenPgpSupportSignOnly() {
return sOpenPgpSupportSignOnly;
}
public static void setCryptoSupportSignOnly(boolean supportSignOnly) {
sCryptoSupportSignOnly = supportSignOnly;
public static void setOpenPgpSupportSignOnly(boolean supportSignOnly) {
sOpenPgpSupportSignOnly = supportSignOnly;
}
public static String getAttachmentDefaultPath() {

View file

@ -202,7 +202,7 @@ public class MessageLoaderHelper {
return;
}
if (K9.isCryptoProviderConfigured()) {
if (K9.isOpenPgpProviderConfigured()) {
startOrResumeCryptoOperation();
return;
}

View file

@ -67,7 +67,7 @@ public class RecipientPresenter implements PermissionPingCallback {
private final RecipientsChangedListener listener;
private ReplyToParser replyToParser;
private Account account;
private String cryptoProvider;
private String openPgpProvider;
private Boolean hasContactPicker;
private ComposeCryptoStatus cachedCryptoStatus;
private PendingIntent pendingUserInteractionIntent;
@ -251,7 +251,7 @@ public class RecipientPresenter implements PermissionPingCallback {
menu.findItem(R.id.openpgp_inline_enable).setVisible(isCryptoConfigured && !cryptoEnablePgpInline);
menu.findItem(R.id.openpgp_inline_disable).setVisible(isCryptoConfigured && cryptoEnablePgpInline);
boolean showSignOnly = isCryptoConfigured && K9.getCryptoSupportSignOnly();
boolean showSignOnly = isCryptoConfigured && K9.getOpenPgpSupportSignOnly();
boolean isSignOnly = cachedCryptoStatus.isSignOnly();
menu.findItem(R.id.openpgp_sign_only).setVisible(showSignOnly && !isSignOnly);
menu.findItem(R.id.openpgp_sign_only_disable).setVisible(showSignOnly && isSignOnly);
@ -442,7 +442,7 @@ public class RecipientPresenter implements PermissionPingCallback {
}
private void addRecipientsFromAddresses(final RecipientType recipientType, final Address... addresses) {
new RecipientLoader(context, cryptoProvider, addresses) {
new RecipientLoader(context, openPgpProvider, addresses) {
@Override
public void deliverResult(List<Recipient> result) {
Recipient[] recipientArray = result.toArray(new Recipient[result.size()]);
@ -455,7 +455,7 @@ public class RecipientPresenter implements PermissionPingCallback {
}
private void addRecipientFromContactUri(final RecipientType recipientType, final Uri uri) {
new RecipientLoader(context, cryptoProvider, uri, false) {
new RecipientLoader(context, openPgpProvider, uri, false) {
@Override
public void deliverResult(List<Recipient> result) {
// TODO handle multiple available mail addresses for a contact?
@ -611,13 +611,13 @@ public class RecipientPresenter implements PermissionPingCallback {
}
private void setupCryptoProvider() {
String cryptoProvider = K9.getCryptoProvider();
if (TextUtils.isEmpty(cryptoProvider)) {
cryptoProvider = null;
String openPgpProvider = K9.getOpenPgpProvider();
if (TextUtils.isEmpty(openPgpProvider)) {
openPgpProvider = null;
}
boolean providerIsBound = openPgpServiceConnection != null && openPgpServiceConnection.isBound();
boolean isSameProvider = cryptoProvider != null && cryptoProvider.equals(this.cryptoProvider);
boolean isSameProvider = openPgpProvider != null && openPgpProvider.equals(this.openPgpProvider);
if (isSameProvider && providerIsBound) {
cryptoProviderBindOrCheckPermission();
return;
@ -628,15 +628,15 @@ public class RecipientPresenter implements PermissionPingCallback {
openPgpServiceConnection = null;
}
this.cryptoProvider = cryptoProvider;
this.openPgpProvider = openPgpProvider;
if (cryptoProvider == null) {
if (openPgpProvider == null) {
cryptoProviderState = CryptoProviderState.UNCONFIGURED;
return;
}
cryptoProviderState = CryptoProviderState.UNINITIALIZED;
openPgpServiceConnection = new OpenPgpServiceConnection(context, cryptoProvider, new OnBound() {
openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProvider, new OnBound() {
@Override
public void onBound(IOpenPgpService2 service) {
cryptoProviderBindOrCheckPermission();
@ -649,7 +649,7 @@ public class RecipientPresenter implements PermissionPingCallback {
});
cryptoProviderBindOrCheckPermission();
recipientMvpView.setCryptoProvider(cryptoProvider);
recipientMvpView.setCryptoProvider(openPgpProvider);
}
private void cryptoProviderBindOrCheckPermission() {
@ -784,7 +784,7 @@ public class RecipientPresenter implements PermissionPingCallback {
@VisibleForTesting
void setOpenPgpServiceConnection(OpenPgpServiceConnection openPgpServiceConnection, String cryptoProvider) {
this.openPgpServiceConnection = openPgpServiceConnection;
this.cryptoProvider = cryptoProvider;
this.openPgpProvider = cryptoProvider;
}
public enum CryptoProviderState {

View file

@ -693,13 +693,13 @@ public class AccountSettings extends K9PreferenceActivity {
}
});
mHasCrypto = K9.isCryptoProviderConfigured();
mHasCrypto = K9.isOpenPgpProviderConfigured();
PreferenceScreen cryptoMenu = (PreferenceScreen) findPreference(PREFERENCE_CRYPTO);
if (mHasCrypto) {
mCryptoKey = (OpenPgpKeyPreference) findPreference(PREFERENCE_CRYPTO_KEY);
mCryptoKey.setValue(mAccount.getCryptoKey());
mCryptoKey.setOpenPgpProvider(K9.getCryptoProvider());
mCryptoKey.setOpenPgpProvider(K9.getOpenPgpProvider());
// TODO: other identities?
mCryptoKey.setDefaultUserId(OpenPgpApiHelper.buildUserId(mAccount.getIdentity(0)));
mCryptoKey.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

View file

@ -93,8 +93,8 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_HIDE_USERAGENT = "privacy_hide_useragent";
private static final String PREFERENCE_HIDE_TIMEZONE = "privacy_hide_timezone";
private static final String PREFERENCE_CRYPTO_APP = "crypto_app";
private static final String PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY = "crypto_support_sign_only";
private static final String PREFERENCE_OPENPGP_PROVIDER = "openpgp_provider";
private static final String PREFERENCE_OPENPGP_SUPPORT_SIGN_ONLY = "openpgp_support_sign_only";
private static final String PREFERENCE_AUTOFIT_WIDTH = "messageview_autofit_width";
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
@ -155,8 +155,8 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxPreference mWrapFolderNames;
private CheckBoxListPreference mVisibleRefileActions;
private OpenPgpAppPreference mCryptoProvider;
private CheckBoxPreference mCryptoSupportSignOnly;
private OpenPgpAppPreference mOpenPgpProvider;
private CheckBoxPreference mOpenPgpSupportSignOnly;
private CheckBoxPreference mQuietTimeEnabled;
private CheckBoxPreference mDisableNotificationDuringQuietTime;
@ -384,27 +384,27 @@ public class Prefs extends K9PreferenceActivity {
mHideUserAgent.setChecked(K9.hideUserAgent());
mHideTimeZone.setChecked(K9.hideTimeZone());
mCryptoProvider = (OpenPgpAppPreference) findPreference(PREFERENCE_CRYPTO_APP);
mCryptoProvider.setValue(K9.getCryptoProvider());
mOpenPgpProvider = (OpenPgpAppPreference) findPreference(PREFERENCE_OPENPGP_PROVIDER);
mOpenPgpProvider.setValue(K9.getOpenPgpProvider());
if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) {
mCryptoProvider.addLegacyProvider(
mOpenPgpProvider.addLegacyProvider(
APG_PROVIDER_PLACEHOLDER, getString(R.string.apg), R.drawable.ic_apg_small);
}
mCryptoProvider.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
mOpenPgpProvider.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
if (APG_PROVIDER_PLACEHOLDER.equals(value)) {
mCryptoProvider.setValue("");
mOpenPgpProvider.setValue("");
showDialog(DIALOG_APG_DEPRECATION_WARNING);
} else {
mCryptoProvider.setValue(value);
mOpenPgpProvider.setValue(value);
}
return false;
}
});
mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY);
mCryptoSupportSignOnly.setChecked(K9.getCryptoSupportSignOnly());
mOpenPgpSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_OPENPGP_SUPPORT_SIGN_ONLY);
mOpenPgpSupportSignOnly.setChecked(K9.getOpenPgpSupportSignOnly());
mAttachmentPathPreference = findPreference(PREFERENCE_ATTACHMENT_DEF_PATH);
mAttachmentPathPreference.setSummary(K9.getAttachmentDefaultPath());
@ -561,8 +561,8 @@ public class Prefs extends K9PreferenceActivity {
K9.setHideUserAgent(mHideUserAgent.isChecked());
K9.setHideTimeZone(mHideTimeZone.isChecked());
K9.setCryptoProvider(mCryptoProvider.getValue());
K9.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked());
K9.setOpenPgpProvider(mOpenPgpProvider.getValue());
K9.setOpenPgpSupportSignOnly(mOpenPgpSupportSignOnly.isChecked());
StorageEditor editor = storage.edit();
K9.save(editor);
@ -601,7 +601,7 @@ public class Prefs extends K9PreferenceActivity {
dialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mCryptoProvider.show();
mOpenPgpProvider.show();
}
});
break;

View file

@ -290,10 +290,10 @@ public class GlobalSettings {
s.put("pgpSignOnlyDialogCounter", Settings.versions(
new V(45, new IntegerRangeSetting(0, Integer.MAX_VALUE, 0))
));
s.put("cryptoProvider", Settings.versions(
new V(46, new StringSetting(K9.NO_CRYPTO_PROVIDER))
s.put("openpgpProvider", Settings.versions(
new V(46, new StringSetting(K9.NO_OPENPGP_PROVIDER))
));
s.put("cryptoSupportSignOnly", Settings.versions(
s.put("openpgpSupportSignOnly", Settings.versions(
new V(47, new BooleanSetting(false))
));

View file

@ -89,7 +89,7 @@ public class MessageCryptoHelper {
public MessageCryptoHelper(Context context) {
this.context = context.getApplicationContext();
if (!K9.isCryptoProviderConfigured()) {
if (!K9.isOpenPgpProviderConfigured()) {
throw new IllegalStateException("MessageCryptoHelper must only be called with a openpgp provider!");
}
}
@ -207,7 +207,7 @@ public class MessageCryptoHelper {
}
private void connectToCryptoProviderService() {
String openPgpProviderPackage = K9.getCryptoProvider();
String openPgpProviderPackage = K9.getOpenPgpProvider();
openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProviderPackage,
new OnBound() {
@Override

View file

@ -59,7 +59,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
return false;
}
boolean suppressSignOnlyMessages = !K9.getCryptoSupportSignOnly();
boolean suppressSignOnlyMessages = !K9.getOpenPgpSupportSignOnly();
if (suppressSignOnlyMessages && displayStatus.isUnencryptedSigned()) {
return false;
}
@ -222,8 +222,8 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
@Nullable
private static Drawable getOpenPgpApiProviderIcon(Context context) {
try {
String openPgpProvider = K9.getCryptoProvider();
if (K9.NO_CRYPTO_PROVIDER.equals(openPgpProvider)) {
String openPgpProvider = K9.getOpenPgpProvider();
if (K9.NO_OPENPGP_PROVIDER.equals(openPgpProvider)) {
return null;
}
return context.getPackageManager().getApplicationIcon(openPgpProvider);

View file

@ -115,7 +115,7 @@ public class MessageTopView extends LinearLayout {
containerView, false);
containerView.addView(view);
boolean hideUnsignedTextDivider = !K9.getCryptoSupportSignOnly();
boolean hideUnsignedTextDivider = !K9.getOpenPgpSupportSignOnly();
view.displayMessageViewContainer(messageViewInfo, new OnRenderingFinishedListener() {
@Override
public void onLoadFinished() {

View file

@ -234,7 +234,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
mMessageView, mAccount, messageViewInfo);
if (!handledByCryptoPresenter) {
mMessageView.showMessage(mAccount, messageViewInfo);
if (K9.isCryptoProviderConfigured()) {
if (K9.isOpenPgpProviderConfigured()) {
mMessageView.getMessageHeaderView().setCryptoStatusDisabled();
} else {
mMessageView.getMessageHeaderView().hideCryptoStatus();
@ -244,7 +244,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
private void displayHeaderForLoadingMessage(LocalMessage message) {
mMessageView.setHeaders(message, mAccount);
if (K9.isCryptoProviderConfigured()) {
if (K9.isOpenPgpProviderConfigured()) {
mMessageView.getMessageHeaderView().setCryptoStatusLoading();
}
displayMessageSubject(getSubjectForMessage(message));

View file

@ -415,12 +415,12 @@
<org.openintents.openpgp.util.OpenPgpAppPreference
android:persistent="false"
android:key="crypto_app"
android:key="openpgp_provider"
android:title="@string/account_settings_crypto_app" />
<CheckBoxPreference
android:persistent="false"
android:key="crypto_support_sign_only"
android:key="openpgp_support_sign_only"
android:title="@string/account_settings_crypto_support_sign_only"
/>

View file

@ -254,7 +254,7 @@ public class RecipientPresenterTest {
IOpenPgpService2 openPgpService2 = mock(IOpenPgpService2.class);
Intent permissionPingIntent = new Intent();
K9.setCryptoProvider(CRYPTO_PROVIDER);
K9.setOpenPgpProvider(CRYPTO_PROVIDER);
permissionPingIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
when(account.getCryptoKey()).thenReturn(CRYPTO_KEY_ID);
when(openPgpServiceConnection.isBound()).thenReturn(true);