com.google.zxing.client.result.AddressBookParsedResult Java Examples

The following examples show how to use com.google.zxing.client.result.AddressBookParsedResult. 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: QRCodeEncoder.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #2
Source File: QRCodeEncoder.java    From android-apps with MIT License 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toIterable(contact.getNames()),
                                    contact.getOrg(),
                                    toIterable(contact.getAddresses()),
                                    toIterable(contact.getPhoneNumbers()),
                                    toIterable(contact.getEmails()),
                                    contact.getURL(),
                                    null);
  // Make sure we've encoded at least one field.
  if (encoded[1].length() > 0) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #3
Source File: QRCodeEncoder.java    From reacteu-app with MIT License 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toIterable(contact.getNames()),
                                    contact.getOrg(),
                                    toIterable(contact.getAddresses()),
                                    toIterable(contact.getPhoneNumbers()),
                                    toIterable(contact.getEmails()),
                                    contact.getURL(),
                                    null);
  // Make sure we've encoded at least one field.
  if (encoded[1].length() > 0) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(fakeR.getId("string", "contents_contact"));
  }
}
 
Example #4
Source File: AddressBookResultHandler.java    From android-apps with MIT License 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #5
Source File: AddressBookResultHandler.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  String[] emails = addressResult.getEmails();

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  fields[2] = phoneNumbers != null && phoneNumbers.length > 0;
  fields[3] = emails != null && emails.length > 0;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #6
Source File: QRCodeEncoder.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #7
Source File: AddressBookResultHandler.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
    super(activity, result);
    AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
    String[] addresses = addressResult.getAddresses();
    boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
    String[] phoneNumbers = addressResult.getPhoneNumbers();
    boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
    String[] emails = addressResult.getEmails();
    boolean hasEmailAddress = emails != null && emails.length > 0;

    fields = new boolean[4];
    fields[0] = true; // Add contact is always available
    fields[1] = hasAddress;
    fields[2] = hasPhoneNumber;
    fields[3] = hasEmailAddress;
}
 
Example #8
Source File: AddressBookResultHandler.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #9
Source File: QRCodeEncoder.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #10
Source File: AddressBookResultHandler.java    From android-quick-response-code with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
    super(activity, result);
    AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
    String[] addresses = addressResult.getAddresses();
    boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
    String[] phoneNumbers = addressResult.getPhoneNumbers();
    boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
    String[] emails = addressResult.getEmails();
    boolean hasEmailAddress = emails != null && emails.length > 0;

    fields = new boolean[4];
    fields[0] = true; // Add contact is always available
    fields[1] = hasAddress;
    fields[2] = hasPhoneNumber;
    fields[3] = hasEmailAddress;
}
 
Example #11
Source File: AddressBookResultHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #12
Source File: QRCodeEncoder.java    From weex with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #13
Source File: QRCodeEncoder.java    From zxingfragmentlib with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #14
Source File: AddressBookResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #15
Source File: QRCodeEncoder.java    From ZXing-Orient with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #16
Source File: AddressBookResultHandler.java    From zxingfragmentlib with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #17
Source File: QRCodeEncoder.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #18
Source File: AddressBookResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example #19
Source File: AddressBookResultHandler.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  AddressBookParsedResult addressResult = (AddressBookParsedResult) getResult();
  String[] addresses = addressResult.getAddresses();
  String address1 = addresses == null || addresses.length < 1 ? null : addresses[0];
  String[] addressTypes = addressResult.getAddressTypes();
  String address1Type = addressTypes == null || addressTypes.length < 1 ? null : addressTypes[0];
  int action = mapIndexToAction(index);
  switch (action) {
    case 0:
      addContact(addressResult.getNames(),
                 addressResult.getPronunciation(),
                 addressResult.getPhoneNumbers(),
                 addressResult.getPhoneTypes(),
                 addressResult.getEmails(),
                 addressResult.getEmailTypes(),
                 addressResult.getNote(),
                 addressResult.getInstantMessenger(),
                 address1,
                 address1Type,
                 addressResult.getOrg(),
                 addressResult.getTitle(),
                 addressResult.getURL(),
                 addressResult.getBirthday());
      break;
    case 1:
      String[] names = addressResult.getNames();
      String title = names != null ? names[0] : null;
      searchMap(address1, title);
      break;
    case 2:
      dialPhone(addressResult.getPhoneNumbers()[0]);
      break;
    case 3:
      sendEmail(addressResult.getEmails()[0], null, null);
      break;
    default:
      break;
  }
}
 
Example #20
Source File: QRCodeEncoder.java    From android-apps with MIT License 5 votes vote down vote up
private void encodeContentsFromShareIntentDefault(Intent intent) throws WriterException {
  format = BarcodeFormat.QR_CODE;
  Bundle bundle = intent.getExtras();
  if (bundle == null) {
    throw new WriterException("No extras");
  }
  Uri uri = (Uri) bundle.getParcelable(Intent.EXTRA_STREAM);
  if (uri == null) {
    throw new WriterException("No EXTRA_STREAM");
  }
  byte[] vcard;
  String vcardString;
  try {
    InputStream stream = activity.getContentResolver().openInputStream(uri);
    int length = stream.available();
    if (length <= 0) {
      throw new WriterException("Content stream is empty");
    }
    vcard = new byte[length];
    int bytesRead = stream.read(vcard, 0, length);
    if (bytesRead < length) {
      throw new WriterException("Unable to fully read available bytes from content stream");
    }
    vcardString = new String(vcard, 0, bytesRead, "UTF-8");
  } catch (IOException ioe) {
    throw new WriterException(ioe);
  }
  Log.d(TAG, "Encoding share intent content:");
  Log.d(TAG, vcardString);
  Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
  ParsedResult parsedResult = ResultParser.parseResult(result);
  if (!(parsedResult instanceof AddressBookParsedResult)) {
    throw new WriterException("Result was not an address");
  }
  encodeQRCodeContents((AddressBookParsedResult) parsedResult);
  if (contents == null || contents.length() == 0) {
    throw new WriterException("No content to encode");
  }
}
 
Example #21
Source File: AddressBookResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  AddressBookParsedResult addressResult = (AddressBookParsedResult) getResult();
  String[] addresses = addressResult.getAddresses();
  String address1 = addresses == null || addresses.length < 1 ? null : addresses[0];
  String[] addressTypes = addressResult.getAddressTypes();
  String address1Type = addressTypes == null || addressTypes.length < 1 ? null : addressTypes[0];
  int action = mapIndexToAction(index);
  switch (action) {
    case 0:
      addContact(addressResult.getNames(),
                 addressResult.getPronunciation(),
                 addressResult.getPhoneNumbers(),
                 addressResult.getPhoneTypes(),
                 addressResult.getEmails(),
                 addressResult.getEmailTypes(),
                 addressResult.getNote(),
                 addressResult.getInstantMessenger(),
                 address1,
                 address1Type,
                 addressResult.getOrg(),
                 addressResult.getTitle(),
                 addressResult.getURL(),
                 addressResult.getBirthday());
      break;
    case 1:
      String[] names = addressResult.getNames();
      String title = names != null ? names[0] : null;
      searchMap(address1, title);
      break;
    case 2:
      dialPhone(addressResult.getPhoneNumbers()[0]);
      break;
    case 3:
      sendEmail(addressResult.getEmails()[0], null, null);
      break;
    default:
      break;
  }
}
 
Example #22
Source File: AddressBookResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
   super(activity, result);
BUTTON_TEXTS = new int[]{
     fakeR.getId("string", "button_add_contact"),
     fakeR.getId("string", "button_show_map"),
     fakeR.getId("string", "button_dial"),
     fakeR.getId("string", "button_email"),
   };
   AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
   String[] addresses = addressResult.getAddresses();
   boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
   String[] phoneNumbers = addressResult.getPhoneNumbers();
   boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
   String[] emails = addressResult.getEmails();
   boolean hasEmailAddress = emails != null && emails.length > 0;

   fields = new boolean[MAX_BUTTON_COUNT];
   fields[0] = true; // Add contact is always available
   fields[1] = hasAddress;
   fields[2] = hasPhoneNumber;
   fields[3] = hasEmailAddress;

   buttonCount = 0;
   for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
     if (fields[x]) {
       buttonCount++;
     }
   }
 }
 
Example #23
Source File: QRCodeEncoder.java    From reacteu-app with MIT License 5 votes vote down vote up
private void encodeFromStreamExtra(Intent intent) throws WriterException {
  format = BarcodeFormat.QR_CODE;
  Bundle bundle = intent.getExtras();
  if (bundle == null) {
    throw new WriterException("No extras");
  }
  Uri uri = (Uri) bundle.getParcelable(Intent.EXTRA_STREAM);
  if (uri == null) {
    throw new WriterException("No EXTRA_STREAM");
  }
  byte[] vcard;
  String vcardString;
  try {
    InputStream stream = activity.getContentResolver().openInputStream(uri);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[2048];
    int bytesRead;
    while ((bytesRead = stream.read(buffer)) > 0) {
      baos.write(buffer, 0, bytesRead);
    }
    vcard = baos.toByteArray();
    vcardString = new String(vcard, 0, vcard.length, "UTF-8");
  } catch (IOException ioe) {
    throw new WriterException(ioe);
  }
  Log.d(TAG, "Encoding share intent content:");
  Log.d(TAG, vcardString);
  Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
  ParsedResult parsedResult = ResultParser.parseResult(result);
  if (!(parsedResult instanceof AddressBookParsedResult)) {
    throw new WriterException("Result was not an address");
  }
  encodeQRCodeContents((AddressBookParsedResult) parsedResult);
  if (contents == null || contents.length() == 0) {
    throw new WriterException("No content to encode");
  }
}
 
Example #24
Source File: AddressBookResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  AddressBookParsedResult addressResult = (AddressBookParsedResult) getResult();
  String[] addresses = addressResult.getAddresses();
  String address1 = addresses == null || addresses.length < 1 ? null : addresses[0];
  String[] addressTypes = addressResult.getAddressTypes();
  String address1Type = addressTypes == null || addressTypes.length < 1 ? null : addressTypes[0];
  int action = mapIndexToAction(index);
  switch (action) {
    case 0:
      addContact(addressResult.getNames(),
                 addressResult.getNicknames(),
                 addressResult.getPronunciation(),
                 addressResult.getPhoneNumbers(),
                 addressResult.getPhoneTypes(),
                 addressResult.getEmails(),
                 addressResult.getEmailTypes(),
                 addressResult.getNote(),
                 addressResult.getInstantMessenger(),
                 address1,
                 address1Type,
                 addressResult.getOrg(),
                 addressResult.getTitle(),
                 addressResult.getURLs(),
                 addressResult.getBirthday(),
                 addressResult.getGeo());
      break;
    case 1:
      searchMap(address1);
      break;
    case 2:
      dialPhone(addressResult.getPhoneNumbers()[0]);
      break;
    case 3:
      sendEmail(addressResult.getEmails(), null, null, null, null);
      break;
    default:
      break;
  }
}
 
Example #25
Source File: AddressBookResultHandler.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  AddressBookParsedResult addressResult = (AddressBookParsedResult) getResult();
  String[] addresses = addressResult.getAddresses();
  String address1 = addresses == null || addresses.length < 1 ? null : addresses[0];
  String[] addressTypes = addressResult.getAddressTypes();
  String address1Type = addressTypes == null || addressTypes.length < 1 ? null : addressTypes[0];
  int action = mapIndexToAction(index);
  switch (action) {
    case 0:
      addContact(addressResult.getNames(),
                 addressResult.getNicknames(),
                 addressResult.getPronunciation(),
                 addressResult.getPhoneNumbers(),
                 addressResult.getPhoneTypes(),
                 addressResult.getEmails(),
                 addressResult.getEmailTypes(),
                 addressResult.getNote(),
                 addressResult.getInstantMessenger(),
                 address1,
                 address1Type,
                 addressResult.getOrg(),
                 addressResult.getTitle(),
                 addressResult.getURLs(),
                 addressResult.getBirthday(),
                 addressResult.getGeo());
      break;
    case 1:
      searchMap(address1);
      break;
    case 2:
      dialPhone(addressResult.getPhoneNumbers()[0]);
      break;
    case 3:
      sendEmail(addressResult.getEmails(), null, null, null, null);
      break;
    default:
      break;
  }
}
 
Example #26
Source File: AddressBookResultHandler.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  AddressBookParsedResult addressResult = (AddressBookParsedResult) getResult();
  String[] addresses = addressResult.getAddresses();
  String address1 = addresses == null || addresses.length < 1 ? null : addresses[0];
  String[] addressTypes = addressResult.getAddressTypes();
  String address1Type = addressTypes == null || addressTypes.length < 1 ? null : addressTypes[0];
  int action = mapIndexToAction(index);
  switch (action) {
    case 0:
      addContact(addressResult.getNames(),
                 addressResult.getNicknames(),
                 addressResult.getPronunciation(),
                 addressResult.getPhoneNumbers(),
                 addressResult.getPhoneTypes(),
                 addressResult.getEmails(),
                 addressResult.getEmailTypes(),
                 addressResult.getNote(),
                 addressResult.getInstantMessenger(),
                 address1,
                 address1Type,
                 addressResult.getOrg(),
                 addressResult.getTitle(),
                 addressResult.getURLs(),
                 addressResult.getBirthday(),
                 addressResult.getGeo());
      break;
    case 1:
      searchMap(address1);
      break;
    case 2:
      dialPhone(addressResult.getPhoneNumbers()[0]);
      break;
    case 3:
      sendEmail(addressResult.getEmails(), null, null, null, null);
      break;
    default:
      break;
  }
}
 
Example #27
Source File: AddressBookResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  AddressBookParsedResult addressResult = (AddressBookParsedResult) getResult();
  String[] addresses = addressResult.getAddresses();
  String address1 = addresses == null || addresses.length < 1 ? null : addresses[0];
  String[] addressTypes = addressResult.getAddressTypes();
  String address1Type = addressTypes == null || addressTypes.length < 1 ? null : addressTypes[0];
  int action = mapIndexToAction(index);
  switch (action) {
    case 0:
      addContact(addressResult.getNames(),
                 addressResult.getNicknames(),
                 addressResult.getPronunciation(),
                 addressResult.getPhoneNumbers(),
                 addressResult.getPhoneTypes(),
                 addressResult.getEmails(),
                 addressResult.getEmailTypes(),
                 addressResult.getNote(),
                 addressResult.getInstantMessenger(),
                 address1,
                 address1Type,
                 addressResult.getOrg(),
                 addressResult.getTitle(),
                 addressResult.getURLs(),
                 addressResult.getBirthday(),
                 addressResult.getGeo());
      break;
    case 1:
      searchMap(address1);
      break;
    case 2:
      dialPhone(addressResult.getPhoneNumbers()[0]);
      break;
    case 3:
      sendEmail(addressResult.getEmails(), null, null, null, null);
      break;
    default:
      break;
  }
}
 
Example #28
Source File: QRCodeEncoder.java    From AndroidWebServ with Apache License 2.0 5 votes vote down vote up
private void encodeFromStreamExtra(Intent intent) throws WriterException {
    format = BarcodeFormat.QR_CODE;
    Bundle bundle = intent.getExtras();
    if (bundle == null) {
        throw new WriterException("No extras");
    }
    Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM);
    if (uri == null) {
        throw new WriterException("No EXTRA_STREAM");
    }
    byte[] vcard;
    String vcardString;
    try {
        InputStream stream = activity.getContentResolver().openInputStream(uri);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[2048];
        int bytesRead;
        while ((bytesRead = stream.read(buffer)) > 0) {
            baos.write(buffer, 0, bytesRead);
        }
        vcard = baos.toByteArray();
        vcardString = new String(vcard, 0, vcard.length, "UTF-8");
    } catch (IOException ioe) {
        throw new WriterException(ioe);
    }
    Log.d(TAG, "Encoding share intent content:");
    Log.d(TAG, vcardString);
    Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
    ParsedResult parsedResult = ResultParser.parseResult(result);
    if (!(parsedResult instanceof AddressBookParsedResult)) {
        throw new WriterException("Result was not an address");
    }
    encodeQRCodeContents((AddressBookParsedResult) parsedResult);
    if (contents == null || contents.length() == 0) {
        throw new WriterException("No content to encode");
    }
}
 
Example #29
Source File: ContactResultFragment.java    From privacy-friendly-qr-scanner with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    result = (AddressBookParsedResult) parsedResult;

    View v = inflater.inflate(R.layout.fragment_result_contact, container, false);

    resultList = v.findViewById(R.id.fragment_result_recycler_view);
    resultList.setLayoutManager(new LinearLayoutManager(getContext()));
    resultList.setAdapter(new ContactResultAdapter(result));

    return v;
}
 
Example #30
Source File: QRCodeEncoder.java    From AndroidWebServ with Apache License 2.0 5 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
    ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
    String[] encoded = encoder.encode(toIterable(contact.getNames()), contact.getOrg(),
            toIterable(contact.getAddresses()), toIterable(contact.getPhoneNumbers()),
            toIterable(contact.getEmails()), toIterable(contact.getURLs()), null);
    // Make sure we've encoded at least one field.
    if (encoded[1].length() > 0) {
        contents = encoded[0];
        displayContents = encoded[1];
        title = activity.getString(R.string.contents_contact);
    }
}