diff options
author | Thialfihar <thialfihar@gmail.com> | 2010-08-17 21:49:34 +0000 |
---|---|---|
committer | Thialfihar <thialfihar@gmail.com> | 2010-08-17 21:49:34 +0000 |
commit | 446f4b493d35c48ebfc54a81e137a08babc0e236 (patch) | |
tree | a8c51303ff257480555f3dfad468638807e26d3b /src/org/thialfihar/android/apg/PreferencesActivity.java | |
parent | e4dd80005c4839f74c76270b1f7c2668e8007305 (diff) | |
download | open-keychain-446f4b493d35c48ebfc54a81e137a08babc0e236.tar.gz open-keychain-446f4b493d35c48ebfc54a81e137a08babc0e236.tar.bz2 open-keychain-446f4b493d35c48ebfc54a81e137a08babc0e236.zip |
added a key server preference, allowing multiple key servers to be added
Update issue 9
Key server preference added.
Diffstat (limited to 'src/org/thialfihar/android/apg/PreferencesActivity.java')
-rw-r--r-- | src/org/thialfihar/android/apg/PreferencesActivity.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/org/thialfihar/android/apg/PreferencesActivity.java b/src/org/thialfihar/android/apg/PreferencesActivity.java index c226a8b2a..f50b9f05c 100644 --- a/src/org/thialfihar/android/apg/PreferencesActivity.java +++ b/src/org/thialfihar/android/apg/PreferencesActivity.java @@ -23,11 +23,13 @@ import java.util.Vector; import org.bouncycastle2.bcpg.HashAlgorithmTags; import org.bouncycastle2.openpgp.PGPEncryptedData; +import android.content.Intent; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; +import android.preference.PreferenceScreen; public class PreferencesActivity extends PreferenceActivity { private ListPreference mLanguage = null; @@ -38,6 +40,7 @@ public class PreferencesActivity extends PreferenceActivity { private IntegerListPreference mFileCompression = null; private CheckBoxPreference mAsciiArmour = null; private CheckBoxPreference mForceV3Signatures = null; + private PreferenceScreen mKeyServerPreference = null; private Preferences mPreferences; @Override @@ -223,6 +226,39 @@ public class PreferencesActivity extends PreferenceActivity { return false; } }); + + mKeyServerPreference = (PreferenceScreen) findPreference(Constants.pref.key_servers); + String servers[] = mPreferences.getKeyServers(); + mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers, servers.length)); + mKeyServerPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + public boolean onPreferenceClick(Preference preference) { + Intent intent = new Intent(PreferencesActivity.this, + KeyServerPreferenceActivity.class); + intent.putExtra(Apg.EXTRA_KEY_SERVERS, mPreferences.getKeyServers()); + startActivityForResult(intent, Id.request.key_server_preference); + return false; + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case Id.request.key_server_preference: { + if (resultCode == RESULT_CANCELED || data == null) { + return; + } + String servers[] = data.getStringArrayExtra(Apg.EXTRA_KEY_SERVERS); + mPreferences.setKeyServers(servers); + mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers, servers.length)); + break; + } + + default: { + super.onActivityResult(requestCode, resultCode, data); + break; + } + } } } |