android.content.ClipboardManager Java Examples
The following examples show how to use
android.content.ClipboardManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClipboardModule.java From react-native-GPay with MIT License | 6 votes |
@ReactMethod public void getString(Promise promise) { try { ClipboardManager clipboard = getClipboardService(); ClipData clipData = clipboard.getPrimaryClip(); if (clipData == null) { promise.resolve(""); } else if (clipData.getItemCount() >= 1) { ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0); promise.resolve("" + firstItem.getText()); } else { promise.resolve(""); } } catch (Exception e) { promise.reject(e); } }
Example #2
Source File: gifa.java From stynico with MIT License | 6 votes |
public void cclick() { EditText et=(EditText) findViewById(R.id.mainEditText1); String os =et.getText().toString(); char[] a = os.toCharArray(); StringBuffer b = new StringBuffer(""); String mo ="敏ۣۖ"; for (int i=0;i < a.length;i++) { b.append(mo.replace('敏', a[i])) ; ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); manager.setText(b); } TextView t=(TextView) findViewById(R.id.mainTextView1); t.setText(b); }
Example #3
Source File: MainActivity.java From FileTransfer with GNU General Public License v3.0 | 6 votes |
@Override protected void onResume() { super.onResume(); ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard != null && clipboard.hasPrimaryClip() && clipboard.getPrimaryClip() != null) { ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); if (item != null && item.getText() != null && item.getText().length() > 0 && !item.getText().equals(mAlreadyWrited)) { File file = new File(Constants.DIR, "clipboard_" + String.valueOf(System.currentTimeMillis()) + ".txt"); try { FileUtils.writeByteArrayToFile(file, item.getText().toString().getBytes(), false); Toast.makeText(this, "已把剪切板中内容写入到该文件中", Toast.LENGTH_SHORT).show(); RxBus.get().post(Constants.RxBusEventType.LOAD_BOOK_LIST, 0); mAlreadyWrited = item.getText().toString(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(this, "文件写入失败", Toast.LENGTH_SHORT).show(); } } } }
Example #4
Source File: CustomTabToolbar.java From delion with Apache License 2.0 | 6 votes |
@Override public boolean onLongClick(View v) { if (v == mCloseButton) { return showAccessibilityToast(v, getResources().getString(R.string.close_tab)); } else if (v == mCustomActionButton) { return showAccessibilityToast(v, mCustomActionButton.getContentDescription()); } else if (v == mTitleUrlContainer) { ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("url", mUrlBar.getText()); clipboard.setPrimaryClip(clip); Toast.makeText(getContext(), R.string.url_copied, Toast.LENGTH_SHORT).show(); return true; } return false; }
Example #5
Source File: DonateActivity.java From dtube-mobile-unofficial with Apache License 2.0 | 6 votes |
public void copyAddress(View v){ String address = null; switch (v.getId()){ case R.id.copybtc: address = "148kJvCVMmHfEPKxerz6Y4jdc94765c5VK"; break; case R.id.copyeth: address = "0x944e6bc2c86144B89EaF7612782a5F570F5967a2"; break; case R.id.copyltc: address = "LPxnm3UQ7VpL9stRCgECZgxkXuvb2jw1ik"; break; } ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("address", address); clipboard.setPrimaryClip(clip); Toast.makeText(this,R.string.copied,Toast.LENGTH_LONG).show(); }
Example #6
Source File: ManChapterItemOnClickListener.java From Man-Man with GNU General Public License v3.0 | 6 votes |
@Override public void onClick(final View v) { PopupMenu pm = new PopupMenu(mContext, v); pm.inflate(R.menu.chapter_item_popup); pm.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.share_link_popup_menu_item: Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TITLE, current.getName()); sendIntent.putExtra(Intent.EXTRA_TEXT, current.getUrl()); mContext.startActivity(Intent.createChooser(sendIntent, mContext.getString(R.string.share_link))); return true; case R.id.copy_link_popup_menu_item: ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); Toast.makeText(mContext.getApplicationContext(), mContext.getString(R.string.copied) + " " + current.getUrl(), Toast.LENGTH_SHORT).show(); clipboard.setPrimaryClip(ClipData.newPlainText(current.getName(), current.getUrl())); return true; } return false; } }); pm.show(); }
Example #7
Source File: gifa.java From stynico with MIT License | 6 votes |
public void c_styTool() { EditText et=(EditText) findViewById(R.id.mainEditText1); String os =et.getText().toString(); char[] a = os.toCharArray(); StringBuffer b = new StringBuffer(""); String mo =getResources().getString(R.string.android_gifa); for (int i=0;i < a.length;i++) { b.append(mo.replace('n', a[i])) ; ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); manager.setText(b); } TextView t=(TextView) findViewById(R.id.mainTextView1); t.setText(b); }
Example #8
Source File: BaseAccessibilityService.java From SmsCode with GNU General Public License v3.0 | 6 votes |
/** * 模拟输入 * * @param nodeInfo nodeInfo * @param text text */ public void inputText(AccessibilityNodeInfo nodeInfo, CharSequence text) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Bundle args = new Bundle(); args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text); nodeInfo.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args); } else { ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); if (cm == null) return; ClipData clipData = ClipData.newPlainText("label", text); cm.setPrimaryClip(clipData); nodeInfo.performAction(AccessibilityNodeInfo.ACTION_FOCUS); nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE); } }
Example #9
Source File: x5_MainActivity.java From stynico with MIT License | 6 votes |
private String getClipboardText() { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); String text = ""; try { if (clipboard != null && clipboard.hasText()) { CharSequence tmpText = clipboard.getText(); clipboard.setText(tmpText); if (tmpText != null && tmpText.length() > 0) { text = tmpText.toString().trim(); } } } catch (Exception e) { e.printStackTrace(); text = ""; } return text; }
Example #10
Source File: TransferTicketDetailActivity.java From alpha-wallet-android with MIT License | 6 votes |
private void onUserTransaction(String hash) { hideDialog(); dialog = new AWalletAlertDialog(this); dialog.setTitle(R.string.transaction_succeeded); dialog.setMessage(hash); dialog.setButtonText(R.string.copy); dialog.setButtonListener(v -> { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("transaction hash", EthereumNetworkBase.getEtherscanURLbyNetwork(token.tokenInfo.chainId) + "tx/" + hash); clipboard.setPrimaryClip(clip); dialog.dismiss(); sendBroadcast(new Intent(PRUNE_ACTIVITY)); }); dialog.setOnDismissListener(v -> { dialog.dismiss(); sendBroadcast(new Intent(PRUNE_ACTIVITY)); new HomeRouter().open(this, true); finish(); }); dialog.show(); }
Example #11
Source File: ViewBuilder.java From QNotified with GNU General Public License v3.0 | 6 votes |
public static LinearLayout newDialogClickableItemClickToCopy(final Context ctx, String title, String value, ViewGroup vg, boolean attach) { return newDialogClickableItem(ctx, title, value, new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Context c = v.getContext(); String msg = ((TextView) v).getText().toString(); if (msg.length() > 0) { ClipboardManager cm = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); if (cm != null) { cm.setText(msg); Utils.showToastShort(c, "已复制文本"); } } return true; } }, vg, attach); }
Example #12
Source File: gifa.java From stynico with MIT License | 6 votes |
public void click() { EditText et=(EditText) findViewById(R.id.mainEditText1); String os =et.getText().toString(); char[] a = os.toCharArray(); StringBuffer b = new StringBuffer(""); String mo ="ζั͡爱 ั͡✾"; for (int i=0;i < a.length;i++) { b.append(mo.replace('爱', a[i])) ; ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); manager.setText(b); } TextView t=(TextView) findViewById(R.id.mainTextView1); t.setText(b); }
Example #13
Source File: AweMeHook.java From xposed-aweme with Apache License 2.0 | 6 votes |
@Override public boolean onLongClick(View v) { if (!mUserConfigManager.isCopyVideoDesc()) { return false; } try { // 把信息复制到粘贴板上 ClipboardManager cm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); cm.setPrimaryClip(ClipData.newPlainText(null, ((TextView) v).getText())); ToastUtil.show("内容已复制到粘贴板!"); } catch (Throwable tr) { Alog.e("出异常了", tr); ToastUtil.show("内容复制到粘贴板出错了!"); } return true; }
Example #14
Source File: ClipboardTest.java From hash-checker with Apache License 2.0 | 6 votes |
@Test public void validateClipboardTest() { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { Activity activity = activityTestRule.getActivity(); String text = "Test text"; new Clipboard( activity, text ).copy(); ClipboardManager clipboardManager = (ClipboardManager) activity.getSystemService( Context.CLIPBOARD_SERVICE ); assertEquals( clipboardManager.getPrimaryClip().getItemAt(0).coerceToText( activity ), text ); }); }
Example #15
Source File: ws_Main3Activity.java From styT with Apache License 2.0 | 6 votes |
private String getClipboardText() { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); String text = ""; try { if (clipboard != null && clipboard.hasText()) { CharSequence tmpText = clipboard.getText(); clipboard.setText(tmpText); if (tmpText != null && tmpText.length() > 0) { text = tmpText.toString().trim(); } } } catch (Exception e) { e.printStackTrace(); text = ""; } return text; }
Example #16
Source File: ChatSelectTouchListener.java From revolution-irc with GNU General Public License v3.0 | 6 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.action_copy: ClipboardManager clipboard = (ClipboardManager) mRecyclerView.getContext() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText("IRC Messages", getSelectedText())); clearSelection(); mode.finish(); return true; case R.id.action_share: Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, getSelectedText()); intent.setType("text/plain"); mRecyclerView.getContext().startActivity(Intent.createChooser(intent, mRecyclerView.getContext().getString(R.string.message_share_title))); clearSelection(); mode.finish(); return true; default: return false; } }
Example #17
Source File: ClipboardManagerUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 6 votes |
public static CharSequence getText() { android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager(); if (APILevel.require(11)) { ClipboardManager cm = (ClipboardManager) clipboardManager; ClipDescription description = cm.getPrimaryClipDescription(); ClipData clipData = cm.getPrimaryClip(); if (clipData != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) return clipData.getItemAt(0).getText(); else return null; } else { return clipboardManager.getText(); } }
Example #18
Source File: PopupActivity.java From ankihelper with GNU General Public License v3.0 | 6 votes |
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if(isFromAndroidQClipboard) { if (!Settings.getInstance(MyApplication.getContext()).getMoniteClipboardQ()) { return; } ClipboardManager cb = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); if (cb.hasPrimaryClip()) { if (cb.hasText()) { String text = cb.getText().toString(); mTextToProcess = text; } } populateWordSelectBox(); bigBangLayout.post( new Runnable() { @Override public void run() { setTargetWord(); if(Utils.containsTranslationField(currentOutputPlan)){ asyncTranslate(mTextToProcess); } } }); } }
Example #19
Source File: Utils.java From DNSHero with GNU General Public License v3.0 | 5 votes |
public static void clickToCopy(@NonNull TextView view, @NonNull String text) { view.setOnClickListener(v -> { ClipboardManager clipboard = (ClipboardManager) view.getContext().getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard == null) return; clipboard.setPrimaryClip(ClipData.newPlainText("", text)); Toaster.with(view.getContext()).message(R.string.copiedToClipboard).show(); }); }
Example #20
Source File: IdentityCookiePreference.java From EhViewer with Apache License 2.0 | 5 votes |
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); if (message != null) { builder.setPositiveButton(R.string.settings_eh_identity_cookies_copy, (dialog, which) -> { ClipboardManager cmb = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); cmb.setPrimaryClip(ClipData.newPlainText(null, message)); Toast.makeText(getContext(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); IdentityCookiePreference.this.onClick(dialog, which); }); } }
Example #21
Source File: DappBrowserFragment.java From alpha-wallet-android with MIT License | 5 votes |
private void copyToClipboard(String address) { ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(KEY_ADDRESS, address); if (clipboard != null) { clipboard.setPrimaryClip(clip); } Toast.makeText(getActivity(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); }
Example #22
Source File: TDevice.java From android-project-wo2b with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") public static void copyTextToBoard(Context context, String string) { if (TextUtils.isEmpty(string)) return; ClipboardManager clip = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clip.setText(string); }
Example #23
Source File: MessagesScreen.java From adamant-android with GNU General Public License v3.0 | 5 votes |
@Override public void copyCompanionId(String companionId) { ClipData clip = ClipData.newPlainText("adamant_address", companionId); ClipboardManager clipboard = (ClipboardManager) this.getSystemService(CLIPBOARD_SERVICE); if (clipboard != null) { clipboard.setPrimaryClip(clip); Toast.makeText(this.getApplicationContext(), R.string.address_was_copied, Toast.LENGTH_LONG).show(); } }
Example #24
Source File: GatheringQRCodeActivity.java From Upchain-wallet with GNU Affero General Public License v3.0 | 5 votes |
private void copyWalletAddress() { ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); // 将文本内容放到系统剪贴板里。 if (cm != null) { // 创建普通字符型ClipData ClipData mClipData = ClipData.newPlainText("Label", walletAddress); // 将ClipData内容放到系统剪贴板里。 cm.setPrimaryClip(mClipData); } ToastUtils.showToast(R.string.gathering_qrcode_copy_success); btnCopyAddress.setText(R.string.gathering_qrcode_copy_success); }
Example #25
Source File: BugReportActivity.java From Phonograph with GNU General Public License v3.0 | 5 votes |
private void copyDeviceInfoToClipBoard() { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(getString(R.string.device_info), deviceInfo.toMarkdown()); clipboard.setPrimaryClip(clip); Toast.makeText(BugReportActivity.this, R.string.copied_device_info_to_clipboard, Toast.LENGTH_LONG).show(); }
Example #26
Source File: FastEdit.java From fastedit with Apache License 2.0 | 5 votes |
public void copy() throws Exception { String selectText = getSelectText(); if (selectText == null) { return; } try { ClipboardManager cm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); cm.setPrimaryClip(ClipData.newPlainText("copy", selectText)); } catch (Exception e) { Toast.makeText(getContext(), "文字太长,复制失败!", Toast.LENGTH_SHORT).show(); throw e; } }
Example #27
Source File: ClipboardUtil.java From text_converter with GNU General Public License v3.0 | 5 votes |
public static void setClipboard(Context context, String text) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", text); if (clipboard != null) { clipboard.setPrimaryClip(clip); Toast.makeText(context, R.string.message_copied, Toast.LENGTH_SHORT).show(); } }
Example #28
Source File: FragmentCreateChannelViewModel.java From iGap-Android with GNU Affero General Public License v3.0 | 5 votes |
public void onClickTxtInputLink(View view) { if (isRadioButtonPrivate.get()) { final PopupMenu popup = new PopupMenu(G.fragmentActivity, view); //Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.menu_item_copy, popup.getMenu()); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_link_copy: String copy; copy = edtSetLink.get(); ClipboardManager clipboard = (ClipboardManager) G.context.getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("LINK_GROUP", copy); clipboard.setPrimaryClip(clip); break; } return true; } }); popup.show(); // } }
Example #29
Source File: BaseConversionActivity.java From DarkCalculator with MIT License | 5 votes |
private void initTextOut() { textOut = (TextView) findViewById(R.id.text_out); AutofitHelper.create(textOut).setMaxLines(5); textOut.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClipboardManager cmb = (ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(textOut.getText()); Snackbar.make(v, "已复制转换结果", Snackbar.LENGTH_SHORT).show(); } }); }
Example #30
Source File: PreferencesFragment.java From HouSi with Apache License 2.0 | 5 votes |
private void initPreferences() { mSettingCurrentSourceUrlMulti = (ListPreference) findPreference("setting_current_source_url_multi"); mSettingSwitchAlarmService = (SwitchPreference) findPreference("setting_switch_alarm_service"); mSettingServiceStartTime = (PreferenceScreen) findPreference("setting_service_start_time"); mSettingAlarmRepeat = (ListPreference) findPreference("setting_alarm_repeat"); mSettingAboutService = (PreferenceScreen) findPreference("setting_about_service"); mSettingCheckForUpdate = (PreferenceScreen) findPreference("setting_check_for_update"); mSettingCleanCache = (PreferenceScreen) findPreference("setting_clean_cache"); mSettingFaq = (PreferenceScreen) findPreference("setting_faq"); mSettingFeedback = (PreferenceScreen) findPreference("setting_feedback"); mSettingAbout = (PreferenceScreen) findPreference("setting_about"); mSettingAboutCache = (PreferenceScreen) findPreference("setting_about_cache"); mSettingCurrentSourceUrlMulti.setOnPreferenceClickListener(this); mSettingServiceStartTime.setOnPreferenceClickListener(this); mSettingCheckForUpdate.setOnPreferenceClickListener(this); mSettingCleanCache.setOnPreferenceClickListener(this); mSettingFaq.setOnPreferenceClickListener(this); mSettingFeedback.setOnPreferenceClickListener(this); mSettingAbout.setOnPreferenceClickListener(this); mSettingCurrentSourceUrlMulti.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String[] urlEntries = (String[]) ((ListPreference) preference).getEntries(); ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newRawUri("url", Uri.parse(urlEntries[Integer.parseInt((String) newValue)])); clipboardManager.setPrimaryClip(clipData); Toast.makeText(getActivity(), getString(R.string.clipboard_hint), Toast.LENGTH_SHORT).show(); return true; } }); initSourceUrl(); initSwitchAlarmService(); initVersionInfo(); initCache(); }