@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.act_pubkeylist); mListView = (RecyclerView) findViewById(R.id.list); mListView.setHasFixedSize(true); mListView.setLayoutManager(new LinearLayoutManager(this)); mListView.addItemDecoration(new ListItemDecoration(this)); mEmptyView = findViewById(R.id.empty); registerForContextMenu(mListView); clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.copyTv: if (mCommentItem != null) { ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(mCommentItem.getContent()); } dismiss(); break; case R.id.deleteTv: if (mPresenter != null && mCommentItem != null) { mPresenter.deleteComment(mCirclePosition, FormatUtil.checkValue(mCommentItem.getId()),commentPosition); } dismiss(); break; default: break; } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.copyTv: if (mCommentItem != null) { ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(mCommentItem.getContent()); } dismiss(); break; case R.id.deleteTv: if (bnItemOnClickListener != null && mCommentItem != null) { bnItemOnClickListener.deleteComment(mCirclePosition, mCommentItem.getId()); } dismiss(); break; default: break; } }
@Override public void onClick(View v) { switch (v.getId()){ case R.id.action_copy: if (mCommentItem != null) { ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(mCommentItem.getContent()); } dismiss(); break; case R.id.action_delete: if (mBnItemOnClickListener != null && mCommentItem != null) { mBnItemOnClickListener.deleteComment(mBnPosition, mCommentItem.getId()); } dismiss(); break; } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item_copy: ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); cm.setText(url); SnackBarUtil.showSnackBar(R.string.copy_msg, webView, this); break; case R.id.item_browser: Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); break; } return super.onOptionsItemSelected(item); }
public void onClick(View view) { if (view == this.reverseUnits) { int inputUnitPosition = this.inputUnit.getSelectedItemPosition(); this.inputUnit.setSelection(this.outputUnit .getSelectedItemPosition()); this.outputUnit.setSelection(inputUnitPosition); } else if (view == this.clearInput) { this.inputAmount.setText(""); } else if (view == this.copyResult) { CharSequence result = this.outputAmount.getText(); if (result.length() > 0) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(result); Toast.makeText(this, super.getString(R.string.copy_result_message, result), Toast.LENGTH_SHORT).show(); } } else { throw new AssertionError("Unexpected click on view: " + view); } this.recalculate(); }
@Override public void onClick(View v) { int id = v.getId(); if (id == R.id.btn_copy) { ClipboardManager clipboarManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipboarManager.setText(mEtText.getText().toString()); Toast.makeText(this, R.string.added_to_clip_board, Toast.LENGTH_LONG).show(); } else if (id == R.id.btn_search) { String url = String.format( "http://m.baidu.com/s?word=%s", URLEncoder.encode(mEtText.getText().toString())); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); setResult(RESULT_OK); finish(); } }
@Override public void draw() { if (TextUtils.isEmpty(app.getVideoUrl())) { return; } TextView videoLink = activity.findViewById(R.id.video); videoLink.setVisibility(View.VISIBLE); videoLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(app.getVideoUrl()))); } catch (ActivityNotFoundException e) { ((ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE)).setText(app.getVideoUrl()); ContextUtil.toast(v.getContext().getApplicationContext(), R.string.about_copied_to_clipboard); } } }); }
@SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override public boolean onTextContextMenuItem(int id) { if(id == android.R.id.paste){ ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE); String text = clip.getText().toString(); if(text.startsWith(ChatActivity.COPY_IMAGE)){ // intent.setDataAndType(Uri.fromFile(new File("/sdcard/mn1.jpg")), "image/*"); text = text.replace(ChatActivity.COPY_IMAGE, ""); Intent intent = new Intent(context,AlertDialog.class); intent.putExtra("title", "发送以下图片?"); intent.putExtra("forwardImage", text); intent.putExtra("cancel", true); ((Activity)context).startActivityForResult(intent,ChatActivity.REQUEST_CODE_COPY_AND_PASTE); // clip.setText(""); } } return super.onTextContextMenuItem(id); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId() == CLEAR_CODE) { currentLog=new SpannableStringBuilder(); label_log.setText(""); return true; } else if(item.getItemId() == COPY_CODE) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(currentLog); Toast.makeText(this,R.string.message_copied,Toast.LENGTH_SHORT).show(); } return false; }
@SuppressLint("NewApi") @Override public boolean onTextContextMenuItem(int id) { if(id == android.R.id.paste){ ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE); if (clip == null || clip.getText() == null) { return false; } String text = clip.getText().toString(); if(text.startsWith(ChatActivity.COPY_IMAGE)){ // intent.setDataAndType(Uri.fromFile(new File("/sdcard/mn1.jpg")), "image/*"); text = text.replace(ChatActivity.COPY_IMAGE, ""); Intent intent = new Intent(context,AlertDialog.class); String str = context.getResources().getString(R.string.Send_the_following_pictures); intent.putExtra("title", str); intent.putExtra("forwardImage", text); intent.putExtra("cancel", true); ((Activity)context).startActivityForResult(intent,ChatActivity.REQUEST_CODE_COPY_AND_PASTE); // clip.setText(""); } } return super.onTextContextMenuItem(id); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); break; case R.id.action_refresh: //刷新 mWebView.reload(); break; case R.id.action_open_in_browser: //在浏览器中打开 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); break; case R.id.action_copy: //复制网址 ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clip.setText(url); // 复制 CommonUtil.showSnackbar(mWebView, R.string.copy_to_clipboard, getResources().getColor(R.color.Indigo_colorPrimary)); break; default: break; } return super.onOptionsItemSelected(item); }
/** * Constructor used by the inflation apparatus * * @param context */ public RemoteCanvas(final Context context, AttributeSet attrs) { super(context, attrs); clipboard = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE); decoder = new Decoder (this); isRdp = getContext().getPackageName().contains("RDP"); isSpice = getContext().getPackageName().contains("SPICE"); final Display display = ((Activity)context).getWindow().getWindowManager().getDefaultDisplay(); displayWidth = display.getWidth(); displayHeight = display.getHeight(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); displayDensity = metrics.density; if (android.os.Build.MODEL.contains("BlackBerry") || android.os.Build.BRAND.contains("BlackBerry") || android.os.Build.MANUFACTURER.contains("BlackBerry")) { bb = true; } }
public View getView(int position, View convertView, ViewGroup parent) { View vi = convertView; final Discussion entry = data.get(position); if (entry.getMe()) vi = inflater.inflate(R.layout.message_list_out, null); else vi = inflater.inflate(R.layout.message_list_in, null); LinearLayout list = (LinearLayout)vi.findViewById(R.id.messageList); TextView time = (TextView)vi.findViewById(R.id.time); TextView message = (TextView)vi.findViewById(R.id.message); list.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { ClipboardManager cm = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); cm.setText(entry.getMessage()); th.sendNotification(activity, "Copied to clipboard"); return true; } }); message.setText(entry.getMessage()); Timestamp timestamp = entry.getTimestamp(); time.setText(timestamp.getHours()+":"+timestamp.getMinutes()); return vi; }
@Override public void execute(Context ctx, JSONObject data) { try { String string = data.getString("message"); if (TextUtils.isEmpty(string)) { // No message, return return; } // Get clipboard manager and set the text to it ((ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE)) .setText(string); } catch (JSONException e) { } }
public ResultAdapter(Context context, String[] titles) { Log.d(TAG, "constructor"); mContext = context; mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mVersionCode = android.os.Build.VERSION.SDK_INT; if (mVersionCode >= Build.VERSION_CODES.HONEYCOMB) { mClipboardManager = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); } else { mClipboardManager = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); } mResultTitles = titles; mResults = new ArrayList<String>(titles.length); String resultZero = getResString(R.string.result_zero); for (int i = 0; i < titles.length; ++i) { mResults.add(i, resultZero); } }
@Override public boolean onKeyShortcut(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_C: Log.v("MessageList", "�����ˣ�����"); MessageListItem view = (MessageListItem)getSelectedView(); if (view == null) { break; } MessageItem item = view.getMessageItem(); if (item != null && item.isSms()) { ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE); clip.setText(item.mBody); return true; } break; } return super.onKeyShortcut(keyCode, event); }
@Override protected String doInBackground(Integer... params) { //clear the clipboard after the specified interval try{ Thread.sleep(params[0]); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(""); return "success"; }catch(InterruptedException e) { e.printStackTrace(); } return "failure"; }
public void respondToClick(int position, String subject, String body, SendLogDetails.AttachmentType attachmentType, File attachment) { ResolveInfo launchable = getItem(position); ActivityInfo activity=launchable.activityInfo; if (launchable instanceof DummyClipboardLaunchable) { ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(body); Toast.makeText(mContext, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); } else { ComponentName name= new ComponentName(activity.applicationInfo.packageName, activity.name); Intent actionSendIntent= createSendIntent(subject, body, attachmentType, attachment); actionSendIntent.setComponent(name); mContext.startActivity(actionSendIntent); } }
public void onLongClickMsgBody(){ if(listElem.msg.isImgMsg()) return; AlertDialog.Builder ab = new Builder(OTRoomBase.this); ab.setTitle(getString(R.string.oto_select_recommend_task)); ab.setItems(getResources().getStringArray(R.array.oto_chat_msg_menu), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { CharSequence text = nowConvResource.body.getText(); ClipboardManager cm = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); switch(which){ case 0: cm.setText(text); break; } } }); ab.show(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: return MenuManager.back(this); case R.id.action_refresh: Toast.makeText(getApplicationContext(), getString(R.string.text_refreshing), Toast.LENGTH_SHORT).show(); refresh(); return true; case R.id.action_copy: ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); cm.setText(searchText); Toast.makeText(getApplicationContext(), getString(R.string.text_copied), Toast.LENGTH_SHORT).show(); return true; case R.id.action_settings: return MenuManager.openSettings(this); } return super.onOptionsItemSelected(item); }
private TextView handleBuildSuccessTextView(final String logUrl) { TextView showText = new TextView(getActivity()); showText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); showText.setPadding(15, 30, 15, 30); showText.setText(getString(R.string.log_submit_activity__copy_this_url_and_add_it_to_your_issue, logUrl)); showText.setAutoLinkMask(Activity.RESULT_OK); showText.setMovementMethod(LinkMovementMethod.getInstance()); showText.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { @SuppressWarnings("deprecation") ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setText(logUrl); Toast.makeText(getActivity(), R.string.log_submit_activity__copied_to_clipboard, Toast.LENGTH_SHORT).show(); return true; } }); Linkify.addLinks(showText, Linkify.WEB_URLS); return showText; }
/** Action Bar SMS Button */ public void onSmsClick() { if (mPhoneNum != null && mPhoneNum.compareTo("null") != 0) { Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms:" + mPhoneNum)); sendIntent.putExtra("address", mPhoneNum); sendIntent.putExtra("sms_body", "@" + mUserName + " "); ClipboardManager CbM = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); CbM.setText("@" + mUserName + " "); startActivity(sendIntent); } else { startActivity(new Intent(this, SettingsActivity.class)); Toast.makeText(this, "Enter Gateway Number", Toast.LENGTH_SHORT).show(); } }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Object o = parent.getItemAtPosition(position); if(o == null || !(o instanceof Comment)) return false; Comment c = (Comment)o; ClipboardManager ma = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ ClipData text = ClipData.newHtmlText(c.userName, c.content, c.content); ((android.content.ClipboardManager) ma).setPrimaryClip(text); }else{ ma.setText(c.content); } Toast.makeText(this, "#"+c.count+"的内容已复制", 0).show(); return true; }
public final void copyName() { try { CommanderAdapter ca = getListAdapter( true ); if( ca == null ) return; ClipboardManager clipboard = (ClipboardManager)c.getSystemService( Context.CLIPBOARD_SERVICE ); int pos = getSelection( true ); if( pos >= 0 ) { String in = ca.getItemName( pos, true ); if( in != null ) { if( in.startsWith( RootAdapter.DEFAULT_LOC ) ) in = Uri.parse( in ).getPath(); clipboard.setText( in ); } } } catch( Exception e ) { e.printStackTrace(); } }
private void doPaste() { ClipboardManager clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); if(!clip.hasText()){ Toast tt = Toast.makeText(this, "No text to Paste..", Toast.LENGTH_SHORT); tt.show(); return; } CharSequence paste = clip.getText(); byte[] utf8; try { utf8 = paste.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { Log.e(TermDebug.LOG_TAG, "UTF-8 encoding not found."); return; } getCurrentTermSession().write(paste.toString()); }
public void copyToClipboard(){ final CharSequence genPw = getText(); if (genPw == null) { return; } final ClipboardManager clipMan = (ClipboardManager)getContext().getSystemService(Application.CLIPBOARD_SERVICE); clipMan.setText(genPw); if (genPw.length() > 0){ if (domain != null){ Toast.makeText(getContext(), getResources().getString(R.string.toast_copied, domain), Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(getContext(), getResources().getString(R.string.toast_copied_no_domain), Toast.LENGTH_SHORT).show(); } } }
/** * {@inheritDoc} */ @SuppressWarnings("deprecation") @Override public boolean onContextItemSelected(MenuItem item) { if(item.getItemId() == R.id.copy_to_clipboard) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); // Clicked position must be aligned to list headers count int position = info.position - chatListView.getHeaderViewsCount(); // Gets clicked message ChatMessage clickedMsg = chatListAdapter.getMessage(position); // Copy message content to clipboard ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setText(clickedMsg.getContentForClipboard()); return true; } return super.onContextItemSelected(item); }
@Override public boolean onKeyShortcut(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_C: MessageListItem view = (MessageListItem)getSelectedView(); if (view == null) { break; } MessageItem item = view.getMessageItem(); if (item != null && item.isSms()) { ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE); clip.setText(item.mBody); return true; } break; } return super.onKeyShortcut(keyCode, event); }
@Override public boolean onContextItemSelected( MenuItem item ) { int pos = ( (AdapterContextMenuInfo) item.getMenuInfo( ) ).position; LogItem log = (LogItem) getListView( ).getItemAtPosition( pos ); if ( log != null && log.getMsg( ) != null ) { ClipboardManager cm = (ClipboardManager) getSystemService( CLIPBOARD_SERVICE ); if ( cm != null ) { cm.setText( log.getMsg( ) ); Util.shortToast( this, R.string.copied_hint ); } } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = null; if (item.getItemId() == android.R.id.home) { finish(); return true; } else if (item.getItemId() == R.id.menu_clear_clipboard) { ClipboardManager clipBoard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipBoard.setText(""); return true; } else if (item.getItemId() == R.id.menu_settings) { intent = new Intent(getApplicationContext(), SettingsActivity.class); startActivity(intent); return true; } else if (item.getItemId() == R.id.menu_quit) { intent = new Intent(getApplicationContext(), MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("EXIT", true); startActivity(intent); return true; } else { return super.onOptionsItemSelected(item); } }