@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.cart_add_by_voice:
       Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
       intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
       intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.cart_add_voice_prompt));
       intent.putExtra(
           RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
       intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
       startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
       break;
     case R.id.cart_add_by_barcode:
       IntentIntegrator integrator = new IntentIntegrator(this);
       integrator.initiateScan();
       break;
     case android.R.id.home:
       if (mDrawerLayout.isDrawerOpen(mDrawerList)) mDrawerLayout.closeDrawer(mDrawerList);
       else {
         // Specify the parent activity
         Intent parentActivityIntent = new Intent(this, ShopCartOverviewFragmentActivity.class);
         parentActivityIntent.addFlags(
             Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(parentActivityIntent);
         this.finish();
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.btnScan) {
      // Initiate scan
      IntentIntegrator scanIntegrator = new IntentIntegrator(this);

      scanIntegrator.initiateScan();
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       return tabManager.onAndroidHome(item);
     case R.id.menu_login:
       Intent intent = new Intent(this, ConnectionAssistantActivity.class);
       lastTab = tabManager.getCurrentTab();
       //				tabManager.switchToTab(RallyeTabManager.TAB_WAIT_FOR_MODEL);
       startActivityForResult(intent, ConnectionAssistantActivity.REQUEST_CODE);
       break;
     case R.id.menu_logout:
       new AlertDialog.Builder(this)
           .setTitle(R.string.logout)
           .setMessage(R.string.are_you_sure)
           .setCancelable(true)
           .setNegativeButton(android.R.string.cancel, null)
           .setPositiveButton(
               android.R.string.ok,
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   server.logout();
                 }
               })
           .create()
           .show();
       server.tryLogout();
       break;
     case R.id.menu_upload_overview:
       intent = new Intent(this, UploadOverviewActivity.class);
       startActivity(intent);
       break;
     case R.id.menu_share_barcode:
       IntentIntegrator zx = new IntentIntegrator(this);
       ObjectMapper mapper = Serialization.getJsonInstance();
       try {
         zx.shareText(mapper.writeValueAsString(server.exportLogin()));
       } catch (JsonProcessingException e) {
         Log.e(THIS, "Could not serialize exported Login", e);
         Toast.makeText(this, R.string.export_barcode_error, Toast.LENGTH_SHORT).show();
       }
       break;
       //			case R.id.menu_reconnect: //there is no more temporary offline, we cannot know if push
       // messages will reach us
       //				model.reconnect();
       //				break;
     case R.id.menu_settings:
       intent = new Intent(this, SettingsActivity.class);
       startActivity(intent);
       break;
     default:
       return false;
   }
   return true;
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.webModeration:
       IntentIntegrator integrator = new IntentIntegrator(this);
       integrator.setCaptureActivity(CaptureActivityAnyOrientation.class);
       integrator.setOrientationLocked(false);
       integrator.initiateScan();
   }
   return super.onOptionsItemSelected(item);
 }
예제 #5
0
 public void onClick(View view) {
   if (isEmulator()) {
     searchBook("9789631186192");
   } else {
     IntentIntegrator.initiateScan(this);
   }
 }
예제 #6
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   if (scanResult != null) {
     searchBook(scanResult.getContents());
   }
 }
  // 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);
  }
예제 #8
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.scan:
       wrapInstallDialog(integrator.initiateScan(IntentIntegrator.QR_CODE_TYPES));
       break;
     case R.id.show:
       wrapInstallDialog(integrator.shareText(localFingerprint));
       break;
     case R.id.copy:
       ((ClipboardManager) getSystemService(CLIPBOARD_SERVICE))
           .setText(((TextView) findViewById(R.id.otr_local_fingerprint)).getText());
       break;
     default:
       break;
   }
 }
  @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());
    }
  }
예제 #10
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());
   }
 }
 public void scanNow() {
   IntentIntegrator integrator = new IntentIntegrator(this);
   integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
   integrator.setPrompt("Scan a barcode");
   integrator.setResultDisplayDuration(0);
   integrator.setWide(); // Wide scanning rectangle, may work better for 1D barcodes
   integrator.setCameraId(0); // Use a specific camera of the device
   integrator.initiateScan();
 }
예제 #12
0
파일: Dashboard.java 프로젝트: dreab8/eCard
 @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
     }
   }
 }
 @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();
   }
 }
예제 #14
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);
   }
 }
예제 #15
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();
   }
 }
예제 #16
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();
   }
 }
  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();
    }
  }
예제 #18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ii = new IntentIntegrator(this);

    Bundle content = getIntent().getExtras();
    if (content != null) {
      String user = content.getString(LoginReferences.USERNAME),
          pass = content.getString(LoginReferences.PASSWORD);
      // TODO create format login
      ii.shareText(user + "\n" + pass);
    }
    finish();
  }
예제 #19
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);
        }
      }
    }
  }
 @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);
   }
 }
예제 #21
0
 private void startScannerApplication() {
   final IntentIntegrator integrator = new IntentIntegrator(this);
   // integrator dialog is English only, therefore localize it
   integrator.setButtonYesByID(android.R.string.yes);
   integrator.setButtonNoByID(android.R.string.no);
   integrator.setTitleByID(R.string.menu_scan_geo);
   integrator.setMessageByID(R.string.menu_scan_description);
   integrator.initiateScan(IntentIntegrator.QR_CODE_TYPES);
 }
  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;
  }
예제 #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bar_code);

    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setCaptureActivity(AnyOrientationCaptureActivity.class);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
    integrator.setPrompt("Scan something"); // Optional- take out or change if needed
    integrator.setOrientationLocked(false); // Scanning can be done in any orientation
    integrator.setBeepEnabled(false);
    integrator.initiateScan();
  }
  /**
   * 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();
    }
  }
예제 #25
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();
   }
 }
예제 #26
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null && resultCode == RESULT_OK) {

      // BIG HACK
      search("oreo");
      // Toast.makeText(this, "Contents: " + scanResult.getContents() +
      // "FormatName: " + scanResult.getFormatName(),
      // Toast.LENGTH_LONG).show();
    }

    if (requestCode == TTS_TEXT_RESULT && resultCode == RESULT_OK) {
      search(intent.getStringExtra("WORD"));
    }
  }
예제 #27
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   final IntentResult scanningResult =
       IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   System.out.println("*****************************RESULTADO");
   handleResult(scanningResult);
   /* if (scanningResult != null) {
       String scanContent = scanningResult.getContents();
       String scanFormat = scanningResult.getFormatName();
       txtCodigo.setText("CODIGO: "+ scanContent );
       txtTipo.setText("TIPO: "+ scanFormat);
   } 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();
  }
예제 #29
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);
   }
 }
예제 #30
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();
    }
  }