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.
This commit is contained in:
Thialfihar 2010-08-17 23:05:41 +00:00
parent fc0ae774cd
commit c57c36b3a5
7 changed files with 52 additions and 30 deletions

View File

@ -29,7 +29,7 @@
<TableRow>
<TextView android:id="@+id/label_algorithm"
android:text="Algorithm"
android:text="@string/label_algorithm"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
@ -45,7 +45,7 @@
<TableRow>
<TextView android:id="@+id/label_size"
android:text="Key Size"
android:text="@string/label_keySize"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"

View File

@ -43,7 +43,7 @@
<TextView
android:id="@+id/label_keyId"
android:text="Key ID"
android:text="@string/label_keyId"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
@ -63,7 +63,7 @@
<TextView
android:id="@+id/label_algorithm"
android:text="Algorithm"
android:text="@string/label_algorithm"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
@ -82,7 +82,7 @@
<TextView
android:id="@+id/label_creation"
android:text="Creation"
android:text="@string/label_creation"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
@ -99,7 +99,7 @@
<TextView
android:id="@+id/label_expiry"
android:text="Expiry"
android:text="@string/label_expiry"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
@ -116,7 +116,7 @@
<TextView
android:id="@+id/label_usage"
android:text="Usage"
android:text="@string/label_usage"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"

View File

@ -29,7 +29,7 @@
<RadioButton
android:id="@+id/isMainUserId"
android:text="Main User ID"
android:text="@string/label_mainUserId"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"/>
@ -49,7 +49,7 @@
<TextView
android:id="@+id/label_name"
android:text="Name"
android:text="@string/label_name"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@ -68,7 +68,7 @@
<TextView
android:id="@+id/label_email"
android:text="Email"
android:text="@string/label_email"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@ -87,7 +87,7 @@
<TextView
android:id="@+id/label_comment"
android:text="Comment"
android:text="@string/label_comment"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"

View File

@ -20,6 +20,11 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<Spinner
android:id="@+id/keyServer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"

View File

@ -113,6 +113,15 @@
<string name="label_language">Language</string>
<string name="label_forceV3Signature">Force V3 Signatures</string>
<string name="label_keyServers">Key Servers</string>
<string name="label_keyId">Key ID</string>
<string name="label_creation">Creation</string>
<string name="label_expiry">Expiry</string>
<string name="label_usage">Usage</string>
<string name="label_keySize">Key Size</string>
<string name="label_mainUserId">Main User ID</string>
<string name="label_name">Name</string>
<string name="label_comment">Comment</string>
<string name="label_email">Email</string>
<string name="noKeysSelected">Select</string>
<string name="oneKeySelected">1 Selected</string>
@ -263,6 +272,7 @@
<string name="progress_verifyingIntegrity">verifying integrity...</string>
<string name="progress_deletingSecurely">deleting \'%s\' securely...</string>
<string name="progress_querying">querying...</string>
<string name="progress_queryingServer">querying %s...</string>
<!-- permission strings -->
<string name="permission_read_key_details_label">Read key details from APG.</string>

View File

@ -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<String> adapter =
new ArrayAdapter<String>(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) {

View File

@ -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 {