diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui')
4 files changed, 37 insertions, 15 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index c16a52e9c..efa526e33 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -36,6 +36,7 @@ import android.provider.ContactsContract; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; +import android.support.v7.widget.CardView; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -87,6 +88,7 @@ public class ViewKeyActivity extends BaseActivity implements private FloatingActionButton mFab; private AspectRatioImageView mPhoto; private ImageButton mQrCode; + private CardView mQrCodeLayout; // NFC private NfcAdapter mNfcAdapter; @@ -121,6 +123,7 @@ public class ViewKeyActivity extends BaseActivity implements mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code); + mQrCodeLayout = (CardView) findViewById(R.id.view_key_qr_code_layout); mDataUri = getIntent().getData(); if (mDataUri == null) { @@ -169,7 +172,7 @@ public class ViewKeyActivity extends BaseActivity implements if (mIsSecret) { startSafeSlinger(mDataUri); } else { - certify(mDataUri); + scanQrCode(); } } }); @@ -264,6 +267,12 @@ public class ViewKeyActivity extends BaseActivity implements return super.onOptionsItemSelected(item); } + private void scanQrCode() { + Intent scanQrCode = new Intent(this, QrCodeScanActivity.class); + scanQrCode.setAction(QrCodeScanActivity.ACTION_SCAN_WITH_RESULT); + startActivityForResult(scanQrCode, 0); + } + private void showQrCodeDialog() { Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class); qrCodeIntent.setData(mDataUri); @@ -403,9 +412,6 @@ public class ViewKeyActivity extends BaseActivity implements } 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, @@ -418,7 +424,6 @@ public class ViewKeyActivity extends BaseActivity implements anim.setDuration(200); mQrCode.startAnimation(anim); } -// } }; loadTask.execute(); @@ -580,7 +585,6 @@ public class ViewKeyActivity extends BaseActivity implements && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; - AsyncTask<String, Void, Bitmap> photoTask = new AsyncTask<String, Void, Bitmap>() { protected Bitmap doInBackground(String... fingerprint) { @@ -606,9 +610,15 @@ public class ViewKeyActivity extends BaseActivity implements mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.GONE); mFab.setVisibility(View.GONE); - mQrCode.setVisibility(View.GONE); + mQrCodeLayout.setVisibility(View.GONE); } else if (isExpired) { - mStatusText.setText(R.string.view_key_expired); + if (mIsSecret) { + mStatusText.setText(R.string.view_key_expired_secret); + mActionEdit.setVisibility(View.VISIBLE); + } else { + mStatusText.setText(R.string.view_key_expired); + mActionEdit.setVisibility(View.GONE); + } mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons, true); color = getResources().getColor(R.color.android_red_light); @@ -616,16 +626,15 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); - mActionEdit.setVisibility(View.GONE); mFab.setVisibility(View.GONE); - mQrCode.setVisibility(View.GONE); + mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { mStatusText.setText(R.string.view_key_my_key); mStatusImage.setVisibility(View.GONE); color = getResources().getColor(R.color.primary); photoTask.execute(fingerprint); loadQrCode(fingerprint); - mQrCode.setVisibility(View.VISIBLE); + mQrCodeLayout.setVisibility(View.VISIBLE); mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); @@ -637,7 +646,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); mActionEdit.setVisibility(View.GONE); - mQrCode.setVisibility(View.GONE); + mQrCodeLayout.setVisibility(View.GONE); if (isVerified) { mStatusText.setText(R.string.view_key_verified); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index 840dea471..37f9113bb 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -33,6 +33,7 @@ import com.astuetz.PagerSlidingTabStrip; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -237,4 +238,15 @@ public class ViewKeyAdvActivity extends BaseActivity implements public void onLoaderReset(Loader<Cursor> loader) { } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + // if a result has been returned, display a notify + if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) { + OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); + result.createNotify(this).show(); + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index 571c86b82..f30ab2b33 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -88,7 +88,6 @@ public class ViewKeyFragment extends LoaderFragment implements return root; } - private void showUserIdInfo(final int position) { final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); final int isVerified = mUserIdsAdapter.getIsVerified(position); @@ -130,13 +129,15 @@ public class ViewKeyFragment extends LoaderFragment implements getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); } + // don't show revoked user ids here, irrelevant for average users + public static final String WHERE = UserPackets.IS_REVOKED + " = 0"; public Loader<Cursor> onCreateLoader(int id, Bundle args) { setContentShown(false); Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + UserIdsAdapter.USER_IDS_PROJECTION, WHERE, null, null); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java index 0bb4100c5..b8d4ea7d2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java @@ -59,7 +59,7 @@ public class QrCodeUtils { for (int y = 0; y < height; y++) { final int offset = y * width; for (int x = 0; x < width; x++) { - pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.WHITE; + pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT; } } |