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.ActionBarActivity;
import android.text.format.DateFormat;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
@ -76,11 +75,12 @@ public class ViewCertActivity extends ActionBarActivity
private Uri mDataUri;
private long mSignerKeyId;
private long mCertifierKeyId;
private TextView mSigneeKey, mSigneeUid, mAlgorithm, mType, mRReason, mCreation;
private TextView mSignerKey, mSignerUid, mStatus;
private TextView mSigneeKey, mSigneeUid, mAlgorithm, mType, mReason, mCreation;
private TextView mCertifierKey, mCertifierUid, mStatus;
private View mRowReason;
private View mViewCertifierButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -96,14 +96,16 @@ public class ViewCertActivity extends ActionBarActivity
mSigneeUid = (TextView) findViewById(R.id.signee_uid);
mAlgorithm = (TextView) findViewById(R.id.algorithm);
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);
mSignerKey = (TextView) findViewById(R.id.signer_key_id);
mSignerUid = (TextView) findViewById(R.id.signer_uid);
mCertifierKey = (TextView) findViewById(R.id.signer_key_id);
mCertifierUid = (TextView) findViewById(R.id.signer_uid);
mRowReason = findViewById(R.id.row_reason);
mViewCertifierButton = findViewById(R.id.view_cert_view_cert_key);
mDataUri = getIntent().getData();
if (mDataUri == null) {
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);
mCreation.setText(DateFormat.getDateFormat(getApplicationContext()).format(creationDate));
mSignerKeyId = data.getLong(INDEX_KEY_ID_CERTIFIER);
String signerKey = PgpKeyHelper.convertKeyIdToHex(mSignerKeyId);
mSignerKey.setText(signerKey);
mCertifierKeyId = data.getLong(INDEX_KEY_ID_CERTIFIER);
String certifierKey = PgpKeyHelper.convertKeyIdToHex(mCertifierKeyId);
mCertifierKey.setText(certifierKey);
String signerUid = data.getString(INDEX_SIGNER_UID);
if (signerUid != null) {
mSignerUid.setText(signerUid);
String certifierUid = data.getString(INDEX_SIGNER_UID);
if (certifierUid != null) {
mCertifierUid.setText(certifierUid);
} else {
mSignerUid.setText(R.string.unknown_uid);
mCertifierUid.setText(R.string.unknown_uid);
}
PGPSignature sig = PgpConversionHelper.BytesToPGPSignature(data.getBlob(INDEX_DATA));
@ -149,10 +151,12 @@ public class ViewCertActivity extends ActionBarActivity
ProviderHelper providerHelper = new ProviderHelper(this);
PGPKeyRing signeeRing = providerHelper.getPGPKeyRing(
KeychainContract.KeyRingData.buildPublicKeyRingUri(
Long.toString(data.getLong(INDEX_MASTER_KEY_ID))));
Long.toString(data.getLong(INDEX_MASTER_KEY_ID)))
);
PGPKeyRing signerRing = providerHelper.getPGPKeyRing(
KeychainContract.KeyRingData.buildPublicKeyRingUri(
Long.toString(sig.getKeyID())));
Long.toString(sig.getKeyID()))
);
try {
sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider(
@ -203,27 +207,41 @@ public class ViewCertActivity extends ActionBarActivity
p = new RevocationReason(false, p.getData());
}
String reason = ((RevocationReason) p).getRevocationDescription();
mRReason.setText(reason);
mReason.setText(reason);
mRowReason.setVisibility(View.VISIBLE);
}
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
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
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@ -233,25 +251,6 @@ public class ViewCertActivity extends ActionBarActivity
NavUtils.navigateUpTo(this, viewIntent);
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);
}

View File

@ -44,6 +44,7 @@
<TableLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:stretchColumns="1">
@ -164,6 +165,8 @@
<TableLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_marginBottom="4dp"
android:layout_weight="1"
android:stretchColumns="1">
@ -192,17 +195,39 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingRight="10dip"
android:text="@string/label_email" />
android:text="@string/label_user_id" />
<TextView
android:id="@+id/signer_uid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"/>
android:paddingRight="5dip" />
</TableRow>
</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>
</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_hide">Hide advanced settings</string>
<string name="btn_share_encrypted_signed">Share encrypted/signed message…</string>
<string name="btn_view_cert_key">View certification key</string>
<!-- menu -->
<string name="menu_preferences">Settings</string>