aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/services/BarcodeProvider.java14
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java2
2 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/services/BarcodeProvider.java b/src/main/java/de/pixart/messenger/services/BarcodeProvider.java
index cd28cb74d..f32082e1a 100644
--- a/src/main/java/de/pixart/messenger/services/BarcodeProvider.java
+++ b/src/main/java/de/pixart/messenger/services/BarcodeProvider.java
@@ -18,8 +18,9 @@ import android.util.Log;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
-import com.google.zxing.aztec.AztecWriter;
import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.io.File;
import java.io.FileNotFoundException;
@@ -105,7 +106,7 @@ public class BarcodeProvider extends ContentProvider implements ServiceConnectio
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
- Bitmap bitmap = createAztecBitmap(account.getShareableUri(), 1024);
+ Bitmap bitmap = create2dBarcodeBitmap(account.getShareableUri(), 1024);
OutputStream outputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
outputStream.close();
@@ -168,12 +169,12 @@ public class BarcodeProvider extends ContentProvider implements ServiceConnectio
return Uri.parse("content://" + packageId + AUTHORITY + "/" + account.getJid().toBareJid() + ".png");
}
- public static Bitmap createAztecBitmap(String input, int size) {
+ public static Bitmap create2dBarcodeBitmap(String input, int size) {
try {
- final AztecWriter AZTEC_WRITER = new AztecWriter();
+ final QRCodeWriter barcodeWriter = new QRCodeWriter();
final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
- hints.put(EncodeHintType.ERROR_CORRECTION, 10);
- final BitMatrix result = AZTEC_WRITER.encode(input, BarcodeFormat.AZTEC, size, size, hints);
+ hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
+ final BitMatrix result = barcodeWriter.encode(input, BarcodeFormat.QR_CODE, size, size, hints);
final int width = result.getWidth();
final int height = result.getHeight();
final int[] pixels = new int[width * height];
@@ -187,6 +188,7 @@ public class BarcodeProvider extends ContentProvider implements ServiceConnectio
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
} catch (final Exception e) {
+ e.printStackTrace();
return null;
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 4835ab03e..d7467b7a4 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -1095,7 +1095,7 @@ public abstract class XmppActivity extends Activity {
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
final int width = (size.x < size.y ? size.x : size.y);
- Bitmap bitmap = BarcodeProvider.createAztecBitmap(uri, width);
+ Bitmap bitmap = BarcodeProvider.create2dBarcodeBitmap(uri, width);
ImageView view = new ImageView(this);
view.setBackgroundColor(Color.WHITE);
view.setImageBitmap(bitmap);