List of usage examples for android.content Intent EXTRA_SUBJECT
String EXTRA_SUBJECT
To view the source code for android.content Intent EXTRA_SUBJECT.
Click Source Link
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void emailLog(final CallbackContext callback, final String email) { cordova.getThreadPool().execute(new Runnable() { public void run() { String log = readLog(); if (log == null) { callback.error(500);/*from w ww. j av a 2s .com*/ return; } Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("message/rfc822"); mailer.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); mailer.putExtra(Intent.EXTRA_SUBJECT, "BackgroundGeolocation log"); try { JSONObject state = getState(); if (state.has("license")) { state.put("license", "<SECRET>"); } if (state.has("orderId")) { state.put("orderId", "<SECRET>"); } mailer.putExtra(Intent.EXTRA_TEXT, state.toString(4)); } catch (JSONException e) { Log.w(TAG, "- Failed to write state to email body"); e.printStackTrace(); } File file = new File(Environment.getExternalStorageDirectory(), "background-geolocation.log"); try { FileOutputStream stream = new FileOutputStream(file); try { stream.write(log.getBytes()); stream.close(); mailer.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); file.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { Log.i(TAG, "FileNotFound"); e.printStackTrace(); } try { cordova.getActivity() .startActivityForResult(Intent.createChooser(mailer, "Send log: " + email + "..."), 1); callback.success(); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(cordova.getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show(); callback.error("There are no email clients installed"); } } }); }
From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java
/** * //from w ww. ja v a 2 s .c o m */ public void startShareResultsIntent() { try { JSONObject resultListItem = testResult.getJSONObject(0); final String shareText = resultListItem.getString("share_text"); final String shareSubject = resultListItem.getString("share_subject"); final Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, shareText); sendIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubject); sendIntent.setType("text/plain"); activity.startActivity(Intent.createChooser(sendIntent, null)); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.irccloud.android.activity.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_logout: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Logout"); builder.setMessage("Would you like to logout of IRCCloud?"); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override/*from ww w . j av a2s. c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Logout", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); conn.logout(); if (mGoogleApiClient.isConnected()) { Auth.CredentialsApi.disableAutoSignIn(mGoogleApiClient) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } }); } else { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } } }); AlertDialog dialog = builder.create(); dialog.setOwnerActivity(this); dialog.show(); break; case R.id.menu_settings: Intent i = new Intent(this, PreferencesActivity.class); startActivity(i); break; case R.id.menu_feedback: try { String bugReport = "Briefly describe the issue below:\n\n\n\n\n" + "===========\n" + ((NetworkConnection.getInstance().getUserInfo() != null) ? ("UID: " + NetworkConnection.getInstance().getUserInfo().id + "\n") : "") + "App version: " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " (" + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + ")\n" + "Device: " + Build.MODEL + "\n" + "Android version: " + Build.VERSION.RELEASE + "\n" + "Firmware fingerprint: " + Build.FINGERPRINT + "\n"; File logsDir = new File(getFilesDir(), ".Fabric/com.crashlytics.sdk.android.crashlytics-core/log-files/"); File log = null; File output = null; if (logsDir.exists()) { long max = Long.MIN_VALUE; for (File f : logsDir.listFiles()) { if (f.lastModified() > max) { max = f.lastModified(); log = f; } } if (log != null) { File f = new File(getFilesDir(), "logs"); f.mkdirs(); output = new File(f, LOG_FILENAME); byte[] b = new byte[1]; FileOutputStream out = new FileOutputStream(output); FileInputStream is = new FileInputStream(log); is.skip(5); while (is.available() > 0 && is.read(b, 0, 1) > 0) { if (b[0] == ' ') { while (is.available() > 0 && is.read(b, 0, 1) > 0) { out.write(b); if (b[0] == '\n') break; } } } is.close(); out.close(); } } Intent email = new Intent(Intent.ACTION_SEND); email.setData(Uri.parse("mailto:")); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "IRCCloud Team <team@irccloud.com>" }); email.putExtra(Intent.EXTRA_TEXT, bugReport); email.putExtra(Intent.EXTRA_SUBJECT, "IRCCloud for Android"); if (log != null) { email.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", output)); } startActivityForResult(Intent.createChooser(email, "Send Feedback:"), 0); } catch (Exception e) { Toast.makeText(this, "Unable to generate email report: " + e.getMessage(), Toast.LENGTH_SHORT) .show(); Crashlytics.logException(e); NetworkConnection.printStackTraceToCrashlytics(e); } break; } return super.onOptionsItemSelected(item); }
From source file:com.ibuildapp.romanblack.CataloguePlugin.ProductDetails.java
/** * Initializing user interface// ww w . ja v a2 s.c o m */ private void initializeUI() { setContentView(R.layout.details_layout); hideTopBar(); navBarHolder = (RelativeLayout) findViewById(R.id.navbar_holder); List<String> imageUrls = new ArrayList<>(); imageUrls.add(product.imageURL); imageUrls.addAll(product.imageUrls); final float density = getResources().getDisplayMetrics().density; int topBarHeight = (int) (TOP_BAR_HEIGHT * density); TextView apply_button = (TextView) findViewById(R.id.apply_button); View basket = findViewById(R.id.basket); View bottomSeparator = findViewById(R.id.bottom_separator); quantity = (EditText) findViewById(R.id.quantity); roundsList = (RecyclerView) findViewById(R.id.details_recyclerview); if (imageUrls.size() <= 1) roundsList.setVisibility(View.GONE); LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); roundsList.setLayoutManager(layoutManager); pager = (ViewPager) findViewById(R.id.viewpager); if (!"".equals(imageUrls.get(0))) { final RoundAdapter rAdapter = new RoundAdapter(this, imageUrls); roundsList.setAdapter(rAdapter); float width = getResources().getDisplayMetrics().widthPixels; float height = getResources().getDisplayMetrics().heightPixels; height -= 2 * topBarHeight; height -= com.ibuildapp.romanblack.CataloguePlugin.utils.Utils.getStatusBarHeight(this); pager.getLayoutParams().width = (int) width; pager.getLayoutParams().height = (int) height; newCurrentItem = 0; pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { oldCurrentItem = newCurrentItem; newCurrentItem = position; rAdapter.setCurrentItem(newCurrentItem); rAdapter.notifyItemChanged(newCurrentItem); if (oldCurrentItem != -1) rAdapter.notifyItemChanged(oldCurrentItem); } @Override public void onPageScrollStateChanged(int state) { } }); pager.setPageTransformer(true, new InnerPageTransformer()); adapter = new DetailsViewPagerAdapter(getSupportFragmentManager(), imageUrls); roundsList.addItemDecoration(new RecyclerView.ItemDecoration() { @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { int totalWidth = (int) (adapter.getCount() * 21 * density); int screenWidth = getResources().getDisplayMetrics().widthPixels; int position = parent.getChildAdapterPosition(view); if ((totalWidth < screenWidth) && position == 0) outRect.left = (screenWidth - totalWidth) / 2; } }); pager.setAdapter(adapter); } else { roundsList.setVisibility(View.GONE); pager.setVisibility(View.GONE); } buyLayout = (RelativeLayout) findViewById(R.id.details_buy_layout); if (product.itemType.equals(ProductItemType.EXTERNAL)) quantity.setVisibility(View.GONE); else quantity.setVisibility(View.VISIBLE); if (Statics.isBasket) { buyLayout.setVisibility(View.VISIBLE); onShoppingCartItemAdded(); apply_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideKeyboard(); quantity.setText(StringUtils.isBlank(quantity.getText().toString()) ? "1" : quantity.getText().toString()); quantity.clearFocus(); String message = ""; int quant = Integer.valueOf(quantity.getText().toString()); List<ShoppingCart.Product> products = ShoppingCart.getProducts(); int count = 0; for (ShoppingCart.Product product : products) count += product.getQuantity(); try { message = new PluralResources(getResources()).getQuantityString(R.plurals.items_to_cart, count + quant, count + quant); } catch (NoSuchMethodException e) { e.printStackTrace(); } int index = products.indexOf(new ShoppingCart.Product.Builder().setId(product.id).build()); ShoppingCart.insertProduct(new ShoppingCart.Product.Builder().setId(product.id) .setQuantity((index == -1 ? 0 : products.get(index).getQuantity()) + quant).build()); onShoppingCartItemAdded(); com.ibuildapp.romanblack.CataloguePlugin.utils.Utils.showDialog(ProductDetails.this, R.string.shopping_cart_dialog_title, message, R.string.shopping_cart_dialog_continue, R.string.shopping_cart_dialog_view_cart, new com.ibuildapp.romanblack.CataloguePlugin.utils.Utils.OnDialogButtonClickListener() { @Override public void onPositiveClick(DialogInterface dialog) { dialog.dismiss(); } @Override public void onNegativeClick(DialogInterface dialog) { Intent intent = new Intent(ProductDetails.this, ShoppingCartPage.class); ProductDetails.this.startActivity(intent); } }); } }); if (product.itemType.equals(ProductItemType.EXTERNAL)) { basket.setVisibility(View.GONE); apply_button.setText(product.itemButtonText); apply_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ProductDetails.this, ExternalProductDetailsActivity.class); intent.putExtra("itemUrl", product.itemUrl); startActivity(intent); } }); } else { basket.setVisibility(View.VISIBLE); apply_button.setText(R.string.shopping_cart_add_to_cart); } } else { if (product.itemType.equals(ProductItemType.EXTERNAL)) buyLayout.setVisibility(View.VISIBLE); else buyLayout.setVisibility(View.GONE); apply_button.setText(R.string.buy_now); basket.setVisibility(View.GONE); findViewById(R.id.cart_items).setVisibility(View.GONE); /*apply_button_padding_left = 0; apply_button.setGravity(Gravity.CENTER); apply_button.setPadding(apply_button_padding_left, 0, 0, 0);*/ if (TextUtils.isEmpty(Statics.PAYPAL_CLIENT_ID) || product.price == 0) { bottomSeparator.setVisibility(View.GONE); apply_button.setVisibility(View.GONE); basket.setVisibility(View.GONE); } else { apply_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { payer.singlePayment(new Payer.Item.Builder().setPrice(product.price) .setCurrencyCode(Payer.CurrencyCode.valueOf(Statics.uiConfig.currency)) .setName(product.name).setEndpoint(Statics.ENDPOINT).setAppId(Statics.appId) .setWidgetId(Statics.widgetId).setItemId(product.item_id).build()); } }); } if (product.itemType.equals(ProductItemType.EXTERNAL)) { basket.setVisibility(View.GONE); apply_button.setText(product.itemButtonText); apply_button.setVisibility(View.VISIBLE); apply_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ProductDetails.this, ExternalProductDetailsActivity.class); intent.putExtra("itemUrl", product.itemUrl); startActivity(intent); } }); } } backBtn = (LinearLayout) findViewById(R.id.back_btn); backBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); title = (TextView) findViewById(R.id.title_text); title.setMaxWidth((int) (screenWidth * 0.55)); if (category != null && !TextUtils.isEmpty(category.name)) title.setText(category.name); View basketBtn = findViewById(R.id.basket_view_btn); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(ProductDetails.this, ShoppingCartPage.class); startActivity(intent); } }; basketBtn.setOnClickListener(listener); View hamburgerView = findViewById(R.id.hamburger_view_btn); hamburgerView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { animateRootContainer(); } }); if (!showSideBar) { hamburgerView.setVisibility(View.GONE); basketBtn.setVisibility(View.VISIBLE); basketBtn.setVisibility(Statics.isBasket ? View.VISIBLE : View.GONE); findViewById(R.id.cart_items).setVisibility(View.VISIBLE); } else { hamburgerView.setVisibility(View.VISIBLE); findViewById(R.id.cart_items).setVisibility(View.INVISIBLE); basketBtn.setVisibility(View.GONE); if (Statics.isBasket) shopingCartIndex = setTopBarRightButton(basketBtn, getResources().getString(R.string.shopping_cart), listener); } productTitle = (TextView) findViewById(R.id.product_title); productTitle.setText(product.name); product_sku = (TextView) findViewById(R.id.product_sku); if (TextUtils.isEmpty(product.sku)) { product_sku.setVisibility(View.GONE); product_sku.setText(""); } else { product_sku.setVisibility(View.VISIBLE); product_sku.setText(getString(R.string.item_sku) + " " + product.sku); } productDescription = (WebView) findViewById(R.id.product_description); productDescription.getSettings().setJavaScriptEnabled(true); productDescription.getSettings().setDomStorageEnabled(true); productDescription.setWebChromeClient(new WebChromeClient()); productDescription.setWebViewClient(new WebViewClient() { @Override public void onLoadResource(WebView view, String url) { if (!alreadyLoaded && (url.startsWith("http://www.youtube.com/get_video_info?") || url.startsWith("https://www.youtube.com/get_video_info?")) && Build.VERSION.SDK_INT <= 11) { try { String path = url.contains("https://www.youtube.com/get_video_info?") ? url.replace("https://www.youtube.com/get_video_info?", "") : url.replace("http://www.youtube.com/get_video_info?", ""); String[] parqamValuePairs = path.split("&"); String videoId = null; for (String pair : parqamValuePairs) { if (pair.startsWith("video_id")) { videoId = pair.split("=")[1]; break; } } if (videoId != null) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse("http://www.youtube.com/watch?v=" + videoId))); alreadyLoaded = !alreadyLoaded; } } catch (Exception ex) { } } else { super.onLoadResource(view, url); } } @Override public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { final AlertDialog.Builder builder = new AlertDialog.Builder(ProductDetails.this); builder.setMessage(R.string.catalog_notification_error_ssl_cert_invalid); builder.setPositiveButton(ProductDetails.this.getResources().getString(R.string.catalog_continue), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.proceed(); } }); builder.setNegativeButton(ProductDetails.this.getResources().getString(R.string.catalog_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (url.contains("youtube.com/embed")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse(url))); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("tel:")) { Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); startActivity(intent); return true; } else if (url.startsWith("mailto:")) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(url)); startActivity(intent); return true; } else if (url.contains("youtube.com")) { try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse(url))); return true; } catch (Exception ex) { return false; } } else if (url.contains("goo.gl") || url.contains("maps") || url.contains("maps.yandex") || url.contains("livegpstracks")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setData(Uri.parse(url))); return true; } else { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setData(Uri.parse(url))); return true; } } }); productDescription.loadDataWithBaseURL(null, product.description, "text/html", "UTF-8", null); productPrice = (TextView) findViewById(R.id.product_price); productPrice.setVisibility( "0.00".equals(String.format(Locale.US, "%.2f", product.price)) ? View.GONE : View.VISIBLE); String result = com.ibuildapp.romanblack.CataloguePlugin.utils.Utils .currencyToPosition(Statics.uiConfig.currency, product.price); if (result.contains(getResources().getString(R.string.rest_number_pattern))) result = result.replace(getResources().getString(R.string.rest_number_pattern), ""); productPrice.setText(result); likeCount = (TextView) findViewById(R.id.like_count); likeImage = (ImageView) findViewById(R.id.like_image); if (!TextUtils.isEmpty(product.imageURL)) { new Thread(new Runnable() { @Override public void run() { String token = FacebookAuthorizationActivity.getFbToken( com.appbuilder.sdk.android.Statics.FACEBOOK_APP_ID, com.appbuilder.sdk.android.Statics.FACEBOOK_APP_SECRET); if (TextUtils.isEmpty(token)) return; List<String> urls = new ArrayList<String>(); urls.add(product.imageURL); final Map<String, String> res = FacebookAuthorizationActivity.getLikesForUrls(urls, token); if (res != null) { runOnUiThread(new Runnable() { @Override public void run() { likeCount.setText(res.get(product.imageURL)); } }); } Log.e("", ""); } }).start(); } shareBtn = (LinearLayout) findViewById(R.id.share_button); if (Statics.uiConfig.showShareButton) shareBtn.setVisibility(View.VISIBLE); else shareBtn.setVisibility(View.GONE); shareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialogSharing(new DialogSharing.Configuration.Builder() .setFacebookSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { // checking Internet connection if (!Utils.networkAvailable(ProductDetails.this)) Toast.makeText(ProductDetails.this, getResources().getString(R.string.alert_no_internet), Toast.LENGTH_SHORT).show(); else { if (Authorization .getAuthorizedUser(Authorization.AUTHORIZATION_TYPE_FACEBOOK) != null) { shareFacebook(); } else { Authorization.authorize(ProductDetails.this, FACEBOOK_AUTHORIZATION_ACTIVITY, Authorization.AUTHORIZATION_TYPE_FACEBOOK); } } } }).setTwitterSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { // checking Internet connection if (!Utils.networkAvailable(ProductDetails.this)) Toast.makeText(ProductDetails.this, getResources().getString(R.string.alert_no_internet), Toast.LENGTH_SHORT).show(); else { if (Authorization .getAuthorizedUser(Authorization.AUTHORIZATION_TYPE_TWITTER) != null) { shareTwitter(); } else { Authorization.authorize(ProductDetails.this, TWITTER_AUTHORIZATION_ACTIVITY, Authorization.AUTHORIZATION_TYPE_TWITTER); } } } }).setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { Intent intent = chooseEmailClient(); intent.setType("text/html"); // ************************************************************************************************* // preparing sharing message String downloadThe = getString(R.string.directoryplugin_email_download_this); String androidIphoneApp = getString( R.string.directoryplugin_email_android_iphone_app); String postedVia = getString(R.string.directoryplugin_email_posted_via); String foundThis = getString(R.string.directoryplugin_email_found_this); // prepare content String downloadAppUrl = String.format( "http://%s/projects.php?action=info&projectid=%s", com.appbuilder.sdk.android.Statics.BASE_DOMEN, Statics.appId); String adPart = String.format( downloadThe + " %s " + androidIphoneApp + ": <a href=\"%s\">%s</a><br>%s", Statics.appName, downloadAppUrl, downloadAppUrl, postedVia + " <a href=\"http://ibuildapp.com\">www.ibuildapp.com</a>"); // content part String contentPath = String.format( "<!DOCTYPE html><html><body><b>%s</b><br><br>%s<br><br>%s</body></html>", product.name, product.description, com.ibuildapp.romanblack.CataloguePlugin.Statics.hasAd ? adPart : ""); contentPath = contentPath.replaceAll("\\<img.*?>", ""); // prepare image to attach // FROM ASSETS InputStream stream = null; try { if (!TextUtils.isEmpty(product.imageRes)) { stream = manager.open(product.imageRes); String fileName = inputStreamToFile(stream); File copyTo = new File(fileName); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(copyTo)); } } catch (IOException e) { // from cache File copyTo = new File(product.imagePath); if (copyTo.exists()) { intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(copyTo)); } } intent.putExtra(Intent.EXTRA_SUBJECT, product.name); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(contentPath)); startActivity(intent); } }).build()); // openOptionsMenu(); } }); likeBtn = (LinearLayout) findViewById(R.id.like_button); if (Statics.uiConfig.showLikeButton) likeBtn.setVisibility(View.VISIBLE); else likeBtn.setVisibility(View.GONE); likeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Utils.networkAvailable(ProductDetails.this)) { if (!TextUtils.isEmpty(product.imageURL)) { if (Authorization.isAuthorized(Authorization.AUTHORIZATION_TYPE_FACEBOOK)) { new Thread(new Runnable() { @Override public void run() { List<String> userLikes = null; try { userLikes = FacebookAuthorizationActivity.getUserOgLikes(); for (String likeUrl : userLikes) { if (likeUrl.compareToIgnoreCase(product.imageURL) == 0) { likedbyMe = true; break; } } if (!likedbyMe) { if (FacebookAuthorizationActivity.like(product.imageURL)) { String likeCountStr = likeCount.getText().toString(); try { final int res = Integer.parseInt(likeCountStr); runOnUiThread(new Runnable() { @Override public void run() { likeCount.setText(Integer.toString(res + 1)); enableLikeButton(false); Toast.makeText(ProductDetails.this, getString(R.string.like_success), Toast.LENGTH_SHORT).show(); } }); } catch (NumberFormatException e) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(ProductDetails.this, getString(R.string.like_error), Toast.LENGTH_SHORT).show(); } }); } } } else { runOnUiThread(new Runnable() { @Override public void run() { enableLikeButton(false); Toast.makeText(ProductDetails.this, getString(R.string.already_liked), Toast.LENGTH_SHORT) .show(); } }); } } catch (FacebookAuthorizationActivity.FacebookNotAuthorizedException e) { if (!Utils.networkAvailable(ProductDetails.this)) { Toast.makeText(ProductDetails.this, getString(R.string.alert_no_internet), Toast.LENGTH_SHORT) .show(); return; } Authorization.authorize(ProductDetails.this, AUTHORIZATION_FB, Authorization.AUTHORIZATION_TYPE_FACEBOOK); } catch (FacebookAuthorizationActivity.FacebookAlreadyLiked facebookAlreadyLiked) { facebookAlreadyLiked.printStackTrace(); } } }).start(); } else { if (!Utils.networkAvailable(ProductDetails.this)) { Toast.makeText(ProductDetails.this, getString(R.string.alert_no_internet), Toast.LENGTH_SHORT).show(); return; } Authorization.authorize(ProductDetails.this, AUTHORIZATION_FB, Authorization.AUTHORIZATION_TYPE_FACEBOOK); } } else Toast.makeText(ProductDetails.this, getString(R.string.nothing_to_like), Toast.LENGTH_SHORT) .show(); } else Toast.makeText(ProductDetails.this, getString(R.string.alert_no_internet), Toast.LENGTH_SHORT) .show(); } }); if (TextUtils.isEmpty(product.imageURL)) { enableLikeButton(false); } else { if (Authorization.isAuthorized(Authorization.AUTHORIZATION_TYPE_FACEBOOK)) { new Thread(new Runnable() { @Override public void run() { List<String> userLikes = null; try { userLikes = FacebookAuthorizationActivity.getUserOgLikes(); for (String likeUrl : userLikes) { if (likeUrl.compareToIgnoreCase(product.imageURL) == 0) { likedbyMe = true; break; } } runOnUiThread(new Runnable() { @Override public void run() { enableLikeButton(!likedbyMe); } }); } catch (FacebookAuthorizationActivity.FacebookNotAuthorizedException e) { e.printStackTrace(); } } }).start(); } } // product bitmap rendering image = (AlphaImageView) findViewById(R.id.product_image); image.setVisibility(View.GONE); if (!TextUtils.isEmpty(product.imageRes)) { try { InputStream input = manager.open(product.imageRes); Bitmap btm = BitmapFactory.decodeStream(input); if (btm != null) { int ratio = btm.getWidth() / btm.getHeight(); image.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenWidth / ratio)); image.setImageBitmapWithAlpha(btm); //image.setImageBitmap(btm); return; } } catch (IOException e) { } } if (!TextUtils.isEmpty(product.imagePath)) { Bitmap btm = BitmapFactory.decodeFile(product.imagePath); if (btm != null) { if (btm.getWidth() != 0 && btm.getHeight() != 0) { float ratio = (float) btm.getWidth() / (float) btm.getHeight(); image.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, (int) (screenWidth / ratio))); image.setImageBitmapWithAlpha(btm); image.setVisibility(View.GONE); return; } } } if (!TextUtils.isEmpty(product.imageURL)) { new Thread(new Runnable() { @Override public void run() { product.imagePath = com.ibuildapp.romanblack.CataloguePlugin.utils.Utils .downloadFile(product.imageURL); if (!TextUtils.isEmpty(product.imagePath)) { SqlAdapter.updateProduct(product); final Bitmap btm = BitmapFactory.decodeFile(product.imagePath); if (btm != null) { runOnUiThread(new Runnable() { @Override public void run() { if (btm.getWidth() != 0 && btm.getHeight() != 0) { float ratio = (float) btm.getWidth() / (float) btm.getHeight(); image.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, (int) (screenWidth / ratio))); image.setImageBitmapWithAlpha(btm); image.setVisibility(View.GONE); } } }); } } } }).start(); } image.setVisibility(View.GONE); }
From source file:com.justone.android.main.MainActivity.java
public void shareOnClick(View view) { String shareTitle = ""; String shareContent = " "; if (tabs.getCurrentTabTag() == "home tab") { shareTitle = "home tab"; shareContent = shareContent + ((TextView) this.findViewById(R.id.fPage_tView)).getText().toString() + ((TextView) this.findViewById(R.id.imageBelow_tView)).getText().toString() + "() " + ((TextView) this.findViewById(R.id.home_share_url)).getText().toString(); } else if (tabs.getCurrentTabTag() == "QA Tab") { shareTitle = "QA Tab"; shareContent = shareContent + ((TextView) this.findViewById(R.id.question_content)).getText().toString() + " - () " + ((TextView) this.findViewById(R.id.qa_share_url)).getText().toString(); } else if (tabs.getCurrentTabTag() == "list tab") { shareTitle = "list tab"; shareContent = shareContent + "" + ((TextView) this.findViewById(R.id.one_content_title)).getText().toString() + " by " + ((TextView) this.findViewById(R.id.one_content_author)).getText().toString() + "- () " + ((TextView) this.findViewById(R.id.list_share_url)).getText().toString(); }// w w w . j a v a 2 s . co m Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // intent.setPackage("com.sina.weibo"); intent.putExtra(Intent.EXTRA_SUBJECT, ""); //intent.putExtra(Intent.EXTRA_TEXT, shareTitle+" VOL.516 () http://caodan.org/516-photo.html "); intent.putExtra(Intent.EXTRA_TEXT, shareContent); intent.putExtra(Intent.EXTRA_TITLE, shareTitle); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "")); }
From source file:com.pacoapp.paco.ui.MyExperimentsActivity.java
public void launchEmailTo(final String emailAddress) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { emailAddress }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.email_subject_paco_feedback)); emailIntent.setType("plain/text"); startActivity(emailIntent);/*from w w w . j a va 2s . c om*/ }
From source file:ca.uwaterloo.magic.goodhikes.MapsActivity.java
public void CaptureMapScreen() { GoogleMap.SnapshotReadyCallback callback = new GoogleMap.SnapshotReadyCallback() { Bitmap bitmap;/* w w w . ja v a 2s. co m*/ @Override public void onSnapshotReady(Bitmap snapshot) { // TODO Auto-generated method stub bitmap = snapshot; String path = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "route_screenshot", null); Uri uri_image = Uri.parse(path); // share intent Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_STREAM, uri_image); sendIntent.putExtra(Intent.EXTRA_TEXT, "My Route"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Hey! Check out my route on Goodhikes"); sendIntent.setType("image/*"); startActivity(Intent.createChooser(sendIntent, "Share to...")); } }; mMap.snapshot(callback); }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.button_add_device) addDevice();/*from w ww .ja va2 s . c o m*/ else if (itemId == R.id.button_about) { mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.button_about) .setMessage(R.string.about) .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickinstaller) .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); final String installer_file = getResources() .getStringArray(R.array.installer_values)[which]; mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickdownloader) .setItems(R.array.download_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String action = getResources().getStringArray( R.array.download_values)[which]; if (ACTION_DOWNLOAD_SDCARD.equals(action) && copyFileToSDCard(installer_file)) Toast.makeText(TapLockSettings.this, "Done!", Toast.LENGTH_SHORT).show(); else if (ACTION_DOWNLOAD_EMAIL.equals(action) && copyFileToSDCard(installer_file)) { Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); emailIntent.setType( "application/java-archive"); emailIntent.putExtra(Intent.EXTRA_TEXT, getString( R.string.email_instructions)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + Environment .getExternalStorageDirectory() .getPath() + "/" + installer_file)); startActivity(Intent.createChooser( emailIntent, getString( R.string.button_getserver))); } } }) .create(); mDialog.show(); } }).create(); mDialog.show(); } }).setPositiveButton(R.string.button_license, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.button_license).setMessage(R.string.license).create(); mDialog.show(); } }).create(); mDialog.show(); } return super.onOptionsItemSelected(item); }
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Handles click on confirmation to send info. *//*from ww w . j a v a2s. co m*/ private void onClickReallySendInfo() { ContextAccessor.getInstanceAndLogPreferences(this); // write settings to log MindBell.logDebug("Excluded from battery optimization (always false for SDK < 23)? -> " + Utils.isAppWhitelisted(this)); Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getText(R.string.emailAddress).toString(), null)); i.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.emailSubject)); i.putExtra(Intent.EXTRA_TEXT, getInfoMailText()); try { startActivity(Intent.createChooser(i, getText(R.string.emailChooseApp))); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(this, getText(R.string.noEmailClients), Toast.LENGTH_SHORT).show(); } }
From source file:android_network.hetnet.vpn_service.Util.java
public static void sendLogcat(final Uri uri, final Context context) { AsyncTask task = new AsyncTask<Object, Object, Intent>() { @Override/*from w w w . ja v a 2s. co m*/ protected Intent doInBackground(Object... objects) { StringBuilder sb = new StringBuilder(); sb.append(context.getString(R.string.msg_issue)); sb.append("\r\n\r\n\r\n\r\n"); // Get version info String version = getSelfVersionName(context); sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context))); sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT)); sb.append("\r\n"); // Get device info sb.append(String.format("Brand: %s\r\n", Build.BRAND)); sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER)); sb.append(String.format("Model: %s\r\n", Build.MODEL)); sb.append(String.format("Product: %s\r\n", Build.PRODUCT)); sb.append(String.format("Device: %s\r\n", Build.DEVICE)); sb.append(String.format("Host: %s\r\n", Build.HOST)); sb.append(String.format("Display: %s\r\n", Build.DISPLAY)); sb.append(String.format("Id: %s\r\n", Build.ID)); sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context))); String abi; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) abi = Build.CPU_ABI; else abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?"); sb.append(String.format("ABI: %s\r\n", abi)); sb.append("\r\n"); sb.append(String.format("VPN dialogs: %B\r\n", isPackageInstalled("com.android.vpndialogs", context))); try { sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null)); } catch (Throwable ex) { sb.append("Prepared: ").append((ex.toString())).append("\r\n") .append(Log.getStackTraceString(ex)); } sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context))); sb.append("\r\n"); sb.append(getGeneralInfo(context)); sb.append("\r\n\r\n"); sb.append(getNetworkInfo(context)); sb.append("\r\n\r\n"); sb.append(getSubscriptionInfo(context)); sb.append("\r\n\r\n"); // Get settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Map<String, ?> all = prefs.getAll(); for (String key : all.keySet()) sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n"); sb.append("\r\n"); // Write logcat OutputStream out = null; try { Log.i(TAG, "Writing logcat URI=" + uri); out = context.getContentResolver().openOutputStream(uri); out.write(getLogcat().toString().getBytes()); out.write(getTrafficLog(context).toString().getBytes()); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n"); } finally { if (out != null) try { out.close(); } catch (IOException ignored) { } } // Build intent Intent sendEmail = new Intent(Intent.ACTION_SEND); sendEmail.setType("message/rfc822"); sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" }); sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat"); sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString()); sendEmail.putExtra(Intent.EXTRA_STREAM, uri); return sendEmail; } @Override protected void onPostExecute(Intent sendEmail) { if (sendEmail != null) try { context.startActivity(sendEmail); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }; task.execute(); }