mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
Prettify qr code in advanced key view
This commit is contained in:
parent
4ccd9f9bb1
commit
11c3436454
@ -17,16 +17,20 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import android.app.ActivityOptions;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
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.widget.CardView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -58,7 +62,8 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
|
|
||||||
private TextView mFingerprint;
|
private TextView mFingerprint;
|
||||||
private ImageView mFingerprintQrCode;
|
private ImageView mQrCode;
|
||||||
|
private CardView mQrCodeLayout;
|
||||||
private View mFingerprintShareButton;
|
private View mFingerprintShareButton;
|
||||||
private View mFingerprintClipboardButton;
|
private View mFingerprintClipboardButton;
|
||||||
private View mKeyShareButton;
|
private View mKeyShareButton;
|
||||||
@ -80,7 +85,8 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
mProviderHelper = new ProviderHelper(ViewKeyAdvShareFragment.this.getActivity());
|
mProviderHelper = new ProviderHelper(ViewKeyAdvShareFragment.this.getActivity());
|
||||||
|
|
||||||
mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint);
|
mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint);
|
||||||
mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image);
|
mQrCode = (ImageView) view.findViewById(R.id.view_key_qr_code);
|
||||||
|
mQrCodeLayout = (CardView) view.findViewById(R.id.view_key_qr_code_layout);
|
||||||
mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share);
|
mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share);
|
||||||
mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard);
|
mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard);
|
||||||
mKeyShareButton = view.findViewById(R.id.view_key_action_key_share);
|
mKeyShareButton = view.findViewById(R.id.view_key_action_key_share);
|
||||||
@ -91,7 +97,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
|
mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
|
||||||
PorterDuff.Mode.SRC_IN);
|
PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
mFingerprintQrCode.setOnClickListener(new View.OnClickListener() {
|
mQrCodeLayout.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showQrCodeDialog();
|
showQrCodeDialog();
|
||||||
@ -213,8 +219,18 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
private void showQrCodeDialog() {
|
private void showQrCodeDialog() {
|
||||||
Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class);
|
Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class);
|
||||||
|
|
||||||
|
// create the transition animation - the images in the layouts
|
||||||
|
// of both activities are defined with android:transitionName="qr_code"
|
||||||
|
Bundle opts = null;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
ActivityOptions options = ActivityOptions
|
||||||
|
.makeSceneTransitionAnimation(getActivity(), mQrCodeLayout, "qr_code");
|
||||||
|
opts = options.toBundle();
|
||||||
|
}
|
||||||
|
|
||||||
qrCodeIntent.setData(mDataUri);
|
qrCodeIntent.setData(mDataUri);
|
||||||
startActivity(qrCodeIntent);
|
ActivityCompat.startActivity(getActivity(), qrCodeIntent, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -325,14 +341,14 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
// scale the image up to our actual size. we do this in code rather
|
// 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.
|
// than let the ImageView do this because we don't require filtering.
|
||||||
Bitmap scaled = Bitmap.createScaledBitmap(qrCode,
|
Bitmap scaled = Bitmap.createScaledBitmap(qrCode,
|
||||||
mFingerprintQrCode.getHeight(), mFingerprintQrCode.getHeight(),
|
mQrCode.getHeight(), mQrCode.getHeight(),
|
||||||
false);
|
false);
|
||||||
mFingerprintQrCode.setImageBitmap(scaled);
|
mQrCode.setImageBitmap(scaled);
|
||||||
|
|
||||||
// simple fade-in animation
|
// simple fade-in animation
|
||||||
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
|
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
|
||||||
anim.setDuration(200);
|
anim.setDuration(200);
|
||||||
mFingerprintQrCode.startAnimation(anim);
|
mQrCode.startAnimation(anim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<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">
|
||||||
|
|
||||||
@ -67,15 +68,36 @@
|
|||||||
android:layout_height="1dip"
|
android:layout_height="1dip"
|
||||||
android:background="?android:attr/listDivider" />
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/view_key_fingerprint_qr_code_image"
|
<android.support.v7.widget.CardView
|
||||||
android:paddingTop="8dp"
|
android:id="@+id/view_key_qr_code_layout"
|
||||||
android:paddingBottom="8dp"
|
android:transitionName="qr_code"
|
||||||
|
android:visibility="visible"
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="200dp"
|
android:layout_height="200dp"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
style="@style/SelectableItem" />
|
android:clickable="true"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
|
card_view:cardBackgroundColor="@android:color/white"
|
||||||
|
card_view:cardUseCompatPadding="true"
|
||||||
|
card_view:cardCornerRadius="4dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/view_key_qr_code"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
|
<!--<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_gravity="center_horizontal"-->
|
||||||
|
<!--android:layout_weight="1"-->
|
||||||
|
<!--style="@style/SelectableItem" />-->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
|
Loading…
Reference in New Issue
Block a user