// 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;
    }
  }
 @SuppressWarnings("deprecation")
 @SuppressLint("NewApi")
 public static void copyToClipBoard(Context context, String strText) {
   final ClipboardManager manager =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   manager.setText(strText);
 }
 @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 #4
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);
      }
    }
  }
 /**
  * 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();
 }
 @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);
     }
   }
 }
Exemple #7
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();
 }
 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();
 }
  @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;
  }
 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;
 }
Exemple #11
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;
 }
  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;
    }
  }
Exemple #13
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 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);
 }
 private void openDonate() {
   String alipayAccount = getString(R.string.alipay_account);
   ClipboardManager cm =
       (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
   cm.setPrimaryClip(ClipData.newPlainText("AlipayAccount", alipayAccount));
   Toast.makeText(getActivity(), getString(R.string.msg_donate, alipayAccount), Toast.LENGTH_LONG)
       .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;
 }
Exemple #17
0
  public static void copyToClipboard(Context context, String data) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData cd = ClipData.newPlainText("msg", data);
    cm.setPrimaryClip(cd);

    // Inform the user
    Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show();
  }
Exemple #18
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();
  }
Exemple #19
0
 public static void set(Context context, String text) {
   if (!VipApplication.getInstance().lockLooper) {
     Looper.prepare();
     VipApplication.getInstance().lockLooper = true;
   }
   ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   cmb.setText(text);
   Log.v("DEV", "Clipboard set:" + text);
 }
 /**
  * 获取剪贴板的意图
  *
  * @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;
 }
 private void processSelectionOption(int which, TLRPC.TL_messages_stickerSet stickerSet) {
   if (which == 0) {
     StickersQuery.removeStickersSet(
         getParentActivity(), stickerSet.set, (stickerSet.set.flags & 2) == 0 ? 1 : 2);
   } else if (which == 1) {
     StickersQuery.removeStickersSet(getParentActivity(), stickerSet.set, 0);
   } else if (which == 2) {
     try {
       Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/plain");
       intent.putExtra(
           Intent.EXTRA_TEXT,
           String.format(
               Locale.US, "https://telegram.me/addstickers/%s", stickerSet.set.short_name));
       getParentActivity()
           .startActivityForResult(
               Intent.createChooser(
                   intent, LocaleController.getString("StickersShare", R.string.StickersShare)),
               500);
     } catch (Exception e) {
       FileLog.e("tmessages", e);
     }
   } else if (which == 3) {
     try {
       if (Build.VERSION.SDK_INT < 11) {
         android.text.ClipboardManager clipboard =
             (android.text.ClipboardManager)
                 ApplicationLoader.applicationContext.getSystemService(
                     Context.CLIPBOARD_SERVICE);
         clipboard.setText(
             String.format(
                 Locale.US, "https://telegram.me/addstickers/%s", stickerSet.set.short_name));
       } else {
         android.content.ClipboardManager clipboard =
             (android.content.ClipboardManager)
                 ApplicationLoader.applicationContext.getSystemService(
                     Context.CLIPBOARD_SERVICE);
         android.content.ClipData clip =
             android.content.ClipData.newPlainText(
                 "label",
                 String.format(
                     Locale.US,
                     "https://telegram.me/addstickers/%s",
                     stickerSet.set.short_name));
         clipboard.setPrimaryClip(clip);
       }
       Toast.makeText(
               getParentActivity(),
               LocaleController.getString("LinkCopied", R.string.LinkCopied),
               Toast.LENGTH_SHORT)
           .show();
     } catch (Exception e) {
       FileLog.e("tmessages", e);
     }
   }
 }
 public void onClickCopy(View view) {
   String text =
       mBufferTextView
           .getText()
           .toString(); // mShowDataInHexFormat ? mHexSpanBuffer.toString() :
                        // mAsciiSpanBuffer.toString();
   ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   ClipData clip = ClipData.newPlainText("UART", text);
   clipboard.setPrimaryClip(clip);
 }
 private void copyContent() {
   final Editable text = getText();
   int textLength = text.length();
   setSelection(0, textLength);
   ClipboardManager clipboard =
       (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
   clipboard.setPrimaryClip(ClipData.newPlainText(null, text));
   Toast.makeText(getContext(), R.string.text_copied_toast, Toast.LENGTH_SHORT).show();
   setSelection(textLength);
 }
 public boolean copyTextToClipboard(String text, int labelResId) {
   ClipboardManager mClipBoardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   String label = getResources().getString(labelResId);
   if (mClipBoardManager != null) {
     ClipData mClipData = ClipData.newPlainText(label, text);
     mClipBoardManager.setPrimaryClip(mClipData);
     return true;
   }
   return false;
 }
 /**
  * 粘贴【剪切板】功能
  *
  * @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();
 }
Exemple #26
0
 public static void copyToClipboard(String text) {
   // 得到剪贴板管理器
   try {
     ClipboardManager cmb =
         (ClipboardManager)
             GlobalContext.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
     cmb.setPrimaryClip(ClipData.newPlainText(null, text.trim()));
   } catch (Exception e) {
   }
 }
Exemple #27
0
 @OnClick(R.id.debug_pushwoosh_copy_pushtoken)
 void onPushwooshCopyPushTokenButton() {
   final Context context = getContext().getApplicationContext();
   final String pushToken = PushManager.getPushToken(context);
   Timber.d("PushToken: %s", pushToken);
   ClipboardManager clipboard =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   ClipData clip = ClipData.newPlainText("label", pushToken);
   clipboard.setPrimaryClip(clip);
   Toast.makeText(context, "Copy PushToken to Buffer", Toast.LENGTH_SHORT).show();
 }
Exemple #28
0
 @OnClick(R.id.debug_copy_deviceid)
 void onCopyDeviceIdButton() {
   final Context context = getContext().getApplicationContext();
   final String uniqueDeviceId = DeviceManagerTools.getUniqueDeviceId(context);
   Timber.d("DeviceId: %s", uniqueDeviceId);
   ClipboardManager clipboard =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   ClipData clip = ClipData.newPlainText("label", uniqueDeviceId);
   clipboard.setPrimaryClip(clip);
   Toast.makeText(context, "Copy DeviceId to Buffer", Toast.LENGTH_SHORT).show();
 }
Exemple #29
0
 public static void copy2Clipboard(String str2Copy, Context context) {
   if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
     android.content.ClipboardManager clipboardManager =
         (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboardManager.setText(str2Copy);
   } else {
     android.text.ClipboardManager clipboardManager =
         (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboardManager.setText(str2Copy);
   }
 }
 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() + "'");
   }
 }