public static void SetFileExplorerLink( TextView txtFilename, Spanned htmlString, final String pathToLinkTo, final Context context) { final Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file://" + pathToLinkTo), "resource/folder"); intent.setAction(Intent.ACTION_VIEW); if (intent.resolveActivity(context.getPackageManager()) != null) { txtFilename.setLinksClickable(true); txtFilename.setClickable(true); txtFilename.setMovementMethod(LinkMovementMethod.getInstance()); txtFilename.setSelectAllOnFocus(false); txtFilename.setTextIsSelectable(false); txtFilename.setText(htmlString); txtFilename.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { context.startActivity(intent); } }); } }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnQueryTextListener(this); MenuItemCompat.setOnActionExpandListener( menu.findItem(R.id.action_search), new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { mPreviousList = new ArrayList<Track>(mTracks); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { getTracks(mPreviousList); return true; } }); mSoundcloudLink = (TextView) menu.findItem(R.id.soundcloud_url).getActionView(); mSoundcloudLink.setTextIsSelectable(true); return true; }
public static void showShareDialog(final Context mContext, GCSavedSet savedSet) { AlertDialog.Builder alert = new AlertDialog.Builder(mContext); alert.setTitle(mContext.getString(R.string.share_code)); alert.setIcon(R.drawable.ic_share_black_48dp); TextView input = new TextView(mContext); input.setTextIsSelectable(true); final String shareString = getShareString(savedSet); input.setText(shareString); input.setGravity(Gravity.CENTER_HORIZONTAL); input.setPadding(64, 32, 64, 32); alert.setView(input); alert.setPositiveButton( mContext.getString(R.string.copy), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", shareString); clipboard.setPrimaryClip(clip); Toast.makeText(mContext, "Copied to clipboard", Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); alert.setNegativeButton( mContext.getString(R.string.share), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra( Intent.EXTRA_TEXT, "https://deeplink.me/glovercolorapp.com/entercode/" + shareString); sendIntent.setType("text/plain"); mContext.startActivity(Intent.createChooser(sendIntent, "Share gloving set with")); } }); alert.setNeutralButton( mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); }
@SuppressLint("NewApi") public void onMenuCopyClicked() { String text = dobroitem.post.getMessage() == null ? dobroitem.post.getFormattedText().toString() : dobroitem.post.getMessage(); /* Intent i = new Intent(getContext(), CopyPasteActivity.class); i.putExtra("text", ); i.putExtra(GDActivity.GD_ACTION_BAR_TITLE, "Скопируйте текст"); getContext().startActivity(i); */ View v = null; if (Build.VERSION.SDK_INT < 11) { EditText edit = new EditText(getContext()); edit.setPadding(10, 10, 10, 10); edit.setGravity(Gravity.TOP); edit.setTextColor(Color.BLACK); edit.setBackgroundColor(Color.WHITE); edit.setInputType(InputType.TYPE_NULL); edit.setHorizontallyScrolling(false); edit.setSingleLine(false); edit.setText(text); v = edit; } else { SharedPreferences prefs = DobroApplication.getApplicationStatic().getDefaultPrefs(); int font_size = 10; try { font_size = Integer.parseInt(prefs.getString("font_size", "16")); } catch (Exception e) { } if (font_size < 10) font_size = 10; TextView edit = new TextView(getContext()); edit.setPadding(10, 10, 10, 10); edit.setTextSize(font_size); edit.setTextColor(Color.BLACK); edit.setBackgroundColor(Color.WHITE); edit.setFocusable(true); edit.setTextIsSelectable(true); edit.setText(text); v = edit; } Dialog d = new Dialog(getContext(), android.R.style.Theme_NoTitleBar_Fullscreen); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setCanceledOnTouchOutside(true); d.setContentView(v); d.show(); }
@Override public void setTextIsSelectable(boolean selectable) { mTextIsSelectable = selectable; super.setTextIsSelectable(selectable); }