Java Code Examples for com.google.zxing.integration.android.IntentResult#getFormatName()

The following examples show how to use com.google.zxing.integration.android.IntentResult#getFormatName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QrCodeHandler.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
public void onScanPerformed(IntentResult scanResult) {
    if (scanResult == null || scanResult.getFormatName() == null) {
        return; // aborted
    }

    handleOpenPgp4Fpr(scanResult.getContents());
}
 
Example 2
Source File: WelcomeActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode==IntentIntegrator.REQUEST_CODE) {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if (scanResult == null || scanResult.getFormatName() == null) {
            return; // aborted
        }
        String qrRaw = scanResult.getContents();
        DcLot qrParsed = dcContext.checkQr(qrRaw);
        switch (qrParsed.getState()) {
            case DcContext.DC_QR_ACCOUNT:
                String domain = qrParsed.getText1();
                new AlertDialog.Builder(this)
                        .setMessage(getString(R.string.qraccount_ask_create_and_login, domain))
                        .setPositiveButton(R.string.ok, (dialog, which) -> startQrAccountCreation(qrRaw))
                        .setNegativeButton(R.string.cancel, null)
                        .setCancelable(false)
                        .show();
                break;

            default:
                new AlertDialog.Builder(this)
                        .setMessage(R.string.qraccount_qr_code_cannot_be_used)
                        .setPositiveButton(R.string.ok, null)
                        .show();
                break;
        }
    }
}
 
Example 3
Source File: ScannerActivity.java    From SecScanQR with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method handles the results of the scan
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if(result != null){
        if(result.getContents()==null){
            Toast.makeText(this, getResources().getText(R.string.error_canceled_scan), Toast.LENGTH_LONG).show();
        } else {
            qrcodeFormat = result.getFormatName();
            qrcode = result.getContents();
            if(!qrcode.equals("")){
                codeImage.setVisibility(View.VISIBLE);
                showQrImage();
                mTvFormat.setVisibility(View.VISIBLE);
                mLabelInformation.setVisibility(View.VISIBLE);
                mLabelFormat.setVisibility(View.VISIBLE);
                mTvFormat.setText(qrcodeFormat);
                mTvInformation.setText(qrcode);
                action_navigation.setVisibility(View.VISIBLE);
                if(qrcode.contains("BEGIN:VCARD") & qrcode.contains("END:VCARD")){
                    action_navigation_web_button.setVisibility(View.GONE);
                    action_navigation_contact_button.setVisibility(View.VISIBLE);
                } else {
                    action_navigation_contact_button.setVisibility(View.GONE);
                    action_navigation_web_button.setVisibility(View.VISIBLE);
                }


                //Check if history is activated
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
                String history_setting = prefs.getString("pref_history", "");
                if(history_setting.equals("false")){
                    //Don't save QR-Code in history
                } else {
                    addToDatabase(mTvInformation.getText().toString(), mTvFormat.getText().toString());
                }
                //Automatic Clipboard if activated
                Boolean auto_scan = prefs.getBoolean("pref_start_auto_clipboard", false);
                if(auto_scan == true){
                    copyToClipboard(mTvInformation, qrcode, activity);
                }
            }

        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}