From c57c36b3a53f92ece7df2c6c1f1e0316a2c92bb9 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Tue, 17 Aug 2010 23:05:41 +0000 Subject: [PATCH] use the key server preference to fill a Spinner in the key server query activity, allowing to query each server, also moved some previously static labels into strings.xml Update issue 9 Key server preferences are now used in key server query activity. --- res/layout/create_key.xml | 4 +-- res/layout/edit_key_key_item.xml | 10 +++---- res/layout/edit_key_user_id_item.xml | 8 +++--- res/layout/key_server_query_layout.xml | 5 ++++ res/values/strings.xml | 10 +++++++ .../android/apg/KeyServerQueryActivity.java | 27 ++++++++++++++++++- .../apg/ui/widget/KeyServerEditor.java | 18 ------------- 7 files changed, 52 insertions(+), 30 deletions(-) diff --git a/res/layout/create_key.xml b/res/layout/create_key.xml index ab327ffeb..d8ccc73ec 100644 --- a/res/layout/create_key.xml +++ b/res/layout/create_key.xml @@ -29,7 +29,7 @@ @@ -49,7 +49,7 @@ + + Language Force V3 Signatures Key Servers + Key ID + Creation + Expiry + Usage + Key Size + Main User ID + Name + Comment + Email Select 1 Selected @@ -263,6 +272,7 @@ verifying integrity... deleting \'%s\' securely... querying... + querying %s... Read key details from APG. diff --git a/src/org/thialfihar/android/apg/KeyServerQueryActivity.java b/src/org/thialfihar/android/apg/KeyServerQueryActivity.java index 1d3a476e1..b1cab67ed 100644 --- a/src/org/thialfihar/android/apg/KeyServerQueryActivity.java +++ b/src/org/thialfihar/android/apg/KeyServerQueryActivity.java @@ -9,6 +9,8 @@ import org.thialfihar.android.apg.KeyServer.QueryException; import org.thialfihar.android.apg.KeyServer.TooManyResponses; import android.app.Activity; +import android.app.Dialog; +import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -19,12 +21,14 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.ListView; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -33,6 +37,7 @@ public class KeyServerQueryActivity extends BaseActivity { private EditText mQuery; private Button mSearch; private KeyInfoListAdapter mAdapter; + private Spinner mKeyServer; private int mQueryType; private String mQueryString; @@ -52,6 +57,19 @@ public class KeyServerQueryActivity extends BaseActivity { mAdapter = new KeyInfoListAdapter(this); mList.setAdapter(mAdapter); + mKeyServer = (Spinner) findViewById(R.id.keyServer); + ArrayAdapter adapter = + new ArrayAdapter(this, + android.R.layout.simple_spinner_item, + mPreferences.getKeyServers()); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mKeyServer.setAdapter(adapter); + if (adapter.getCount() > 0) { + mKeyServer.setSelection(0); + } else { + mSearch.setEnabled(false); + } + mList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView adapter, View view, int position, long keyId) { @@ -83,6 +101,13 @@ public class KeyServerQueryActivity extends BaseActivity { startThread(); } + protected Dialog onCreateDialog(int id) { + ProgressDialog progress = (ProgressDialog) super.onCreateDialog(id); + progress.setMessage(this.getString(R.string.progress_queryingServer, + (String)mKeyServer.getSelectedItem())); + return progress; + } + @Override public void run() { String error = null; @@ -90,7 +115,7 @@ public class KeyServerQueryActivity extends BaseActivity { Message msg = new Message(); try { - HkpKeyServer server = new HkpKeyServer("pool.sks-keyservers.net"); + HkpKeyServer server = new HkpKeyServer((String)mKeyServer.getSelectedItem()); if (mQueryType == Id.query.search) { mSearchResult = server.search(mQueryString); } else if (mQueryType == Id.query.get) { diff --git a/src/org/thialfihar/android/apg/ui/widget/KeyServerEditor.java b/src/org/thialfihar/android/apg/ui/widget/KeyServerEditor.java index b58fc6036..4e1fed398 100644 --- a/src/org/thialfihar/android/apg/ui/widget/KeyServerEditor.java +++ b/src/org/thialfihar/android/apg/ui/widget/KeyServerEditor.java @@ -16,33 +16,15 @@ package org.thialfihar.android.apg.ui.widget; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Vector; - -import org.bouncycastle2.openpgp.PGPPublicKey; -import org.bouncycastle2.openpgp.PGPSecretKey; -import org.thialfihar.android.apg.Apg; -import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.R; -import org.thialfihar.android.apg.utils.Choice; -import android.app.DatePickerDialog; -import android.app.Dialog; import android.content.Context; -import android.content.DialogInterface; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.DatePicker; import android.widget.ImageButton; import android.widget.LinearLayout; -import android.widget.Spinner; import android.widget.TextView; public class KeyServerEditor extends LinearLayout implements Editor, OnClickListener {