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.tinfoil.sms.sms.SendMessageActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void copyText(String message) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText(MESSAGE_LABEL, message); clipboard.setPrimaryClip(clip);//w ww .j av a 2 s . com } else { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(message); } }
From source file:net.sourceforge.fidocadj.FidoMain.java
/** Stores the given String in the clipboard. *///from w w w. j a v a 2s . c om public void copyText(String s) { // Gets a handle to the clipboard service. ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("simple text", s.toString()); clipboard.setPrimaryClip(clip); }
From source file:net.sourceforge.fidocadj.FidoMain.java
/** Get the current data (as String) in the clipboard. *//* w w w . j a va2 s . c om*/ public String pasteText() { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); String pasteData = ""; ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); // Gets the clipboard as text. pasteData = item.getText().toString(); // If the string contains data, then the paste operation is done return pasteData; }
From source file:com.haomee.chat.activity.ChatActivity.java
private void setUpView() { // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); init_from_data();// w ww. ja va2 s. co m // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType, uId); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); hideBottom(); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:it.ciopper90.gojack2.MessageListActivity.java
/** * {@inheritDoc}/*from w w w .j a va 2s .com*/ */ public final boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) { final Context context = this; final Message m = Message.getMessage(this, (Cursor) parent.getItemAtPosition(position)); final Uri target = m.getUri(); final int read = m.getRead(); final int type = m.getType(); Builder builder = new Builder(context); builder.setTitle(R.string.message_options_); final Contact contact = this.conv.getContact(); final String a = contact.getNumber(); Log.d(TAG, "p: " + a); final String n = contact.getName(); String[] items = this.longItemClickDialog; if (TextUtils.isEmpty(n)) { items[WHICH_VIEW_CONTACT] = this.getString(R.string.add_contact_); } else { items[WHICH_VIEW_CONTACT] = this.getString(R.string.view_contact_); } items[WHICH_CALL] = this.getString(R.string.call) + " " + contact.getDisplayName(); if (read == 0) { items = items.clone(); items[WHICH_MARK_UNREAD] = context.getString(R.string.mark_read_); } if (type == Message.SMS_DRAFT) { items = items.clone(); items[WHICH_FORWARD] = context.getString(R.string.send_draft_); } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Intent i = null; switch (which) { case WHICH_VIEW_CONTACT: if (n == null) { i = ContactsWrapper.getInstance().getInsertPickIntent(a); Conversation.flushCache(); } else { final Uri u = MessageListActivity.this.conv.getContact().getUri(); i = new Intent(Intent.ACTION_VIEW, u); } try { MessageListActivity.this.startActivity(i); } catch (ActivityNotFoundException e) { Log.e(TAG, "activity not found: " + i.getAction(), e); Toast.makeText(MessageListActivity.this, "activity not found", Toast.LENGTH_LONG).show(); } break; case WHICH_CALL: MessageListActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("tel:" + a))); break; case WHICH_MARK_UNREAD: ConversationListActivity.markRead(context, target, 1 - read); MessageListActivity.this.markedUnread = true; break; case WHICH_REPLY: // MessageListActivity.this.startActivity(ConversationListActivity // .getComposeIntent(MessageListActivity.this, a)); break; case WHICH_FORWARD: int resId; if (type == Message.SMS_DRAFT) { resId = R.string.send_draft_; // i = // ConversationListActivity.getComposeIntent(MessageListActivity.this, // MessageListActivity.this.conv.getContact().getNumber()); } else { resId = R.string.forward_; i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra("forwarded_message", true); } CharSequence text = null; if (PreferencesActivity.decodeDecimalNCR(context)) { text = Converter.convertDecNCR2Char(m.getBody()); } else { text = m.getBody(); } i.putExtra(Intent.EXTRA_TEXT, text); i.putExtra("sms_body", text); context.startActivity(Intent.createChooser(i, context.getString(resId))); break; case WHICH_COPY_TEXT: final ClipboardManager cm = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); if (PreferencesActivity.decodeDecimalNCR(context)) { cm.setText(Converter.convertDecNCR2Char(m.getBody())); } else { cm.setText(m.getBody()); } break; case WHICH_VIEW_DETAILS: final int t = m.getType(); Builder b = new Builder(context); b.setTitle(R.string.view_details_); b.setCancelable(true); StringBuilder sb = new StringBuilder(); final String a = m.getAddress(context); final long d = m.getDate(); final String ds = DateFormat.format(context.getString(R.string.DATEFORMAT_details), d) .toString(); String sentReceived; String fromTo; if (t == Calls.INCOMING_TYPE) { sentReceived = context.getString(R.string.received_); fromTo = context.getString(R.string.from_); } else if (t == Calls.OUTGOING_TYPE) { sentReceived = context.getString(R.string.sent_); fromTo = context.getString(R.string.to_); } else { sentReceived = "ukwn:"; fromTo = "ukwn:"; } sb.append(sentReceived + " "); sb.append(ds); sb.append("\n"); sb.append(fromTo + " "); sb.append(a); sb.append("\n"); sb.append(context.getString(R.string.type_)); if (m.isMMS()) { sb.append(" MMS"); } else { sb.append(" SMS"); } b.setMessage(sb.toString()); b.setPositiveButton(android.R.string.ok, null); b.show(); break; case WHICH_DELETE: ConversationListActivity.deleteMessages(context, target, R.string.delete_message_, R.string.delete_message_question, null); break; default: break; } } }); builder.show(); return true; }
From source file:de.baumann.browser.Browser_right.java
@Override protected void onResume() { super.onResume(); //To change body of overridden methods use File | Settings | File Templates. mWebView.onResume();//from w w w. ja va 2s . c om final String URL = sharedPref.getString("openURL", "https://github.com/scoute-dich/browser/"); new Handler().postDelayed(new Runnable() { public void run() { if (URL.equals(mWebView.getUrl()) || URL.equals("")) { Log.i(TAG, "Tab switched"); } else if (URL.equals("copyLogin")) { Snackbar snackbar = Snackbar .make(mWebView, R.string.pass_copy_userName, Snackbar.LENGTH_INDEFINITE) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { ClipboardManager clipboard = (ClipboardManager) Browser_right.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText("userName", sharedPref.getString("copyUN", ""))); Snackbar snackbar = Snackbar .make(mWebView, R.string.pass_copy_userPW, Snackbar.LENGTH_INDEFINITE) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { ClipboardManager clipboard = (ClipboardManager) Browser_right.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText("userName", sharedPref.getString("copyPW", ""))); } }); snackbar.show(); } }); snackbar.show(); } else if (URL.contains("openLogin")) { mWebView.loadUrl(URL.replace("openLogin", "")); Snackbar snackbar = Snackbar .make(mWebView, R.string.pass_copy_userName, Snackbar.LENGTH_INDEFINITE) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { ClipboardManager clipboard = (ClipboardManager) Browser_right.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText("userName", sharedPref.getString("copyUN", ""))); Snackbar snackbar = Snackbar .make(mWebView, R.string.pass_copy_userPW, Snackbar.LENGTH_INDEFINITE) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { ClipboardManager clipboard = (ClipboardManager) Browser_right.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText("userName", sharedPref.getString("copyPW", ""))); } }); snackbar.show(); } }); snackbar.show(); } else { mWebView.loadUrl(URL); } } }, 100); }
From source file:info.guardianproject.otr.app.im.app.ChatView.java
@Override protected void onFinishInflate() { // mStatusIcon = (ImageView) findViewById(R.id.statusIcon); // mDeliveryIcon = (ImageView) findViewById(R.id.deliveryIcon); // mTitle = (TextView) findViewById(R.id.title); mHistory = (ListView) findViewById(R.id.history); mComposeMessage = (EditText) findViewById(R.id.composeMessage); mSendButton = (ImageButton) findViewById(R.id.btnSend); mHistory.setOnItemClickListener(mOnItemClickListener); mButtonAttach = (ImageButton) findViewById(R.id.btnAttach); mViewAttach = findViewById(R.id.attachPanel); mStatusWarningView = findViewById(R.id.warning); mWarningText = (TextView) findViewById(R.id.warningText); mProgressTransfer = (ProgressBar) findViewById(R.id.progressTransfer); // mOtrSwitch = (CompoundButton)findViewById(R.id.otrSwitch); mProgressBarOtr = (ProgressBar) findViewById(R.id.progressBarOtr); mButtonAttach.setOnClickListener(new OnClickListener() { @Override/*from w ww . j a v a2 s . com*/ public void onClick(View v) { if (mViewAttach.getVisibility() == View.GONE) mViewAttach.setVisibility(View.VISIBLE); else mViewAttach.setVisibility(View.GONE); } }); ((ImageButton) findViewById(R.id.btnAttachAudio)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mNewChatActivity.startAudioPicker(); } }); ((ImageButton) findViewById(R.id.btnAttachPicture)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mNewChatActivity.startImagePicker(); } }); ((ImageButton) findViewById(R.id.btnTakePicture)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mNewChatActivity.startPhotoTaker(); } }); ((ImageButton) findViewById(R.id.btnAttachFile)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mNewChatActivity.startFilePicker(); } }); mHistory.setOnItemLongClickListener(new OnItemLongClickListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (arg1 instanceof MessageView) { String textToCopy = ((MessageView) arg1).getLastMessage(); int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) mNewChatActivity .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(textToCopy); // } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mNewChatActivity .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("chat", textToCopy); clipboard.setPrimaryClip(clip); // } Toast.makeText(mNewChatActivity, mContext.getString(R.string.toast_chat_copied_to_clipboard), Toast.LENGTH_SHORT).show(); return true; } return false; } }); mWarningText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showVerifyDialog(); } }); //mOtrSwitch.setOnCheckedChangeListener(mOtrListener); mComposeMessage.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: sendMessage(); return true; case KeyEvent.KEYCODE_ENTER: if (event.isAltPressed()) { mComposeMessage.append("\n"); return true; } } } return false; } }); mComposeMessage.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null) { if (event.isAltPressed()) { return false; } } InputMethodManager imm = (InputMethodManager) mContext .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null && imm.isActive(v)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); } sendMessage(); return true; } }); // TODO: this is a hack to implement BUG #1611278, when dispatchKeyEvent() works with // the soft keyboard, we should remove this hack. mComposeMessage.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int before, int after) { } public void onTextChanged(CharSequence s, int start, int before, int after) { //log("TextWatcher: " + s); userActionDetected(); } public void afterTextChanged(Editable s) { } }); mSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { sendMessage(); } }); Button btnApproveSubscription = (Button) findViewById(R.id.btnApproveSubscription); btnApproveSubscription.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mNewChatActivity.approveSubscription(mProviderId, mRemoteAddress); mHandler.postDelayed(new Runnable() { public void run() { bindChat(mLastChatId); } }, 2000); } }); Button btnDeclineSubscription = (Button) findViewById(R.id.btnDeclineSubscription); btnDeclineSubscription.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mHandler.postDelayed(new Runnable() { public void run() { mNewChatActivity.declineSubscription(mProviderId, mRemoteAddress); } }, 500); } }); /* mActionBox = (View)findViewById(R.id.actionBox); ImageButton btnActionBox = (ImageButton)findViewById(R.id.btnActionBox); btnActionBox.setOnClickListener(new OnClickListener () { @Override public void onClick(View v) { mEmojiPager.setVisibility(View.GONE); if (mActionBox.getVisibility() == View.GONE) mActionBox.setVisibility(View.VISIBLE); else mActionBox.setVisibility(View.GONE); } }); View btnEndChat = findViewById(R.id.btnEndChat); btnEndChat.setOnClickListener(new OnClickListener () { @Override public void onClick(View v) { ChatView.this.closeChatSession(); } }); View btnProfile = findViewById(R.id.btnProfile); btnProfile.setOnClickListener(new OnClickListener () { @Override public void onClick(View v) { viewProfile(); } }); View btnSharePicture = findViewById(R.id.btnSendPicture); btnSharePicture.setOnClickListener(new OnClickListener () { @Override public void onClick(View v) { if (mLastSessionStatus != null && mLastSessionStatus == SessionStatus.ENCRYPTED) { mNewChatActivity.startImagePicker(); } else { mHandler.showServiceErrorAlert(getContext().getString(R.string.please_enable_chat_encryption_to_share_files)); } } }); View btnShareFile = findViewById(R.id.btnSendFile); btnShareFile.setOnClickListener(new OnClickListener () { @Override public void onClick(View v) { if (mLastSessionStatus != null && mLastSessionStatus == SessionStatus.ENCRYPTED) { mNewChatActivity.startFilePicker(); } else { mHandler.showServiceErrorAlert(getContext().getString(R.string.please_enable_chat_encryption_to_share_files)); } } }); */ initEmoji(); mMessageAdapter = new MessageAdapter(mNewChatActivity, null); mHistory.setAdapter(mMessageAdapter); }
From source file:com.googlecode.networklog.AppFragment.java
@SuppressWarnings("deprecation") void copyIpAddress(ChildItem childItem) { String hostString = ""; if (childItem.sentPackets > 0 && childItem.out != null) { String sentAddressString; String sentPortString;/*w ww .j av a2s . co m*/ if (NetworkLog.resolveHosts && NetworkLog.resolveCopies) { sentAddressString = NetworkLog.resolver.resolveAddress(childItem.sentAddress); if (sentAddressString == null) { sentAddressString = childItem.sentAddress; } } else { sentAddressString = childItem.sentAddress; } if (NetworkLog.resolvePorts && NetworkLog.resolveCopies) { sentPortString = NetworkLog.resolver.resolveService(String.valueOf(childItem.sentPort)); } else { sentPortString = String.valueOf(childItem.sentPort); } hostString = sentAddressString + ":" + sentPortString; } else if (childItem.receivedPackets > 0 && childItem.in != null) { String receivedAddressString; String receivedPortString; if (NetworkLog.resolveHosts && NetworkLog.resolveCopies) { receivedAddressString = NetworkLog.resolver.resolveAddress(childItem.receivedAddress); if (receivedAddressString == null) { receivedAddressString = childItem.receivedAddress; } } else { receivedAddressString = childItem.receivedAddress; } if (NetworkLog.resolvePorts && NetworkLog.resolveCopies) { receivedPortString = NetworkLog.resolver.resolveService(String.valueOf(childItem.receivedPort)); } else { receivedPortString = String.valueOf(childItem.receivedPort); } hostString = receivedAddressString + ":" + receivedPortString; } ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); /* newer API 11 clipboard unsupported on older devices ClipData clip = ClipData.newPlainText("NetworkLog IP Address", hostString); clipboard.setPrimaryClip(clip); */ /* use older deprecated ClipboardManager to support older devices */ clipboard.setText(hostString); }
From source file:co.taqat.call.ChatFragment.java
private void copyTextMessageToClipboard(int id) { LinphoneChatMessage message = null;/*from w ww . j a v a 2 s.com*/ for (int i = 0; i < adapter.getCount(); i++) { LinphoneChatMessage msg = adapter.getItem(i); if (msg.getStorageId() == id) { message = msg; break; } } String txt = null; if (message != null) { txt = message.getText(); } if (txt != null) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = android.content.ClipData.newPlainText("Message", txt); clipboard.setPrimaryClip(clip); LinphoneActivity.instance().displayCustomToast(getString(R.string.text_copied_to_clipboard), Toast.LENGTH_SHORT); } }
From source file:com.gmail.charleszq.picorner.ui.ImageDetailFragment.java
private void saveToClipboard(String s) { ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); ClipData data = ClipData.newPlainText(getString(R.string.app_name), s); cm.setPrimaryClip(data);// w w w . j a v a 2s.c o m }