aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-10-09 16:25:38 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-10-09 16:25:38 +0200
commit9d01490d4e254bc9d9acbe4bf53ec22e53411495 (patch)
tree5e37948ac08d8de29af30f230d17bafb6bb50bed
parenta54a0c34fe9bf7ed04d9ce7dae6453ee9c18445d (diff)
downloadopen-keychain-9d01490d4e254bc9d9acbe4bf53ec22e53411495.tar.gz
open-keychain-9d01490d4e254bc9d9acbe4bf53ec22e53411495.tar.bz2
open-keychain-9d01490d4e254bc9d9acbe4bf53ec22e53411495.zip
reduce memory footprint in QrCodeActivity as well
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeActivity.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeActivity.java
index 6193be297..cc66a33a3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeActivity.java
@@ -17,10 +17,12 @@
package org.sufficientlysecure.keychain.ui;
+import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.ImageView;
import org.sufficientlysecure.keychain.Constants;
@@ -38,8 +40,6 @@ public class QrCodeActivity extends ActionBarActivity {
private ImageView mFingerprintQrCode;
- private static final int QR_CODE_SIZE = 1000;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -87,7 +87,20 @@ public class QrCodeActivity extends ActionBarActivity {
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
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) {
Log.e(Constants.TAG, "key not found!", e);
Notify.showNotify(this, R.string.error_key_not_found, Style.ERROR);