From 2f640980dd17b8641afe815c46800a3b9411dd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 8 Nov 2015 19:29:51 +0100 Subject: Cleanup settings activity --- .../keychain/ui/SettingsActivity.java | 67 ---------------------- OpenKeychain/src/main/res/xml/gui_preferences.xml | 10 ---- 2 files changed, 77 deletions(-) delete mode 100644 OpenKeychain/src/main/res/xml/gui_preferences.xml (limited to 'OpenKeychain/src/main') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java index 8118c2fa7..f5c239558 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java @@ -54,14 +54,8 @@ import java.util.List; public class SettingsActivity extends AppCompatPreferenceActivity { - public static final String ACTION_PREFS_CLOUD = "org.sufficientlysecure.keychain.ui.PREFS_CLOUD"; - public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV"; - public static final String ACTION_PREFS_PROXY = "org.sufficientlysecure.keychain.ui.PREFS_PROXY"; - public static final String ACTION_PREFS_GUI = "org.sufficientlysecure.keychain.ui.PREFS_GUI"; - public static final int REQUEST_CODE_KEYSERVER_PREF = 0x00007005; - private PreferenceScreen mKeyServerPreference = null; private static Preferences sPreferences; private ThemeChanger mThemeChanger; @@ -74,49 +68,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity { super.onCreate(savedInstanceState); setupToolbar(); - - String action = getIntent().getAction(); - - if (ACTION_PREFS_CLOUD.equals(action)) { - addPreferencesFromResource(R.xml.cloud_search_prefs); - - mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); - mKeyServerPreference.setSummary(keyserverSummary(this)); - mKeyServerPreference - .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - public boolean onPreferenceClick(Preference preference) { - Intent intent = new Intent(SettingsActivity.this, - SettingsKeyServerActivity.class); - intent.putExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS, - sPreferences.getKeyServers()); - startActivityForResult(intent, REQUEST_CODE_KEYSERVER_PREF); - return false; - } - }); - initializeSearchKeyserver( - (SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER) - ); - initializeSearchKeybase( - (SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYBASE) - ); - - } else if (ACTION_PREFS_ADV.equals(action)) { - addPreferencesFromResource(R.xml.passphrase_preferences); - - initializePassphraseCacheSubs( - (CheckBoxPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_SUBS)); - - initializePassphraseCacheTtl( - (IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL)); - - initializeUseNumKeypadForYubiKeyPin( - (CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN)); - - } else if (ACTION_PREFS_GUI.equals(action)) { - addPreferencesFromResource(R.xml.gui_preferences); - - initializeTheme((ListPreference) findPreference(Constants.Pref.THEME)); - } } @Override @@ -447,23 +398,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity { } } - /** - * This fragment shows gui preferences. - */ - public static class GuiPrefsFragment extends PreferenceFragment { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - - // Load the preferences from an XML resource - addPreferencesFromResource(R.xml.gui_preferences); - - initializeTheme((ListPreference) findPreference(Constants.Pref.THEME)); - } - } - /** * This fragment shows the keyserver/contacts sync preferences */ @@ -576,7 +510,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity { return PassphrasePrefsFragment.class.getName().equals(fragmentName) || CloudSearchPrefsFragment.class.getName().equals(fragmentName) || ProxyPrefsFragment.class.getName().equals(fragmentName) - || GuiPrefsFragment.class.getName().equals(fragmentName) || SyncPrefsFragment.class.getName().equals(fragmentName) || ExperimentalPrefsFragment.class.getName().equals(fragmentName) || super.isValidFragment(fragmentName); diff --git a/OpenKeychain/src/main/res/xml/gui_preferences.xml b/OpenKeychain/src/main/res/xml/gui_preferences.xml deleted file mode 100644 index cda7beeef..000000000 --- a/OpenKeychain/src/main/res/xml/gui_preferences.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - -- cgit v1.2.3 From 89d016c49be3d9258822f2803744697a0d48c80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 8 Nov 2015 20:02:50 +0100 Subject: Get whole public key via ACTION_GET_KEY --- .../keychain/remote/OpenPgpService.java | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'OpenKeychain/src/main') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index e7709e58e..7dfb3f3f6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -25,7 +25,6 @@ import android.net.Uri; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.Parcelable; -import android.support.annotation.Nullable; import android.text.TextUtils; import org.openintents.openpgp.IOpenPgpService; @@ -34,13 +33,15 @@ import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpMetadata; import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; +import org.spongycastle.bcpg.ArmoredOutputStream; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEntryParcel; import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult; -import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation; +import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation; +import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants; import org.sufficientlysecure.keychain.pgp.PgpSignEncryptInputParcel; import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; @@ -684,16 +685,47 @@ public class OpenPgpService extends RemoteService { } - private Intent getKeyImpl(Intent data) { + private Intent getKeyImpl(Intent data, ParcelFileDescriptor output) { try { long masterKeyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0); + // output is optional, for getting the key + OutputStream outputStream = + (output != null) ? new ParcelFileDescriptor.AutoCloseOutputStream(output) : null; + try { // try to find key, throws NotFoundException if not in db! - mProviderHelper.getCanonicalizedPublicKeyRing(masterKeyId); + CanonicalizedPublicKeyRing keyRing = + mProviderHelper.getCanonicalizedPublicKeyRing(masterKeyId); Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + + // return public key if requested by defining a output stream + if (outputStream != null) { + boolean requestAsciiArmor = + data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false); + + ArmoredOutputStream arOutStream = null; + try { + if (requestAsciiArmor) { + arOutStream = new ArmoredOutputStream(outputStream); + keyRing.encode(arOutStream); + } else { + keyRing.encode(outputStream); + } + } finally { + try { + if (arOutStream != null) { + arOutStream.close(); + } + outputStream.close(); + } catch (IOException e) { + Log.e(Constants.TAG, "IOException when closing OutputStream", e); + } + } + } + // also return PendingIntent that opens the key view activity result.putExtra(OpenPgpApi.RESULT_INTENT, getShowKeyPendingIntent(masterKeyId)); @@ -890,7 +922,7 @@ public class OpenPgpService extends RemoteService { return getKeyIdsImpl(data); } case OpenPgpApi.ACTION_GET_KEY: { - return getKeyImpl(data); + return getKeyImpl(data, output); } default: { return null; -- cgit v1.2.3