diff options
Diffstat (limited to 'OpenKeychain/src')
9 files changed, 90 insertions, 36 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; } } diff --git a/OpenKeychain/src/main/res/drawable/cardview_header.xml b/OpenKeychain/src/main/res/drawable/cardview_header.xml new file mode 100644 index 000000000..9bab96ea9 --- /dev/null +++ b/OpenKeychain/src/main/res/drawable/cardview_header.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <size + android:height="1dp" + android:width="1000dp" /> + + <solid android:color="@color/bg_gray" /> + +</shape>
\ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index 17303ee84..25b978e37 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" + xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -52,12 +53,12 @@ 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" /> + android:layout_above="@+id/view_key_status" + android:layout_toLeftOf="@+id/view_key_qr_code_layout" + android:layout_toStartOf="@+id/view_key_qr_code_layout" /> <TextView android:id="@+id/view_key_status" @@ -67,19 +68,18 @@ android:layout_marginStart="48dp" android:layout_marginRight="48dp" android:layout_marginEnd="48dp" - android:layout_above="@+id/toolbar2" android:text="" android:textColor="@color/tab_text" android:textAppearance="?android:attr/textAppearanceSmall" - android:layout_toLeftOf="@+id/view_key_qr_code" - android:layout_toStartOf="@+id/view_key_qr_code" /> - + android:layout_above="@+id/toolbar2" + android:layout_toLeftOf="@+id/view_key_qr_code_layout" + android:layout_toStartOf="@+id/view_key_qr_code_layout" /> <LinearLayout android:id="@+id/toolbar2" android:orientation="horizontal" android:layout_alignParentBottom="true" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:minHeight="?attr/actionBarSize" android:layout_height="wrap_content" android:layout_alignParentLeft="true" @@ -128,23 +128,30 @@ android:visibility="invisible" android:src="@drawable/status_signature_unverified_cutout_96px" android:layout_height="96dp" - android:layout_gravity="center_vertical" - android:layout_above="@+id/toolbar2" + android:layout_above="@id/toolbar2" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginRight="16dp" /> - <ImageButton - android:id="@+id/view_key_qr_code" - android:layout_width="96dp" - android:layout_height="96dp" + <android.support.v7.widget.CardView + android:id="@+id/view_key_qr_code_layout" android:visibility="gone" - style="?android:attr/borderlessButtonStyle" - android:layout_gravity="center_vertical" - android:layout_above="@+id/toolbar2" + android:layout_below="@id/toolbar" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" - android:layout_marginRight="20dp" /> + android:layout_marginRight="20dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + card_view:cardBackgroundColor="@android:color/white" + card_view:cardUseCompatPadding="true" + card_view:cardCornerRadius="4dp"> + + <ImageButton + android:id="@+id/view_key_qr_code" + android:layout_width="96dp" + android:layout_height="96dp" + style="?android:attr/borderlessButtonStyle" /> + </android.support.v7.widget.CardView> </RelativeLayout> diff --git a/OpenKeychain/src/main/res/layout/view_key_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_fragment.xml index d37a41236..8e1bad3a8 100644 --- a/OpenKeychain/src/main/res/layout/view_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_fragment.xml @@ -8,6 +8,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="16dp" + android:paddingBottom="16dp" android:paddingLeft="16dp" android:paddingRight="16dp"> @@ -15,7 +16,10 @@ android:id="@+id/card_view" android:layout_gravity="center" android:layout_width="match_parent" - android:layout_height="200dp" + android:layout_height="wrap_content" + card_view:cardBackgroundColor="@android:color/white" + card_view:cardElevation="2sp" + card_view:cardUseCompatPadding="true" card_view:cardCornerRadius="4dp"> <LinearLayout @@ -24,10 +28,9 @@ android:orientation="vertical"> <TextView - style="@style/SectionHeader" + style="@style/CardViewHeader" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" android:text="@string/section_user_ids" /> <org.sufficientlysecure.keychain.ui.widget.FixedListView diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 730746787..46d6d3e47 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -584,6 +584,7 @@ <!-- View key --> <string name="view_key_revoked">"Revoked: Key must not be used anymore!"</string> <string name="view_key_expired">"Expired: The contact needs to extend the keys validity!"</string> + <string name="view_key_expired_secret">"Expired: You can extend the keys validity by editing it!"</string> <string name="view_key_my_key">"My Key"</string> <string name="view_key_verified">"Verified Key"</string> <string name="view_key_unverified">"Unverified: Scan QR Code to verify key!"</string> diff --git a/OpenKeychain/src/main/res/values/styles.xml b/OpenKeychain/src/main/res/values/styles.xml index f05bdb0ff..8420e0c13 100644 --- a/OpenKeychain/src/main/res/values/styles.xml +++ b/OpenKeychain/src/main/res/values/styles.xml @@ -20,6 +20,16 @@ <!--<item name="centerMedium">@android:drawable/popup_center_medium</item>--> </style> + <style name="CardViewHeader"> + <item name="android:drawableBottom">@drawable/cardview_header</item> + <item name="android:drawablePadding">16dp</item> + <item name="android:layout_marginTop">16dp</item> + <item name="android:paddingLeft">16dp</item> + <item name="android:textStyle">normal</item> + <item name="android:textColor">@color/header_text</item> + <item name="android:textSize">17sp</item> + </style> + <style name="SectionHeader"> <item name="android:drawableBottom">@drawable/section_header</item> <item name="android:drawablePadding">4dp</item> |