mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
reduce memory footprint in QrCodeActivity as well
This commit is contained in:
parent
a54a0c34fe
commit
9d01490d4e
@ -17,10 +17,12 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
@ -38,8 +40,6 @@ public class QrCodeActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
private ImageView mFingerprintQrCode;
|
private ImageView mFingerprintQrCode;
|
||||||
|
|
||||||
private static final int QR_CODE_SIZE = 1000;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -87,7 +87,20 @@ public class QrCodeActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
|
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
|
||||||
String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
|
String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
|
||||||
mFingerprintQrCode.setImageBitmap(QrCodeUtils.getQRCodeBitmap(qrCodeContent, QR_CODE_SIZE));
|
|
||||||
|
// create a minimal size qr code, we can keep this in ram no problem
|
||||||
|
final Bitmap qrCode = QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0);
|
||||||
|
|
||||||
|
mFingerprintQrCode.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||||
|
new OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
// create actual bitmap in display dimensions
|
||||||
|
Bitmap scaled = Bitmap.createScaledBitmap(qrCode,
|
||||||
|
mFingerprintQrCode.getWidth(), mFingerprintQrCode.getWidth(), false);
|
||||||
|
mFingerprintQrCode.setImageBitmap(scaled);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
Log.e(Constants.TAG, "key not found!", e);
|
Log.e(Constants.TAG, "key not found!", e);
|
||||||
Notify.showNotify(this, R.string.error_key_not_found, Style.ERROR);
|
Notify.showNotify(this, R.string.error_key_not_found, Style.ERROR);
|
||||||
|
Loading…
Reference in New Issue
Block a user