mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
Load QR Code asynchronously and with a fade in animation
This commit is contained in:
parent
57d9c7a013
commit
0f87b81158
@ -19,8 +19,16 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.TransitionDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@ -152,7 +160,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
||||
KeyRings.buildUnifiedKeyRingUri(dataUri),
|
||||
Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
|
||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(data);
|
||||
if(!toClipboard){
|
||||
if (!toClipboard) {
|
||||
content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
|
||||
} else {
|
||||
content = fingerprint;
|
||||
@ -292,10 +300,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob);
|
||||
mFingerprint.setText(PgpKeyHelper.colorizeFingerprint(fingerprint));
|
||||
|
||||
String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
|
||||
mFingerprintQrCode.setImageBitmap(
|
||||
QrCodeUtils.getQRCodeBitmap(qrCodeContent, QR_CODE_SIZE)
|
||||
);
|
||||
loadQrCode(fingerprint);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -311,4 +316,35 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
||||
*/
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return QrCodeUtils.getQRCodeBitmap(qrCodeContent, QR_CODE_SIZE);
|
||||
}
|
||||
|
||||
protected void onPostExecute(Bitmap qrCode) {
|
||||
mFingerprintQrCode.setImageBitmap(qrCode);
|
||||
|
||||
// Transition drawable with a transparent drawable and the final bitmap
|
||||
final TransitionDrawable td =
|
||||
new TransitionDrawable(new Drawable[]{
|
||||
new ColorDrawable(Color.TRANSPARENT),
|
||||
new BitmapDrawable(getResources(), qrCode)
|
||||
});
|
||||
|
||||
mFingerprintQrCode.setImageDrawable(td);
|
||||
td.startTransition(200);
|
||||
}
|
||||
};
|
||||
|
||||
loadTask.execute();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user