Search in sources :

Example 81 with ClipData

use of android.content.ClipData in project RxTools by vondear.

the class RxClipboardTool method getIntent.

/**
 * 获取剪贴板的意图
 *
 * @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;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 82 with ClipData

use of android.content.ClipData in project RxTools by vondear.

the class RxClipboardTool method getText.

/**
 * 获取剪贴板的文本
 *
 * @return 剪贴板的文本
 */
public static CharSequence getText(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).coerceToText(context);
    }
    return null;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 83 with ClipData

use of android.content.ClipData in project run-wallet-android by runplay.

the class WalletTransfersItemDialog method onClick.

@Override
public void onClick(DialogInterface dialogInterface, int which) {
    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    Fragment fragment;
    final Bundle bundle = new Bundle();
    switch(which) {
        case 0:
            String useAddress = transfer.getAddress();
            try {
                useAddress = Checksum.addChecksum(transfer.getAddress());
            } catch (Exception e) {
            }
            ClipData clipAddress = ClipData.newPlainText(getActivity().getString(R.string.address), useAddress);
            clipboard.setPrimaryClip(clipAddress);
            break;
        case 1:
            ClipData clipHash = ClipData.newPlainText(getActivity().getString(R.string.hash), hash);
            clipboard.setPrimaryClip(clipHash);
            break;
        case 2:
            // Log.e("DIALOG","GO");
            if (transfer.isMarkDoubleAddress()) {
                Transfer gottransfer = Store.isAlreadyTransfer(hash, Store.getTransfers());
                if (gottransfer != null) {
                    Store.setCacheTransfer(gottransfer);
                    UiManager.openFragmentBackStack(getActivity(), PendingCancelledFragment.class);
                }
            } else if (!transfer.isCompleted()) {
                Transfer transfer = Store.getCurrentTransferFromHash(hash);
                if (transfer != null) {
                    AppService.nudgeTransaction(getActivity(), Store.getCurrentSeed(), transfer);
                }
            } else {
                Snackbar.make(getActivity().findViewById(R.id.drawer_layout), getString(R.string.messages_transaction_already_confirmed), Snackbar.LENGTH_LONG).show();
            }
            break;
        case 3:
            if (!transfer.isCompleted()) {
                Transfer transfer = Store.getCurrentTransferFromHash(hash);
                if (transfer != null) {
                    AppService.replayBundleTransaction(getActivity(), Store.getCurrentSeed(), hash, transfer.getAddress());
                }
            } else {
                Snackbar.make(getActivity().findViewById(R.id.drawer_layout), getString(R.string.messages_transaction_already_confirmed), Snackbar.LENGTH_LONG).show();
            }
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) Bundle(android.os.Bundle) Transfer(run.wallet.iota.model.Transfer) PendingCancelledFragment(run.wallet.iota.ui.fragment.PendingCancelledFragment) DialogFragment(android.app.DialogFragment) Fragment(android.app.Fragment) ClipData(android.content.ClipData)

Example 84 with ClipData

use of android.content.ClipData in project run-wallet-android by runplay.

the class AboutFragment method onAboutDonationIotaAddressClick.

@OnClick(R.id.about_donation_iota_address)
public void onAboutDonationIotaAddressClick() {
    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(getActivity().getString(R.string.seed), Constants.DONATION_ADDRESS);
    clipboard.setPrimaryClip(clip);
    Snackbar.make(getView(), getString(R.string.messages_iota_donation), Snackbar.LENGTH_LONG).show();
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData) OnClick(butterknife.OnClick)

Example 85 with ClipData

use of android.content.ClipData in project run-wallet-android by runplay.

the class PendingCancelledFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    if (Store.getCacheTransfer() == null) {
        getActivity().onBackPressed();
    } else {
        View v = view.findViewById(R.id.transfer_card);
        TransferViewManager.populateViewHolder(getActivity(), new TransferViewManager.ViewHolder(getActivity(), v), Store.getCacheTransfer(), false, -1, false);
        List<TransferTransaction> transactions = new ArrayList<>();
        transactions.addAll(Store.getCacheTransfer().getTransactions());
        transactions.addAll(Store.getCacheTransfer().getOtherTransactions());
        TransferViewManager.populateTransferTransactionOuts(getActivity(), breakdown, transactions, Store.getCacheTransfer());
        cancelledHash.setText(Store.getCacheTransfer().getHash());
        cancelledHash.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ActivityMan.openAndroidBrowserUrl(getActivity(), sitesHash[0] + Store.getCacheTransfer().getHash());
            }
        });
        copyClip.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Transfer transfer = Store.getCacheTransfer();
                if (transfer != null) {
                    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                    StringBuilder sb = new StringBuilder();
                    sb.append("IOTA Transfer\n\n");
                    sb.append("time: " + Cal.getCal(transfer.getTimestamp()).getDatabaseDate());
                    sb.append("\nhash: " + transfer.getHash());
                    sb.append("\n\nTotal: " + transfer.getValue());
                    sb.append("\nStatus: " + (transfer.isCompleted() ? "Completed" : "Pending"));
                    sb.append("\nmilestone: " + transfer.getMilestone());
                    sb.append("\n\nAddress actions\n");
                    for (TransferTransaction tran : transfer.getTransactions()) {
                        sb.append(tran.getValue());
                        sb.append("    ");
                        sb.append(tran.getAddress());
                    }
                    for (TransferTransaction tran : transfer.getOtherTransactions()) {
                        sb.append(tran.getValue());
                        sb.append("    ");
                        sb.append(tran.getAddress());
                    }
                    sb.append("\n\nUsing run IOTA wallet, Android app http://iota.runplay.com");
                    ClipData clip = ClipData.newPlainText(getActivity().getString(R.string.seed), sb.toString());
                    clipboard.setPrimaryClip(clip);
                    Snackbar.make(getView(), getString(R.string.text_cancelled_copied), Snackbar.LENGTH_SHORT).show();
                }
            }
        });
        cancelledSites.setText(" " + sitesName[0]);
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) ArrayList(java.util.ArrayList) Transfer(run.wallet.iota.model.Transfer) TransferViewManager(run.wallet.iota.ui.TransferViewManager) TransferTransaction(run.wallet.iota.model.TransferTransaction) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ClipData(android.content.ClipData)

Aggregations

ClipData (android.content.ClipData)343 ClipboardManager (android.content.ClipboardManager)190 Intent (android.content.Intent)83 Uri (android.net.Uri)65 View (android.view.View)38 MenuItem (android.view.MenuItem)34 TextView (android.widget.TextView)34 ArrayList (java.util.ArrayList)29 Paint (android.graphics.Paint)24 ImageView (android.widget.ImageView)20 Context (android.content.Context)19 DialogInterface (android.content.DialogInterface)19 PendingIntent (android.app.PendingIntent)16 Bundle (android.os.Bundle)16 RemoteException (android.os.RemoteException)14 SpannableStringBuilder (android.text.SpannableStringBuilder)14 SuppressLint (android.annotation.SuppressLint)12 TargetApi (android.annotation.TargetApi)12 Drawable (android.graphics.drawable.Drawable)11 RecyclerView (android.support.v7.widget.RecyclerView)11