List of usage examples for android.content Context CLIPBOARD_SERVICE
String CLIPBOARD_SERVICE
To view the source code for android.content Context CLIPBOARD_SERVICE.
Click Source Link
From source file:com.kncwallet.wallet.ui.ReceiveFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); this.activity = (AbstractWalletActivity) activity; this.application = (WalletApplication) activity.getApplication(); this.wallet = application.getWallet(); this.prefs = PreferenceManager.getDefaultSharedPreferences(activity); this.loaderManager = getLoaderManager(); this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE); this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); }
From source file:net.zionsoft.obadiah.ui.fragments.TextFragment.java
@Override public void onVersesSelectionChanged(boolean hasSelected) { if (hasSelected) { if (mActionMode != null) return; mActionMode = ((ActionBarActivity) getActivity()).startSupportActionMode(new ActionMode.Callback() { @Override// w w w . ja v a2 s . co m public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { actionMode.getMenuInflater().inflate(R.menu.menu_text_selection_context, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_copy: Analytics.trackUIEvent("copy"); final Activity activity = getActivity(); if (mClipboardManager == null) { // noinspection deprecation mClipboardManager = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); } mClipboardManager.setText( buildText(mVersePagerAdapter.getSelectedVerses(mVerseViewPager.getCurrentItem()))); Toast.makeText(activity, R.string.toast_verses_copied, Toast.LENGTH_SHORT).show(); actionMode.finish(); return true; case R.id.action_share: Analytics.trackUIEvent("share"); startActivity(Intent.createChooser( new Intent().setAction(Intent.ACTION_SEND).setType("text/plain").putExtra( Intent.EXTRA_TEXT, buildText(mVersePagerAdapter .getSelectedVerses(mVerseViewPager.getCurrentItem()))), getResources().getText(R.string.text_share_with))); actionMode.finish(); return true; default: return false; } } @Override public void onDestroyActionMode(ActionMode actionMode) { if (actionMode != mActionMode) return; mVersePagerAdapter.deselectVerses(); mActionMode = null; } }); } else { if (mActionMode != null) mActionMode.finish(); } }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
ClipboardManager getClipboardManager() { Object clipboard = null;//from w w w.j a v a 2 s . co m if (mClipboard == null) { try { clipboard = mService.getSystemService(Context.CLIPBOARD_SERVICE); } catch (Exception e) { Looper.prepare(); // Clipboard manager won't work without this on higher SDK levels... clipboard = mService.getSystemService(Context.CLIPBOARD_SERVICE); } mClipboard = (ClipboardManager) clipboard; if (mClipboard == null) { Log.w("Clipboard managed not accessible."); } } return mClipboard; }
From source file:info.mayuragarkar.calculator.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /** CREATE DATABASE FOR HISTORY HERE */ DatabaseHandler.calcDB = getBaseContext().openOrCreateDatabase(dbName + ".db", MODE_PRIVATE, null); DatabaseHandler.calcDB.execSQL(/*from w w w.java 2 s. c o m*/ "CREATE TABLE IF NOT EXISTS " + tableName + " (firstNum TEXT, secondNum TEXT, answerNum TEXT)"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); /*FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } });*/ /** Button Logics */ firstNumberEditText = (EditText) findViewById(R.id.firstNumberEditText); secondNumberEditText = (EditText) findViewById(R.id.secondNumberEditText); resultEditText = (EditText) findViewById(R.id.resultEditText); addBtn = (Button) findViewById(R.id.plus); factorial = (Button) findViewById(R.id.factorial); subBtn = (Button) findViewById(R.id.minus); divBtn = (Button) findViewById(R.id.divide); mulBtn = (Button) findViewById(R.id.multiply); clearBtn = (Button) findViewById(R.id.clearAll); raisedto = (Button) findViewById(R.id.raisedto); mod = (Button) findViewById(R.id.mod); modinverse = (Button) findViewById(R.id.modinverse); isPrime = (Button) findViewById(R.id.isPrime); copyBtn = (Button) findViewById(R.id.copyBtn); operationApplied = (TextView) findViewById(R.id.operationAppliedText); /** make operation applied empty on run time */ operationApplied.setText(""); /** Make View Pager Initialized Here */ ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(new CustomPagerAdapter(this)); //Bind the title indicator to the adapter CirclePageIndicator titleIndicator = (CirclePageIndicator) findViewById(R.id.indicator); titleIndicator.setViewPager(viewPager); /** clear all button */ clearBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clearall(); clearText(); } }); /** copy contents button */ copyBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (resultEditText.length() > 0) { int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(resultEditText.getText()); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("Big Number History", resultEditText.getText()); clipboard.setPrimaryClip(clip); } Toast.makeText(getApplicationContext(), "Result Copied.", Toast.LENGTH_LONG).show(); } else if (resultEditText.length() <= 0) { Toast.makeText(getApplicationContext(), "Nothing to Copy.", Toast.LENGTH_LONG).show(); } } }); }
From source file:com.coinblesk.client.TransactionDetailActivity.java
private void copyTx() { Log.d(TAG, "Copy Transaction Hash: " + transactionHash); Log.d(TAG, "Transaction Details:\n" + walletServiceBinder.getTransaction(transactionHash).toString()); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Your TX", transactionHash); clipboard.setPrimaryClip(clip);// w ww . ja va2s . c o m View root = findViewById(android.R.id.content); if (root != null) { Snackbar.make(root, UIUtils.toFriendlySnackbarString(this, getString(R.string.snackbar_address_copied)), Snackbar.LENGTH_LONG).setActionTextColor(ContextCompat.getColor(this, R.color.colorAccent)) .setAction("Action", null).show(); } }
From source file:com.google.reviewit.ServerSettingsFragment.java
private void init() { final AutoCompleteTextView urlInput = (AutoCompleteTextView) v(R.id.urlInput); ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.urls)); urlInput.setAdapter(adapter);/* w ww . jav a 2 s . com*/ v(R.id.pasteCredentialsButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.hasPrimaryClip() && clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); String pasteData = item.getText().toString(); if (!pasteData.contains("/.gitcookies")) { return; } pasteData = pasteData.substring(pasteData.indexOf("/.gitcookies")); pasteData = pasteData.substring(pasteData.lastIndexOf(",") + 1); int pos = pasteData.indexOf("="); String user = pasteData.substring(0, pos); pasteData = pasteData.substring(pos + 1); String password = pasteData.substring(0, pasteData.indexOf("\n")); WidgetUtil.setText(v(R.id.userInput), user); WidgetUtil.setText(v(R.id.passwordInput), password); // hide keyboard if it is open View view = getActivity().getCurrentFocus(); if (view != null) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(view.getWindowToken(), 0); } } } }); ((EditText) v(R.id.urlInput)).addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (Strings.isNullOrEmpty(textOf(R.id.nameInput))) { try { String host = new URL(s.toString()).getHost(); int pos = host.indexOf("."); WidgetUtil.setText(v(R.id.nameInput), pos > 0 ? host.substring(0, pos) : host); } catch (MalformedURLException e) { // ignore } } displayCredentialsInfo(s.toString()); } }); v(R.id.saveServerSettings).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enabledForm(false); if (!isServerInputComplete()) { widgetUtil.showError(R.string.incompleteInput); enabledForm(true); return; } if (!isUrlValid()) { widgetUtil.showError(R.string.invalidUrl); enabledForm(true); return; } if (!hasUniqueName()) { widgetUtil.showError(getString(R.string.duplicate_server_name, textOf(R.id.nameInput))); enabledForm(true); return; } setVisible(v(R.id.statusTestConnection, R.id.statusTestConnectionProgress)); WidgetUtil.setText(v(R.id.statusTestConnectionText), null); new AsyncTask<Void, Void, String>() { private TextView status; private View statusTestConnectionProgress; private View statusTestConnection; @Override protected void onPreExecute() { super.onPreExecute(); status = tv(R.id.statusTestConnectionText); statusTestConnectionProgress = v(R.id.statusTestConnectionProgress); statusTestConnection = v(R.id.statusTestConnection); } @Override protected String doInBackground(Void... v) { return testConnection(); } protected void onPostExecute(String errorMsg) { if (errorMsg != null) { enabledForm(true); status.setTextColor(widgetUtil.color(R.color.statusFailed)); status.setText(getString(R.string.test_server_connection_failed)); setInvisible(statusTestConnectionProgress); new AlertDialog.Builder(getContext()).setTitle(getString(R.string.error_title)) .setMessage(getString(R.string.connection_failed, errorMsg)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setNegativeButton(getString(R.string.save_anyway), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setGone(statusTestConnection); onServerSave(saveServerSettings()); } }) .setIcon(android.R.drawable.ic_dialog_alert).show(); } else { status.setTextColor(widgetUtil.color(R.color.statusOk)); status.setText(getString(R.string.test_server_connection_ok)); setGone(statusTestConnection); onServerSave(saveServerSettings()); } } }.execute(); } }); enabledForm(true); setGone(v(R.id.statusTestConnection)); }
From source file:devsoftprog.java.file.manager.android.fm_f_and.WebActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.clip: try {//from ww w. ja va 2 s .c om ClipboardManager clipboard = (ClipboardManager) WebActivity.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(app.html); } catch (Exception e) { Toast.makeText(WebActivity.this, "error: " + e.getMessage(), Toast.LENGTH_LONG).show(); e = null; } return true; default: return true; } }
From source file:devsoftprog.java.file.manager.android.fm_f_and.WebActivity2.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.clip: try {/*from w w w . j av a 2s . com*/ ClipboardManager clipboard = (ClipboardManager) WebActivity2.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(app.html); } catch (Exception e) { Toast.makeText(WebActivity2.this, "error: " + e.getMessage(), Toast.LENGTH_LONG).show(); e = null; } return true; default: return true; } }
From source file:de.schildbach.litecoinwallet.ui.RequestCoinsFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); this.activity = (AbstractBindServiceActivity) activity; this.application = (WalletApplication) activity.getApplication(); this.wallet = application.getWallet(); this.prefs = PreferenceManager.getDefaultSharedPreferences(activity); this.loaderManager = getLoaderManager(); this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE); this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); }
From source file:de.dknapps.pswgendroid.ServiceDetailFragment.java
/** * Generiert das Passwort und kopiert es in die Zwischenablage. * //from ww w . ja va2 s . c o m * FIXME dkn Die callingActivity kann durch getActivity() ersetzt werden. */ public void onClickButtonCopyPassword(final Activity callingActivity, final View buttonOpenUrl) { try { String password = getValidatedOrGeneratedPassword(); ClipboardManager clipboard = (ClipboardManager) callingActivity .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText(null, password)); } catch (Exception e) { PswGenAdapter.handleThrowable(callingActivity, e); } }