package com.baneizalfe.gocarinthia.activities;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.baneizalfe.gocarinthia.R;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;

public class QrCode extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qr_code);
        ImageView image_view = (ImageView) findViewById(R.id.imageView);

        QRCodeWriter qrcw = new QRCodeWriter();

        try {
            // generate a 150x150 QR code

            BitMatrix bm = qrcw.encode("TEST", BarcodeFormat.QR_CODE, 150, 150);
            Bitmap bmp = Bitmap.createBitmap(150, 150, Bitmap.Config.RGB_565);

            for (int x = 0; x < 150; x++) {
                for (int y = 0; y < 150; y++) {
                    bmp.setPixel(x, y, bm.get(x, y) ? Color.BLACK : Color.WHITE);
                }
            }

            bmp = bmp.createScaledBitmap(bmp, 300, 300, false);

            if (bm != null) {
                image_view.setImageBitmap(bmp);
            }

        } catch (WriterException e) {

        }
    }
}

@@ -247,17 +247,106 @@
 rinthia.
-R
+App;%0Aimport com.baneizalfe.gocarinthia.R;%0Aimport com.baneizalfe.gocarinthia.user.AuthToken
 ;%0Aimport
@@ -895,16 +895,148 @@
  QR code
+%0A            AuthToken t = App.getApp().getAuthToken();%0A            String info = %22uid:%22+t.id+%22;bid:%22;//+App.getApp().getBeaconId();
 %0A%0A      
@@ -1072,14 +1072,12 @@
 ode(
-%22TEST%22
+info
 , Ba

add userinfo and beacon id to qrcode