use aztec code instead of qr

This commit is contained in:
Daniel Gultsch 2016-11-21 12:01:01 +01:00
parent 6631705aea
commit 1a7e0fd153
2 changed files with 7 additions and 12 deletions

View File

@ -44,7 +44,6 @@ import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.InputType; import android.text.InputType;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -55,10 +54,8 @@ import android.widget.Toast;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException; import com.google.zxing.aztec.AztecWriter;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import net.java.otr4j.session.SessionID; import net.java.otr4j.session.SessionID;
@ -1072,12 +1069,11 @@ public abstract class XmppActivity extends Activity {
} }
protected Bitmap createQrCodeBitmap(String input, int size) { protected Bitmap createQrCodeBitmap(String input, int size) {
Log.d(Config.LOGTAG,"qr code requested size: "+size);
try { try {
final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter(); final AztecWriter AZTEC_WRITER = new AztecWriter();
final Hashtable<EncodeHintType, Object> hints = new Hashtable<>(); final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M); hints.put(EncodeHintType.ERROR_CORRECTION, 10);
final BitMatrix result = QR_CODE_WRITER.encode(input, BarcodeFormat.QR_CODE, size, size, hints); final BitMatrix result = AZTEC_WRITER.encode(input, BarcodeFormat.AZTEC, size, size, hints);
final int width = result.getWidth(); final int width = result.getWidth();
final int height = result.getHeight(); final int height = result.getHeight();
final int[] pixels = new int[width * height]; final int[] pixels = new int[width * height];
@ -1088,10 +1084,9 @@ public abstract class XmppActivity extends Activity {
} }
} }
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Log.d(Config.LOGTAG,"output size: "+width+"x"+height);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height); bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap; return bitmap;
} catch (final WriterException e) { } catch (final Exception e) {
return null; return null;
} }
} }

View File

@ -371,8 +371,8 @@
<string name="url_copied_to_clipboard">URL copied to clipboard</string> <string name="url_copied_to_clipboard">URL copied to clipboard</string>
<string name="message_copied_to_clipboard">Message copied to clipboard</string> <string name="message_copied_to_clipboard">Message copied to clipboard</string>
<string name="image_transmission_failed">Image transmission failed</string> <string name="image_transmission_failed">Image transmission failed</string>
<string name="scan_qr_code">Scan QR code</string> <string name="scan_qr_code">Scan 2D Barcode</string>
<string name="show_qr_code">Show QR code</string> <string name="show_qr_code">Show 2D Barcode</string>
<string name="show_block_list">Show block list</string> <string name="show_block_list">Show block list</string>
<string name="account_details">Account details</string> <string name="account_details">Account details</string>
<string name="verify_otr">Verify OTR</string> <string name="verify_otr">Verify OTR</string>