Search in sources :

Example 1 with BarcodeEncoder

use of com.journeyapps.barcodescanner.BarcodeEncoder in project OnlineCanteen by josephgunawan97.

the class MainUserActivity method showQR.

private void showQR() {
    Bitmap bitmap;
    // TODO Auto-generated method stub
    AlertDialog.Builder alertadd = new AlertDialog.Builder(this);
    alertadd.setTitle("QR Code");
    LayoutInflater factory = LayoutInflater.from(this);
    final View view = factory.inflate(R.layout.qr_layout, null);
    String text2Qr = user.getUid().toString();
    MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
    try {
        BitMatrix bitMatrix = multiFormatWriter.encode(text2Qr, BarcodeFormat.QR_CODE, 300, 300);
        BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
        bitmap = barcodeEncoder.createBitmap(bitMatrix);
        ImageView image = (ImageView) view.findViewById(R.id.imageView);
        image.setImageBitmap(bitmap);
    } catch (WriterException e) {
        e.printStackTrace();
    }
    alertadd.setView(view);
    alertadd.setNeutralButton("Close", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dlg, int sumthin) {
        }
    });
    alertadd.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) BarcodeEncoder(com.journeyapps.barcodescanner.BarcodeEncoder) BitMatrix(com.google.zxing.common.BitMatrix) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Bitmap(android.graphics.Bitmap) MultiFormatWriter(com.google.zxing.MultiFormatWriter) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) WriterException(com.google.zxing.WriterException)

Example 2 with BarcodeEncoder

use of com.journeyapps.barcodescanner.BarcodeEncoder in project TrebleShot by genonbeta.

the class NetworkDeviceListFragment method updateQRViews.

public void updateQRViews(String networkName, String password, int keyManagement) {
    try {
        MultiFormatWriter formatWriter = new MultiFormatWriter();
        String text = new JSONObject().put(Keyword.NETWORK_NAME, networkName).put(Keyword.NETWORK_PASSWORD, password).put(Keyword.NETWORK_KEYMGMT, keyManagement).toString();
        showCustomView(networkName != null && mFAB != null);
        if (networkName != null) {
            mNetworkInfoTextView.setText(R.string.text_qrCodeAvailableHelp);
            int scaleUsing = getDefaultViewContainer().getWidth() > getDefaultViewContainer().getHeight() ? getDefaultViewContainer().getHeight() : getDefaultViewContainer().getWidth();
            int scaledSize = (int) (scaleUsing / 1.5);
            BitMatrix bitMatrix = formatWriter.encode(text, BarcodeFormat.QR_CODE, scaledSize, scaledSize);
            BarcodeEncoder encoder = new BarcodeEncoder();
            Bitmap bitmap = encoder.createBitmap(bitMatrix);
            mCodeImageView.setImageBitmap(bitmap);
            mNetworkNameTextView.setText(networkName);
            mNetworkPassTextView.setText(password == null ? "-" : password);
        } else {
            mCodeImageView.setImageResource(R.drawable.ic_qrcode_grey600_48dp);
            mNetworkInfoTextView.setText(R.string.text_qrCodeHotspotDisabledHelp);
            mNetworkNameTextView.setText(R.string.text_unknown);
            mNetworkPassTextView.setText(R.string.text_unknown);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Bitmap(android.graphics.Bitmap) JSONObject(org.json.JSONObject) MultiFormatWriter(com.google.zxing.MultiFormatWriter) BarcodeEncoder(com.journeyapps.barcodescanner.BarcodeEncoder) BitMatrix(com.google.zxing.common.BitMatrix)

Example 3 with BarcodeEncoder

use of com.journeyapps.barcodescanner.BarcodeEncoder in project krypton-android by kryptco.

the class MemberQR method onCreateClient.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onCreateClient(TeamService.GenerateClientResult r) {
    if (r.c.error != null) {
        Error.shortToast(getContext(), r.c.error);
        Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
        return;
    }
    Sigchain.Identity identity = r.c.success;
    Sigchain.MemberQRPayload memberQRPayload = new Sigchain.MemberQRPayload(identity.email, identity.publicKey);
    Sigchain.QRPayload qrPayload = new Sigchain.QRPayload(memberQRPayload);
    try {
        BitMatrix qrData = new QRCodeWriter().encode(JSON.toJson(qrPayload), BarcodeFormat.DATA_MATRIX.QR_CODE, 500, 500);
        qr.setImageBitmap(new BarcodeEncoder().createBitmap(qrData));
        qrPayloads.set(new QRPayloads(memberQRPayload, MemberScan.lastScannedPayload.get()));
        loadQRProgress.setAlpha(0);
        joinProgress.animate().setDuration(1000).alpha(1).start();
        new JoinTeamProgress(getContext()).updateTeamData((s, d) -> {
            d.identity = identity;
            d.teamName = qrPayloads.get().admin.teamName;
            return s;
        });
    } catch (WriterException e) {
        e.printStackTrace();
        Error.shortToast(getContext(), "Error creating QRCode");
        Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
        return;
    }
    EventBus.getDefault().post(new PollRead());
}
Also used : Sigchain(co.krypt.krypton.team.Sigchain) BarcodeEncoder(com.journeyapps.barcodescanner.BarcodeEncoder) JoinTeamProgress(co.krypt.krypton.team.onboarding.join.JoinTeamProgress) BitMatrix(com.google.zxing.common.BitMatrix) QRCodeWriter(com.google.zxing.qrcode.QRCodeWriter) WriterException(com.google.zxing.WriterException) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 4 with BarcodeEncoder

use of com.journeyapps.barcodescanner.BarcodeEncoder in project krypton-android by kryptco.

the class AdminQR method onGetTeamHomeData.

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onGetTeamHomeData(TeamService.GetTeamHomeDataResult d) {
    if (d.r.error != null) {
        Error.shortToast(getContext(), d.r.error);
        Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
        return;
    }
    Sigchain.TeamHomeData teamHomeData = d.r.success;
    Sigchain.QRPayload qrPayload = new Sigchain.QRPayload(new Sigchain.AdminQRPayload(teamHomeData.teamPublicKey, teamHomeData.lastBlockHash, teamHomeData.name));
    try {
        BitMatrix qrData = new QRCodeWriter().encode(JSON.toJson(qrPayload), BarcodeFormat.DATA_MATRIX.QR_CODE, 500, 500);
        qr.setImageBitmap(new BarcodeEncoder().createBitmap(qrData));
    } catch (WriterException e) {
        e.printStackTrace();
        Error.shortToast(getContext(), "Error creating QRCode");
        Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
        return;
    }
}
Also used : QRCodeWriter(com.google.zxing.qrcode.QRCodeWriter) Sigchain(co.krypt.krypton.team.Sigchain) BarcodeEncoder(com.journeyapps.barcodescanner.BarcodeEncoder) BitMatrix(com.google.zxing.common.BitMatrix) WriterException(com.google.zxing.WriterException) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

BitMatrix (com.google.zxing.common.BitMatrix)4 BarcodeEncoder (com.journeyapps.barcodescanner.BarcodeEncoder)4 WriterException (com.google.zxing.WriterException)3 Bitmap (android.graphics.Bitmap)2 Sigchain (co.krypt.krypton.team.Sigchain)2 MultiFormatWriter (com.google.zxing.MultiFormatWriter)2 QRCodeWriter (com.google.zxing.qrcode.QRCodeWriter)2 Subscribe (org.greenrobot.eventbus.Subscribe)2 DialogInterface (android.content.DialogInterface)1 NavigationView (android.support.design.widget.NavigationView)1 AlertDialog (android.support.v7.app.AlertDialog)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 JoinTeamProgress (co.krypt.krypton.team.onboarding.join.JoinTeamProgress)1 JSONObject (org.json.JSONObject)1