List of usage examples for android.content Intent ACTION_SENDTO
String ACTION_SENDTO
To view the source code for android.content Intent ACTION_SENDTO.
Click Source Link
From source file:com.dsdar.thosearoundme.TeamViewActivity.java
@Override public boolean onMarkerClick(final Marker theMarker) { if (theMarker.equals(MyAppConstants.myMarker)) { return false; }/* w ww . j a v a2s . com*/ // Normal Marker if (!theMarker.equals(MyAppConstants.myMarker) && (theMarker.getTitle() != null)) { final Dialog aMemberDialog = new Dialog(TeamViewActivity.this, R.style.DialogSlideAnim); aMemberDialog.setContentView(R.layout.member_dialog); TextView aMemberTextName = (TextView) aMemberDialog.findViewById(R.id.tvMemberName); Button aTextButton = (Button) aMemberDialog.findViewById(R.id.bMemberText); Button aPushButton = (Button) aMemberDialog.findViewById(R.id.bMemberPush); Button aCallButton = (Button) aMemberDialog.findViewById(R.id.bMemberCall); Button aRemoveButton = (Button) aMemberDialog.findViewById(R.id.bMemberRemove); String[] res = theMarker.getTitle().split("~"); String title = res[0]; final String phone = res[1]; aMemberTextName.setText("Say hello to " + title + "!"); aMemberDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); aMemberDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); aMemberDialog.getWindow().setGravity(Gravity.BOTTOM); aMemberDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); aMemberDialog.show(); ImageView aCancelButton = (ImageView) aMemberDialog.findViewById(R.id.bCancelMemberDialog); aCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { aMemberDialog.dismiss(); } }); aTextButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Uri sms_uri = Uri.parse("smsto:" + phone); Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri); startActivity(sms_intent); } }); // aPushButton.setOnClickListener(new OnClickListener() { // public void onClick(View v) { // // startActivity(new Intent(Intent.ACTION_VIEW, // // Uri.parse("sms:" // // + theMarker.getSnippet()))); // } // }); aCallButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + phone)); startActivity(callIntent); } }); // aRemoveButton.setOnClickListener(new OnClickListener() { // public void onClick(View v) { // } // }); } else { StickyMarkerBehaviorDialog dialog = new StickyMarkerBehaviorDialog(this); dialog.show(); } return true; }
From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings_menu_item: Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivityForResult(settingsIntent, SETTINGS_ACTIVITY_REQUEST_CODE); return true; case R.id.about_menu_item: new MaterialDialog.Builder(this) .title(getString(R.string.app_name) + " " + getString(R.string.app_version_name) + " 20152017 F8Full") //http://stackoverflow.com/questions/4471025/how-can-you-get-the-manifest-version-number-from-the-apps-layout-xml-variable--> .items(R.array.about_dialog_items) .icon(ContextCompat.getDrawable(NearbyActivity.this, R.drawable.logo_48dp)).autoDismiss(false) .itemsCallback(new MaterialDialog.ListCallback() { @Override//from w w w . ja v a 2 s. c o m public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { Intent intent; switch (which) { case 0: startActivity(Utils.getWebIntent(NearbyActivity.this, "http://www.citybik.es", true, text.toString())); break; case 1: intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.ludoscity.findmybikes")); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } break; case 2: String url = "https://www.facebook.com/findmybikes/"; Uri uri; try { getPackageManager().getPackageInfo("com.facebook.katana", 0); // http://stackoverflow.com/questions/24526882/open-facebook-page-from-android-app-in-facebook-version-v11 uri = Uri.parse("fb://facewebmodal/f?href=" + url); intent = new Intent(Intent.ACTION_VIEW, uri); } catch (PackageManager.NameNotFoundException e) { intent = Utils.getWebIntent(NearbyActivity.this, url, true, text.toString()); } //Seen ActivityNotFoundException in firebase cloud lab (FB package found but can't be launched) if (intent.resolveActivity(getPackageManager()) == null) intent = Utils.getWebIntent(NearbyActivity.this, url, true, text.toString()); startActivity(intent); break; case 3: intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle this intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "ludos+findmybikesfeedback" + getString(R.string.app_version_name) + "@ludoscity.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject)); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } break; case 4: new LicensesDialog.Builder(NearbyActivity.this).setNotices(R.raw.notices).build() .show(); break; case 5: intent = new Intent(NearbyActivity.this, WebViewActivity.class); intent.putExtra(WebViewActivity.EXTRA_URL, "file:///android_res/raw/privacy_policy.html"); intent.putExtra(WebViewActivity.EXTRA_ACTIONBAR_SUBTITLE, getString(R.string.hashtag_privacy)); startActivity(intent); break; case 6: try { // get the Twitter app if possible getPackageManager().getPackageInfo("com.twitter.android", 0); intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=findmybikesdata")); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } catch (PackageManager.NameNotFoundException e) { // no Twitter app, revert to browser intent = Utils.getWebIntent(NearbyActivity.this, "https://twitter.com/findmybikesdata", true, text.toString()); } if (intent.resolveActivity(getPackageManager()) == null) intent = Utils.getWebIntent(NearbyActivity.this, "https://twitter.com/findmybikesdata", true, text.toString()); startActivity(intent); break; case 7: intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/f8full/ludOScity/tree/master/FindMyBikes")); startActivity(intent); break; } } }).show(); return true; } return super.onOptionsItemSelected(item); }
From source file:jackpal.androidterm.Term.java
private void doEmailTranscript() { TermSession session = getCurrentTermSession(); if (session != null) { // Don't really want to supply an address, but // currently it's required, otherwise nobody // wants to handle the intent. String addr = "user@example.com"; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + addr)); String subject = getString(R.string.email_transcript_subject); String title = session.getTitle(); if (title != null) { subject = subject + " - " + title; }// ww w .j a v a 2 s.c om intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, session.getTranscriptText().trim()); try { startActivity(Intent.createChooser(intent, getString(R.string.email_transcript_chooser_title))); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.email_transcript_no_email_activity_found, Toast.LENGTH_LONG).show(); } } }
From source file:org.kontalk.ui.ComposeMessageFragment.java
private void processArguments(Bundle savedInstanceState) { Bundle args;/*from www . j a va2 s. co m*/ if (savedInstanceState != null) { Uri uri = savedInstanceState.getParcelable(Uri.class.getName()); // threadId = ContentUris.parseId(uri); args = new Bundle(); args.putString("action", ComposeMessage.ACTION_VIEW_USERID); args.putParcelable("data", uri); String currentPhoto = savedInstanceState.getString("currentPhoto"); if (currentPhoto != null) { mCurrentPhoto = new File(currentPhoto); } mAudioDialog = AudioDialog.onRestoreInstanceState(getActivity(), savedInstanceState, getAudioFragment(), this); if (mAudioDialog != null) { Log.d(TAG, "recreating audio dialog"); mAudioDialog.show(); } } else { args = myArguments(); } if (args != null && args.size() > 0) { final String action = args.getString("action"); // view intent if (Intent.ACTION_VIEW.equals(action)) { Uri uri = args.getParcelable("data"); ContentResolver cres = getActivity().getContentResolver(); /* * FIXME this will retrieve name directly from contacts, * resulting in a possible discrepancy with users database */ Cursor c = cres.query(uri, new String[] { Syncer.DATA_COLUMN_DISPLAY_NAME, Syncer.DATA_COLUMN_PHONE }, null, null, null); if (c.moveToFirst()) { mUserName = c.getString(0); mUserPhone = c.getString(1); // FIXME should it be retrieved from RawContacts.SYNC3 ?? mUserJID = XMPPUtils.createLocalJID(getActivity(), MessageUtils.sha1(mUserPhone)); Cursor cp = cres.query(Messages.CONTENT_URI, new String[] { Messages.THREAD_ID }, Messages.PEER + " = ?", new String[] { mUserJID }, null); if (cp.moveToFirst()) threadId = cp.getLong(0); cp.close(); } c.close(); if (threadId > 0) { mConversation = Conversation.loadFromId(getActivity(), threadId); } else { mConversation = Conversation.createNew(getActivity()); mConversation.setRecipient(mUserJID); } } // view conversation - just threadId provided else if (ComposeMessage.ACTION_VIEW_CONVERSATION.equals(action)) { Uri uri = args.getParcelable("data"); loadConversationMetadata(uri); } // view conversation - just userId provided else if (ComposeMessage.ACTION_VIEW_USERID.equals(action)) { Uri uri = args.getParcelable("data"); mUserJID = uri.getPathSegments().get(1); mConversation = Conversation.loadFromUserId(getActivity(), mUserJID); if (mConversation == null) { mConversation = Conversation.createNew(getActivity()); mConversation.setNumberHint(args.getString("number")); mConversation.setRecipient(mUserJID); } // this way avoid doing the users database query twice else { if (mConversation.getContact() == null) { mConversation.setNumberHint(args.getString("number")); mConversation.setRecipient(mUserJID); } } threadId = mConversation.getThreadId(); Contact contact = mConversation.getContact(); if (contact != null) { mUserName = contact.getName(); mUserPhone = contact.getNumber(); } else { mUserName = mUserJID; mUserPhone = null; } } } // set title if we are autonomous if (mArguments != null) { String title = mUserName; //if (mUserPhone != null) title += " <" + mUserPhone + ">"; setActivityTitle(title, ""); } // update conversation stuff if (mConversation != null) onConversationCreated(); // non existant thread - check for not synced contact if (threadId <= 0 && mConversation != null) { Contact contact = mConversation.getContact(); if (mUserPhone != null && contact != null ? !contact.isRegistered() : true) { // ask user to send invitation DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // FIXME is this specific to sms app? Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + mUserPhone)); i.putExtra("sms_body", getString(R.string.text_invite_message)); startActivity(i); getActivity().finish(); } }; AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(getActivity()); builder.setTitle(R.string.title_user_not_found).setMessage(R.string.message_user_not_found) // nothing happens if user chooses to contact the user anyway .setPositiveButton(R.string.yes_user_not_found, null) .setNegativeButton(R.string.no_user_not_found, noListener).show(); } } }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
/** * Converts a {@link DataItem} into an {@link ExpandingEntryCardView.Entry} for display. * If the {@link ExpandingEntryCardView.Entry} has no visual elements, null is returned. * * This runs on a background thread. This is set as static to avoid accidentally adding * additional dependencies on unsafe things (like the Activity). * * @param dataItem The {@link DataItem} to convert. * @param secondDataItem A second {@link DataItem} to help build a full entry for some * mimetypes//w w w .j ava 2 s. c o m * @return The {@link ExpandingEntryCardView.Entry}, or null if no visual elements are present. */ private static Entry dataItemToEntry(DataItem dataItem, DataItem secondDataItem, Context context, Contact contactData, final MutableString aboutCardName) { Drawable icon = null; String header = null; String subHeader = null; Drawable subHeaderIcon = null; String text = null; Drawable textIcon = null; StringBuilder primaryContentDescription = new StringBuilder(); Spannable phoneContentDescription = null; Spannable smsContentDescription = null; Intent intent = null; boolean shouldApplyColor = true; Drawable alternateIcon = null; Intent alternateIntent = null; StringBuilder alternateContentDescription = new StringBuilder(); final boolean isEditable = false; EntryContextMenuInfo entryContextMenuInfo = null; Drawable thirdIcon = null; Intent thirdIntent = null; int thirdAction = Entry.ACTION_NONE; String thirdContentDescription = null; Bundle thirdExtras = null; int iconResourceId = 0; context = context.getApplicationContext(); final Resources res = context.getResources(); DataKind kind = dataItem.getDataKind(); if (dataItem instanceof ImDataItem) { final ImDataItem im = (ImDataItem) dataItem; intent = ContactsUtils.buildImIntent(context, im).first; final boolean isEmail = im.isCreatedFromEmail(); final int protocol; if (!im.isProtocolValid()) { protocol = Im.PROTOCOL_CUSTOM; } else { protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : im.getProtocol(); } if (protocol == Im.PROTOCOL_CUSTOM) { // If the protocol is custom, display the "IM" entry header as well to distinguish // this entry from other ones header = res.getString(R.string.header_im_entry); subHeader = Im.getProtocolLabel(res, protocol, im.getCustomProtocol()).toString(); text = im.getData(); } else { header = Im.getProtocolLabel(res, protocol, im.getCustomProtocol()).toString(); subHeader = im.getData(); } entryContextMenuInfo = new EntryContextMenuInfo(im.getData(), header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); } else if (dataItem instanceof OrganizationDataItem) { final OrganizationDataItem organization = (OrganizationDataItem) dataItem; header = res.getString(R.string.header_organization_entry); subHeader = organization.getCompany(); entryContextMenuInfo = new EntryContextMenuInfo(subHeader, header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); text = organization.getTitle(); } else if (dataItem instanceof NicknameDataItem) { final NicknameDataItem nickname = (NicknameDataItem) dataItem; // Build nickname entries final boolean isNameRawContact = (contactData.getNameRawContactId() == dataItem.getRawContactId()); final boolean duplicatesTitle = isNameRawContact && contactData.getDisplayNameSource() == DisplayNameSources.NICKNAME; if (!duplicatesTitle) { header = res.getString(R.string.header_nickname_entry); subHeader = nickname.getName(); entryContextMenuInfo = new EntryContextMenuInfo(subHeader, header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); } } else if (dataItem instanceof NoteDataItem) { final NoteDataItem note = (NoteDataItem) dataItem; header = res.getString(R.string.header_note_entry); subHeader = note.getNote(); entryContextMenuInfo = new EntryContextMenuInfo(subHeader, header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); } else if (dataItem instanceof WebsiteDataItem) { final WebsiteDataItem website = (WebsiteDataItem) dataItem; header = res.getString(R.string.header_website_entry); subHeader = website.getUrl(); entryContextMenuInfo = new EntryContextMenuInfo(subHeader, header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); try { final WebAddress webAddress = new WebAddress(website.buildDataStringForDisplay(context, kind)); intent = new Intent(Intent.ACTION_VIEW, Uri.parse(webAddress.toString())); } catch (final ParseException e) { Log.e(TAG, "Couldn't parse website: " + website.buildDataStringForDisplay(context, kind)); } } else if (dataItem instanceof EventDataItem) { final EventDataItem event = (EventDataItem) dataItem; final String dataString = event.buildDataStringForDisplay(context, kind); final Calendar cal = DateUtils.parseDate(dataString, false); if (cal != null) { final Date nextAnniversary = DateUtils.getNextAnnualDate(cal); final Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath("time"); ContentUris.appendId(builder, nextAnniversary.getTime()); intent = new Intent(Intent.ACTION_VIEW).setData(builder.build()); } header = res.getString(R.string.header_event_entry); if (event.hasKindTypeColumn(kind)) { subHeader = EventCompat.getTypeLabel(res, event.getKindTypeColumn(kind), event.getLabel()) .toString(); } text = DateUtils.formatDate(context, dataString); entryContextMenuInfo = new EntryContextMenuInfo(text, header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); } else if (dataItem instanceof RelationDataItem) { final RelationDataItem relation = (RelationDataItem) dataItem; final String dataString = relation.buildDataStringForDisplay(context, kind); if (!TextUtils.isEmpty(dataString)) { intent = new Intent(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, dataString); intent.setType(Contacts.CONTENT_TYPE); } header = res.getString(R.string.header_relation_entry); subHeader = relation.getName(); entryContextMenuInfo = new EntryContextMenuInfo(subHeader, header, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); if (relation.hasKindTypeColumn(kind)) { text = Relation.getTypeLabel(res, relation.getKindTypeColumn(kind), relation.getLabel()).toString(); } } else if (dataItem instanceof PhoneDataItem) { final PhoneDataItem phone = (PhoneDataItem) dataItem; String phoneLabel = null; if (!TextUtils.isEmpty(phone.getNumber())) { primaryContentDescription.append(res.getString(R.string.call_other)).append(" "); header = sBidiFormatter.unicodeWrap(phone.buildDataStringForDisplay(context, kind), TextDirectionHeuristics.LTR); entryContextMenuInfo = new EntryContextMenuInfo(header, res.getString(R.string.phoneLabelsGroup), dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); if (phone.hasKindTypeColumn(kind)) { final int kindTypeColumn = phone.getKindTypeColumn(kind); final String label = phone.getLabel(); phoneLabel = label; if (kindTypeColumn == Phone.TYPE_CUSTOM && TextUtils.isEmpty(label)) { text = ""; } else { text = Phone.getTypeLabel(res, kindTypeColumn, label).toString(); phoneLabel = text; primaryContentDescription.append(text).append(" "); } } primaryContentDescription.append(header); phoneContentDescription = com.android.contacts.common.util.ContactDisplayUtils .getTelephoneTtsSpannable(primaryContentDescription.toString(), header); icon = res.getDrawable(R.drawable.ic_phone_24dp); iconResourceId = R.drawable.ic_phone_24dp; if (PhoneCapabilityTester.isPhone(context)) { intent = CallUtil.getCallIntent(phone.getNumber()); } alternateIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phone.getNumber(), null)); alternateIcon = res.getDrawable(R.drawable.ic_message_24dp); alternateContentDescription.append(res.getString(R.string.sms_custom, header)); smsContentDescription = com.android.contacts.common.util.ContactDisplayUtils .getTelephoneTtsSpannable(alternateContentDescription.toString(), header); int videoCapability = CallUtil.getVideoCallingAvailability(context); boolean isPresenceEnabled = (videoCapability & CallUtil.VIDEO_CALLING_PRESENCE) != 0; boolean isVideoEnabled = (videoCapability & CallUtil.VIDEO_CALLING_ENABLED) != 0; if (CallUtil.isCallWithSubjectSupported(context)) { thirdIcon = res.getDrawable(R.drawable.ic_call_note_white_24dp); thirdAction = Entry.ACTION_CALL_WITH_SUBJECT; thirdContentDescription = res.getString(R.string.call_with_a_note); // Create a bundle containing the data the call subject dialog requires. thirdExtras = new Bundle(); thirdExtras.putLong(CallSubjectDialog.ARG_PHOTO_ID, contactData.getPhotoId()); thirdExtras.putParcelable(CallSubjectDialog.ARG_PHOTO_URI, UriUtils.parseUriOrNull(contactData.getPhotoUri())); thirdExtras.putParcelable(CallSubjectDialog.ARG_CONTACT_URI, contactData.getLookupUri()); thirdExtras.putString(CallSubjectDialog.ARG_NAME_OR_NUMBER, contactData.getDisplayName()); thirdExtras.putBoolean(CallSubjectDialog.ARG_IS_BUSINESS, false); thirdExtras.putString(CallSubjectDialog.ARG_NUMBER, phone.getNumber()); thirdExtras.putString(CallSubjectDialog.ARG_DISPLAY_NUMBER, phone.getFormattedPhoneNumber()); thirdExtras.putString(CallSubjectDialog.ARG_NUMBER_LABEL, phoneLabel); } else if (isVideoEnabled) { // Check to ensure carrier presence indicates the number supports video calling. int carrierPresence = dataItem.getCarrierPresence(); boolean isPresent = (carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) != 0; if ((isPresenceEnabled && isPresent) || !isPresenceEnabled) { thirdIcon = res.getDrawable(R.drawable.ic_videocam); thirdAction = Entry.ACTION_INTENT; thirdIntent = CallUtil.getVideoCallIntent(phone.getNumber(), CALL_ORIGIN_QUICK_CONTACTS_ACTIVITY); thirdContentDescription = res.getString(R.string.description_video_call); } } } } else if (dataItem instanceof EmailDataItem) { final EmailDataItem email = (EmailDataItem) dataItem; final String address = email.getData(); if (!TextUtils.isEmpty(address)) { primaryContentDescription.append(res.getString(R.string.email_other)).append(" "); final Uri mailUri = Uri.fromParts(ContactsUtils.SCHEME_MAILTO, address, null); intent = new Intent(Intent.ACTION_SENDTO, mailUri); header = email.getAddress(); entryContextMenuInfo = new EntryContextMenuInfo(header, res.getString(R.string.emailLabelsGroup), dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); if (email.hasKindTypeColumn(kind)) { text = Email.getTypeLabel(res, email.getKindTypeColumn(kind), email.getLabel()).toString(); primaryContentDescription.append(text).append(" "); } primaryContentDescription.append(header); icon = res.getDrawable(R.drawable.ic_email_24dp); iconResourceId = R.drawable.ic_email_24dp; } } else if (dataItem instanceof StructuredPostalDataItem) { StructuredPostalDataItem postal = (StructuredPostalDataItem) dataItem; final String postalAddress = postal.getFormattedAddress(); if (!TextUtils.isEmpty(postalAddress)) { primaryContentDescription.append(res.getString(R.string.map_other)).append(" "); intent = StructuredPostalUtils.getViewPostalAddressIntent(postalAddress); header = postal.getFormattedAddress(); entryContextMenuInfo = new EntryContextMenuInfo(header, res.getString(R.string.postalLabelsGroup), dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); if (postal.hasKindTypeColumn(kind)) { text = StructuredPostal.getTypeLabel(res, postal.getKindTypeColumn(kind), postal.getLabel()) .toString(); primaryContentDescription.append(text).append(" "); } primaryContentDescription.append(header); alternateIntent = StructuredPostalUtils.getViewPostalAddressDirectionsIntent(postalAddress); alternateIcon = res.getDrawable(R.drawable.ic_directions_24dp); alternateContentDescription.append(res.getString(R.string.content_description_directions)) .append(" ").append(header); icon = res.getDrawable(R.drawable.ic_place_24dp); iconResourceId = R.drawable.ic_place_24dp; } } else if (dataItem instanceof SipAddressDataItem) { final SipAddressDataItem sip = (SipAddressDataItem) dataItem; final String address = sip.getSipAddress(); if (!TextUtils.isEmpty(address)) { primaryContentDescription.append(res.getString(R.string.call_other)).append(" "); if (PhoneCapabilityTester.isSipPhone(context)) { final Uri callUri = Uri.fromParts(PhoneAccount.SCHEME_SIP, address, null); intent = CallUtil.getCallIntent(callUri); } header = address; entryContextMenuInfo = new EntryContextMenuInfo(header, res.getString(R.string.phoneLabelsGroup), dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); if (sip.hasKindTypeColumn(kind)) { text = SipAddress.getTypeLabel(res, sip.getKindTypeColumn(kind), sip.getLabel()).toString(); primaryContentDescription.append(text).append(" "); } primaryContentDescription.append(header); icon = res.getDrawable(R.drawable.ic_dialer_sip_black_24dp); iconResourceId = R.drawable.ic_dialer_sip_black_24dp; } } else if (dataItem instanceof StructuredNameDataItem) { // If the name is already set and this is not the super primary value then leave the // current value. This way we show the super primary value when we are able to. if (dataItem.isSuperPrimary() || aboutCardName.value == null || aboutCardName.value.isEmpty()) { final String givenName = ((StructuredNameDataItem) dataItem).getGivenName(); if (!TextUtils.isEmpty(givenName)) { aboutCardName.value = res.getString(R.string.about_card_title) + " " + givenName; } else { aboutCardName.value = res.getString(R.string.about_card_title); } } } else { // Custom DataItem header = dataItem.buildDataStringForDisplay(context, kind); text = kind.typeColumn; intent = new Intent(Intent.ACTION_VIEW); final Uri uri = ContentUris.withAppendedId(Data.CONTENT_URI, dataItem.getId()); intent.setDataAndType(uri, dataItem.getMimeType()); if (intent != null) { final String mimetype = intent.getType(); // Build advanced entry for known 3p types. Otherwise default to ResolveCache icon. switch (mimetype) { case MIMETYPE_GPLUS_PROFILE: // If a secondDataItem is available, use it to build an entry with // alternate actions if (secondDataItem != null) { icon = res.getDrawable(R.drawable.ic_google_plus_24dp); alternateIcon = res.getDrawable(R.drawable.ic_add_to_circles_black_24); final GPlusOrHangoutsDataItemModel itemModel = new GPlusOrHangoutsDataItemModel(intent, alternateIntent, dataItem, secondDataItem, alternateContentDescription, header, text, context); populateGPlusOrHangoutsDataItemModel(itemModel); intent = itemModel.intent; alternateIntent = itemModel.alternateIntent; alternateContentDescription = itemModel.alternateContentDescription; header = itemModel.header; text = itemModel.text; } else { if (GPLUS_PROFILE_DATA_5_ADD_TO_CIRCLE.equals(intent.getDataString())) { icon = res.getDrawable(R.drawable.ic_add_to_circles_black_24); } else { icon = res.getDrawable(R.drawable.ic_google_plus_24dp); } } break; case MIMETYPE_HANGOUTS: // If a secondDataItem is available, use it to build an entry with // alternate actions if (secondDataItem != null) { icon = res.getDrawable(R.drawable.ic_hangout_24dp); alternateIcon = res.getDrawable(R.drawable.ic_hangout_video_24dp); final GPlusOrHangoutsDataItemModel itemModel = new GPlusOrHangoutsDataItemModel(intent, alternateIntent, dataItem, secondDataItem, alternateContentDescription, header, text, context); populateGPlusOrHangoutsDataItemModel(itemModel); intent = itemModel.intent; alternateIntent = itemModel.alternateIntent; alternateContentDescription = itemModel.alternateContentDescription; header = itemModel.header; text = itemModel.text; } else { if (HANGOUTS_DATA_5_VIDEO.equals(intent.getDataString())) { icon = res.getDrawable(R.drawable.ic_hangout_video_24dp); } else { icon = res.getDrawable(R.drawable.ic_hangout_24dp); } } break; default: entryContextMenuInfo = new EntryContextMenuInfo(header, mimetype, dataItem.getMimeType(), dataItem.getId(), dataItem.isSuperPrimary()); icon = ResolveCache.getInstance(context).getIcon(dataItem.getMimeType(), intent); // Call mutate to create a new Drawable.ConstantState for color filtering if (icon != null) { icon.mutate(); } shouldApplyColor = false; } } } if (intent != null) { // Do not set the intent is there are no resolves if (!PhoneCapabilityTester.isIntentRegistered(context, intent)) { intent = null; } } if (alternateIntent != null) { // Do not set the alternate intent is there are no resolves if (!PhoneCapabilityTester.isIntentRegistered(context, alternateIntent)) { alternateIntent = null; } else if (TextUtils.isEmpty(alternateContentDescription)) { // Attempt to use package manager to find a suitable content description if needed alternateContentDescription.append(getIntentResolveLabel(alternateIntent, context)); } } // If the Entry has no visual elements, return null if (icon == null && TextUtils.isEmpty(header) && TextUtils.isEmpty(subHeader) && subHeaderIcon == null && TextUtils.isEmpty(text) && textIcon == null) { return null; } // Ignore dataIds from the Me profile. final int dataId = dataItem.getId() > Integer.MAX_VALUE ? -1 : (int) dataItem.getId(); return new Entry(dataId, icon, header, subHeader, subHeaderIcon, text, textIcon, phoneContentDescription == null ? new SpannableString(primaryContentDescription.toString()) : phoneContentDescription, intent, alternateIcon, alternateIntent, smsContentDescription == null ? new SpannableString(alternateContentDescription.toString()) : smsContentDescription, shouldApplyColor, isEditable, entryContextMenuInfo, thirdIcon, thirdIntent, thirdContentDescription, thirdAction, thirdExtras, iconResourceId); }
From source file:com.android.mms.ui.MessageUtils.java
public static Intent createIntentByThreadId(Context context, long threadId, int type) { Intent intent = null;//from w ww. j a va2 s. c om if (Telephony.Threads.CELL_BROADCAST_THREAD == type) { intent = CbMessageListActivity.createIntent(context, threadId); intent.putExtra("bFromLaunch", true); } else { intent = new Intent(context, ComposeMessageActivity.class); intent.putExtra("finish", true); if (threadId > 0) { intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("smsto:" + TextUtils.join(",", Conversation.get(context, threadId, true).getRecipients().getNumbers()))); } } return intent; }
From source file:edu.usf.cutr.opentripplanner.android.fragments.MainFragment.java
@Override public boolean onOptionsItemSelected(final MenuItem pItem) { OTPApp app = ((OTPApp) getActivity().getApplication()); switch (pItem.getItemId()) { case R.id.gps_settings: Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(myIntent);//from w w w.j a v a 2s . co m break; case R.id.settings: getActivity().startActivityForResult(new Intent(getActivity(), SettingsActivity.class), OTPApp.SETTINGS_REQUEST_CODE); break; case R.id.feedback: Server selectedServer = app.getSelectedServer(); String[] recipients = { selectedServer.getContactEmail(), getString(R.string.feedback_email_android_developer) }; String uriText = "mailto:"; for (String recipient : recipients) { uriText += recipient + ";"; } String subject = ""; subject += getResources().getString(R.string.menu_button_feedback_subject); Date d = Calendar.getInstance().getTime(); subject += "[" + d.toString() + "]"; uriText += "?subject=" + subject; String content = ((MyActivity) getActivity()).getCurrentRequestString(); try { uriText += "&body=" + URLEncoder.encode(content, OTPApp.URL_ENCODING); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); return false; } Uri uri = Uri.parse(uriText); Intent sendIntent = new Intent(Intent.ACTION_SENDTO); sendIntent.setData(uri); startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.menu_button_feedback_send_email))); break; case R.id.server_info: Server server = app.getSelectedServer(); if (server == null) { Log.w(OTPApp.TAG, "Tried to get server info when no server was selected"); Toast.makeText(mApplicationContext, mApplicationContext.getResources().getString(R.string.toast_no_server_selected_error), Toast.LENGTH_SHORT).show(); break; } WeakReference<Activity> weakContext = new WeakReference<Activity>(getActivity()); ServerChecker serverChecker = new ServerChecker(weakContext, mApplicationContext, true); serverChecker.execute(server); break; default: break; } return false; }
From source file:com.android.mail.compose.ComposeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final boolean superCreated = super.onCreateOptionsMenu(menu); // Don't render any menu items when there are no accounts. if (mAccounts == null || mAccounts.length == 0) { return superCreated; }/*from www . j a v a 2 s . co m*/ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.compose_menu, menu); /* * Start save in the correct enabled state. * 1) If a user launches compose from within gmail, save is disabled * until they add something, at which point, save is enabled, auto save * on exit; if the user empties everything, save is disabled, exiting does not * auto-save * 2) if a user replies/ reply all/ forwards from within gmail, save is * disabled until they change something, at which point, save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save. * 3) If a user launches compose from another application and something * gets populated (attachments, recipients, body, subject, etc), save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save */ mSave = menu.findItem(R.id.save); String action = getIntent() != null ? getIntent().getAction() : null; enableSave(mInnerSavedState != null ? mInnerSavedState.getBoolean(EXTRA_SAVE_ENABLED) : (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action) || Intent.ACTION_SENDTO.equals(action) || isDraftDirty())); final MenuItem helpItem = menu.findItem(R.id.help_info_menu_item); final MenuItem sendFeedbackItem = menu.findItem(R.id.feedback_menu_item); final MenuItem attachFromServiceItem = menu.findItem(R.id.attach_from_service_stub1); if (helpItem != null) { helpItem.setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.HELP_CONTENT)); } if (sendFeedbackItem != null) { sendFeedbackItem .setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.SEND_FEEDBACK)); } if (attachFromServiceItem != null) { attachFromServiceItem.setVisible(shouldEnableAttachFromServiceMenu(mAccount)); } // Show attach picture on pre-K devices. menu.findItem(R.id.add_photo_attachment).setVisible(!Utils.isRunningKitkatOrLater()); return true; }
From source file:com.tct.mail.compose.ComposeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final boolean superCreated = super.onCreateOptionsMenu(menu); // Don't render any menu items when there are no accounts. if (mAccounts == null || mAccounts.length == 0) { return superCreated; }/*from www.j a v a 2 s . c om*/ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.compose_menu, menu); /* * Start save in the correct enabled state. * 1) If a user launches compose from within gmail, save is disabled * until they add something, at which point, save is enabled, auto save * on exit; if the user empties everything, save is disabled, exiting does not * auto-save * 2) if a user replies/ reply all/ forwards from within gmail, save is * disabled until they change something, at which point, save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save. * 3) If a user launches compose from another application and something * gets populated (attachments, recipients, body, subject, etc), save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save */ mSave = menu.findItem(R.id.save); String action = getIntent() != null ? getIntent().getAction() : null; boolean fromWidget = getIntent() != null && getIntent().getBooleanExtra(EXTRA_FROM_EMAIL_WIDGET, false);//TS: zheng.zou 2015-12-09 EMAIL BUGFIX_1059178 ADD enableSave(mInnerSavedState != null ? mInnerSavedState.getBoolean(EXTRA_SAVE_ENABLED) : ((Intent.ACTION_SEND.equals(action) && !fromWidget) //TS: zheng.zou 2015-12-09 EMAIL BUGFIX_1059178 MOD || Intent.ACTION_SEND_MULTIPLE.equals(action) || Intent.ACTION_SENDTO.equals(action) || shouldSave())); final MenuItem helpItem = menu.findItem(R.id.help_info_menu_item); final MenuItem sendFeedbackItem = menu.findItem(R.id.feedback_menu_item); //TS: Gantao 2015-7-13 EMAIL FEATURE_1033148 DEL_S //For feature:long click the attachment icon menu can show the menu discription, //we should remove its useless sub menu. // final MenuItem attachFromServiceItem = menu.findItem(R.id.attach_from_service_stub1); //TS: Gantao 2015-7-13 EMAIL FEATURE_1033148 DEL_E //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398) MenuItem priority = menu.findItem(R.id.priority); if (priority != null) { // TS: xiaolin.li 2014-11-25 EMAIL READ_PLF MOD_S //priority.setVisible(getResources().getBoolean(R.bool.feature_email_priority_on)); priority.setVisible(PLFUtils.getBoolean(this, "feature_email_priority_on")); // TS: xiaolin.li 2014-11-25 EMAIL READ_PLF MOD_E } //[FEATURE]-Add-END by TSCD.chao zhang if (helpItem != null) { helpItem.setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.HELP_CONTENT)); } if (sendFeedbackItem != null) { sendFeedbackItem .setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.SEND_FEEDBACK)); } //TS: Gantao 2015-7-13 EMAIL FEATURE_1033148 DEL_S //For feature:long click the attachment icon menu can show the menu discription, //we should remove its useless sub menu. // if (attachFromServiceItem != null) { // attachFromServiceItem.setVisible(shouldEnableAttachFromServiceMenu(mAccount)); // } //TS: Gantao 2015-7-13 EMAIL FEATURE_1033148 DEL_E //TS: yanhua.chen 2015-4-30 EMAIL BUGFIX_989399 MOD_S // Show attach picture on pre-K devices. //menu.findItem(R.id.add_photo_attachment).setVisible(!Utils.isRunningKitkatOrLater()); //TS: yanhua.chen 2015-4-30 EMAIL BUGFIX_989399 MOD_E // TS: Gantao 2015-10-30 EMAIL FEATURE_1104470 ADD_S MenuItem saveGroupItem = menu.findItem(R.id.group); if (saveGroupItem != null) { saveGroupItem.setVisible(PLFUtils.getBoolean(this, "feature_email_save_group")); } // TS: Gantao 2015-10-30 EMAIL FEATURE_1104470 ADD_E return true; }