List of usage examples for android.content ClipData newPlainText
static public ClipData newPlainText(CharSequence label, CharSequence text)
From source file:com.zephyrteam.costituzione.DetailedActivity.java
@SuppressWarnings("static-access") public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.copy_entry: String toCopy = mEntry.getTitle() + ": \n" + mEntry.getBody().replace("\n\n", "\n"); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText("Costituzione", toCopy)); new Toast(this).makeText(this, R.string.text_copied_to_clipboard, 2000).show(); break;//from w w w. j ava 2 s . co m case R.id.favourite_status: DatabaseHandler dbh = new DatabaseHandler(this); dbh.open(true); mEntry.setIsFavourite(!mEntry.isFavourite()); dbh.updateFavoriteStatus(mEntry); dbh.close(); new Toast(this) .makeText(this, mEntry.isFavourite() ? R.string.added_to_fav : R.string.removed_from_fav, 2000) .show(); updateFavoriteButton(item); } return true; }
From source file:com.microsoft.azure.engagement.fragment.GetDeviceIdFragment.java
/** * Method that copies the device id// w ww . j a va 2 s .co m */ private final void copyDeviceID() { if (deviceId != null) { final ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Activity.CLIPBOARD_SERVICE); final ClipData clip = ClipData.newPlainText("label", deviceId); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity(), getString(R.string.get_the_device_id_copy_success_message, deviceId), Toast.LENGTH_LONG).show(); Log.d(GetDeviceIdFragment.TAG, "String Device ID copied " + deviceId); } else { Log.w(GetDeviceIdFragment.TAG, "Device ID is null"); } AzmeTracker.sendEvent(getActivity(), "copy_device_id"); }
From source file:test.ya.translater.wgjuh.yaapitmvptest.view.fragments.translate.fragment.TranslateFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); translatePresenterImpl = new TranslatePresenterImpl(ModelImpl.getInstance(), EventBusImpl.getInstance()); translatePresenterImpl.onBindView(this); viewAdapter = new DictionaryTranslateRecyclerViewAdapter(translatePresenterImpl.getDictionaryState(), getActivity());//w w w . j a va 2 s . com translatePresenterImpl.restoreState(); recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext())); recyclerView.setAdapter(viewAdapter); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), LinearLayout.VERTICAL); recyclerView.addItemDecoration(dividerItemDecoration); btnFavorite.setOnClickListener(btn -> { if (btnFavorite.isChecked()) { translatePresenterImpl.addFavorite(); } else { translatePresenterImpl.deleteFavorite(); } }); btn_retry.setOnClickListener(btn_retry -> translatePresenterImpl.startRetry()); translate.setOnClickListener(textView -> { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(((TextView) textView).getText(), ((TextView) textView).getText()); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity().getApplicationContext(), getActivity().getResources().getText(R.string.copy_to_clipdoard), Toast.LENGTH_SHORT).show(); }); }
From source file:com.kobi.metalsexchange.app.CalculateFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.menu_copy) { // Gets a handle to the clipboard service. ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); String price = Utility.getFormattedCurrency(calculateFragmentViewHelper.getPriceResult(), Utility.getPreferredCurrency(getActivity()), getActivity(), false); ClipData clip = ClipData.newPlainText("rate", price); clipboard.setPrimaryClip(clip);/*from w ww . j ava 2 s . c om*/ Toast toast = Toast.makeText(getActivity().getBaseContext(), getString(R.string.copy_to_clipboard_toast, price), Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } return super.onOptionsItemSelected(item); }
From source file:at.alladin.rmbt.android.sync.RMBTSyncRequestCodeFragment.java
@Override public boolean onContextItemSelected(MenuItem mi) { if (mi.getItemId() == codeText.getId()) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("sync_code", codeText.getText()); clipboard.setPrimaryClip(clip);/* w ww. j ava 2s . c o m*/ return true; } return super.onContextItemSelected(mi); }
From source file:com.mikifus.padland.PadListActivity.java
/** * If there is a share intent this function gets the extra text * and copies it into clipboard/*from w w w . j av a2 s .c o m*/ */ private void _textFromIntent() { String extra_text = getIntent().getStringExtra(Intent.EXTRA_TEXT); if (extra_text != null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(extra_text); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", extra_text); clipboard.setPrimaryClip(clip); } Toast.makeText(this, getString(R.string.activity_padlist_implicitintent_text_copied), Toast.LENGTH_LONG) .show(); } }
From source file:com.softminds.matrixcalculator.OperationFragments.TraceFragment.java
private void RunToGetTrace(int position, ProgressDialog progressDialog) { double result = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(position).getTrace(); final String formatted = GetText(result); progressDialog.dismiss();/* w ww .j av a 2s .c om*/ String formatted2 = getString(R.string.trace_is) + " " + formatted; new AlertDialog.Builder(getContext()).setCancelable(true).setMessage(formatted2) .setTitle(R.string.trace_text) .setPositiveButton(R.string.copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ClipboardManager manager = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData data = ClipData.newPlainText("TRACE_RES", formatted); manager.setPrimaryClip(data); if (manager.hasPrimaryClip()) Toast.makeText(getContext(), R.string.CopyToClip, Toast.LENGTH_SHORT).show(); else Log.e(TAG, "Cannot Put Data to Clip"); dialog.dismiss(); } }).setNeutralButton(R.string.Done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); }
From source file:com.secupwn.aimsicd.ui.activities.DebugLogs.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Show the Up button in the action bar. getSupportActionBar().setDisplayHomeAsUpEnabled(true); runOnUiThread(new Runnable() { @Override//from w w w . jav a2 s. c o m public void run() { logView.setFocusable(false); } }); btnClear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { clearLogs(); } catch (IOException e) { log.error("Error clearing logs", e); } } }); btnCopy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData cd = ClipData.newPlainText("log", logView.getText()); clipboard.setPrimaryClip(cd); Helpers.msgShort(DebugLogs.this, getString(R.string.msg_copied_to_clipboard)); } }); btnStop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (updateLogs) { updateLogs = false; btnStop.setText(getString(R.string.btn_start_logs)); } else { startLogging(); } } }); /* // logcat radio buffer toggle on/off btnRadio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (isRadioLogs) { isRadioLogs = false; btnRadio.setText(getString(R.string.btn_radio_logs)); } else { isRadioLogs = true; btnRadio.setText(getString(R.string.btn_main_logs)); } } }); */ }
From source file:com.endiansoftware.echo.remotewatch.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDisplay = (TextView) findViewById(R.id.display); context = getApplicationContext();/* w w w . j a v a 2 s . co m*/ // Check device for Play Services APK. If check succeeds, proceed with GCM registration. if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(context); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("label", regid); clipboard.setPrimaryClip(clip); if (regid.isEmpty()) { registerInBackground(); } } else { Log.i(TAG, "No valid Google Play Services APK found."); } }
From source file:net.eledge.android.europeana.gui.fragment.RecordDetailsFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupClipboardAction(ListView mListView) { mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override// w ww . ja va2 s.co m public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { RecordView record = mRecordViewAdapter.getItem(position); Activity activity = RecordDetailsFragment.this.getActivity(); ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); clipboard .setPrimaryClip( ClipData.newPlainText(GuiUtils.getString(getActivity(), record.getLabel()), StringUtils.join( record.getValues(recordController.record, (EuropeanaApplication) getActivity().getApplication()), ";"))); GuiUtils.toast(activity, R.string.msg_copied2clipboard); return true; } }); }