Java 类com.google.zxing.client.android.Intents 实例源码

项目:coinblesk-client-gui    文件:SendDialogFragment.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == Constants.QR_ACTIVITY_RESULT_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            final String scanContent = data.getStringExtra(Intents.Scan.RESULT);
            try {
                BitcoinURI bitcoinURI = new BitcoinURI(scanContent);
                if (bitcoinURI.getAddress() != null) {
                    addressEditText.setText(bitcoinURI.getAddress().toString());
                    return;
                }
            } catch (BitcoinURIParseException e) {
                Log.w(TAG, "Could not parse scanned content: '" + scanContent + "'", e);
            }
            // set to scanned content if no address detected
            addressEditText.setText(scanContent);
        }
    }
}
项目:loyalty-card-locker    文件:LoyaltyCardViewActivityTest.java   
/**
 * Register a handler in the package manager for a image capture intent
 */
private void registerMediaStoreIntentHandler()
{
    // Add something that will 'handle' the media capture intent
    RobolectricPackageManager packageManager = shadowOf(RuntimeEnvironment.application.getPackageManager());

    ResolveInfo info = new ResolveInfo();
    info.isDefault = true;

    ApplicationInfo applicationInfo = new ApplicationInfo();
    applicationInfo.packageName = "does.not.matter";
    info.activityInfo = new ActivityInfo();
    info.activityInfo.applicationInfo = applicationInfo;
    info.activityInfo.name = "DoesNotMatter";

    Intent intent = new Intent(Intents.Scan.ACTION);

    packageManager.addResolveInfoForIntent(intent, info);
}
项目:appquest-pedometer    文件:WalkActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IntentIntegrator.REQUEST_CODE
            && resultCode == RESULT_OK) {

        Bundle extras = data.getExtras();
        String commands = extras.getString(
                Intents.Scan.RESULT);
        JSONObject jsonCommands = null;
        try {
            jsonCommands = new JSONObject(commands);
            if (startOrEnd == 's') {
                this.startStation = jsonCommands.getInt("startStation");
                ((TextView) findViewById(R.id.commandOutTextView)).setText(commands);
            } else {
                this.endStation = jsonCommands.getInt("endStation");
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
项目:keepass2android    文件:SearchBookContentsActivity.java   
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
项目:keepass2android    文件:EncodeActivity.java   
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  Intent intent = getIntent();
  if (intent == null) {
    finish();
  } else {
    String action = intent.getAction();
    if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) {
      setContentView(R.layout.encode);
    } else {
      finish();
    }
  }
}
项目:keepass2android    文件:EncodeActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.encode, menu);
  boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
  int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
  MenuItem encodeItem = menu.findItem(R.id.menu_encode);
  encodeItem.setTitle(encodeNameResource);
  Intent intent = getIntent();
  if (intent != null) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
  }
  return super.onCreateOptionsMenu(menu);
}
项目:keepass2android    文件:QRCodeEncoder.java   
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
  this.activity = activity;
  this.dimension = dimension;
  this.useVCard = useVCard;
  String action = intent.getAction();
  if (action.equals(Intents.Encode.ACTION)) {
    encodeContentsFromZXingIntent(intent);
  } else if (action.equals(Intent.ACTION_SEND)) {
    encodeContentsFromShareIntent(intent);
  }
}
项目:keepass2android    文件:QRCodeEncoder.java   
private boolean encodeContentsFromZXingIntent(Intent intent) {
   // Default to QR_CODE if no format given.
  String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
  format = null;
  if (formatString != null) {
    try {
      format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
      // Ignore it then
    }
  }
  if (format == null || format == BarcodeFormat.QR_CODE) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    if (type == null || type.isEmpty()) {
      return false;
    }
    this.format = BarcodeFormat.QR_CODE;
    encodeQRCodeContents(intent, type);
  } else {
    String data = intent.getStringExtra(Intents.Encode.DATA);
    if (data != null && !data.isEmpty()) {
      contents = data;
      displayContents = data;
      title = activity.getString(R.string.contents_text);
    }
  }
  return contents != null && !contents.isEmpty();
}
项目:text_converter    文件:BarCodeCodecFragment.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == IntentIntegrator.REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            final String contents = data.getStringExtra(Intents.Scan.RESULT);
            mInput.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mInput.setText(contents);
                    if (getContext() != null) {
                        Toast.makeText(getContext(), R.string.decoded, Toast.LENGTH_SHORT).show();
                    }
                }
            }, 200);
        }

    } else if (requestCode == REQUEST_PICK_IMAGE) {
        if (resultCode == RESULT_OK) {
            if (mDecodeImageTask != null && !mDecodeImageTask.isCancelled()) {
                mDecodeImageTask.cancel(true);
            }
            mDecodeImageTask = new DecodeImageTask(getContext().getApplicationContext(), mInput);
            mDecodeImageTask.execute(data.getData());
        }

    }
}
项目:weex-3d-map    文件:SearchBookContentsActivity.java   
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
项目:weex-3d-map    文件:ShareActivity.java   
private void launchSearch(String text) {
  Intent intent = new Intent(Intents.Encode.ACTION);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
  intent.putExtra(Intents.Encode.DATA, text);
  intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
  startActivity(intent);
}
项目:weex-3d-map    文件:ShareActivity.java   
private void showTextAsBarcode(String text) {
  Log.i(TAG, "Showing text as barcode: " + text);
  if (text == null) {
    return; // Show error?
  }
  Intent intent = new Intent(Intents.Encode.ACTION);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
  intent.putExtra(Intents.Encode.DATA, text);
  intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
  startActivity(intent);
}
项目:weex-3d-map    文件:EncodeActivity.java   
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  Intent intent = getIntent();
  if (intent == null) {
    finish();
  } else {
    String action = intent.getAction();
    if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) {
      setContentView(R.layout.encode);
    } else {
      finish();
    }
  }
}
项目:weex-3d-map    文件:EncodeActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.encode, menu);
  boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
  int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
  MenuItem encodeItem = menu.findItem(R.id.menu_encode);
  encodeItem.setTitle(encodeNameResource);
  Intent intent = getIntent();
  if (intent != null) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
  }
  return super.onCreateOptionsMenu(menu);
}
项目:weex-3d-map    文件:QRCodeEncoder.java   
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
  this.activity = activity;
  this.dimension = dimension;
  this.useVCard = useVCard;
  String action = intent.getAction();
  if (action.equals(Intents.Encode.ACTION)) {
    encodeContentsFromZXingIntent(intent);
  } else if (action.equals(Intent.ACTION_SEND)) {
    encodeContentsFromShareIntent(intent);
  }
}
项目:weex-3d-map    文件:QRCodeEncoder.java   
private boolean encodeContentsFromZXingIntent(Intent intent) {
   // Default to QR_CODE if no format given.
  String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
  format = null;
  if (formatString != null) {
    try {
      format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
      // Ignore it then
    }
  }
  if (format == null || format == BarcodeFormat.QR_CODE) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    if (type == null || type.isEmpty()) {
      return false;
    }
    this.format = BarcodeFormat.QR_CODE;
    encodeQRCodeContents(intent, type);
  } else {
    String data = intent.getStringExtra(Intents.Encode.DATA);
    if (data != null && !data.isEmpty()) {
      contents = data;
      displayContents = data;
      title = activity.getString(R.string.contents_text);
    }
  }
  return contents != null && !contents.isEmpty();
}
项目:weex-3d-map    文件:ResultHandler.java   
final void searchBookContents(String isbnOrUrl) {
  Intent intent = new Intent(Intents.SearchBookContents.ACTION);
  intent.setClassName(activity, SearchBookContentsActivity.class.getName());
  putExtra(intent, Intents.SearchBookContents.ISBN, isbnOrUrl);
  launchIntent(intent);
}
项目:weex-3d-map    文件:HistoryActivity.java   
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
  if (adapter.getItem(position).getResult() != null) {
    Intent intent = new Intent(this, CaptureActivity.class);
    intent.putExtra(Intents.History.ITEM_NUMBER, position);
    setResult(Activity.RESULT_OK, intent);
    finish();
  }
}
项目:weex-3d-map    文件:HistoryManager.java   
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
项目:KeePass2Android    文件:SearchBookContentsActivity.java   
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
项目:KeePass2Android    文件:EncodeActivity.java   
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  Intent intent = getIntent();
  if (intent == null) {
    finish();
  } else {
    String action = intent.getAction();
    if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) {
      setContentView(R.layout.encode);
    } else {
      finish();
    }
  }
}
项目:KeePass2Android    文件:EncodeActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.encode, menu);
  boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
  int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
  MenuItem encodeItem = menu.findItem(R.id.menu_encode);
  encodeItem.setTitle(encodeNameResource);
  Intent intent = getIntent();
  if (intent != null) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
  }
  return super.onCreateOptionsMenu(menu);
}
项目:KeePass2Android    文件:QRCodeEncoder.java   
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
  this.activity = activity;
  this.dimension = dimension;
  this.useVCard = useVCard;
  String action = intent.getAction();
  if (action.equals(Intents.Encode.ACTION)) {
    encodeContentsFromZXingIntent(intent);
  } else if (action.equals(Intent.ACTION_SEND)) {
    encodeContentsFromShareIntent(intent);
  }
}
项目:KeePass2Android    文件:QRCodeEncoder.java   
private boolean encodeContentsFromZXingIntent(Intent intent) {
   // Default to QR_CODE if no format given.
  String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
  format = null;
  if (formatString != null) {
    try {
      format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
      // Ignore it then
    }
  }
  if (format == null || format == BarcodeFormat.QR_CODE) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    if (type == null || type.isEmpty()) {
      return false;
    }
    this.format = BarcodeFormat.QR_CODE;
    encodeQRCodeContents(intent, type);
  } else {
    String data = intent.getStringExtra(Intents.Encode.DATA);
    if (data != null && !data.isEmpty()) {
      contents = data;
      displayContents = data;
      title = activity.getString(R.string.contents_text);
    }
  }
  return contents != null && !contents.isEmpty();
}
项目:faims-android    文件:HistoryManager.java   
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure()) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
项目:PortraitZXing    文件:SearchBookContentsActivity.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}
项目:PortraitZXing    文件:ShareActivity.java   
private void launchSearch(String text) {
    Intent intent = new Intent(Intents.Encode.ACTION);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
    intent.putExtra(Intents.Encode.DATA, text);
    intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
    startActivity(intent);
}
项目:PortraitZXing    文件:ShareActivity.java   
private void showTextAsBarcode(String text) {
    Log.i(TAG, "Showing text as barcode: " + text);
    if (text == null) {
        return; // Show error?
    }
    Intent intent = new Intent(Intents.Encode.ACTION);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
    intent.putExtra(Intents.Encode.DATA, text);
    intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
    startActivity(intent);
}
项目:PortraitZXing    文件:EncodeActivity.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Intent intent = getIntent();
    if (intent == null) {
        finish();
    } else {
        String action = intent.getAction();
        if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) {
            setContentView(R.layout.encode);
        } else {
            finish();
        }
    }
}
项目:PortraitZXing    文件:EncodeActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.encode, menu);
    boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
    int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
    MenuItem encodeItem = menu.findItem(R.id.menu_encode);
    encodeItem.setTitle(encodeNameResource);
    Intent intent = getIntent();
    if (intent != null) {
        String type = intent.getStringExtra(Intents.Encode.TYPE);
        encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
    }
    return super.onCreateOptionsMenu(menu);
}
项目:PortraitZXing    文件:QRCodeEncoder.java   
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
    this.activity = activity;
    this.dimension = dimension;
    this.useVCard = useVCard;
    String action = intent.getAction();
    if (Intents.Encode.ACTION.equals(action)) {
        encodeContentsFromZXingIntent(intent);
    } else if (Intent.ACTION_SEND.equals(action)) {
        encodeContentsFromShareIntent(intent);
    }
}
项目:PortraitZXing    文件:QRCodeEncoder.java   
private boolean encodeContentsFromZXingIntent(Intent intent) {
    // Default to QR_CODE if no format given.
    String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
    format = null;
    if (formatString != null) {
        try {
            format = BarcodeFormat.valueOf(formatString);
        } catch (IllegalArgumentException iae) {
            // Ignore it then
        }
    }
    if (format == null || format == BarcodeFormat.QR_CODE) {
        String type = intent.getStringExtra(Intents.Encode.TYPE);
        if (type == null || type.isEmpty()) {
            return false;
        }
        this.format = BarcodeFormat.QR_CODE;
        encodeQRCodeContents(intent, type);
    } else {
        String data = intent.getStringExtra(Intents.Encode.DATA);
        if (data != null && !data.isEmpty()) {
            contents = data;
            displayContents = data;
            title = activity.getString(R.string.contents_text);
        }
    }
    return contents != null && !contents.isEmpty();
}
项目:PortraitZXing    文件:HistoryActivity.java   
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    if (adapter.getItem(position).getResult() != null) {
        Intent intent = new Intent(this, CaptureActivity.class);
        intent.putExtra(Intents.History.ITEM_NUMBER, position);
        setResult(Activity.RESULT_OK, intent);
        finish();
    }
}
项目:PortraitZXing    文件:HistoryManager.java   
public void addHistoryItem(Result result, ResultHandler handler) {
    // Do not save this item to the history if the preference is turned off,
    // or the contents are
    // considered secure.
    if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) || handler.areContentsSecure()
            || !enableHistory) {
        return;
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
        deletePrevious(result.getText());
    }

    ContentValues values = new ContentValues();
    values.put(DBHelper.TEXT_COL, result.getText());
    values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
    values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
    values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

    SQLiteOpenHelper helper = new DBHelper(activity);
    SQLiteDatabase db = null;
    try {
        db = helper.getWritableDatabase();
        // Insert the new entry into the DB.
        db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
    } finally {
        close(null, db);
    }
}
项目:PortraitZXing    文件:SearchBookContentsActivity.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}
项目:PortraitZXing    文件:ShareActivity.java   
private void launchSearch(String text) {
    Intent intent = new Intent(Intents.Encode.ACTION);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
    intent.putExtra(Intents.Encode.DATA, text);
    intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
    startActivity(intent);
}
项目:PortraitZXing    文件:ShareActivity.java   
private void showTextAsBarcode(String text) {
    Log.i(TAG, "Showing text as barcode: " + text);
    if (text == null) {
        return; // Show error?
    }
    Intent intent = new Intent(Intents.Encode.ACTION);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
    intent.putExtra(Intents.Encode.DATA, text);
    intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
    startActivity(intent);
}
项目:PortraitZXing    文件:EncodeActivity.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Intent intent = getIntent();
    if (intent == null) {
        finish();
    } else {
        String action = intent.getAction();
        if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) {
            setContentView(R.layout.encode);
        } else {
            finish();
        }
    }
}
项目:PortraitZXing    文件:EncodeActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.encode, menu);
    boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
    int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
    MenuItem encodeItem = menu.findItem(R.id.menu_encode);
    encodeItem.setTitle(encodeNameResource);
    Intent intent = getIntent();
    if (intent != null) {
        String type = intent.getStringExtra(Intents.Encode.TYPE);
        encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
    }
    return super.onCreateOptionsMenu(menu);
}
项目:PortraitZXing    文件:QRCodeEncoder.java   
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
    this.activity = activity;
    this.dimension = dimension;
    this.useVCard = useVCard;
    String action = intent.getAction();
    if (Intents.Encode.ACTION.equals(action)) {
        encodeContentsFromZXingIntent(intent);
    } else if (Intent.ACTION_SEND.equals(action)) {
        encodeContentsFromShareIntent(intent);
    }
}