private void processDrop(DragEvent event) {
   final ClipData data = event.getClipData();
   final int N = data.getItemCount();
   for (int i = 0; i < N; i++) {
     ClipData.Item item = data.getItemAt(i);
     String text = item.coerceToText(getContext()).toString();
     if (this.tile.type.equalsIgnoreCase(Constants.BLANK)) {
       String[] tileArgs = text.split(";");
       this.setTile(
           new Tile(
               this.tile.posOnBoard,
               tileArgs[1],
               Integer.parseInt(tileArgs[0]),
               MoveDirection.NONE,
               tileArgs[4],
               Constants.stringToBmp.get(tileArgs[1])));
       Constants.droppedOnBlank = true;
       // Communicator.getInstance(null,
       // null).sendMoveTile(tileArgs[1]);
       ClientCommunicator.getInstance(getContext(), null).sendMoveRequset(tile);
     } else {
       Constants.droppedOnBlank = false;
     }
   }
 }
 public boolean onActivityResult(final int requestCode, final int resultCode, final Intent data) {
   if (requestCode == ACTIVITY_FILE_CHOOSER) {
     choosing = false;
     if (resultCode == Activity.RESULT_OK) {
       Uri uri = data.getData();
       if (uri != null) {
         // 單選
         chosenFiles = getFilesFromUris(activity, new Uri[] {uri}, mustCanRead);
         return true;
       } else if (Build.VERSION.SDK_INT >= 16) {
         // 複選
         ClipData clipData = data.getClipData();
         if (clipData != null) {
           int count = clipData.getItemCount();
           if (count > 0) {
             Uri[] uris = new Uri[count];
             for (int i = 0; i < count; i++) {
               uris[i] = clipData.getItemAt(i).getUri();
             }
             chosenFiles = getFilesFromUris(activity, uris, mustCanRead);
             return true;
           }
         }
       }
     }
   }
   return false;
 }
  private Address getAddressFromPrimaryClip() {
    if (!clipboardManager.hasPrimaryClip()) return null;

    final ClipData clip = clipboardManager.getPrimaryClip();
    final ClipDescription clipDescription = clip.getDescription();

    if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
      final CharSequence clipText = clip.getItemAt(0).getText();
      if (clipText == null) return null;

      try {
        return new Address(Constants.NETWORK_PARAMETERS, clipText.toString().trim());
      } catch (final AddressFormatException x) {
        return null;
      }
    } else if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_URILIST)) {
      final Uri clipUri = clip.getItemAt(0).getUri();
      if (clipUri == null) return null;
      try {
        return new BitcoinURI(clipUri.toString()).getAddress();
      } catch (final BitcoinURIParseException x) {
        return null;
      }
    } else {
      return null;
    }
  }
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
    final int action = ev.getAction();
    if (action == MotionEvent.ACTION_DOWN) {
      final ClipData clip = mClipping;
      if (clip != null) {
        final Bitmap icon = clip.getIcon();
        DragShadowBuilder shadow;
        if (icon != null) {
          shadow =
              new DragShadowBuilder(this) {
                public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
                  shadowSize.set(icon.getWidth(), icon.getHeight());
                  shadowTouchPoint.set(shadowSize.x / 2, shadowSize.y / 2);
                }

                public void onDrawShadow(Canvas canvas) {
                  canvas.drawBitmap(icon, 0, 0, new Paint());
                }
              };
        } else {
          // uhhh, what now?
          shadow = new DragShadowBuilder(this);
        }

        startDrag(clip, shadow, null, 0);

        // TODO: only discard the clipping if it was accepted
        stash(null);

        return true;
      }
    }
    return false;
  }
  private void onFinished(Uri... uris) {
    final Intent intent = new Intent();
    if (uris.length == 1) {
      intent.setData(uris[0]);
    } else if (uris.length > 1) {
      final ClipData clipData = new ClipData(null, mState.acceptMimes, new ClipData.Item(uris[0]));
      for (int i = 1; i < uris.length; i++) {
        clipData.addItem(new ClipData.Item(uris[i]));
      }
      intent.setClipData(clipData);
    }

    if (mState.action == ACTION_GET_CONTENT) {
      intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else if (mState.action == ACTION_OPEN_TREE) {
      intent.addFlags(
          Intent.FLAG_GRANT_READ_URI_PERMISSION
              | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
              | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
              | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
    } else {
      intent.addFlags(
          Intent.FLAG_GRANT_READ_URI_PERMISSION
              | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
              | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
    }

    setResult(Activity.RESULT_OK, intent);
    finish();
    Log.d(TAG, "onFinished: uri=" + Arrays.toString(uris) + ", data=" + intent);
  }
 boolean processDrop(DragEvent event, ImageView imageView) {
   // Attempt to parse clip data with expected format: category||entry_id.
   // Ignore event if data does not conform to this format.
   ClipData data = event.getClipData();
   if (data != null) {
     if (data.getItemCount() > 0) {
       Item item = data.getItemAt(0);
       String textData = (String) item.getText();
       if (textData != null) {
         StringTokenizer tokenizer = new StringTokenizer(textData, "||");
         if (tokenizer.countTokens() != 2) {
           return false;
         }
         int category = -1;
         int entryId = -1;
         try {
           category = Integer.parseInt(tokenizer.nextToken());
           entryId = Integer.parseInt(tokenizer.nextToken());
         } catch (NumberFormatException exception) {
           return false;
         }
         updateContentAndRecycleBitmap(category, entryId);
         // Update list fragment with selected entry.
         TitlesFragment titlesFrag =
             (TitlesFragment) getFragmentManager().findFragmentById(R.id.titles_frag);
         titlesFrag.selectPosition(entryId);
         return true;
       }
     }
   }
   return false;
 }
 @Override
 protected void onResume() {
   super.onResume();
   final int entryCount = getSupportFragmentManager().getBackStackEntryCount();
   final ClipboardManager clipboardManager =
       (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   if (entryCount == 0
       && clipboardManager.hasPrimaryClip()
       && clipboardManager.getPrimaryClip().getItemCount() > 0) {
     final ClipData primaryClip = clipboardManager.getPrimaryClip();
     final ClipData.Item item = primaryClip.getItemAt(0);
     final String text = item.coerceToText(this).toString();
     if (text.trim().length() > 0) {
       final Snackbar snackbar =
           Snackbar.with(this)
               .text(getString(R.string.paste_from_clipboard_prompt))
               .actionLabel(getString(R.string.paste_clipboard_action))
               .actionColorResource(R.color.sharelock_orange)
               .actionListener(
                   new ActionClickListener() {
                     @Override
                     public void onActionClicked(Snackbar snackbar) {
                       bus.postSticky(new ClipboardSecretEvent(text));
                       clipboardManager.setPrimaryClip(ClipData.newPlainText("", ""));
                     }
                   })
               .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);
       SnackbarManager.show(snackbar);
     }
   }
 }
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == FILE_CODE && resultCode == Activity.RESULT_OK) {
      if (data.getBooleanExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false)) {
        // For JellyBean and above
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
          ClipData clip = data.getClipData();

          if (clip != null) {
            for (int i = 0; i < clip.getItemCount(); i++) {
              Uri uri = clip.getItemAt(i).getUri();
              uploadFile(uri.getPath());
            }
          }
        } else {
          ArrayList<String> paths = data.getStringArrayListExtra(FilePickerActivity.EXTRA_PATHS);

          if (paths != null) {
            for (String path : paths) {
              Uri uri = Uri.parse(path);
              uploadFile(uri.getPath());
            }
          }
        }

      } else {
        Uri uri = data.getData();
        uploadFile(uri.getPath());
      }
    }
  }
 /**
  * 获取剪贴板的意图
  *
  * @param context 上下文
  * @return 剪贴板的意图
  */
 public static Intent getIntent(Context context) {
   ClipboardManager clipboard =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   ClipData clip = clipboard.getPrimaryClip();
   if (clip != null && clip.getItemCount() > 0) {
     return clip.getItemAt(0).getIntent();
   }
   return null;
 }
 /**
  * 粘贴【剪切板】功能
  *
  * @return 返回剪贴板的内容
  */
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 public String paste() {
   // 粘贴部分【本案例不需要粘贴】
   ClipboardManager myClipboard;
   myClipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   // 需要做的下一件事就是通过调用ClipData类的数据方法的相应类型来实例化ClipData对象。如果文本数据在newPlainText方法被调用。必须将数据设置为剪贴板管理器对象的剪辑。
   ClipData clipData = myClipboard.getPrimaryClip();
   ClipData.Item item = clipData.getItemAt(0);
   return item.getText().toString();
 }
 private void pasteContent() {
   ClipData clip = getPrimaryClip();
   if (clip != null) {
     for (int i = 0; i < clip.getItemCount(); i++) {
       CharSequence paste = clip.getItemAt(i).coerceToText(getContext());
       if (canPaste(paste)) {
         ((Editable) getText()).insert(getSelectionEnd(), paste);
       }
     }
   }
 }
  @Override
  public boolean onLongClick(View v) {
    // Create a new ClipData.Item from the ImageView object's generateTag
    ClipData data = ClipData.newPlainText("id", String.valueOf(sousTache.getId()));
    data.addItem(new ClipData.Item(sousTache.getEtat().name()));
    View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
    v.startDrag(data, shadowBuilder, v, 0);
    v.setVisibility(View.INVISIBLE);

    return true;
  }
 protected void copyMessageText(MessageEditorData editorData) {
   MyLog.v(this, "text='" + editorData.body + "'");
   if (!TextUtils.isEmpty(editorData.body)) {
     // http://developer.android.com/guide/topics/text/copy-paste.html
     ClipboardManager clipboard =
         (ClipboardManager)
             MyContextHolder.get().context().getSystemService(Context.CLIPBOARD_SERVICE);
     ClipData clip = ClipData.newPlainText(I18n.trimTextAt(editorData.body, 40), editorData.body);
     clipboard.setPrimaryClip(clip);
     MyLog.v(this, "clip='" + clip.toString() + "'");
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == IMAGE_GALLERY_RESULT && resultCode == RESULT_OK) {
     ClipData clip = data.getClipData();
     if (clip != null) {
       for (int i = 0; i < clip.getItemCount(); i++) {
         Uri uri = clip.getItemAt(i).getUri();
         Log.d(TAG, "File: " + uri.getPath());
       }
     }
   }
 }
 /**
  * Get the remote input results bundle from an intent. The returned Bundle will contain a
  * key/value for every result key populated by remote input collector. Use the {@link
  * Bundle#getCharSequence(String)} method to retrieve a value.
  *
  * @param intent The intent object that fired in response to an action or content intent which
  *     also had one or more remote input requested.
  */
 public static Bundle getResultsFromIntent(Intent intent) {
   ClipData clipData = intent.getClipData();
   if (clipData == null) {
     return null;
   }
   ClipDescription clipDescription = clipData.getDescription();
   if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
     return null;
   }
   if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
     return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
   }
   return null;
 }
  // used in the web dialog popup /res/layout/web_menu_popup.xml
  public void webviewActionClicked(View v) {
    switch (v.getId()) {
      case R.id.saveimage:
        dismissDialog();
        String url = ((LinearLayout) v.getParent()).getTag().toString();
        Tools.DownloadAsyncTask download = new Tools.DownloadAsyncTask(url);
        download.execute(url);

        break;
      case R.id.openinnewtab:
        dismissDialog();
        webWindows.add(new CustomWebView(MainActivity.this, null, null));
        ((ViewGroup) webLayout.findViewById(R.id.webviewholder)).removeAllViews();
        webWindows
            .get(webWindows.size() - 1)
            .loadUrl(((LinearLayout) v.getParent()).getTag().toString());
        ((ViewGroup) webLayout.findViewById(R.id.webviewholder))
            .addView(webWindows.get(webWindows.size() - 1));
        ((EditText) bar.findViewById(R.id.browser_searchbar)).setText("");
        browserListViewAdapter.notifyDataSetChanged();
        break;
      case R.id.copyurl:
        dismissDialog();
        String url2 = ((LinearLayout) v.getParent()).getTag().toString();

        // Gets a handle to the Clipboard Manager
        ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("Copied URL", url2);
        clipboard.setPrimaryClip(clip);
        break;
    }
  }
 public void setPrimaryClip(ClipData clip, String callingPackage) {
   synchronized (this) {
     if (clip != null && clip.getItemCount() <= 0) {
       throw new IllegalArgumentException("No items");
     }
     final int callingUid = Binder.getCallingUid();
     if (mAppOps.noteOp(AppOpsManager.OP_WRITE_CLIPBOARD, callingUid, callingPackage)
         != AppOpsManager.MODE_ALLOWED) {
       return;
     }
     checkDataOwnerLocked(clip, callingUid);
     clearActiveOwnersLocked();
     PerUserClipboard clipboard = getClipboard();
     clipboard.primaryClip = clip;
     final long ident = Binder.clearCallingIdentity();
     final int n = clipboard.primaryClipListeners.beginBroadcast();
     try {
       for (int i = 0; i < n; i++) {
         try {
           ListenerInfo li = (ListenerInfo) clipboard.primaryClipListeners.getBroadcastCookie(i);
           if (mAppOps.checkOpNoThrow(AppOpsManager.OP_READ_CLIPBOARD, li.mUid, li.mPackageName)
               == AppOpsManager.MODE_ALLOWED) {
             clipboard.primaryClipListeners.getBroadcastItem(i).dispatchPrimaryClipChanged();
           }
         } catch (RemoteException e) {
           // The RemoteCallbackList will take care of removing
           // the dead object for us.
         }
       }
     } finally {
       clipboard.primaryClipListeners.finishBroadcast();
       Binder.restoreCallingIdentity(ident);
     }
   }
 }
Exemple #18
0
 void copyIntent() {
   ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
   ClipData clip = ClipData.newIntent("intent", intent);
   cm.setPrimaryClip(clip);
   Toast.makeText(this, "Intent Copied", 0).show();
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    String listItemName1 = Biography[info.position - 1];
    ListView wirdlist = (ListView) findViewById(R.id.biolist);
    LayoutInflater mInflater = getLayoutInflater();
    final View mLayout =
        mInflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));
    final TextView mText = (TextView) mLayout.findViewById(R.id.toast_text);
    Toast mToast = new Toast(getApplicationContext());
    mToast.setDuration(Toast.LENGTH_SHORT);
    mToast.setView(mLayout);

    if (item.getItemId() == 0) {

      int menuItemIndex = item.getItemId();
      String[] menuItems = getResources().getStringArray(R.array.menu2);
      String menuItemName = menuItems[menuItemIndex];

      ClipData clip = ClipData.newPlainText("simple text", listItemName1);
      clipboard.setPrimaryClip(clip);

      mText.setText("Text Copied");
      mToast.show();
    }

    return true;
  }
 private void copyTextToClipboard() {
   final Object service = this.getSystemService(CLIPBOARD_SERVICE);
   final ClipboardManager clipboard = (ClipboardManager) service;
   final ClipData clipData = ClipData.newPlainText("Debug Information", this.debugText);
   clipboard.setPrimaryClip(clipData);
   Toast.makeText(this, R.string.debug_copied, Toast.LENGTH_SHORT).show();
 }
 /**
  * Copies the given device ID to the clipboard (and shows a Toast telling about it).
  *
  * @param id The device ID to copy.
  */
 public static void copyDeviceId(Context context, String id) {
   ClipboardManager clipboard =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   ClipData clip = ClipData.newPlainText(context.getString(R.string.device_id), id);
   clipboard.setPrimaryClip(clip);
   Toast.makeText(context, R.string.device_id_copied_to_clipboard, Toast.LENGTH_SHORT).show();
 }
Exemple #22
0
 public static void copyToClipBoard(Context context, String text, String success) {
   ClipData clipData = ClipData.newPlainText("meizhi_copy", text);
   ClipboardManager manager =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   manager.setPrimaryClip(clipData);
   ToastUtils.showShort(success);
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case 1:
        AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();

        // The textview which holds the parsed xml
        CharSequence selectedTexts =
            ((EmojiconTextView) menuInfo.targetView.findViewById(R.id.message_text)).getText();
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("Intent", (CharSequence) selectedTexts);
        ((android.content.ClipboardManager) clipboard).setPrimaryClip(clip);
        Toast.makeText(getApplicationContext(), "Selected text is copied", Toast.LENGTH_SHORT)
            .show();
        break;

      case 2:
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        CharSequence textToShare =
            ((EmojiconTextView) info.targetView.findViewById(R.id.message_text)).getText();
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_TEXT, textToShare);
        shareIntent.setType("text/plain");
        startActivity(Intent.createChooser(shareIntent, "Hiaite zangin share in"));
    }
    return super.onContextItemSelected(item);
  }
 @Override
 public void setText(String label, String text) {
   ClipboardManager clipboardManager =
       (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
   ClipData clip = ClipData.newPlainText(label, text);
   clipboardManager.setPrimaryClip(clip);
 }
Exemple #25
0
  @SuppressWarnings("deprecation")
  @SuppressLint("NewApi")
  /*
   * Cancel clipboard content
   */
  public void cancelClipBoardContent() {

    if (android.os.Build.VERSION.SDK_INT < 11) {
      android.text.ClipboardManager clipboard =
          (android.text.ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
      if (clipboard != null) {
        clipboard.setText("");
      }
    } else {
      android.content.ClipboardManager clipboard =
          (android.content.ClipboardManager)
              getContext().getSystemService(Context.CLIPBOARD_SERVICE);
      if (clipboard != null
          && clipboard.getPrimaryClip() != null
          && clipboard.getPrimaryClip().getItemCount() > 0) {
        android.content.ClipData clip = android.content.ClipData.newPlainText("", "");
        clipboard.setPrimaryClip(clip);
      }
    }
  }
Exemple #26
0
 @Override
 public boolean onPreferenceClick(final Preference preference) {
   final ClipboardManager cm =
       (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
   switch (preference.getKey()) {
     case "license":
       new LicensesDialog.Builder(getActivity())
           .setNotices(R.raw.notices)
           .setIncludeOwnLicense(true)
           .build()
           .showAppCompat();
       break;
     default:
       new AlertDialog.Builder(getActivity())
           .setMessage("复制到剪贴板?")
           .setPositiveButton(
               "确定",
               (dialogInterface, i) -> {
                 ClipData myClip;
                 CharSequence text = preference.getSummary();
                 myClip = ClipData.newPlainText("text", text);
                 cm.setPrimaryClip(myClip);
               })
           .setNegativeButton(
               "取消",
               (dialogInterface, i) -> {
                 dialogInterface.cancel();
               })
           .show();
       break;
   }
   return true;
 }
 public static boolean setText(final Context context, final CharSequence text) {
   if (context == null) return false;
   final ClipboardManager clipboardManager =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   clipboardManager.setPrimaryClip(ClipData.newPlainText(text, text));
   return true;
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     finish();
     overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right);
     return true;
   } else if (item.getItemId() == R.id.action_browser) {
     Intent intent =
         new Intent(
             Intent.ACTION_VIEW,
             Uri.parse(
                 getIntent()
                     .getDataString()
                     .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
     startActivity(intent);
     finish();
     return true;
   } else if (item.getItemId() == R.id.action_save) {
     DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
     if (d != null) {
       DownloadManager.Request r =
           new DownloadManager.Request(
               Uri.parse(
                   getIntent()
                       .getDataString()
                       .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
       if (Build.VERSION.SDK_INT >= 11) {
         r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
         r.allowScanningByMediaScanner();
       }
       d.enqueue(r);
     }
     return true;
   } else if (item.getItemId() == R.id.action_copy) {
     if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
       android.text.ClipboardManager clipboard =
           (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
       clipboard.setText(
           getIntent()
               .getDataString()
               .replace(getResources().getString(R.string.IMAGE_SCHEME), "http"));
     } else {
       @SuppressLint("ServiceCast")
       android.content.ClipboardManager clipboard =
           (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
       android.content.ClipData clip =
           android.content.ClipData.newRawUri(
               "IRCCloud Image URL",
               Uri.parse(
                   getIntent()
                       .getDataString()
                       .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
       clipboard.setPrimaryClip(clip);
     }
     Toast.makeText(ImageViewerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT)
         .show();
   }
   return super.onOptionsItemSelected(item);
 }
Exemple #29
0
  /** copy wallet address to clipboard */
  public void copyToClipboard() {

    ClipboardManager myClipboard =
        (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData myClip = ClipData.newPlainText("text", this.user_address_wallet);
    myClipboard.setPrimaryClip(myClip);
    Toast.makeText(getActivity().getApplicationContext(), "Text Copied", Toast.LENGTH_SHORT).show();
  }
 @Override
 public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
   DraftRaw draftRaw = mLazyList.get(position);
   ClipboardManager cbm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   cbm.setPrimaryClip(ClipData.newPlainText(null, draftRaw.getContent()));
   Toast.makeText(this, R.string.draft_copied_clipboard, Toast.LENGTH_SHORT).show();
   return false;
 }