use of com.journeyapps.barcodescanner.BarcodeView in project krypton-android by kryptco.
the class AdminScan method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_teams_invite_inperson_scan, container, false);
lastScannedPayload.set(null);
barcodeView = v.findViewById(R.id.camera_preview_in_person_scan);
barcodeView.decodeContinuous(new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
if (result.getText() != null) {
try {
Sigchain.MemberQRPayload qr = JSON.fromJson(result.getText(), Sigchain.QRPayload.class).memberQRPayload;
if (qr == null) {
Error.shortToast(getContext(), "Make sure you are scanning a member that is trying to join the team.");
return;
}
if (lastScannedPayload.compareAndSet(null, qr)) {
Transitions.beginSlide(AdminScan.this).addToBackStack(null).replace(R.id.fragmentOverlay, new AdminVerify()).commitAllowingStateLoss();
} else {
Log.i(TAG, "not first scan");
}
} catch (JsonParseException e) {
Log.e(TAG, "could not parse QR code", e);
Error.shortToast(getContext(), "Invalid QR code");
}
}
}
@Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
}
});
AppCompatTextView detailText = v.findViewById(R.id.inPersonScanDetail);
detailText.setText("Scan your team member's QR code to add them to your team.");
return v;
}
use of com.journeyapps.barcodescanner.BarcodeView in project krypton-android by kryptco.
the class MemberScan method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_teams_invite_inperson_scan, container, false);
lastScannedPayload.set(null);
barcodeView = v.findViewById(R.id.camera_preview_in_person_scan);
barcodeView.decodeContinuous(new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
if (result.getText() != null) {
try {
Sigchain.AdminQRPayload qr = JSON.fromJson(result.getText(), Sigchain.QRPayload.class).adminQRPayload;
if (qr == null) {
Error.shortToast(getContext(), "Make sure you are scanning an admin that is already on a team.");
return;
}
if (lastScannedPayload.compareAndSet(null, qr)) {
Transitions.beginSlide(MemberScan.this).addToBackStack(null).replace(R.id.fragmentOverlay, new MemberEnterEmail()).commitAllowingStateLoss();
} else {
Log.i(TAG, "not first scan");
}
} catch (JsonParseException e) {
Log.e(TAG, "could not parse QR code", e);
Error.shortToast(getContext(), "Invalid QR code");
}
}
}
@Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
}
});
AppCompatTextView detailText = v.findViewById(R.id.inPersonScanDetail);
detailText.setText("Scan your team admin's QR code to join their team.");
return v;
}
use of com.journeyapps.barcodescanner.BarcodeView in project krypton-android by kryptco.
the class PairFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
final View rootView = inflater.inflate(R.layout.fragment_pair, container, false);
barcodeView = (BarcodeView) rootView.findViewById(R.id.camera_preview);
barcodeView.decodeContinuous(new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
if (result.getText() != null) {
try {
PairingQR pairingQR = PairingQR.parseJson(result.getText());
Log.i(TAG, "found pairingQR: " + Base64.encodeToString(pairingQR.workstationPublicKey, Base64.DEFAULT));
onPairingScanned(pairingQR);
} catch (JsonParseException e) {
Log.e(TAG, "could not parse QR code", e);
}
}
}
@Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
}
});
pairingStatusView = rootView.findViewById(R.id.pairingStatusLayout);
pairingStatusText = (TextView) rootView.findViewById(R.id.pairingStatusText);
cameraPermissionInfoLayout = (ConstraintLayout) rootView.findViewById(R.id.cameraPermissionInfo);
cameraPermissionInfoLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClickRequestCameraPermission(getActivity());
}
});
requestCameraPermissionButton = (Button) rootView.findViewById(R.id.requestCameraPermissionButton);
requestCameraPermissionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClickRequestCameraPermission(getActivity());
}
});
refreshCameraPermissionInfoVisibility();
cameraPermissionHeader = (TextView) rootView.findViewById(R.id.cameraPermissionTitle);
cameraPermissionText = (TextView) rootView.findViewById(R.id.cameraPermissionExplanation);
if (getActivity() instanceof OnboardingActivity) {
cameraPermissionHeader.setTextSize(16);
cameraPermissionText.setTextSize(14);
}
return rootView;
}
Aggregations