added a key server preference, allowing multiple key servers to be added

Update issue 9
Key server preference added.
This commit is contained in:
Thialfihar
2010-08-17 21:49:34 +00:00
parent e4dd80005c
commit 446f4b493d
12 changed files with 479 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
package org.thialfihar.android.apg;
import java.util.Vector;
import org.bouncycastle2.bcpg.HashAlgorithmTags;
import org.bouncycastle2.openpgp.PGPEncryptedData;
@@ -133,4 +135,35 @@ public class Preferences {
editor.putBoolean(Constants.pref.has_seen_help, value);
editor.commit();
}
public String[] getKeyServers() {
String rawData = mSharedPreferences.getString(Constants.pref.key_servers,
Constants.defaults.key_servers);
Vector<String> servers = new Vector<String>();
String chunks[] = rawData.split(",");
for (int i = 0; i < chunks.length; ++i) {
String tmp = chunks[i].trim();
if (tmp.length() > 0) {
servers.add(tmp);
}
}
return servers.toArray(chunks);
}
public void setKeyServers(String[] value) {
SharedPreferences.Editor editor = mSharedPreferences.edit();
String rawData = "";
for (int i = 0; i < value.length; ++i) {
String tmp = value[i].trim();
if (tmp.length() == 0) {
continue;
}
if (!"".equals(rawData)) {
rawData += ",";
}
rawData += tmp;
}
editor.putString(Constants.pref.key_servers, rawData);
editor.commit();
}
}