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.raza.betternts.activities.TabFragment2.java
private void menuOption(Cursor cursor, int selectedOption) { String name = cursor.getString(cursor.getColumnIndex(DbSchema.COL_NAME)); String url = cursor.getString(cursor.getColumnIndex(DbSchema.COL_URL)); switch (selectedOption) { //Open in browser case 0: {//from www . j a v a2s .c om Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browse); break; } //Copy to clipboard case 1: { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(name, url); clipboard.setPrimaryClip(clip); Toast.makeText(getContext(), "Link copied to clipboard", Toast.LENGTH_SHORT).show(); break; } //Share case 2: { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, url); sendIntent.setType("text/plain"); startActivity(sendIntent); break; } case 3: { moveToMain(cursor); Toast.makeText(getContext(), name + "\nrestored to Vacancies tab", Toast.LENGTH_SHORT).show(); } } }
From source file:com.espian.library.about.AbsAboutActivity.java
public void copy(String type, Uri uri, String backup) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipboardManager newCm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); newCm.setPrimaryClip(ClipData.newUri(getContentResolver(), type, uri)); } else {/*from w ww . j a va 2 s .c om*/ android.text.ClipboardManager oldCm = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); oldCm.setText(backup); } Toast.makeText(this, getString(R.string.copy_to_clip, backup), Toast.LENGTH_SHORT).show(); }
From source file:com.wordpress.ebc81.rtl_ais_android.StreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_stream); prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE); terminal = (TextView) findViewById(R.id.terminal); scroll = (ScrollView) findViewById(R.id.ScrollArea); arguments = (EditText) findViewById(R.id.commandline); String argperf = prefs.getString(CMD_LINE_TEXT_PREF, arguments.getText().toString()); arguments.setText(argperf);/* w w w . j a va 2 s .c o m*/ terminal.setText(LogRtlAis.getFullLog()); ((Button) findViewById(R.id.enable_gui)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { findViewById(R.id.statusmsg).setVisibility(View.GONE); findViewById(R.id.gui).setVisibility(View.VISIBLE); } }); (forceroot = (CheckBox) findViewById(R.id.forceRoot)) .setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { final SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(DISABLE_JAVA_FIX_PREF, isChecked); editor.commit(); } }); forceroot.setChecked(prefs.getBoolean(DISABLE_JAVA_FIX_PREF, false)); (onoff = (ToggleButton) findViewById(R.id.onoff)).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { onoff.setChecked(false); LogRtlAis.clear(); String argumentStr = arguments.getText().toString(); startActivityForResult( new Intent(Intent.ACTION_VIEW).setData(Uri.parse( getString(R.string.intent_filter_schema) + "://" + arguments.getText().toString())), START_REQ_CODE); if (!argumentStr.isEmpty()) { final SharedPreferences.Editor editor = prefs.edit(); editor.putString(CMD_LINE_TEXT_PREF, argumentStr); editor.commit(); } } }); ((Button) findViewById(R.id.bt_default)).setOnClickListener(new Button.OnClickListener() { //@SuppressWarnings("deprecation") //@SuppressLint("NewApi") @Override public void onClick(View v) { arguments.setText(getString(R.string.default_args)); } }); ((Button) findViewById(R.id.stop)).setOnClickListener(new Button.OnClickListener() { //@SuppressWarnings("deprecation") //@SuppressLint("NewApi") @Override public void onClick(View v) { startActivityForResult(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(getString(R.string.intent_filter_schema) + "://-exit")), START_REQ_CODE); } }); ((Button) findViewById(R.id.copybutton)).setOnClickListener(new Button.OnClickListener() { //@SuppressWarnings("deprecation") //@SuppressLint("NewApi") @Override public void onClick(View v) { final String textToClip = terminal.getText().toString(); 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(textToClip); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("text label", textToClip); clipboard.setPrimaryClip(clip); } Toast.makeText(getApplicationContext(), R.string.copied_to_clip, Toast.LENGTH_LONG).show(); } }); ((Button) findViewById(R.id.clearbutton)).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { LogRtlAis.clear(); } }); ((Button) findViewById(R.id.help)).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { showDialog(dialogs.DIAG_ABOUT); } }); ((Button) findViewById(R.id.license)).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { showDialog(dialogs.DIAG_LICENSE); } }); }
From source file:com.eng.arab.translator.androidtranslator.translate.TranslateViewActivity.java
private void initTranslatorPanel() { mainPanel = (LinearLayout) findViewById(R.id.activity_translator_translate); srcCard = (CardView) findViewById(R.id.src_card); srcToolbar = (Toolbar) findViewById(R.id.src_toolbar); srcToolbar.inflateMenu(R.menu.src_card); srcToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override/*ww w .j av a 2s . c om*/ public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_paste: srcText.setText(readFromClipboard()); trgText.setTextColor(Color.BLACK);// Set Default Color showAToast("Pasted"); break; /*case R.id.action_share: if (keyboard_flag == 0) { hideSoftKeyboard(); keyboard_flag = 1; } else keyboard_flag = 0; Toast.makeText(TranslateViewActivity.this,"Share",Toast.LENGTH_SHORT).show(); break;*/ case R.id.action_clear: showAToast("Cleared"); srcText.setText(""); trgText.setTextColor(Color.BLACK);// Set Default Color //trgText.setText(""); break; } return true; } }); srcToolbar.setOnClickListener(this); srcToolbar.setTitle("ARABIC");/**UPPER Text to translate*/ srcContent = (LinearLayout) findViewById(R.id.src_translate_content); translateButton = (Button) findViewById(R.id.main_translate_button); translateButton.setOnClickListener(this); trgCard = (CardView) findViewById(R.id.translate_trg_card); trgToolbar = (Toolbar) findViewById(R.id.translate_trg_toolbar); trgToolbar.inflateMenu(R.menu.trg_card); trgToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_trg_audio: //Toast.makeText(TranslateViewActivity.this,"TRG AUDIO",Toast.LENGTH_SHORT).show(); speakEnglishTranslation(); break; case R.id.action_copy: android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(trgText.getText()); showAToast("English translation copied"); trgText.setTextColor(Color.BLUE); // Set color as Higlight break; /*case R.id.action_share: Toast.makeText(TranslateViewActivity.this,"Share",Toast.LENGTH_SHORT).show(); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, trgText.getText().toString()); startActivity(Intent.createChooser(intent, getResources().getText(R.string.share_with))); break;*/ } return true; } }); trgToolbar.setOnClickListener(this); trgToolbar.setTitle("ENGLISH");/**LOWER Translated*/ trgContent = (LinearLayout) findViewById(R.id.trg_content); srcText = (EditText) findViewById(R.id.src_text); trgTextScroll = (ScrollView) findViewById(R.id.trg_text_scroll); trgText = (TextView) findViewById(R.id.trg_text); mainPanel.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { private int trgCardPreEditingVisibility; @Override public void onGlobalLayout() { final int heightDiffPx = mainPanel.getRootView().getHeight() - mainPanel.getHeight(); final int heightDiffDp = (int) (heightDiffPx / (getResources().getDisplayMetrics().densityDpi / 160f)); if (heightDiffDp > 150 && !editing) { // if more than 150 dps, its probably a keyboard... editing = true; trgCardPreEditingVisibility = trgCard.getVisibility(); trgCard.setVisibility(View.GONE); // updateSrcToolbar(); } else if (heightDiffDp < 150 && editing) { editing = false; trgCard.setVisibility(trgCardPreEditingVisibility); srcText.clearFocus(); // updateSrcToolbar(); } } }); final Intent intent = getIntent(); if (Intent.ACTION_SEND.equals(intent.getAction()) && "text/plain".equals(intent.getType())) { srcText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } //snackBar(); }
From source file:com.mobshep.mobileshepherd.BrokenCrypto1.java
public void copyMessage3(View v) { String copiedMessage3 = messageThree.getText().toString(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("message3", copiedMessage3); clipboard.setPrimaryClip(clip);//from ww w . j ava2 s.com showToast(); }
From source file:org.tigase.mobile.chat.ChatHistoryFragment.java
private void copyMessageBody(final long id) { ClipboardManager clipMan = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); Cursor cc = null;/* w ww . jav a 2s. co m*/ try { cc = getChatEntry(id); String t = cc.getString(cc.getColumnIndex(ChatTableMetaData.FIELD_BODY)); clipMan.setText(t); } finally { if (cc != null && !cc.isClosed()) cc.close(); } }
From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java
private void clipboard(TextView tv) { int which;// w w w . jav a 2 s. com switch (tv.getId()) { case txt_request_url: which = req_url; break; case txt_response_headers: which = response_headers; break; case txt_response_body: which = response_body; break; default: which = UNSET; } String what = which == UNSET ? "" : getString(which) + " "; what += getString(clippy); Toast.makeText(getActivity(), what, Toast.LENGTH_SHORT).show(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // old way ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setText(tv.getText()); } else { clipboard11(tv); } }
From source file:com.gudong.appkit.ui.activity.MainActivity.java
private void showDonateDialog() { String htmlFileName = Utils.isChineseLanguage() ? "donate_ch.html" : "donate.html"; DialogUtil.showCustomDialogWithTwoAction(this, getSupportFragmentManager(), getString(R.string.action_donate), htmlFileName, "donate", getString(R.string.action_close), null, getString(R.string.action_copy_to_clipboard), new DialogInterface.OnClickListener() { @Override/*from w ww.j av a 2 s. com*/ public void onClick(DialogInterface dialog, int which) { String alipay = "com.eg.android.AlipayGphone"; AppEntity alipayApp = DataHelper.getAppByPackageName(alipay); if (alipayApp != null) { //?? ClipboardManager cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); cmb.setPrimaryClip(ClipData.newPlainText(null, "gudong.name@gmail.com")); Toast.makeText(MainActivity.this, R.string.copy_success, Toast.LENGTH_LONG).show(); //? try { NavigationManager.openApp(MainActivity.this, alipay); } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(MainActivity.this, getString(R.string.support_exception_for_alipay), Toast.LENGTH_SHORT).show(); } } }); }
From source file:org.csploit.android.WifiScannerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences themePrefs = getSharedPreferences("THEME", 0); Boolean isDark = themePrefs.getBoolean("isDark", false); if (isDark)//from w w w.j av a 2 s.c om setTheme(R.style.DarkTheme); else setTheme(R.style.AppTheme); setContentView(R.layout.wifi_scanner); mWifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); mClipboard = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE); mWifiMatcher = new WirelessMatcher(getResources().openRawResource(R.raw.alice)); mScanReceiver = new ScanReceiver(); mConnectionReceiver = new ConnectionReceiver(); mStatusText = (TextView) findViewById(R.id.scanStatusText); mAdapter = new ScanAdapter(); mKeyList = new ArrayList<>(); getListView().setAdapter(mAdapter); mStatusText.setText(getString(R.string.wifi_initializing)); if (!mWifiManager.isWifiEnabled()) { mStatusText.setText(getString(R.string.wifi_activating_iface)); mWifiManager.setWifiEnabled(true); mStatusText.setText(getString(R.string.wifi_activated)); } mScanReceiver.register(this); if (mMenu != null) { MenuItem menuScan = mMenu.findItem(R.id.scan); MenuItemCompat.setActionView(menuScan, new ProgressBar(this)); } mStatusText.setText(getString(R.string.wifi_scanning)); mScanning = true; mWifiManager.startScan(); }