Toolbar: qr code in header, cleanup of fragment

This commit is contained in:
Dominik Schürmann 2015-02-25 13:49:21 +01:00
parent 430ba2f777
commit fa92ceeae3
21 changed files with 301 additions and 855 deletions

View File

@ -7,6 +7,9 @@ python copy OpenKeychain navigation white check 24
python copy OpenKeychain navigation black expand_less 24 python copy OpenKeychain navigation black expand_less 24
python copy OpenKeychain navigation black expand_more 24 python copy OpenKeychain navigation black expand_more 24
python copy OpenKeychain navigation white refresh 24 python copy OpenKeychain navigation white refresh 24
python copy OpenKeychain action white swap_vert 24
python copy OpenKeychain action white swap_vert_circle 24
python copy OpenKeychain editor white mode_edit 24
# navigation drawer sections # navigation drawer sections
python copy OpenKeychain communication black vpn_key 24 python copy OpenKeychain communication black vpn_key 24

View File

@ -6,6 +6,7 @@ dependencies {
compile 'com.android.support:support-v4:21.0.3' compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3' compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.3'
compile project(':extern:openpgp-api-lib') compile project(':extern:openpgp-api-lib')
compile project(':extern:openkeychain-api-lib') compile project(':extern:openkeychain-api-lib')
compile project(':extern:html-textview') compile project(':extern:html-textview')

View File

@ -36,13 +36,10 @@ import android.provider.ContactsContract;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader; import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.animation.AlphaAnimation;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
@ -55,11 +52,13 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.QrCodeUtils;
import org.sufficientlysecure.keychain.ui.widget.AspectRatioImageView; import org.sufficientlysecure.keychain.ui.widget.AspectRatioImageView;
import org.sufficientlysecure.keychain.util.ContactHelper; import org.sufficientlysecure.keychain.util.ContactHelper;
import org.sufficientlysecure.keychain.util.ExportHelper; import org.sufficientlysecure.keychain.util.ExportHelper;
@ -84,8 +83,10 @@ public class ViewKeyActivity extends BaseActivity implements
private ImageButton mActionEncryptFile; private ImageButton mActionEncryptFile;
private ImageButton mActionEncryptText; private ImageButton mActionEncryptText;
private ImageButton mActionVerify; private ImageButton mActionVerify;
private ImageButton mActionEdit;
private FloatingActionButton mFab; private FloatingActionButton mFab;
private AspectRatioImageView mPhoto; private AspectRatioImageView mPhoto;
private ImageButton mQrCode;
// NFC // NFC
private NfcAdapter mNfcAdapter; private NfcAdapter mNfcAdapter;
@ -96,6 +97,9 @@ public class ViewKeyActivity extends BaseActivity implements
private static final int LOADER_ID_UNIFIED = 0; private static final int LOADER_ID_UNIFIED = 0;
private boolean mIsSecret;
private boolean mHasEncrypt;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -113,8 +117,10 @@ public class ViewKeyActivity extends BaseActivity implements
mActionEncryptFile = (ImageButton) findViewById(R.id.view_key_action_encrypt_files); mActionEncryptFile = (ImageButton) findViewById(R.id.view_key_action_encrypt_files);
mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text);
mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify);
mActionEdit = (ImageButton) findViewById(R.id.view_key_action_edit);
mFab = (FloatingActionButton) findViewById(R.id.fab); mFab = (FloatingActionButton) findViewById(R.id.fab);
mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo);
mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code);
mDataUri = getIntent().getData(); mDataUri = getIntent().getData();
if (mDataUri == null) { if (mDataUri == null) {
@ -134,6 +140,48 @@ public class ViewKeyActivity extends BaseActivity implements
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
mActionEncryptFile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
encrypt(mDataUri, false);
}
});
mActionEncryptText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
encrypt(mDataUri, true);
}
});
mActionVerify.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
certify(mDataUri);
}
});
mActionEdit.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
editKey(mDataUri);
}
});
mFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mIsSecret) {
startSafeSlinger(mDataUri);
} else {
certify(mDataUri);
}
}
});
mQrCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showQrCodeDialog();
}
});
// Prepare the loaders. Either re-connect with an existing ones, // Prepare the loaders. Either re-connect with an existing ones,
// or start new ones. // or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
@ -199,6 +247,13 @@ public class ViewKeyActivity extends BaseActivity implements
advancedIntent.setData(mDataUri); advancedIntent.setData(mDataUri);
startActivity(advancedIntent); startActivity(advancedIntent);
} }
case R.id.menu_key_view_refresh: {
try {
updateFromKeyserver(mDataUri, mProviderHelper);
} catch (ProviderHelper.NotFoundException e) {
Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR);
}
}
} }
} catch (ProviderHelper.NotFoundException e) { } catch (ProviderHelper.NotFoundException e) {
Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR); Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR);
@ -207,6 +262,12 @@ public class ViewKeyActivity extends BaseActivity implements
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void showQrCodeDialog() {
Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class);
qrCodeIntent.setData(mDataUri);
startActivity(qrCodeIntent);
}
private void exportToFile(Uri dataUri, ExportHelper exportHelper, ProviderHelper providerHelper) private void exportToFile(Uri dataUri, ExportHelper exportHelper, ProviderHelper providerHelper)
throws ProviderHelper.NotFoundException { throws ProviderHelper.NotFoundException {
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri); Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri);
@ -248,6 +309,119 @@ public class ViewKeyActivity extends BaseActivity implements
} }
} }
private void encrypt(Uri dataUri, boolean text) {
// If there is no encryption key, don't bother.
if (!mHasEncrypt) {
Notify.showNotify(this, R.string.error_no_encrypt_subkey, Notify.Style.ERROR);
return;
}
try {
long keyId = new ProviderHelper(this)
.getCachedPublicKeyRing(dataUri)
.extractOrGetMasterKeyId();
long[] encryptionKeyIds = new long[]{keyId};
Intent intent;
if (text) {
intent = new Intent(this, EncryptTextActivity.class);
intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT);
intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
} else {
intent = new Intent(this, EncryptFilesActivity.class);
intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA);
intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
}
// used instead of startActivity set actionbar based on callingPackage
startActivityForResult(intent, 0);
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
}
private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper)
throws ProviderHelper.NotFoundException {
byte[] blob = (byte[]) providerHelper.getGenericData(
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
Intent queryIntent = new Intent(this, ImportKeysActivity.class);
queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT);
queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint);
startActivityForResult(queryIntent, 0);
}
private void certify(Uri dataUri) {
long keyId = 0;
try {
keyId = new ProviderHelper(this)
.getCachedPublicKeyRing(dataUri)
.extractOrGetMasterKeyId();
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
Intent certifyIntent = new Intent(this, CertifyKeyActivity.class);
certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId});
startActivityForResult(certifyIntent, 0);
}
private void editKey(Uri dataUri) {
Intent editIntent = new Intent(this, EditKeyActivity.class);
editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri));
startActivityForResult(editIntent, 0);
}
private void startSafeSlinger(Uri dataUri) {
long keyId = 0;
try {
keyId = new ProviderHelper(this)
.getCachedPublicKeyRing(dataUri)
.extractOrGetMasterKeyId();
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
Intent safeSlingerIntent = new Intent(this, SafeSlingerActivity.class);
safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId);
startActivityForResult(safeSlingerIntent, 0);
}
/**
* Load QR Code asynchronously and with a fade in animation
*
* @param fingerprint
*/
private void loadQrCode(final String fingerprint) {
AsyncTask<Void, Void, Bitmap> loadTask =
new AsyncTask<Void, Void, Bitmap>() {
protected Bitmap doInBackground(Void... unused) {
String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
// render with minimal size
return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0);
}
protected void onPostExecute(Bitmap qrCode) {
// only change view, if fragment is attached to activity
// if (ViewKeyFragment.this.isAdded()) {
// scale the image up to our actual size. we do this in code rather
// than let the ImageView do this because we don't require filtering.
Bitmap scaled = Bitmap.createScaledBitmap(qrCode,
mQrCode.getHeight(), mQrCode.getHeight(),
false);
mQrCode.setImageBitmap(scaled);
// simple fade-in animation
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(200);
mQrCode.startAnimation(anim);
}
// }
};
loadTask.execute();
}
/** /**
* NFC: Initialize NFC sharing if OS and device supports it * NFC: Initialize NFC sharing if OS and device supports it
*/ */
@ -347,7 +521,8 @@ public class ViewKeyActivity extends BaseActivity implements
KeychainContract.KeyRings.EXPIRY, KeychainContract.KeyRings.EXPIRY,
KeychainContract.KeyRings.VERIFIED, KeychainContract.KeyRings.VERIFIED,
KeychainContract.KeyRings.HAS_ANY_SECRET, KeychainContract.KeyRings.HAS_ANY_SECRET,
KeychainContract.KeyRings.FINGERPRINT KeychainContract.KeyRings.FINGERPRINT,
KeychainContract.KeyRings.HAS_ENCRYPT
}; };
static final int INDEX_MASTER_KEY_ID = 1; static final int INDEX_MASTER_KEY_ID = 1;
@ -357,6 +532,7 @@ public class ViewKeyActivity extends BaseActivity implements
static final int INDEX_VERIFIED = 5; static final int INDEX_VERIFIED = 5;
static final int INDEX_HAS_ANY_SECRET = 6; static final int INDEX_HAS_ANY_SECRET = 6;
static final int INDEX_FINGERPRINT = 7; static final int INDEX_FINGERPRINT = 7;
static final int INDEX_HAS_ENCRYPT = 8;
@Override @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) { public Loader<Cursor> onCreateLoader(int id, Bundle args) {
@ -395,12 +571,26 @@ public class ViewKeyActivity extends BaseActivity implements
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT)); String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT));
boolean isSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0;
boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0;
boolean isExpired = !data.isNull(INDEX_EXPIRY) boolean isExpired = !data.isNull(INDEX_EXPIRY)
&& new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date());
boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; boolean isVerified = data.getInt(INDEX_VERIFIED) > 0;
AsyncTask<String, Void, Bitmap> photoTask =
new AsyncTask<String, Void, Bitmap>() {
protected Bitmap doInBackground(String... fingerprint) {
return ContactHelper.photoFromFingerprint(getContentResolver(), fingerprint[0]);
}
protected void onPostExecute(Bitmap photo) {
mPhoto.setImageBitmap(photo);
mPhoto.setVisibility(View.VISIBLE);
}
};
// Note: order is important // Note: order is important
int color; int color;
if (isRevoked) { if (isRevoked) {
@ -409,55 +599,53 @@ public class ViewKeyActivity extends BaseActivity implements
KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED, R.color.icons, true); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED, R.color.icons, true);
color = getResources().getColor(R.color.android_red_light); color = getResources().getColor(R.color.android_red_light);
mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptFile.setVisibility(View.GONE);
mActionEncryptText.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.GONE);
mActionVerify.setVisibility(View.INVISIBLE); mActionVerify.setVisibility(View.GONE);
mFab.setVisibility(View.INVISIBLE); mActionEdit.setVisibility(View.GONE);
mFab.setVisibility(View.GONE);
mQrCode.setVisibility(View.GONE);
} else if (isExpired) { } else if (isExpired) {
mStatusText.setText(R.string.view_key_expired); mStatusText.setText(R.string.view_key_expired);
mStatusImage.setVisibility(View.VISIBLE); mStatusImage.setVisibility(View.VISIBLE);
KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons, true); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons, true);
color = getResources().getColor(R.color.android_red_light); color = getResources().getColor(R.color.android_red_light);
mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptFile.setVisibility(View.GONE);
mActionEncryptText.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.GONE);
mActionVerify.setVisibility(View.INVISIBLE); mActionVerify.setVisibility(View.GONE);
mFab.setVisibility(View.INVISIBLE); mActionEdit.setVisibility(View.GONE);
} else if (isSecret) { mFab.setVisibility(View.GONE);
mQrCode.setVisibility(View.GONE);
} else if (mIsSecret) {
mStatusText.setText(R.string.view_key_my_key); mStatusText.setText(R.string.view_key_my_key);
mStatusImage.setVisibility(View.INVISIBLE); mStatusImage.setVisibility(View.GONE);
color = getResources().getColor(R.color.primary); color = getResources().getColor(R.color.primary);
photoTask.execute(fingerprint);
loadQrCode(fingerprint);
mQrCode.setVisibility(View.VISIBLE);
mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptFile.setVisibility(View.VISIBLE);
mActionEncryptText.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE);
mActionVerify.setVisibility(View.INVISIBLE); mActionVerify.setVisibility(View.GONE);
mFab.setVisibility(View.INVISIBLE); // TODO mActionEdit.setVisibility(View.VISIBLE);
mFab.setVisibility(View.VISIBLE);
mFab.setIconDrawable(getResources().getDrawable(R.drawable.ic_swap_vert_white_24dp));
} else { } else {
mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptFile.setVisibility(View.VISIBLE);
mActionEncryptText.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE);
mActionEdit.setVisibility(View.GONE);
mQrCode.setVisibility(View.GONE);
if (isVerified) { if (isVerified) {
mStatusText.setText(R.string.view_key_verified); mStatusText.setText(R.string.view_key_verified);
mStatusImage.setVisibility(View.VISIBLE); mStatusImage.setVisibility(View.VISIBLE);
KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_VERIFIED, R.color.icons, true); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_VERIFIED, R.color.icons, true);
color = getResources().getColor(R.color.primary); color = getResources().getColor(R.color.primary);
AsyncTask<String, Void, Bitmap> photoTask =
new AsyncTask<String, Void, Bitmap>() {
protected Bitmap doInBackground(String... fingerprint) {
return ContactHelper.photoFromFingerprint(getContentResolver(), fingerprint[0]);
}
protected void onPostExecute(Bitmap photo) {
mPhoto.setImageBitmap(photo);
mPhoto.setVisibility(View.VISIBLE);
}
};
photoTask.execute(fingerprint); photoTask.execute(fingerprint);
mActionVerify.setVisibility(View.INVISIBLE); mActionVerify.setVisibility(View.GONE);
mFab.setVisibility(View.INVISIBLE); mFab.setVisibility(View.GONE);
} else { } else {
mStatusText.setText(R.string.view_key_unverified); mStatusText.setText(R.string.view_key_unverified);
mStatusImage.setVisibility(View.VISIBLE); mStatusImage.setVisibility(View.VISIBLE);

View File

@ -18,84 +18,36 @@
package org.sufficientlysecure.keychain.ui; package org.sufficientlysecure.keychain.ui;
import android.annotation.TargetApi;
import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader; import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.QrCodeUtils;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.io.IOException;
import java.util.Date;
public class ViewKeyFragment extends LoaderFragment implements public class ViewKeyFragment extends LoaderFragment implements
LoaderManager.LoaderCallbacks<Cursor> { LoaderManager.LoaderCallbacks<Cursor> {
public static final String ARG_DATA_URI = "uri"; public static final String ARG_DATA_URI = "uri";
private View mActionEdit;
private View mActionEditDivider;
private View mActionEncryptFiles;
private View mActionEncryptText;
private View mActionEncryptTextText;
private View mActionCertify;
private View mActionCertifyText;
private ImageView mActionCertifyImage;
private View mActionUpdate;
private TextView mFingerprint;
private ImageView mFingerprintQrCode;
private View mFingerprintShareButton;
private View mFingerprintClipboardButton;
private View mKeyShareButton;
private View mKeyClipboardButton;
private ImageButton mKeySafeSlingerButton;
private View mNfcHelpButton;
private View mNfcPrefsButton;
private View mKeyUploadButton;
private ListView mUserIds; private ListView mUserIds;
private static final int LOADER_ID_UNIFIED = 0;
private static final int LOADER_ID_USER_IDS = 1; private static final int LOADER_ID_USER_IDS = 1;
// conservative attitude
private boolean mHasEncrypt = true;
private UserIdsAdapter mUserIdsAdapter; private UserIdsAdapter mUserIdsAdapter;
private Uri mDataUri; private Uri mDataUri;
@ -123,18 +75,7 @@ public class ViewKeyFragment extends LoaderFragment implements
mProviderHelper = new ProviderHelper(getActivity()); mProviderHelper = new ProviderHelper(getActivity());
mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
mActionEdit = view.findViewById(R.id.view_key_action_edit);
mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider);
mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text);
mActionEncryptTextText = view.findViewById(R.id.view_key_action_encrypt_text_text);
mActionEncryptFiles = view.findViewById(R.id.view_key_action_encrypt_files);
mActionCertify = view.findViewById(R.id.view_key_action_certify);
mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text);
mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image);
// make certify image gray, like action icons
mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
PorterDuff.Mode.SRC_IN);
mActionUpdate = view.findViewById(R.id.view_key_action_update);
mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
@ -143,176 +84,10 @@ public class ViewKeyFragment extends LoaderFragment implements
} }
}); });
mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint);
mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image);
mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share);
mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard);
mKeyShareButton = view.findViewById(R.id.view_key_action_key_share);
mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard);
mKeySafeSlingerButton = (ImageButton) view.findViewById(R.id.view_key_action_key_safeslinger);
mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help);
mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs);
mKeyUploadButton = view.findViewById(R.id.view_key_action_upload);
mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mNfcPrefsButton.setVisibility(View.VISIBLE);
} else {
mNfcPrefsButton.setVisibility(View.GONE);
}
mFingerprintQrCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showQrCodeDialog();
}
});
mFingerprintShareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
share(mDataUri, mProviderHelper, true, false);
}
});
mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
share(mDataUri, mProviderHelper, true, true);
}
});
mKeyShareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
share(mDataUri, mProviderHelper, false, false);
}
});
mKeyClipboardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
share(mDataUri, mProviderHelper, false, true);
}
});
mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startSafeSlinger(mDataUri);
}
});
mNfcHelpButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showNfcHelpDialog();
}
});
mNfcPrefsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showNfcPrefs();
}
});
mKeyUploadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
uploadToKeyserver();
}
});
return root; return root;
} }
private void startSafeSlinger(Uri dataUri) {
long keyId = 0;
try {
keyId = new ProviderHelper(getActivity())
.getCachedPublicKeyRing(dataUri)
.extractOrGetMasterKeyId();
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class);
safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId);
startActivityForResult(safeSlingerIntent, 0);
}
private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly,
boolean toClipboard) {
try {
String content;
if (fingerprintOnly) {
byte[] data = (byte[]) providerHelper.getGenericData(
KeyRings.buildUnifiedKeyRingUri(dataUri),
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data);
if (!toClipboard) {
content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
} else {
content = fingerprint;
}
} else {
Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(dataUri);
// get public keyring as ascii armored string
content = providerHelper.getKeyRingAsArmoredString(uri);
}
if (toClipboard) {
ClipboardReflection.copyToClipboard(getActivity(), content);
String message;
if (fingerprintOnly) {
message = getResources().getString(R.string.fingerprint_copied_to_clipboard);
} else {
message = getResources().getString(R.string.key_copied_to_clipboard);
}
Notify.showNotify(getActivity(), message, Notify.Style.OK);
} else {
// Android will fail with android.os.TransactionTooLargeException if key is too big
// see http://www.lonestarprod.com/?p=34
if (content.length() >= 86389) {
Notify.showNotify(getActivity(), R.string.key_too_big_for_sharing,
Notify.Style.ERROR);
return;
}
// let user choose application
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, content);
sendIntent.setType("text/plain");
String title;
if (fingerprintOnly) {
title = getResources().getString(R.string.title_share_fingerprint_with);
} else {
title = getResources().getString(R.string.title_share_key);
}
startActivity(Intent.createChooser(sendIntent, title));
}
} catch (PgpGeneralException | IOException e) {
Log.e(Constants.TAG, "error processing key!", e);
Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR);
} catch (ProviderHelper.NotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR);
}
}
private void showQrCodeDialog() {
Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class);
qrCodeIntent.setData(mDataUri);
startActivity(qrCodeIntent);
}
private void showNfcHelpDialog() {
ShareNfcDialogFragment dialog = ShareNfcDialogFragment.newInstance();
dialog.show(getActivity().getSupportFragmentManager(), "shareNfcDialog");
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void showNfcPrefs() {
Intent intentSettings = new Intent(
Settings.ACTION_NFCSHARING_SETTINGS);
startActivity(intentSettings);
}
private void showUserIdInfo(final int position) { private void showUserIdInfo(final int position) {
final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position);
@ -347,82 +122,21 @@ public class ViewKeyFragment extends LoaderFragment implements
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
mActionEncryptFiles.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
encrypt(mDataUri, false);
}
});
mActionEncryptText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
encrypt(mDataUri, true);
}
});
mActionCertify.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
certify(mDataUri);
}
});
mActionEdit.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
editKey(mDataUri);
}
});
mActionUpdate.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
try {
updateFromKeyserver(mDataUri, new ProviderHelper(getActivity()));
} catch (NotFoundException e) {
Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR);
}
}
});
mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0);
mUserIds.setAdapter(mUserIdsAdapter); mUserIds.setAdapter(mUserIdsAdapter);
// Prepare the loaders. Either re-connect with an existing ones, // Prepare the loaders. Either re-connect with an existing ones,
// or start new ones. // or start new ones.
getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
} }
static final String[] UNIFIED_PROJECTION = new String[]{
KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET,
KeyRings.USER_ID, KeyRings.FINGERPRINT,
KeyRings.ALGORITHM, KeyRings.KEY_SIZE, KeyRings.CREATION, KeyRings.EXPIRY,
KeyRings.IS_REVOKED, KeyRings.HAS_ENCRYPT,
};
static final int INDEX_UNIFIED_MASTER_KEY_ID = 1;
static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2;
static final int INDEX_UNIFIED_USER_ID = 3;
static final int INDEX_UNIFIED_FINGERPRINT = 4;
static final int INDEX_UNIFIED_ALGORITHM = 5;
static final int INDEX_UNIFIED_KEY_SIZE = 6;
static final int INDEX_UNIFIED_CREATION = 7;
static final int INDEX_UNIFIED_EXPIRY = 8;
static final int INDEX_UNIFIED_IS_REVOKED = 9;
static final int INDEX_UNIFIED_HAS_ENCRYPT = 10;
public Loader<Cursor> onCreateLoader(int id, Bundle args) { public Loader<Cursor> onCreateLoader(int id, Bundle args) {
setContentShown(false); setContentShown(false);
switch (id) { Uri baseUri = UserPackets.buildUserIdsUri(mDataUri);
case LOADER_ID_UNIFIED: { return new CursorLoader(getActivity(), baseUri,
Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); UserIdsAdapter.USER_IDS_PROJECTION, null, null, null);
return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null);
}
case LOADER_ID_USER_IDS: {
Uri baseUri = UserPackets.buildUserIdsUri(mDataUri);
return new CursorLoader(getActivity(), baseUri,
UserIdsAdapter.USER_IDS_PROJECTION, null, null, null);
}
default:
return null;
}
} }
public void onLoadFinished(Loader<Cursor> loader, Cursor data) { public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
@ -435,63 +149,8 @@ public class ViewKeyFragment extends LoaderFragment implements
} }
// Swap the new cursor in. (The framework will take care of closing the // Swap the new cursor in. (The framework will take care of closing the
// old cursor once we return.) // old cursor once we return.)
switch (loader.getId()) {
case LOADER_ID_UNIFIED: {
if (data.moveToFirst()) {
byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT);
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob);
mFingerprint.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint));
loadQrCode(fingerprint); mUserIdsAdapter.swapCursor(data);
if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) {
// edit button
mActionEdit.setVisibility(View.VISIBLE);
mActionEditDivider.setVisibility(View.VISIBLE);
} else {
// edit button
mActionEdit.setVisibility(View.GONE);
mActionEditDivider.setVisibility(View.GONE);
}
// If this key is revoked, it cannot be used for anything!
if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) {
mActionEdit.setEnabled(false);
mActionCertify.setEnabled(false);
mActionCertifyText.setEnabled(false);
mActionEncryptText.setEnabled(false);
mActionEncryptTextText.setEnabled(false);
mActionEncryptFiles.setEnabled(false);
} else {
mActionEdit.setEnabled(true);
Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000);
if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) {
mActionCertify.setEnabled(false);
mActionCertifyText.setEnabled(false);
mActionEncryptText.setEnabled(false);
mActionEncryptTextText.setEnabled(false);
mActionEncryptFiles.setEnabled(false);
} else {
mActionCertify.setEnabled(true);
mActionCertifyText.setEnabled(true);
mActionEncryptText.setEnabled(true);
mActionEncryptTextText.setEnabled(true);
mActionEncryptFiles.setEnabled(true);
}
}
mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0;
break;
}
}
case LOADER_ID_USER_IDS:
mUserIdsAdapter.swapCursor(data);
break;
}
setContentShown(true); setContentShown(true);
} }
@ -507,109 +166,4 @@ public class ViewKeyFragment extends LoaderFragment implements
} }
} }
/**
* Load QR Code asynchronously and with a fade in animation
*
* @param fingerprint
*/
private void loadQrCode(final String fingerprint) {
AsyncTask<Void, Void, Bitmap> loadTask =
new AsyncTask<Void, Void, Bitmap>() {
protected Bitmap doInBackground(Void... unused) {
String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
// render with minimal size
return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0);
}
protected void onPostExecute(Bitmap qrCode) {
// only change view, if fragment is attached to activity
if (ViewKeyFragment.this.isAdded()) {
// scale the image up to our actual size. we do this in code rather
// than let the ImageView do this because we don't require filtering.
Bitmap scaled = Bitmap.createScaledBitmap(qrCode,
mFingerprintQrCode.getHeight(), mFingerprintQrCode.getHeight(),
false);
mFingerprintQrCode.setImageBitmap(scaled);
// simple fade-in animation
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(200);
mFingerprintQrCode.startAnimation(anim);
}
}
};
loadTask.execute();
}
private void uploadToKeyserver() {
Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class);
uploadIntent.setData(mDataUri);
startActivityForResult(uploadIntent, 0);
}
private void encrypt(Uri dataUri, boolean text) {
// If there is no encryption key, don't bother.
if (!mHasEncrypt) {
Notify.showNotify(getActivity(), R.string.error_no_encrypt_subkey, Notify.Style.ERROR);
return;
}
try {
long keyId = new ProviderHelper(getActivity())
.getCachedPublicKeyRing(dataUri)
.extractOrGetMasterKeyId();
long[] encryptionKeyIds = new long[]{keyId};
Intent intent;
if (text) {
intent = new Intent(getActivity(), EncryptTextActivity.class);
intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT);
intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
} else {
intent = new Intent(getActivity(), EncryptFilesActivity.class);
intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA);
intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
}
// used instead of startActivity set actionbar based on callingPackage
startActivityForResult(intent, 0);
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
}
private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper)
throws NotFoundException {
byte[] blob = (byte[]) providerHelper.getGenericData(
KeyRings.buildUnifiedKeyRingUri(dataUri),
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
Intent queryIntent = new Intent(getActivity(), ImportKeysActivity.class);
queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT);
queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint);
startActivityForResult(queryIntent, 0);
}
private void certify(Uri dataUri) {
long keyId = 0;
try {
keyId = new ProviderHelper(getActivity())
.getCachedPublicKeyRing(dataUri)
.extractOrGetMasterKeyId();
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class);
certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId});
startActivityForResult(certifyIntent, 0);
}
private void editKey(Uri dataUri) {
Intent editIntent = new Intent(getActivity(), EditKeyActivity.class);
editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri));
startActivityForResult(editIntent, 0);
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

View File

@ -44,40 +44,35 @@
android:transitionGroup="false" android:transitionGroup="false"
android:touchscreenBlocksFocus="false" /> android:touchscreenBlocksFocus="false" />
<LinearLayout <TextView
android:id="@+id/name_layout" android:id="@+id/view_key_name"
android:orientation="horizontal"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_above="@+id/toolbar2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginStart="48dp"
android:layout_marginRight="48dp"
android:layout_marginEnd="48dp"
android:layout_above="@+id/view_key_status"
android:text=""
android:textColor="@color/icons"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_toLeftOf="@+id/view_key_qr_code"
android:layout_toStartOf="@+id/view_key_qr_code" />
<LinearLayout <TextView
android:orientation="vertical" android:id="@+id/view_key_status"
android:layout_marginLeft="32dp" android:layout_width="match_parent"
android:layout_marginStart="32dp" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_marginLeft="48dp"
android:layout_height="wrap_content"> android:layout_marginStart="48dp"
android:layout_marginRight="48dp"
<TextView android:layout_marginEnd="48dp"
android:id="@+id/view_key_name" android:layout_above="@+id/toolbar2"
android:layout_width="wrap_content" android:text=""
android:layout_height="wrap_content" android:textColor="@color/tab_text"
android:text="" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/icons" android:layout_toLeftOf="@+id/view_key_qr_code"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:layout_toStartOf="@+id/view_key_qr_code" />
<TextView
android:id="@+id/view_key_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/tab_text"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
@ -116,6 +111,15 @@
android:visibility="invisible" android:visibility="invisible"
style="?android:attr/borderlessButtonStyle" style="?android:attr/borderlessButtonStyle"
android:src="@drawable/ic_action_verified_cutout" /> android:src="@drawable/ic_action_verified_cutout" />
<ImageButton
android:id="@+id/view_key_action_edit"
android:layout_width="64dp"
android:layout_height="64dp"
android:visibility="invisible"
style="?android:attr/borderlessButtonStyle"
android:src="@drawable/ic_mode_edit_white_24dp" />
</LinearLayout> </LinearLayout>
<ImageView <ImageView
@ -130,6 +134,18 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginRight="16dp" /> android:layout_marginRight="16dp" />
<ImageButton
android:id="@+id/view_key_qr_code"
android:layout_width="96dp"
android:layout_height="96dp"
android:visibility="gone"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="center_vertical"
android:layout_above="@+id/toolbar2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="20dp" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout

View File

@ -1,358 +1,42 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="16dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp"> android:paddingRight="16dp">
<TextView <android.support.v7.widget.CardView
style="@style/SectionHeader" android:id="@+id/card_view"
android:layout_width="wrap_content" android:layout_gravity="center"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:text="@string/section_user_ids"
android:layout_weight="1" />
<org.sufficientlysecure.keychain.ui.widget.FixedListView
android:id="@+id/view_key_user_ids"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_weight="1" />
<TextView
style="@style/SectionHeader"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="14dp"
android:text="@string/section_actions"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/view_key_action_certify"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:clickable="true"
android:paddingRight="4dp"
style="@style/SelectableItem"
android:orientation="horizontal">
<TextView
android:id="@+id/view_key_action_certify_text"
android:paddingLeft="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="@string/key_view_action_certify"
android:layout_weight="1"
android:gravity="center_vertical" />
<ImageView
android:id="@+id/view_key_action_certify_image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/status_signature_verified_cutout_24px"
android:layout_gravity="center_vertical" />
</LinearLayout>
<View
android:id="@+id/view_key_action_certify_divider"
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/view_key_action_edit"
android:paddingLeft="8dp"
android:paddingRight="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/key_view_action_edit"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_edit"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:id="@+id/view_key_action_edit_divider"
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<LinearLayout
android:id="@+id/view_key_action_encrypt_text"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:clickable="true"
style="@style/SelectableItem"
android:orientation="horizontal">
<TextView
android:id="@+id/view_key_action_encrypt_text_text"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="@string/key_view_action_encrypt"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_secure"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/view_key_action_encrypt_files"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/key_view_action_encrypt_files"
android:drawableRight="@drawable/ic_action_secure"
android:drawablePadding="8dp"
android:gravity="center_vertical"
style="@style/SelectableItem" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/view_key_action_update"
android:paddingLeft="8dp"
android:paddingRight="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/key_view_action_update"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_download"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<TextView
style="@style/SectionHeader"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:text="@string/section_fingerprint"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/view_key_action_fingerprint_share"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:clickable="true"
style="@style/SelectableItem"
android:orientation="horizontal">
<TextView
android:id="@+id/view_key_fingerprint"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text=""
android:layout_weight="1"
android:typeface="monospace"
android:drawableRight="@drawable/ic_action_share"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/view_key_action_fingerprint_clipboard"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_copy"
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<ImageView
android:id="@+id/view_key_fingerprint_qr_code_image"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_width="200dp"
android:layout_height="200dp" android:layout_height="200dp"
android:layout_gravity="center_horizontal" card_view:cardCornerRadius="4dp">
android:layout_weight="1"
style="@style/SelectableItem" />
<TextView <LinearLayout
style="@style/SectionHeader" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="0dp" android:orientation="vertical">
android:layout_marginTop="14dp"
android:text="@string/section_share_key"
android:layout_weight="1" />
<LinearLayout <TextView
android:id="@+id/view_key_action_key_share" style="@style/SectionHeader"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="?android:attr/listPreferredItemHeight" android:layout_height="wrap_content"
android:clickable="true" android:layout_marginTop="8dp"
style="@style/SelectableItem" android:text="@string/section_user_ids" />
android:orientation="horizontal">
<TextView <org.sufficientlysecure.keychain.ui.widget.FixedListView
android:paddingLeft="8dp" android:id="@+id/view_key_user_ids"
android:paddingRight="8dp" android:layout_width="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_marginBottom="4dp" />
android:layout_height="match_parent" </LinearLayout>
android:text="@string/key_view_action_share_with" </android.support.v7.widget.CardView>
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_share"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/view_key_action_key_clipboard"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_copy"
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/view_key_action_key_safeslinger"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_safeslinger"
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/view_key_action_upload"
android:paddingLeft="8dp"
android:paddingRight="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/key_view_action_upload"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_upload"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<LinearLayout
android:id="@+id/view_key_action_nfc_help"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:clickable="true"
style="@style/SelectableItem"
android:orientation="horizontal"
android:layout_marginBottom="8dp">
<TextView
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="@string/key_view_action_share_nfc"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_help"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/view_key_action_nfc_prefs"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_settings"
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
</LinearLayout>
</LinearLayout> </LinearLayout>