integrated key server look-up into decrypt Activity, allowing to touch an unkown signature to import the key

Update issue 39
added:
<string name="unknownSignatureKeyTouchToLookUp">Unknown signature, touch to look up key.</string>
This commit is contained in:
Thialfihar 2010-08-18 12:26:13 +00:00
parent 08305b4963
commit 996a1dbe1c
7 changed files with 38 additions and 11 deletions

View File

@ -144,7 +144,8 @@
android:id="@+id/signature"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
android:layout_width="fill_parent"
android:clickable="true">
<RelativeLayout
android:layout_height="wrap_content"

View File

@ -208,6 +208,7 @@
<string name="keyCreationElGamalInfo">Note: only subkeys support ElGamal, and for ElGamal the nearest keysize of 1536, 2048, 3072, 4096, or 8192 will be used.</string>
<string name="keyNotFound">Couldn\'t find key %08X.</string>
<string name="keysFound">Found %s key(s).</string>
<string name="unknownSignatureKeyTouchToLookUp">Unknown signature, touch to look up key.</string>
<!-- error_lowerCase: phrases, no punctuation, all lowercase,
they will be put after "errorMessage", e.g. "Error: file not found" -->

View File

@ -116,6 +116,7 @@ public class Apg {
public static final String SELECT_SECRET_KEY = "org.thialfihar.android.apg.intent.SELECT_SECRET_KEY";
public static final String IMPORT = "org.thialfihar.android.apg.intent.IMPORT";
public static final String LOOK_UP_KEY_ID = "org.thialfihar.android.apg.intent.LOOK_UP_KEY_ID";
public static final String LOOK_UP_KEY_ID_AND_RETURN = "org.thialfihar.android.apg.intent.LOOK_UP_KEY_ID_AND_RETURN";
}
public static final String EXTRA_TEXT = "text";

View File

@ -28,6 +28,7 @@ import java.util.regex.Matcher;
import org.bouncycastle2.jce.provider.BouncyCastleProvider;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.thialfihar.android.apg.provider.DataProvider;
import android.app.Dialog;
@ -276,6 +277,21 @@ public class DecryptActivity extends BaseActivity {
}
mSignatureLayout.setVisibility(View.GONE);
mSignatureLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mSignatureKeyId == 0) {
return;
}
PGPPublicKeyRing key = Apg.getPublicKeyRing(mSignatureKeyId);
if (key != null) {
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
intent.setAction(Apg.Intent.LOOK_UP_KEY_ID);
intent.putExtra(Apg.EXTRA_KEY_ID, mSignatureKeyId);
startActivity(intent);
}
}
});
mDecryptButton.setOnClickListener(new OnClickListener() {
@Override
@ -599,6 +615,7 @@ public class DecryptActivity extends BaseActivity {
mSignatureStatusImage.setImageResource(R.drawable.overlay_ok);
} else if (data.getBoolean(Apg.EXTRA_SIGNATURE_UNKNOWN)) {
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
Toast.makeText(this, R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG).show();
} else {
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
}

View File

@ -82,7 +82,7 @@ public class HkpKeyServer extends KeyServer {
} catch (UnknownHostException e) {
throw new QueryException(e.toString());
}
for (int i = 5; i < ips.length; ++i) {
for (int i = 0; i < ips.length; ++i) {
try {
String url = "http://" + ips[i].getHostAddress() + ":" + mPort + request;
URL realUrl = new URL(url);

View File

@ -86,7 +86,8 @@ public class KeyServerQueryActivity extends BaseActivity {
});
Intent intent = getIntent();
if (Apg.Intent.LOOK_UP_KEY_ID.equals(intent.getAction())) {
if (Apg.Intent.LOOK_UP_KEY_ID.equals(intent.getAction()) ||
Apg.Intent.LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) {
long keyId = intent.getLongExtra(Apg.EXTRA_KEY_ID, 0);
if (keyId != 0) {
String query = "0x" + Apg.keyToHex(keyId);
@ -168,15 +169,21 @@ public class KeyServerQueryActivity extends BaseActivity {
mAdapter.setKeys(mSearchResult);
}
} else if (mQueryType == Id.query.get) {
Intent orgIntent = getIntent();
if (Apg.Intent.LOOK_UP_KEY_ID_AND_RETURN.equals(orgIntent.getAction())) {
if (mKeyData != null) {
Intent intent = new Intent();
intent.putExtra(Apg.EXTRA_TEXT, mKeyData);
setResult(RESULT_OK, intent);
} else {
setResult(RESULT_CANCELED);
}
finish();
} else {
if (mKeyData != null) {
Intent intent = new Intent(this, PublicKeyListActivity.class);
intent.setAction(Apg.Intent.IMPORT);
intent.putExtra(Apg.EXTRA_TEXT, mKeyData);
Intent orgIntent = getIntent();
if (Apg.Intent.LOOK_UP_KEY_ID.equals(orgIntent.getAction())) {
setResult(RESULT_OK, intent);
finish();
} else {
startActivity(intent);
}
}

View File

@ -91,7 +91,7 @@ public class PublicKeyListActivity extends KeyListActivity {
}
Intent intent = new Intent(this, KeyServerQueryActivity.class);
intent.setAction(Apg.Intent.LOOK_UP_KEY_ID);
intent.setAction(Apg.Intent.LOOK_UP_KEY_ID_AND_RETURN);
intent.putExtra(Apg.EXTRA_KEY_ID, keyId);
startActivityForResult(intent, Id.request.look_up_key_id);
return true;