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) {
}
}
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);
}
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);
}
});
}
});
}
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]);
}
}
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();
}
Aggregations