Search in sources :

Example 76 with ClipboardManager

use of android.content.ClipboardManager in project AisenWeiBo by wangdan.

the class AisenUtils method copyToClipboard.

public static void copyToClipboard(String text) {
    // 得到剪贴板管理器
    try {
        ClipboardManager cmb = (ClipboardManager) GlobalContext.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
        cmb.setPrimaryClip(ClipData.newPlainText(null, text.trim()));
    } catch (Exception e) {
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) TaskException(org.aisen.android.network.task.TaskException)

Example 77 with ClipboardManager

use of android.content.ClipboardManager in project AndroidChromium by JackyAndroid.

the class LocationBarLayout method initializeControls.

@Override
public void initializeControls(WindowDelegate windowDelegate, ActionBarDelegate actionBarDelegate, WindowAndroid windowAndroid) {
    mWindowDelegate = windowDelegate;
    mActionModeController = new ActionModeController(getContext(), actionBarDelegate);
    mActionModeController.setCustomSelectionActionModeCallback(new ToolbarActionModeCallback() {

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            boolean retVal = super.onCreateActionMode(mode, menu);
            mode.getMenuInflater().inflate(R.menu.textselectionmenu, menu);
            return retVal;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            if (item.getItemId() == R.id.copy_url) {
                ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("url", mOriginalUrl);
                clipboard.setPrimaryClip(clip);
                mode.finish();
                return true;
            } else {
                return super.onActionItemClicked(mode, item);
            }
        }
    });
    mWindowAndroid = windowAndroid;
    // If the user focused the omnibox prior to the native libraries being initialized,
    // autocomplete will not always be enabled, so we force it enabled in that case.
    mUrlBar.setIgnoreTextChangesForAutocomplete(false);
}
Also used : ClipboardManager(android.content.ClipboardManager) ToolbarActionModeCallback(org.chromium.chrome.browser.toolbar.ToolbarActionModeCallback) ActionMode(android.view.ActionMode) ActionModeController(org.chromium.chrome.browser.toolbar.ActionModeController) MenuItem(android.view.MenuItem) Menu(android.view.Menu) ClipData(android.content.ClipData)

Example 78 with ClipboardManager

use of android.content.ClipboardManager in project LeafPic by HoraApps.

the class DonateActivity method setTheme.

private void setTheme() {
    /**** ToolBar *****/
    toolbar.setBackgroundColor(getPrimaryColor());
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_arrow_left).color(Color.WHITE).sizeDp(19));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    toolbar.setTitle(getString(org.horaapps.leafpic.R.string.donate));
    setStatusBarColor();
    setNavBarColor();
    setRecentApp(getString(org.horaapps.leafpic.R.string.donate));
    final Button btnDonateIap = (Button) findViewById(R.id.button_donate_play_store);
    btnDonateIap.setText(String.format("%s %d€", getString(R.string.donate).toUpperCase(), progress));
    themeSeekBar(bar);
    bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            if (i == 0)
                progress = 2;
            else
                progress = (i + 1) * 2;
            btnDonateIap.setText(String.format("%s %d€", getString(R.string.donate).toUpperCase(), progress));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    /**** Title Cards ***/
    ((TextView) findViewById(org.horaapps.leafpic.R.id.team_name)).setTextColor(getAccentColor());
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_item_title)).setTextColor(getAccentColor());
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_item_title)).setTextColor(getAccentColor());
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_item_title)).setTextColor(getAccentColor());
    /** BackGround **/
    findViewById(org.horaapps.leafpic.R.id.donate_background).setBackgroundColor(getBackgroundColor());
    /** Cards **/
    int color = getCardBackgroundColor();
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_card)).setCardBackgroundColor(color);
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_card)).setCardBackgroundColor(color);
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_card)).setCardBackgroundColor(color);
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_header_card)).setCardBackgroundColor(color);
    /** Icons **/
    color = getIconColor();
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_icon_title)).setColor(color);
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_icon_title)).setColor(color);
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_icon_title)).setColor(color);
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_header_icon)).setColor(color);
    /** TextViews **/
    color = getTextColor();
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_item)).setTextColor(color);
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_item)).setTextColor(color);
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_item)).setTextColor(color);
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_header_item)).setTextColor(color);
    /***** ScrolView *****/
    setScrollViewColor(scr);
    /** ACTIONS **/
    findViewById(org.horaapps.leafpic.R.id.button_donate_paypal).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cts.launchUrl("https://www.paypal.me/HoraApps");
        }
    });
    findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_item).setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copied to Clipboard", ((TextView) v).getText());
            clipboard.setPrimaryClip(clip);
            StringUtils.showToast(getApplicationContext(), getString(org.horaapps.leafpic.R.string.address_copied));
            return true;
        }
    });
    findViewById(R.id.button_donate_play_store).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mHelper != null)
                mHelper.flagEndAsync();
            mHelper.launchPurchaseFlow(DonateActivity.this, "donation_" + progress, 123, new IabHelper.OnIabPurchaseFinishedListener() {

                @Override
                public void onIabPurchaseFinished(IabResult result, Purchase info) {
                    mHelper.consumeAsync(info, mPurchaseFinishedListener);
                }
            });
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) Purchase(org.horaapps.leafpic.util.inapppurchase.Purchase) SeekBar(android.widget.SeekBar) CardView(android.support.v7.widget.CardView) IabResult(org.horaapps.leafpic.util.inapppurchase.IabResult) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) View(android.view.View) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) Button(android.widget.Button) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) ClipData(android.content.ClipData)

Example 79 with ClipboardManager

use of android.content.ClipboardManager in project android_frameworks_base by ParanoidAndroid.

the class WebViewClassic method showPasteWindow.

private void showPasteWindow() {
    ClipboardManager cm = (ClipboardManager) (mContext.getSystemService(Context.CLIPBOARD_SERVICE));
    if (cm.hasPrimaryClip()) {
        Point cursorPoint = new Point(contentToViewX(mSelectCursorBase.x), contentToViewY(mSelectCursorBase.y));
        Point cursorTop = calculateBaseCaretTop();
        cursorTop.set(contentToViewX(cursorTop.x), contentToViewY(cursorTop.y));
        int[] location = new int[2];
        mWebView.getLocationInWindow(location);
        int offsetX = location[0] - getScrollX();
        int offsetY = location[1] - getScrollY();
        cursorPoint.offset(offsetX, offsetY);
        cursorTop.offset(offsetX, offsetY);
        if (mPasteWindow == null) {
            mPasteWindow = new PastePopupWindow();
        }
        mPasteWindow.show(cursorPoint, cursorTop, location[0], location[1]);
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) Point(android.graphics.Point) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 80 with ClipboardManager

use of android.content.ClipboardManager in project android_frameworks_base by ParanoidAndroid.

the class TextView method setPrimaryClip.

private void setPrimaryClip(ClipData clip) {
    ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(clip);
    LAST_CUT_OR_COPY_TIME = SystemClock.uptimeMillis();
}
Also used : ClipboardManager(android.content.ClipboardManager)

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