List of usage examples for android.content Intent ACTION_DIAL
String ACTION_DIAL
To view the source code for android.content Intent ACTION_DIAL.
Click Source Link
From source file:com.wit.android.support.content.intent.DialerIntent.java
/** *//* w ww . j a v a 2 s .c o m*/ @Nullable @Override public Intent buildIntent() { if (TextUtils.isEmpty(mPhoneNumber)) { Log.e(TAG, "Can not create an DIALER intent. No phone number specified."); return null; } return new Intent(Intent.ACTION_DIAL, Uri.parse(SCHEME + mPhoneNumber)); }
From source file:spit.matrix2017.Fragments.ContactUsFragment.java
@Nullable @Override/*w w w. ja va 2s . co m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_contactus, container, false); findOnMap = (Button) view.findViewById(R.id.findOnMap); visitWebsite = (Button) view.findViewById(R.id.visitWebsite); contact_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_one); contact_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_two); save_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_one); save_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_two); emailId_matrix_TextView = (TextView) view.findViewById(R.id.emailId_matrix_TextView); emailId_matrix_TextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String to = "principal@spit.ac.in"; Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setType("text/plain"); intent.setData(Uri.parse("mailto:" + to)); intent.putExtra(Intent.EXTRA_EMAIL, to); try { startActivity(Intent.createChooser(intent, "Send Email")); } catch (Exception e) { Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show(); } } }); visitWebsite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.spit.ac.in"))); } }); findOnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uri = Uri .parse("http://maps.google.com/maps?q=" + Uri.encode(getString(R.string.college_name))); Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri); mapIntent.setPackage("com.google.android.apps.maps"); try { startActivity(mapIntent); } catch (ActivityNotFoundException ex) { try { Intent newIntent = new Intent(Intent.ACTION_VIEW, uri); startActivity(newIntent); } catch (ActivityNotFoundException innerEx) { Toast.makeText(getContext(), "Please install a maps application", Toast.LENGTH_LONG).show(); } } } }); View.OnClickListener dialerOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_DIAL); switch (v.getId()) { case R.id.contact_us_call_one: intent.setData(Uri.parse("tel:" + "02226707440")); break; case R.id.contact_us_call_two: intent.setData(Uri.parse("tel:" + "02226287250")); break; } startActivity(intent); } }; contact_one_Button.setOnClickListener(dialerOnClickListener); contact_two_Button.setOnClickListener(dialerOnClickListener); View.OnClickListener saveOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI); switch (v.getId()) { case R.id.contact_us_save_one: intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T."); intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226707440"); break; case R.id.contact_us_save_two: intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T."); intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226708520"); break; } startActivity(intent); } }; save_one_Button.setOnClickListener(saveOnClickListener); save_two_Button.setOnClickListener(saveOnClickListener); return view; }
From source file:com.albedinsky.android.support.intent.DialerIntent.java
/** */ @NonNull @Override protected Intent onBuild() { return new Intent(Intent.ACTION_DIAL, Uri.fromParts(URI_SCHEME, mPhoneNumber, null)); }
From source file:com.hybris.mobile.app.commerce.fragment.StoreDetailsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Store name needed for this fragment if (StringUtils.isBlank(getActivity().getIntent().getStringExtra(IntentConstants.STORE_NAME))) { throw new IllegalArgumentException(); }// w w w . j ava 2 s. co m // Getting the map fragment if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { mMapFragment = ((MapFragment) (getChildFragmentManager().findFragmentById(R.id.store_details_map))); } if (mMapFragment == null) { mMapFragment = ((MapFragment) (getFragmentManager().findFragmentById(R.id.store_details_map))); } mStoreAddress = (TextView) getView().findViewById(R.id.store_details_address); mStoreName = (TextView) getView().findViewById(R.id.store_details_name); mStoreDistance = (TextView) getView().findViewById(R.id.store_details_distance); mStoreTel = (TextView) getView().findViewById(R.id.store_details_tel); mStoreDirections = (TextView) getView().findViewById(R.id.store_details_directions); mStoreTel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (StringUtils.isNotBlank(mStoreTel.getText())) { try { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + mStoreTel.getText().toString().replaceAll("[^\\d.]", "")))); } catch (ActivityNotFoundException e) { Log.e(TAG, e.getLocalizedMessage()); } } } }); mStoreHoursMon = (TextView) getView().findViewById(R.id.store_details_monday); mStoreHoursTue = (TextView) getView().findViewById(R.id.store_details_tuesday); mStoreHoursWed = (TextView) getView().findViewById(R.id.store_details_wednesday); mStoreHoursThu = (TextView) getView().findViewById(R.id.store_details_thursday); mStoreHoursFri = (TextView) getView().findViewById(R.id.store_details_friday); mStoreHoursSat = (TextView) getView().findViewById(R.id.store_details_saturday); mStoreHoursSun = (TextView) getView().findViewById(R.id.store_details_sunday); // Store query QueryStore queryStore = new QueryStore(); queryStore.setStoreName(getActivity().getIntent().getStringExtra(IntentConstants.STORE_NAME)); CommerceApplication.getContentServiceHelper().getStore(this, mRequestId, queryStore, false, null, new OnRequestListener() { @Override public void beforeRequest() { UIUtils.showLoadingActionBar(getActivity(), true); getView().findViewById(R.id.store_details_loading).setVisibility(View.VISIBLE); getView().findViewById(R.id.store_details_bloc).setVisibility(View.GONE); } @Override public void afterRequestBeforeResponse() { } @Override public void afterRequest(boolean isDataSynced) { UIUtils.showLoadingActionBar(getActivity(), false); getView().findViewById(R.id.store_details_loading).setVisibility(View.GONE); getView().findViewById(R.id.store_details_bloc).setVisibility(View.VISIBLE); } }); }
From source file:mah.farmer.ui.ProductInfoActivity.java
/** * APPLayout,?/*www.jav a2 s . c o m*/ */ private void initAppBarLayout() { //???? farmerProduct = (FarmerProduct) getIntent().getSerializableExtra("products"); //ID produt_avatar = (ImageView) findViewById(R.id.productinfo_avatar); mFab = findViewById(R.id.flexible_example_fab); danjia = (TextView) findViewById(R.id.product_danjia); desc = (TextView) findViewById(R.id.productinfo_desc); xiaoliang = (TextView) findViewById(R.id.product_xiaoliang); supplier_name = (TextView) findViewById(R.id.supplier_name); supplier_location = (TextView) findViewById(R.id.supplier_location); supplier_avatar = (ImageView) findViewById(R.id.supplier_avatar); addshoppingcart = (LinearLayout) findViewById(R.id.add_shopping_cart); product_leibie = (TextView) findViewById(R.id.product_leibie); //?? danjia.setText("?" + farmerProduct.getMyprice() + "/"); desc.setText(farmerProduct.getDescription()); if (farmerProduct.getSalesNum() == null || farmerProduct.getSalesNum().equals("")) { xiaoliang.setText("???"); } else { xiaoliang.setText("?" + farmerProduct.getSalesNum() + ""); } product_leibie .setText("" + farmerProduct.getTagOne() + " ?" + farmerProduct.getTagTwo()); supplier_location.setText("?" + farmerProduct.getSupplierAddress()); supplier_name.setText(": " + farmerProduct.getSupplier()); //? if (farmerProduct.getAvata_md5() != null && !farmerProduct.getAvata_md5().equals("")) { ImageLoader.getInstance().displayImage(farmerProduct.getAvata_md5(), produt_avatar, ImageLoadOptions.getOptions()); } else { produt_avatar.setImageResource(R.drawable.default_head); } //? getSupplierAvatar(); //?? mFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //?? Uri uri = Uri.parse("tel:" + farmerProduct.getSupplierPhone()); Intent intent = new Intent(Intent.ACTION_DIAL, uri); startActivity(intent); } }); //??? addshoppingcart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //??? if (FarmerConfig.getCachedFarmerNickname(ProductInfoActivity.this) .equals(farmerProduct.getSupplier())) { new SweetAlertDialog(ProductInfoActivity.this, SweetAlertDialog.ERROR_TYPE) .setTitleText("?").setContentText("??") .show(); } else { Intent intent = new Intent(ProductInfoActivity.this, AddShoppingDeliveryActivity.class); intent.putExtra("userTrueName", FarmerConfig.getCachedFarmerPhoTruename(ProductInfoActivity.this)); intent.putExtra("userAddress", FarmerConfig.getCachedFarmerAddress(ProductInfoActivity.this)); intent.putExtra("userPhone", FarmerConfig.getCachedFarmerPhone(ProductInfoActivity.this)); intent.putExtra("product", farmerProduct); startActivity(intent); } } }); //toolbar? Toolbar toolbar = (Toolbar) findViewById(R.id.flexible_example_toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); AppBarLayout appbar = (AppBarLayout) findViewById(R.id.flexible_example_appbar); appbar.addOnOffsetChangedListener(this); /** * */ final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById( R.id.flexible_example_collapsing); collapsingToolbarLayout.setTitle(farmerProduct.getName()); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.farmer_shop_list_back)); // transperent color = #00000000 collapsingToolbarLayout.setCollapsedTitleTextColor(Color.rgb(232, 247, 239)); }
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 . j a v a2 s . c om*/ } 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:org.montanafoodhub.app.producer.ProducerDetailFragment.java
private void onClickContact() { if (hasEmail(_producer)) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + _producer.getContactEmail() + "," + HubInit.getHubEmailTo())); intent.putExtra(Intent.EXTRA_SUBJECT, "Hub Request For: " + _producer.getName()); intent.putExtra(Intent.EXTRA_TEXT, "<grower love here...>"); ActivityUtils.startImplicitActivity(getActivity(), intent, R.string.no_email_application, LogTag); } else {//from ww w. j av a 2s .c o m Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + _producer.getContactEmail())); ActivityUtils.startImplicitActivity(getActivity(), intent, R.string.no_phone_application, LogTag); } }
From source file:org.apache.cordova.core.InAppBrowser.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackId The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *//*from w w w . ja v a2 s.c o m*/ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { try { if (action.equals("open")) { this.callbackContext = callbackContext; String url = args.getString(0); String target = args.optString(1); if (target == null || target.equals("") || target.equals(NULL)) { target = SELF; } HashMap<String, Boolean> features = parseFeature(args.optString(2)); Log.d(LOG_TAG, "target = " + target); url = updateUrl(url); String result = ""; // SELF if (SELF.equals(target)) { Log.d(LOG_TAG, "in self"); // load in webview if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) { this.webView.loadUrl(url); } //Load the dialer else if (url.startsWith(WebView.SCHEME_TEL)) { try { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString()); } } // load in InAppBrowser else { result = this.showWebPage(url, features); } } // SYSTEM else if (SYSTEM.equals(target)) { Log.d(LOG_TAG, "in system"); result = this.openExternal(url); } // BLANK - or anything else else { Log.d(LOG_TAG, "in blank"); result = this.showWebPage(url, features); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result); pluginResult.setKeepCallback(true); this.callbackContext.sendPluginResult(pluginResult); } else if (action.equals("close")) { closeDialog(); this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } else if (action.equals("injectScriptCode")) { String jsWrapper = null; if (args.getBoolean(1)) { jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId()); } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("injectScriptFile")) { String jsWrapper; if (args.getBoolean(1)) { jsWrapper = String.format( "(function(d) { var c = d.createElement('script'); c.src = %%s; c.onload = function() { prompt('', 'gap-iab://%s'); }; d.body.appendChild(c); })(document)", callbackContext.getCallbackId()); } else { jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %s; d.body.appendChild(c); })(document)"; } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("injectStyleCode")) { String jsWrapper; if (args.getBoolean(1)) { jsWrapper = String.format( "(function(d) { var c = d.createElement('style'); c.innerHTML = %%s; d.body.appendChild(c); prompt('', 'gap-iab://%s');})(document)", callbackContext.getCallbackId()); } else { jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %s; d.body.appendChild(c); })(document)"; } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("injectStyleFile")) { String jsWrapper; if (args.getBoolean(1)) { jsWrapper = String.format( "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%s; d.head.appendChild(c); prompt('', 'gap-iab://%s');})(document)", callbackContext.getCallbackId()); } else { jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %s; d.head.appendChild(c); })(document)"; } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("show")) { Runnable runnable = new Runnable() { @Override public void run() { dialog.show(); } }; this.cordova.getActivity().runOnUiThread(runnable); this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } else { return false; } } catch (JSONException e) { this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); } return true; }
From source file:org.apache.cordova.InAppBrowser.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackId The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *//*from www . j a v a2 s. com*/ public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException { if (action.equals("open")) { this.callbackContext = callbackContext; final String url = args.getString(0); String t = args.optString(1); if (t == null || t.equals("") || t.equals(NULL)) { t = SELF; } final String target = t; final HashMap<String, Boolean> features = parseFeature(args.optString(2)); Log.d(LOG_TAG, "target = " + target); this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { String result = ""; // SELF if (SELF.equals(target)) { Log.d(LOG_TAG, "in self"); // load in webview if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) { webView.loadUrl(url); } //Load the dialer else if (url.startsWith(WebView.SCHEME_TEL)) { try { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString()); } } // load in InAppBrowser else { result = showWebPage(url, features); } } // SYSTEM else if (SYSTEM.equals(target)) { Log.d(LOG_TAG, "in system"); result = openExternal(url); } // BLANK - or anything else else { Log.d(LOG_TAG, "in blank"); result = showWebPage(url, features); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); } }); } else if (action.equals("close")) { closeDialog(); } else if (action.equals("injectScriptCode")) { String jsWrapper = null; if (args.getBoolean(1)) { jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId()); } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("injectScriptFile")) { String jsWrapper; if (args.getBoolean(1)) { jsWrapper = String.format( "(function(d) { var c = d.createElement('script'); c.src = %%s; c.onload = function() { prompt('', 'gap-iab://%s'); }; d.body.appendChild(c); })(document)", callbackContext.getCallbackId()); } else { jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %s; d.body.appendChild(c); })(document)"; } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("injectStyleCode")) { String jsWrapper; if (args.getBoolean(1)) { jsWrapper = String.format( "(function(d) { var c = d.createElement('style'); c.innerHTML = %%s; d.body.appendChild(c); prompt('', 'gap-iab://%s');})(document)", callbackContext.getCallbackId()); } else { jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %s; d.body.appendChild(c); })(document)"; } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("injectStyleFile")) { String jsWrapper; if (args.getBoolean(1)) { jsWrapper = String.format( "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%s; d.head.appendChild(c); prompt('', 'gap-iab://%s');})(document)", callbackContext.getCallbackId()); } else { jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %s; d.head.appendChild(c); })(document)"; } injectDeferredObject(args.getString(0), jsWrapper); } else if (action.equals("show")) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { dialog.show(); } }); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); pluginResult.setKeepCallback(true); this.callbackContext.sendPluginResult(pluginResult); } else { return false; } return true; }
From source file:com.artemchep.horario.ui.fragments.details.TeacherDetailsFragment.java
@Override protected ViewGroup onCreateContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @NonNull List<ContentItem<Teacher>> contentItems, @Nullable Bundle savedInstanceState) { getToolbar().inflateMenu(R.menu.details_teacher); ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.fragment_details_teacher, container, false); initWithFab(R.id.action_edit, R.drawable.ic_pencil_white_24dp); mNoteContainer = vg.findViewById(R.id.info_container); mPhoneContainer = vg.findViewById(R.id.phone_container); mPhoneContainer.setOnClickListener(new View.OnClickListener() { @Override/*w w w.j a va 2s . co m*/ public void onClick(View view) { if (TextUtils.isEmpty(mModel.phone)) { Timber.tag(TAG).w("Tried to copy an empty phone!"); return; } // Copy email to clipboard ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mModel.phone, mModel.phone); // TODO: More informative description of the clip clipboard.setPrimaryClip(clip); // Show toast message String msg = getString(R.string.details_phone_clipboard, mModel.phone); Toasty.info(getContext(), msg).show(); } }); mEmailContainer = vg.findViewById(R.id.email_container); mEmailContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.email)) { Timber.tag(TAG).w("Tried to copy an empty email!"); return; } // Copy email to clipboard ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mModel.email, mModel.email); // TODO: More informative description of the clip clipboard.setPrimaryClip(clip); // Show toast message String msg = getString(R.string.details_email_clipboard, mModel.email); Toasty.info(getContext(), msg).show(); } }); mPhoneButton = (Button) mPhoneContainer.findViewById(R.id.phone_send); mPhoneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.phone)) { Timber.tag(TAG).w("Tried to call an empty phone!"); return; } Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + mModel.phone)); try { startActivity(intent); } catch (ActivityNotFoundException ignored) { } } }); mEmailButton = (Button) mEmailContainer.findViewById(R.id.email_send); mEmailButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.email)) { Timber.tag(TAG).w("Tried to send to an empty email!"); return; } String[] recipients = { mModel.email }; Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle it try { startActivity(intent); } catch (ActivityNotFoundException e) { // TODO:!!!!! String msg = "No email app"; //getString(R.string.feedback_error_no_app); Toasty.info(getContext(), msg).show(); } } }); mNoteTextView = (TextView) mNoteContainer.findViewById(R.id.info); mEmailTextView = (TextView) mEmailContainer.findViewById(R.id.email); mPhoneTextView = (TextView) mPhoneContainer.findViewById(R.id.phone); // Note contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.info)) { mNoteContainer.setVisibility(View.GONE); } else { mNoteContainer.setVisibility(View.VISIBLE); mNoteTextView.setText(model.info); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.info : null; String b = model != null ? model.info : null; return !TextUtils.equals(a, b); } }); // Email contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.email)) { mEmailContainer.setVisibility(View.GONE); } else { mEmailContainer.setVisibility(View.VISIBLE); mEmailTextView.setText(model.info); if (PatternUtils.isEmail(model.email)) { mEmailButton.setVisibility(View.VISIBLE); } else mEmailButton.setVisibility(View.GONE); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.email : null; String b = model != null ? model.email : null; return !TextUtils.equals(a, b); } }); // Phone contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.phone)) { mPhoneContainer.setVisibility(View.GONE); } else { mPhoneContainer.setVisibility(View.VISIBLE); mPhoneTextView.setText(model.phone); if (PatternUtils.isPhone(model.phone)) { mPhoneButton.setVisibility(View.VISIBLE); } else mPhoneButton.setVisibility(View.GONE); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.phone : null; String b = model != null ? model.phone : null; return !TextUtils.equals(a, b); } }); return vg; }