// Need to add this here since the ZXing library creates a new activity from activity, not
  // fragment
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (scanResult != null) {
      mCodeText = scanResult.getContents();
      setCode(mCodeText);
    } else if (requestCode == VOICE_RECOGNITION_REQUEST_CODE) {
      if (resultCode == Activity.RESULT_OK) {

        ArrayList<String> textMatchList =
            data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        if (!textMatchList.isEmpty()) {
          String text = textMatchList.get(0);
          TextView textView = (TextView) findViewById(R.id.cart_grocery_edit_name);
          textView.setText(text);
        }
      } else if (resultCode == RecognizerIntent.RESULT_AUDIO_ERROR) {
        makeToast("Audio error");
      } else if (resultCode == RecognizerIntent.RESULT_CLIENT_ERROR) {
        makeToast("Client error");
      } else if (resultCode == RecognizerIntent.RESULT_NETWORK_ERROR) {
        makeToast("Network error");
      } else if (resultCode == RecognizerIntent.RESULT_NO_MATCH) {
        makeToast("Please repeat the item");
      } else if (resultCode == RecognizerIntent.RESULT_SERVER_ERROR) {
        makeToast("Server error");
      }
    }

    super.onActivityResult(requestCode, resultCode, data);
  }
Exemplo n.º 2
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   if (scanResult != null) {
     searchBook(scanResult.getContents());
   }
 }
Exemplo n.º 3
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   super.onActivityResult(requestCode, resultCode, intent);
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   if (scanResult != null) {
     ((FormEditText) builder.getDialog().findViewById(R.id.device_code_input))
         .setText(scanResult.getContents());
   }
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (scanResult != null) {
      mTxtBarCode.setText(scanResult.getContents());
    }
  }
Exemplo n.º 5
0
  private void handleResult(IntentResult scanResult) {
    boolean lb_salida = true;
    if (scanResult != null) {

      updateUITextViews(scanResult.getContents(), scanResult.getFormatName());

    } else {
      Toast.makeText(this, "No se ha leído nada :(", Toast.LENGTH_SHORT).show();
    }
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   if (scanResult != null && !TextUtils.isEmpty(scanResult.getContents())) {
     FirebaseManager.authorizeCode(scanResult.getContents());
     Toast.makeText(
             ModerationActivity.this, R.string.message_authentication_started, Toast.LENGTH_SHORT)
         .show();
   }
 }
Exemplo n.º 7
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   IntentResult scanningResult =
       IntentIntegratorForFragment.parseActivityResult(requestCode, resultCode, data);
   if (scanningResult != null) {
     String scanContent = scanningResult.getContents();
     if (scanContent != null && !scanContent.equals("") && !scanContent.equals(" ")) {
       mEan.setText(scanContent);
     }
   }
 }
Exemplo n.º 8
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == IntentIntegrator.BARCODE_REQUEST) {
     IntentResult scanResult =
         IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
     if (scanResult.getContents() != null) {
       Log.v("dev", "content of scan : " + scanResult.getContents());
       // TODO reuse the scan
     }
   }
 }
Exemplo n.º 9
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   if (scanResult != null) {
     String code = scanResult.getContents();
     boolean equals = code != null && code.equals(remoteFingerprint);
     verifiedView.setChecked(equals);
     if (equals) showDialog(R.string.action_otr_smp_verified);
     else showDialog(R.string.action_otr_smp_unverified);
   }
 }
Exemplo n.º 10
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
   if (scanResult == null || scanResult.getContents() == null) {
     return;
   }
   if (scanResult.getFormatName().equals("CODE_128")) {
     Log.d(TAG, "Setting serial number to: " + scanResult.getContents());
     prefs.edit().putString("share_key", scanResult.getContents()).apply();
     returnToHome();
   }
 }
Exemplo n.º 11
0
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   IntentResult scanningResult =
       IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   if (scanningResult != null) {
     String scanContent = scanningResult.getContents();
     if (scanContent != null) {
       ean.setText(scanContent);
     }
   } else {
     String message = getString(R.string.barcode_scanner_error);
     Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
   }
 }
 @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, "扫描未完成,获取消息失败", Toast.LENGTH_LONG).show();
     } else {
       textView.setText(result.getContents());
       // Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
     }
   } else {
     super.onActivityResult(requestCode, resultCode, data);
   }
 }
Exemplo n.º 13
0
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    // get scan result
    IntentResult getResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    if (getResult != null) {
      String scanContent = getResult.getContents();
      String scanFormat = getResult.getFormatName();

      formatTxt.setText(String.format("FORMAT: %1$s", scanFormat));
      contentTxt.setText(String.format("CONTENT: %1$s", scanContent));
    } else {
      Toast.makeText(this, "No data!", Toast.LENGTH_LONG).show();
    }
  }
Exemplo n.º 14
0
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (dataItem == null) return;

    if (resultCode == Activity.RESULT_OK) {
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
      if (scanResult != null) {
        String qrCode = scanResult.getContents();
        NextLevel nl = dataItem.getNextLevel(qrCode);
        if (nl != null) {
          showNextLevel(this, nl);
        }
      }
    }
  }
  public static boolean handleKeyScanResult(
      int requestCode, int resultCode, Intent data, Activity activity) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);

    if (scanResult != null) {

      String otrKeyPassword = scanResult.getContents();

      SharedPreferences prefs =
          PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext());

      String otrKeyStorePath = prefs.getString("keystoreimport", null);

      Log.d("OTR", "got password: "******" for path: " + otrKeyStorePath);

      if (otrKeyPassword != null && otrKeyStorePath != null) {

        otrKeyPassword =
            otrKeyPassword.replace("\n", "").replace("\r", ""); // remove any padding, newlines, etc

        try {
          File otrKeystoreAES = new File(otrKeyStorePath);
          if (otrKeystoreAES.exists()) {
            try {

              IOtrKeyManager keyMan =
                  ((ImApp) activity.getApplication()).getRemoteImService().getOtrKeyManager();

              return keyMan.importOtrKeyStoreWithPassword(
                  otrKeystoreAES.getCanonicalPath(), otrKeyPassword);

            } catch (Exception e) {

              OtrDebugLogger.log("error getting keyman", e);
              return false;
            }
          }
        } catch (Exception e) {
          Toast.makeText(activity, "unable to open keystore for import", Toast.LENGTH_LONG).show();
          return false;
        }
      } else {
        Log.d("OTR", "no key store path saved");
        return false;
      }
    }

    return false;
  }
Exemplo n.º 16
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == RESULT_OK) {
     IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
     if (result == null || mOnScanListener == null) {
       return;
     }
     String isbn = result.getContents();
     Log.d(TAG, "ISBN = " + isbn);
     mOnScanListener.onScan(isbn);
   } else {
     Toast.makeText(this, "Reading ISBN cancelled. Try again!", Toast.LENGTH_SHORT).show();
   }
 }
  /**
   * function handle scan result
   *
   * @param requestCode
   * @param resultCode
   * @param intent
   */
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    // retrieve scan result
    IntentResult scanningResult =
        IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    if (scanningResult != null) {
      // we have a result
      String scanContent = scanningResult.getContents();
      etUPCCode.setText(scanContent);
    } else {
      Toast toast =
          Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT);
      toast.show();
    }
  }
  /** Gets called when the QR code was read is provided by zxing */
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    // Cancel if activity result is not a QR code scan result
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (result == null) {
      super.onActivityResult(requestCode, resultCode, intent);
      return;
    }

    // User cancelled QR code scanning?
    if (result.getContents() == null) {
      Toast.makeText(getActivity(), R.string.canceled_toast, Toast.LENGTH_LONG).show();
      return;
    }

    qrData = result.getContents();
    tryHandleQRData();
  }
Exemplo n.º 19
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   if (result != null) {
     if (result.getContents() == null) {
       Log.d("MainActivity", "Cancelled scan");
       Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
     } else {
       Log.d("MainActivity", "Scanned");
       Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
     }
   } else {
     Log.d("MainActivity", "Weird");
     // This is important, otherwise the result will not be passed to the fragment
     super.onActivityResult(requestCode, resultCode, data);
   }
 }
Exemplo n.º 20
0
  @Override
  protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    final IntentResult scanningResult =
        IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if ((scanningResult != null)
        && ScanningBarCodeUtil.BAR_CODE_EAN_13.equals(scanningResult.getFormatName())) {
      final String barCode = scanningResult.getContents();
      final Intent browseItemsIntent = new Intent(this, BrowseItemsActivity.class);
      browseItemsIntent.putExtra(BAR_CODE, barCode);

      startActivity(browseItemsIntent);
    } else {
      Toast.makeText(this, getString(R.string.no_scan_data), Toast.LENGTH_LONG).show();
    }
  }
Exemplo n.º 21
0
 @Override
 public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
   final IntentResult scanResult =
       IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   if (scanResult != null) {
     final String scan = scanResult.getContents();
     if (StringUtils.isBlank(scan)) {
       return;
     }
     SearchActivity.startActivityScan(scan, this);
   } else if (requestCode == SEARCH_REQUEST_CODE) {
     // SearchActivity activity returned without making a search
     if (resultCode == RESULT_CANCELED) {
       String query = intent.getStringExtra(SearchManager.QUERY);
       if (query == null) {
         query = "";
       }
       Dialogs.message(this, res.getString(R.string.unknown_scan) + "\n\n" + query);
     }
   }
 }
Exemplo n.º 22
0
  /**
   * Catch the result of a scanned barcode
   *
   * @param requestCode int
   * @param resultCode int
   * @param data Intent
   */
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {

    // parse the result in a intentresult object
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);

    if (result != null) {
      if (result.getContents() == null) {
        // mToast = Utility.showToast(getActivity(), mToast, getString(R.string.scanner_cancelled));
      } else {

        // get the scanned code and code format
        String scanned_ean = result.getContents();

        // inform the user about the ean number
        // mToast = Utility.showToast(getActivity(), mToast, "Scanned barcode: "+ ean);

        // once we have an isbn, add it to the search field (this will trigger the bookservice call)
        ean.setText(scanned_ean);
      }
    }
  }
  /**
   * function handle scan result receives the intent from the scanned activity
   *
   * @param requestCode scanned code
   * @param resultCode result of scanned code
   * @param intent intent
   */
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // retrieve scan result and parse it into an instance of the intent result class
    IntentResult scanningResult =
        IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    // check we have a result
    if (scanningResult != null) {
      // save the result to a string variable
      String scanContent = scanningResult.getContents();
      // put the scan result in a new file
      try {
        FileOutputStream fout = openFileOutput(file, MODE_WORLD_READABLE);
        fout.write(scanContent.getBytes()); // write the result to the file
        fout.close();
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      // Toast message to inform the user that the database has been recorded.
      Toast toast =
          Toast.makeText(
              getApplicationContext(),
              "Medication recorded. Now select pharmacy",
              Toast.LENGTH_LONG);
      toast.getView().setBackgroundColor(Color.WHITE);
      TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
      v.setTextColor(Color.BLACK);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    } else {
      // if no result is recorded inform the user
      Toast toast =
          Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_LONG);
      toast.show();
    }
  }
Exemplo n.º 24
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    barcode = result.getContents(); // Store scanned value here
    // Code for sending barcode variable to ShoppingCartActivity
    intent =
        new Intent(
            getApplicationContext(),
            ShoppingCartActivity.class); // create new Intent for sending to ShoppingCartActivity
    intent.putExtra("barcode", barcode); // Add barcode variable to 'extra' in the Intent
    startActivity(intent);

    // TODO: Delete commented code after ShoppingCartActivity works
    /*
    if(result != null) {
        if(result.getContents() == null) {
            Log.d("MainActivity", "Cancelled scan");
            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
        } else {
            Log.d("MainActivity", "Scanned");
            Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
        }
    } else {
        Log.d("MainActivity", "Weird");
        // This is important, otherwise the result will not be passed to the fragment
        super.onActivityResult(requestCode, resultCode, data);
    }
    */

    // TODO: Add following code block to ShoppingCartActivity after set up
    /*
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        barcode = extras.getString("barcode");
    }
     */
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == EnrollSelectActivity.ACTIVITY_CODE && resultCode == RESULT_OK) {
      updateCredentialList();
    } else if (requestCode == CredentialDetailActivity.ACTIVITY_CODE
        && resultCode == CredentialDetailActivity.RESULT_DELETE) {
      int hashCode = data.getIntExtra(CredentialDetailActivity.ARG_RESULT_DELETE, 0);
      if (hashCode != 0) tryDeleteCredential(hashCode);
    } else if (requestCode == IRMAPreferenceActivity.ACTIVITY_CODE) {
      if (PreferenceManager.getDefaultSharedPreferences(this)
          .getBoolean("allow_screenshots", false))
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
      else
        getWindow()
            .setFlags(
                WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    } else { // Must be from the QR scanner
      MetricsReporter.getInstance()
          .reportAggregrateMeasurement(
              "qr_scan_time", System.currentTimeMillis() - qrScanStartTime);

      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);

      // Process the results from the QR-scanning activity
      if (scanResult == null) return;
      String contents = scanResult.getContents();
      if (contents == null) return;

      IrmaQr qr;
      try {
        qr = GsonUtil.getGson().fromJson(contents, IrmaQr.class);
      } catch (Exception e) {
        irmaClientHandler.onFailure(
            IrmaClient.Action.UNKNOWN, "Not an IRMA session", null, "Content: " + contents);
        return;
      }

      String qrType = qr.getType();
      if (qrType == null) qrType = "";
      switch (qrType) {
        case "schememanager":
          Log.i(TAG, "Adding new scheme manager from qr code!");
          SchemeManagerHandler.confirmAndDownloadManager(
              GsonUtil.getGson().fromJson(contents, SchemeManagerQr.class).getUrl(),
              this,
              new Runnable() {
                @Override
                public void run() {
                  updateCredentialList(false);
                }
              });
          break;
        case "disclosing":
        case "signing":
        case "issuing":
        default:
          launchedFromBrowser = false;
          onlineEnrolling = false;
          IrmaClient.NewSession(contents, irmaClientHandler);
          break;
      }
    }
  }
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   if (scanResult != null) {
     room_no.setText(scanResult.getContents());
   }
 }
Exemplo n.º 27
0
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   Log.i("scan dialog res.", "Ive got data for you!");
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   if (scanResult != null && scanResult.getContents() != "") {
     String jsonResult = scanResult.getContents();
     String servername = null;
     String authtoken = null;
     try {
       JSONObject data = new JSONObject(jsonResult);
       servername = data.getString("host");
       authtoken = data.getString("auth_token");
     } catch (Exception e) {
       AlertDialog alertDialog = new AlertDialog.Builder(this).create();
       alertDialog.setTitle("JSON exception");
       alertDialog.setMessage(e.getMessage());
       alertDialog.setButton(
           "OK",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               return;
             }
           });
       alertDialog.show();
     }
     if (servername != null && authtoken != null) {
       if (servername.endsWith("/tasks")) {
         servername = servername.replaceFirst("/tasks$", "");
       }
       PreferenceManager.getDefaultSharedPreferences(this)
           .edit()
           .putString("servername", servername)
           .commit();
       PreferenceManager.getDefaultSharedPreferences(this)
           .edit()
           .putString("authtoken", authtoken)
           .commit();
       AlertDialog alertDialog = new AlertDialog.Builder(this).create();
       alertDialog.setTitle("QR Code decrypted:");
       alertDialog.setMessage("Server Host: " + servername + "\nToken: " + authtoken);
       alertDialog.setButton(
           "OK",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               finish();
             }
           });
       alertDialog.show();
     }
   } else {
     Log.i("scan dialog res.", "NO RESULT");
     AlertDialog alertDialog = new AlertDialog.Builder(this).create();
     alertDialog.setTitle("No Input");
     alertDialog.setMessage("Could not get QR-Code!");
     alertDialog.setButton(
         "OK",
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             return;
           }
         });
     alertDialog.show();
   }
 }