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();
}
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();
}
}
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());
}
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;
}
}
Aggregations