Search in sources :

Example 11 with ClipboardManager

use of android.content.ClipboardManager in project weiciyuan by qii.

the class BrowserCommentFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;
    switch(item.getItemId()) {
        case R.id.menu_comment:
            intent = new Intent(getActivity(), WriteReplyToCommentActivity.class);
            intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
            intent.putExtra("msg", msg);
            getActivity().startActivity(intent);
            break;
        case R.id.menu_share:
            buildShareActionMenu();
            return true;
        case R.id.menu_copy:
            ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", content.getText().toString()));
            Toast.makeText(getActivity(), getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
            break;
        default:
            return super.onOptionsItemSelected(item);
    }
    return true;
}
Also used : ClipboardManager(android.content.ClipboardManager) WriteReplyToCommentActivity(org.qii.weiciyuan.ui.send.WriteReplyToCommentActivity) Intent(android.content.Intent)

Example 12 with ClipboardManager

use of android.content.ClipboardManager in project weiciyuan by qii.

the class MainTimeLineActivity method readClipboard.

//read clipboard to know whether there are any string link can be opened
private void readClipboard() {
    ClipboardManager cm = (ClipboardManager) getApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData cmContent = cm.getPrimaryClip();
    if (cmContent == null) {
        return;
    }
    ClipData.Item item = cmContent.getItemAt(0);
    if (item != null) {
        String url = item.coerceToText(this).toString();
        boolean a = !TextUtils.isEmpty(url) && !url.equals(SettingUtility.getLastFoundWeiboAccountLink());
        boolean b = Utility.isWeiboAccountIdLink(url) || Utility.isWeiboAccountDomainLink(url);
        if (a && b) {
            OpenWeiboAccountLinkDialog dialog = OpenWeiboAccountLinkDialog.newInstance(url);
            dialog.show(getSupportFragmentManager(), "");
            SettingUtility.setLastFoundWeiboAccountLink(url);
        }
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 13 with ClipboardManager

use of android.content.ClipboardManager in project zxingfragmentlib by mitoyarzun.

the class ClipboardInterface method hasText.

public static boolean hasText(Context context) {
    ClipboardManager clipboard = getManager(context);
    ClipData clip = clipboard.getPrimaryClip();
    return clip != null && clip.getItemCount() > 0;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 14 with ClipboardManager

use of android.content.ClipboardManager in project LollipopShowcase by mikepenz.

the class DetailActivity method fillRow.

/**
     * fill the rows with some information
     *
     * @param view
     * @param title
     * @param description
     */
public void fillRow(View view, final String title, final String description) {
    TextView titleView = (TextView) view.findViewById(R.id.title);
    titleView.setText(title);
    TextView descriptionView = (TextView) view.findViewById(R.id.description);
    descriptionView.setText(description);
    view.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("AppInfo", description);
            clipboard.setPrimaryClip(clip);
            Snackbar.make(mCoordinatorLayout, "Copied " + title, Snackbar.LENGTH_SHORT).show();
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ClipData(android.content.ClipData)

Example 15 with ClipboardManager

use of android.content.ClipboardManager in project qksms by moezbhatti.

the class CopyUnreadMessageTextService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    Uri threadUri = intent.getParcelableExtra(EXTRA_THREAD_URI);
    String messages = SmsHelper.getUnreadMessageText(this, threadUri);
    ((ClipboardManager) getSystemService(CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText(messages, messages));
    mHandler.post(new RunnableToast(this, R.string.toast_copy_text, Toast.LENGTH_SHORT));
}
Also used : ClipboardManager(android.content.ClipboardManager) RunnableToast(com.moez.QKSMS.ui.view.RunnableToast) Uri(android.net.Uri)

Aggregations

ClipboardManager (android.content.ClipboardManager)125 ClipData (android.content.ClipData)82 Intent (android.content.Intent)17 View (android.view.View)15 TextView (android.widget.TextView)13 Context (android.content.Context)10 Paint (android.graphics.Paint)9 DialogInterface (android.content.DialogInterface)7 Bundle (android.os.Bundle)7 AlertDialog (android.support.v7.app.AlertDialog)7 Editable (android.text.Editable)7 TextPaint (android.text.TextPaint)7 ImageView (android.widget.ImageView)6 TargetApi (android.annotation.TargetApi)5 Spanned (android.text.Spanned)5 AlertDialog (android.app.AlertDialog)4 Uri (android.net.Uri)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 MenuItem (android.view.MenuItem)3