Design fixes for certification activity

This commit is contained in:
Dominik Schürmann 2014-05-07 14:17:18 +02:00
parent 7c2dc276c1
commit f4cbd8cabb
4 changed files with 71 additions and 55 deletions

View File

@ -28,7 +28,6 @@ import android.support.v4.content.Loader;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -76,11 +75,12 @@ public class ViewCertActivity extends ActionBarActivity
private Uri mDataUri; private Uri mDataUri;
private long mSignerKeyId; private long mCertifierKeyId;
private TextView mSigneeKey, mSigneeUid, mAlgorithm, mType, mRReason, mCreation; private TextView mSigneeKey, mSigneeUid, mAlgorithm, mType, mReason, mCreation;
private TextView mSignerKey, mSignerUid, mStatus; private TextView mCertifierKey, mCertifierUid, mStatus;
private View mRowReason; private View mRowReason;
private View mViewCertifierButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -96,14 +96,16 @@ public class ViewCertActivity extends ActionBarActivity
mSigneeUid = (TextView) findViewById(R.id.signee_uid); mSigneeUid = (TextView) findViewById(R.id.signee_uid);
mAlgorithm = (TextView) findViewById(R.id.algorithm); mAlgorithm = (TextView) findViewById(R.id.algorithm);
mType = (TextView) findViewById(R.id.signature_type); mType = (TextView) findViewById(R.id.signature_type);
mRReason = (TextView) findViewById(R.id.reason); mReason = (TextView) findViewById(R.id.reason);
mCreation = (TextView) findViewById(R.id.creation); mCreation = (TextView) findViewById(R.id.creation);
mSignerKey = (TextView) findViewById(R.id.signer_key_id); mCertifierKey = (TextView) findViewById(R.id.signer_key_id);
mSignerUid = (TextView) findViewById(R.id.signer_uid); mCertifierUid = (TextView) findViewById(R.id.signer_uid);
mRowReason = findViewById(R.id.row_reason); mRowReason = findViewById(R.id.row_reason);
mViewCertifierButton = findViewById(R.id.view_cert_view_cert_key);
mDataUri = getIntent().getData(); mDataUri = getIntent().getData();
if (mDataUri == null) { if (mDataUri == null) {
Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!"); Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!");
@ -133,15 +135,15 @@ public class ViewCertActivity extends ActionBarActivity
Date creationDate = new Date(data.getLong(INDEX_CREATION) * 1000); Date creationDate = new Date(data.getLong(INDEX_CREATION) * 1000);
mCreation.setText(DateFormat.getDateFormat(getApplicationContext()).format(creationDate)); mCreation.setText(DateFormat.getDateFormat(getApplicationContext()).format(creationDate));
mSignerKeyId = data.getLong(INDEX_KEY_ID_CERTIFIER); mCertifierKeyId = data.getLong(INDEX_KEY_ID_CERTIFIER);
String signerKey = PgpKeyHelper.convertKeyIdToHex(mSignerKeyId); String certifierKey = PgpKeyHelper.convertKeyIdToHex(mCertifierKeyId);
mSignerKey.setText(signerKey); mCertifierKey.setText(certifierKey);
String signerUid = data.getString(INDEX_SIGNER_UID); String certifierUid = data.getString(INDEX_SIGNER_UID);
if (signerUid != null) { if (certifierUid != null) {
mSignerUid.setText(signerUid); mCertifierUid.setText(certifierUid);
} else { } else {
mSignerUid.setText(R.string.unknown_uid); mCertifierUid.setText(R.string.unknown_uid);
} }
PGPSignature sig = PgpConversionHelper.BytesToPGPSignature(data.getBlob(INDEX_DATA)); PGPSignature sig = PgpConversionHelper.BytesToPGPSignature(data.getBlob(INDEX_DATA));
@ -149,10 +151,12 @@ public class ViewCertActivity extends ActionBarActivity
ProviderHelper providerHelper = new ProviderHelper(this); ProviderHelper providerHelper = new ProviderHelper(this);
PGPKeyRing signeeRing = providerHelper.getPGPKeyRing( PGPKeyRing signeeRing = providerHelper.getPGPKeyRing(
KeychainContract.KeyRingData.buildPublicKeyRingUri( KeychainContract.KeyRingData.buildPublicKeyRingUri(
Long.toString(data.getLong(INDEX_MASTER_KEY_ID)))); Long.toString(data.getLong(INDEX_MASTER_KEY_ID)))
);
PGPKeyRing signerRing = providerHelper.getPGPKeyRing( PGPKeyRing signerRing = providerHelper.getPGPKeyRing(
KeychainContract.KeyRingData.buildPublicKeyRingUri( KeychainContract.KeyRingData.buildPublicKeyRingUri(
Long.toString(sig.getKeyID()))); Long.toString(sig.getKeyID()))
);
try { try {
sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider( sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider(
@ -203,27 +207,41 @@ public class ViewCertActivity extends ActionBarActivity
p = new RevocationReason(false, p.getData()); p = new RevocationReason(false, p.getData());
} }
String reason = ((RevocationReason) p).getRevocationDescription(); String reason = ((RevocationReason) p).getRevocationDescription();
mRReason.setText(reason); mReason.setText(reason);
mRowReason.setVisibility(View.VISIBLE); mRowReason.setVisibility(View.VISIBLE);
} }
break; break;
} }
} }
} }
// can't do this before the data is initialized
mViewCertifierButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent viewIntent = new Intent(ViewCertActivity.this, ViewKeyActivity.class);
try {
ProviderHelper providerHelper = new ProviderHelper(ViewCertActivity.this);
long signerMasterKeyId = providerHelper.getMasterKeyId(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(Long.toString(mCertifierKeyId))
);
viewIntent.setData(KeyRings.buildGenericKeyRingUri(
Long.toString(signerMasterKeyId))
);
startActivity(viewIntent);
} catch (ProviderHelper.NotFoundException e) {
// TODO notify user of this, maybe offer download?
Log.e(Constants.TAG, "key not found!", e);
}
}
});
} }
@Override @Override
public void onLoaderReset(Loader<Cursor> loader) { public void onLoaderReset(Loader<Cursor> loader) {
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.view_cert, menu);
return true;
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -233,25 +251,6 @@ public class ViewCertActivity extends ActionBarActivity
NavUtils.navigateUpTo(this, viewIntent); NavUtils.navigateUpTo(this, viewIntent);
return true; return true;
} }
case R.id.menu_view_cert_view_signer:
// can't do this before the data is initialized
Intent viewIntent = new Intent(this, ViewKeyActivity.class);
try {
ProviderHelper providerHelper = new ProviderHelper(this);
long signerMasterKeyId = providerHelper.getMasterKeyId(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(Long.toString(mSignerKeyId))
);
viewIntent.setData(KeyRings.buildGenericKeyRingUri(
Long.toString(signerMasterKeyId))
);
startActivity(viewIntent);
} catch (ProviderHelper.NotFoundException e) {
// TODO notify user of this, maybe offer download?
Log.e(Constants.TAG, "key not found!", e);
}
return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -44,6 +44,7 @@
<TableLayout <TableLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_weight="1" android:layout_weight="1"
android:stretchColumns="1"> android:stretchColumns="1">
@ -164,6 +165,8 @@
<TableLayout <TableLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_marginBottom="4dp"
android:layout_weight="1" android:layout_weight="1"
android:stretchColumns="1"> android:stretchColumns="1">
@ -192,7 +195,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingRight="10dip" android:paddingRight="10dip"
android:text="@string/label_email" /> android:text="@string/label_user_id" />
<TextView <TextView
android:id="@+id/signer_uid" android:id="@+id/signer_uid"
@ -203,6 +206,28 @@
</TableLayout> </TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/view_cert_view_cert_key"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_marginBottom="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:clickable="true"
style="@style/SelectableItem"
android:text="@string/btn_view_cert_key"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_person"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_view_cert_view_signer"
app:showAsAction="never"
android:title="View signing key" />
</menu>

View File

@ -69,6 +69,7 @@
<string name="btn_encryption_advanced_settings_show">Show advanced settings</string> <string name="btn_encryption_advanced_settings_show">Show advanced settings</string>
<string name="btn_encryption_advanced_settings_hide">Hide advanced settings</string> <string name="btn_encryption_advanced_settings_hide">Hide advanced settings</string>
<string name="btn_share_encrypted_signed">Share encrypted/signed message…</string> <string name="btn_share_encrypted_signed">Share encrypted/signed message…</string>
<string name="btn_view_cert_key">View certification key</string>
<!-- menu --> <!-- menu -->
<string name="menu_preferences">Settings</string> <string name="menu_preferences">Settings</string>