List of usage examples for android.text TextUtils isGraphic
@Deprecated public static boolean isGraphic(char c)
From source file:com.android.contacts.common.ContactsUtils.java
/** * Test if the given {@link CharSequence} contains any graphic characters, * first checking {@link TextUtils#isEmpty(CharSequence)} to handle null. *///from w ww.j ava2 s . c o m public static boolean isGraphic(CharSequence str) { return !TextUtils.isEmpty(str) && TextUtils.isGraphic(str); }
From source file:com.android.messaging.datamodel.media.VCardResourceEntry.java
private static List<VCardResourceEntryDestinationItem> getContactInfoFromVCardEntry(final VCardEntry vcard) { final Resources resources = Factory.get().getApplicationContext().getResources(); final List<VCardResourceEntry.VCardResourceEntryDestinationItem> retList = new ArrayList<VCardResourceEntry.VCardResourceEntryDestinationItem>(); if (vcard.getPhoneList() != null) { for (final PhoneData phone : vcard.getPhoneList()) { final Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + phone.getNumber())); retList.add(new VCardResourceEntryDestinationItem(phone.getNumber(), Phone.getTypeLabel(resources, phone.getType(), phone.getLabel()).toString(), intent)); }/* w w w .ja v a2 s.co m*/ } if (vcard.getEmailList() != null) { for (final EmailData email : vcard.getEmailList()) { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email.getAddress() }); retList.add(new VCardResourceEntryDestinationItem(email.getAddress(), Phone.getTypeLabel(resources, email.getType(), email.getLabel()).toString(), intent)); } } if (vcard.getPostalList() != null) { for (final PostalData postalData : vcard.getPostalList()) { String type; try { type = resources.getStringArray(android.R.array.postalAddressTypes)[postalData.getType() - 1]; } catch (final NotFoundException ex) { type = resources.getStringArray(android.R.array.postalAddressTypes)[2]; } catch (final Exception e) { LogUtil.e(LogUtil.BUGLE_TAG, "createContactItem postal Exception:" + e); type = resources.getStringArray(android.R.array.postalAddressTypes)[2]; } Intent intent = new Intent(Intent.ACTION_VIEW); final String address = formatAddress(postalData); try { intent.setData(Uri.parse("geo:0,0?q=" + URLEncoder.encode(address, "UTF-8"))); } catch (UnsupportedEncodingException e) { intent = null; } retList.add(new VCardResourceEntryDestinationItem(address, type, intent)); } } if (vcard.getImList() != null) { for (final ImData imData : vcard.getImList()) { String type = null; try { type = resources.getString(Im.getProtocolLabelResource(imData.getProtocol())); } catch (final NotFoundException ex) { // Do nothing since this implies an empty label. } retList.add(new VCardResourceEntryDestinationItem(imData.getAddress(), type, null)); } } if (vcard.getOrganizationList() != null) { for (final OrganizationData organtization : vcard.getOrganizationList()) { String type = null; try { type = resources.getString(Organization.getTypeLabelResource(organtization.getType())); } catch (final NotFoundException ex) { //set other kind as "other" type = resources.getStringArray(android.R.array.organizationTypes)[1]; } catch (final Exception e) { LogUtil.e(LogUtil.BUGLE_TAG, "createContactItem org Exception:" + e); type = resources.getStringArray(android.R.array.organizationTypes)[1]; } retList.add(new VCardResourceEntryDestinationItem(organtization.getOrganizationName(), type, null)); } } if (vcard.getWebsiteList() != null) { for (final WebsiteData web : vcard.getWebsiteList()) { if (web != null && TextUtils.isGraphic(web.getWebsite())) { String website = web.getWebsite(); if (!website.startsWith("http://") && !website.startsWith("https://")) { // Prefix required for parsing to end up with a scheme and result in // navigation website = "http://" + website; } final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(website)); retList.add(new VCardResourceEntryDestinationItem(web.getWebsite(), null, intent)); } } } if (vcard.getBirthday() != null) { final String birthday = vcard.getBirthday(); if (TextUtils.isGraphic(birthday)) { retList.add(new VCardResourceEntryDestinationItem(birthday, resources.getString(R.string.vcard_detail_birthday_label), null)); } } if (vcard.getNotes() != null) { for (final NoteData note : vcard.getNotes()) { final ArrayMap<String, String> curChildMap = new ArrayMap<String, String>(); if (TextUtils.isGraphic(note.getNote())) { retList.add(new VCardResourceEntryDestinationItem(note.getNote(), resources.getString(R.string.vcard_detail_notes_label), null)); } } } return retList; }
From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java
/** * Check the data inserted into the form and it all the required fields are present, * then it adds the contact into DB/*from w w w. j av a 2 s . c o m*/ */ private boolean checkAndInsert() { final Activity activity = getActivity(); if (activity == null) { Log.e(TAG, "Not attached to Activity: cannot insert contact in DB"); return true; // We can close, there's nothing to do anyway } String email = null; ArrayList<String> name = new ArrayList<String>(1), organization = new ArrayList<String>(1), title = new ArrayList<String>(1); if (mNameEditText != null && mNameEditText.getText() != null) { name.add(mNameEditText.getText().toString()); } if (mEmailEditText != null && mEmailEditText.getText() != null) { email = mEmailEditText.getText().toString(); } if (mOrganizationEditText != null && mOrganizationEditText.getText() != null && TextUtils.isGraphic(mOrganizationEditText.getText())) { organization.add(mOrganizationEditText.getText().toString()); } if (mTitleEditText != null && mTitleEditText.getText() != null && TextUtils.isGraphic(mTitleEditText.getText())) { title.add(mTitleEditText.getText().toString()); } if (activity instanceof MainActivity) { final MainActivity mainActivity = (MainActivity) activity; if (!isValidEmailAddress(email)) { // Empty or invalid email field! showEmailError(activity.getString(R.string.error_emailinput_invalid), 1); return false; } if (DataHelper.isEmailAlreadyPresent(mainActivity, email)) { // We add each email only once showEmailError(activity.getString(R.string.error_emailinput_duplicate), 2); return false; } if (DataHelper.insertContact(mainActivity, name, email, organization, title)) { mainActivity.showCroutonNao(activity.getString(R.string.new_contact_added, email), Style.CONFIRM); mainActivity.updateParticipantsCount(); return true; } return false; } else { Log.e(TAG, "The parent Activity is not MainActivity! Wat is this I don't even"); if (DEBUG) Log.d(TAG, "Activity class: " + activity.getLocalClassName()); Toast.makeText(activity, activity.getString(R.string.insert_failed_wrong_parent), Toast.LENGTH_SHORT) .show(); return true; // We can close, there's nothing to do anyway } }
From source file:org.wikipedia.edit.EditSectionActivity.java
private void scrollToHighlight(@Nullable final String highlightText) { if (highlightText == null || !TextUtils.isGraphic(highlightText)) { return;/*w w w.ja va 2 s . com*/ } sectionText.post(new Runnable() { @Override public void run() { sectionContainer.fullScroll(View.FOCUS_DOWN); final int scrollDelayMs = 500; sectionText.postDelayed(new Runnable() { @Override public void run() { setHighlight(highlightText); } }, scrollDelayMs); } }); }