Search in sources :

Example 1 with PaymentOptions

use of com.frostwire.bittorrent.PaymentOptions in project frostwire by frostwire.

the class TransferListAdapter method populateBittorrentDownloadMenuActions.

private String populateBittorrentDownloadMenuActions(BittorrentDownload bittorrentDownload, List<MenuAction> items) {
    String title;
    title = bittorrentDownload.getDisplayName();
    // If it's a torrent download with a single file, we should be able to open it.
    if (bittorrentDownload.isComplete() && bittorrentDownload.getItems().size() > 0) {
        TransferItem transferItem = bittorrentDownload.getItems().get(0);
        String path = transferItem.getFile().getAbsolutePath();
        String mimeType = UIUtils.getMimeType(path);
        items.add(new OpenMenuAction(contextRef.get(), path, mimeType));
    }
    if (!bittorrentDownload.isComplete() && !bittorrentDownload.isSeeding()) {
        if (!bittorrentDownload.isPaused()) {
            items.add(new PauseDownloadMenuAction(contextRef.get(), bittorrentDownload));
        } else {
            boolean wifiIsUp = NetworkManager.instance().isDataWIFIUp();
            boolean bittorrentOnMobileData = !ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_NETWORK_USE_WIFI_ONLY);
            if (wifiIsUp || bittorrentOnMobileData) {
                if (!bittorrentDownload.isComplete()) {
                    items.add(new ResumeDownloadMenuAction(contextRef.get(), bittorrentDownload, R.string.resume_torrent_menu_action));
                }
            }
        }
    }
    if (bittorrentDownload.getState() == TransferState.FINISHED) {
        items.add(new SeedAction(contextRef.get(), bittorrentDownload));
    }
    if (bittorrentDownload.getState() == TransferState.SEEDING) {
        items.add(new StopSeedingAction(contextRef.get(), bittorrentDownload));
    }
    items.add(new CancelMenuAction(contextRef.get(), bittorrentDownload, !bittorrentDownload.isComplete()));
    items.add(new CopyToClipboardMenuAction(contextRef.get(), R.drawable.contextmenu_icon_magnet, R.string.transfers_context_menu_copy_magnet, R.string.transfers_context_menu_copy_magnet_copied, bittorrentDownload.magnetUri() + BTEngine.getInstance().magnetPeers()));
    items.add(new CopyToClipboardMenuAction(contextRef.get(), R.drawable.contextmenu_icon_copy, R.string.transfers_context_menu_copy_infohash, R.string.transfers_context_menu_copy_infohash_copied, bittorrentDownload.getInfoHash()));
    if (bittorrentDownload.isComplete()) {
        // Remove Torrent and Data action.
        items.add(new CancelMenuAction(contextRef.get(), bittorrentDownload, true, true));
    }
    if (bittorrentDownload instanceof UIBittorrentDownload) {
        UIBittorrentDownload uidl = (UIBittorrentDownload) bittorrentDownload;
        if (uidl.hasPaymentOptions()) {
            PaymentOptions po = uidl.getPaymentOptions();
            if (po.bitcoin != null) {
                items.add(new SendBitcoinTipAction(contextRef.get(), po.bitcoin));
            }
            if (po.paypalUrl != null) {
                items.add(new SendFiatTipAction(contextRef.get(), po.paypalUrl));
            }
            if (po.bitcoin != null) {
                items.add(new SendBitcoinTipAction(contextRef.get(), po.bitcoin));
            }
        }
        if (bittorrentDownload.getInfoHash() != null && !"".equals(bittorrentDownload.getInfoHash())) {
            items.add(new TransferDetailsMenuAction(contextRef.get(), R.string.show_torrent_details, bittorrentDownload.getInfoHash()));
        }
    }
    return title;
}
Also used : CopyToClipboardMenuAction(com.frostwire.android.gui.adapters.menu.CopyToClipboardMenuAction) UIBittorrentDownload(com.frostwire.android.gui.transfers.UIBittorrentDownload) PaymentOptions(com.frostwire.bittorrent.PaymentOptions) SeedAction(com.frostwire.android.gui.adapters.menu.SeedAction) CancelMenuAction(com.frostwire.android.gui.adapters.menu.CancelMenuAction) TransferDetailsMenuAction(com.frostwire.android.gui.adapters.menu.TransferDetailsMenuAction) SendFiatTipAction(com.frostwire.android.gui.adapters.menu.SendFiatTipAction) OpenMenuAction(com.frostwire.android.gui.adapters.menu.OpenMenuAction) PauseDownloadMenuAction(com.frostwire.android.gui.adapters.menu.PauseDownloadMenuAction) SendBitcoinTipAction(com.frostwire.android.gui.adapters.menu.SendBitcoinTipAction) ResumeDownloadMenuAction(com.frostwire.android.gui.adapters.menu.ResumeDownloadMenuAction) TransferItem(com.frostwire.transfers.TransferItem) StopSeedingAction(com.frostwire.android.gui.adapters.menu.StopSeedingAction)

Example 2 with PaymentOptions

use of com.frostwire.bittorrent.PaymentOptions in project frostwire by frostwire.

the class TransferDetailFragment method onPrepareOptionsMenu.

@Override
public void onPrepareOptionsMenu(Menu menu) {
    if (uiBittorrentDownload == null) {
        return;
    }
    updatePauseResumeSeedMenuAction();
    MenuItem fiatMenuItem = menu.findItem(R.id.fragment_transfer_detail_menu_donate_fiat);
    MenuItem bitcoinMenuItem = menu.findItem(R.id.fragment_transfer_detail_menu_donate_bitcoin);
    if (!uiBittorrentDownload.hasPaymentOptions()) {
        fiatMenuItem.setVisible(false);
        bitcoinMenuItem.setVisible(false);
    } else {
        PaymentOptions po = uiBittorrentDownload.getPaymentOptions();
        fiatMenuItem.setVisible(po.paypalUrl != null);
        bitcoinMenuItem.setVisible(po.bitcoin != null);
    }
    super.onPrepareOptionsMenu(menu);
}
Also used : MenuItem(android.view.MenuItem) PaymentOptions(com.frostwire.bittorrent.PaymentOptions)

Example 3 with PaymentOptions

use of com.frostwire.bittorrent.PaymentOptions in project frostwire by frostwire.

the class PaymentOptionsPanel method getPaymentOptions.

public PaymentOptions getPaymentOptions() {
    PaymentOptions result = null;
    if (confirmationCheckbox.isSelected()) {
        boolean validBitcoin = bitcoinAddress.hasValidAddress();
        if (validBitcoin || (paypalUrlAddress.getText() != null && !paypalUrlAddress.getText().isEmpty())) {
            final String bitcoin = validBitcoin ? bitcoinAddress.normalizeValidAddress() : null;
            final String paypal = (paypalUrlAddress != null && paypalUrlAddress.getText() != null && !paypalUrlAddress.getText().isEmpty()) ? paypalUrlAddress.getText() : null;
            result = new PaymentOptions(bitcoin, paypal);
        }
    }
    return result;
}
Also used : PaymentOptions(com.frostwire.bittorrent.PaymentOptions)

Example 4 with PaymentOptions

use of com.frostwire.bittorrent.PaymentOptions in project frostwire by frostwire.

the class LibraryFilesTableDataLine method initialize.

/**
 * Initialize the object.
 * It will fail if not given a FileDesc or a File
 * (File is retained for compatibility with the Incomplete folder)
 */
public void initialize(File file) {
    super.initialize(file);
    String fullPath = file.getPath();
    try {
        fullPath = file.getCanonicalPath();
    } catch (IOException ignored) {
    }
    String _name = initializer.getName();
    _type = "";
    if (!file.isDirectory()) {
        // _isDirectory = false;
        int index = _name.lastIndexOf(".");
        int index2 = fullPath.lastIndexOf(File.separator);
        _path = fullPath.substring(0, index2);
        if (index != -1 && index != 0) {
            _type = _name.substring(index + 1);
            _name = _name.substring(0, index);
        }
    } else {
        _path = fullPath;
    // _isDirectory = true;
    }
    // directories implicitly set SizeHolder to null and display nothing
    if (initializer.isFile()) {
        long _size = initializer.length();
        _sizeHolder = new SizeHolder(_size);
    } else {
        _sizeHolder = ZERO_SIZED_HOLDER;
    }
    this.lastModified = new Date(initializer.lastModified());
    this.actionsHolder = new LibraryActionsHolder(this, false);
    this.nameCell = new NameHolder(_name);
    if (initializer != null && initializer.isFile() && FilenameUtils.getExtension(initializer.getName()) != null && FilenameUtils.getExtension(initializer.getName()).toLowerCase().endsWith("torrent")) {
        BTInfoAdditionalMetadataHolder additionalMetadataHolder = null;
        try {
            additionalMetadataHolder = new BTInfoAdditionalMetadataHolder(initializer, initializer.getName());
        } catch (Throwable t) {
            System.err.println("[InvalidTorrent] Can't create BTInfoAdditionalMetadataholder out of " + initializer.getAbsolutePath());
            t.printStackTrace();
        }
        boolean hasLicense = additionalMetadataHolder != null && additionalMetadataHolder.getLicenseBroker() != null;
        boolean hasPaymentOptions = additionalMetadataHolder != null && additionalMetadataHolder.getPaymentOptions() != null;
        if (hasLicense) {
            license = additionalMetadataHolder.getLicenseBroker().getLicenseName();
        }
        if (license == null) {
            license = "";
        }
        if (hasPaymentOptions) {
            paymentOptions = additionalMetadataHolder.getPaymentOptions();
        } else {
            paymentOptions = new PaymentOptions(null, null);
        }
        paymentOptions.setItemName(_name);
    }
}
Also used : NameHolder(com.limegroup.gnutella.gui.tables.NameHolder) BTInfoAdditionalMetadataHolder(com.frostwire.bittorrent.BTInfoAdditionalMetadataHolder) IOException(java.io.IOException) SizeHolder(com.limegroup.gnutella.gui.tables.SizeHolder) PaymentOptions(com.frostwire.bittorrent.PaymentOptions) Date(java.util.Date)

Example 5 with PaymentOptions

use of com.frostwire.bittorrent.PaymentOptions in project frostwire by frostwire.

the class TransferDetailFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Activity activity = getActivity();
    int itemId = item.getItemId();
    PaymentOptions paymentOptions = uiBittorrentDownload.getPaymentOptions();
    switch(itemId) {
        // TODO: Add a force re-announce action
        case R.id.fragment_transfer_detail_menu_delete:
            // TODO: add an action listener and pass to dialog
            new CancelMenuAction(activity, uiBittorrentDownload, true, true).onClick(activity);
            break;
        case R.id.fragment_transfer_detail_menu_pause_resume_seed:
            if (isPausable()) {
                new PauseDownloadMenuAction(activity, uiBittorrentDownload).onClick(activity);
            } else if (isSeedable()) {
                new SeedAction(activity, uiBittorrentDownload).onClick(activity);
            } else if (isResumable()) {
                new ResumeDownloadMenuAction(activity, uiBittorrentDownload, R.string.resume_torrent_menu_action).onClick(activity);
            }
            updatePauseResumeSeedMenuAction();
            break;
        case R.id.fragment_transfer_detail_menu_clear:
            new CancelMenuAction(activity, uiBittorrentDownload, false, false).onClick(activity);
            break;
        case R.id.fragment_transfer_detail_menu_copy_magnet:
            new CopyToClipboardMenuAction(activity, R.drawable.contextmenu_icon_magnet, R.string.transfers_context_menu_copy_magnet, R.string.transfers_context_menu_copy_magnet_copied, uiBittorrentDownload.magnetUri() + BTEngine.getInstance().magnetPeers()).onClick(activity);
            break;
        case R.id.fragment_transfer_detail_menu_copy_infohash:
            new CopyToClipboardMenuAction(activity, R.drawable.contextmenu_icon_copy, R.string.transfers_context_menu_copy_infohash, R.string.transfers_context_menu_copy_infohash_copied, uiBittorrentDownload.getInfoHash()).onClick(activity);
            break;
        case R.id.fragment_transfer_detail_menu_donate_fiat:
            new SendFiatTipAction(activity, paymentOptions.paypalUrl).onClick(activity);
            break;
        case R.id.fragment_transfer_detail_menu_donate_bitcoin:
            new SendBitcoinTipAction(activity, paymentOptions.bitcoin).onClick(activity);
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : CancelMenuAction(com.frostwire.android.gui.adapters.menu.CancelMenuAction) CopyToClipboardMenuAction(com.frostwire.android.gui.adapters.menu.CopyToClipboardMenuAction) SendFiatTipAction(com.frostwire.android.gui.adapters.menu.SendFiatTipAction) Activity(android.app.Activity) PauseDownloadMenuAction(com.frostwire.android.gui.adapters.menu.PauseDownloadMenuAction) SendBitcoinTipAction(com.frostwire.android.gui.adapters.menu.SendBitcoinTipAction) PaymentOptions(com.frostwire.bittorrent.PaymentOptions) ResumeDownloadMenuAction(com.frostwire.android.gui.adapters.menu.ResumeDownloadMenuAction) SeedAction(com.frostwire.android.gui.adapters.menu.SeedAction)

Aggregations

PaymentOptions (com.frostwire.bittorrent.PaymentOptions)6 CancelMenuAction (com.frostwire.android.gui.adapters.menu.CancelMenuAction)2 CopyToClipboardMenuAction (com.frostwire.android.gui.adapters.menu.CopyToClipboardMenuAction)2 PauseDownloadMenuAction (com.frostwire.android.gui.adapters.menu.PauseDownloadMenuAction)2 ResumeDownloadMenuAction (com.frostwire.android.gui.adapters.menu.ResumeDownloadMenuAction)2 SeedAction (com.frostwire.android.gui.adapters.menu.SeedAction)2 SendBitcoinTipAction (com.frostwire.android.gui.adapters.menu.SendBitcoinTipAction)2 SendFiatTipAction (com.frostwire.android.gui.adapters.menu.SendFiatTipAction)2 Activity (android.app.Activity)1 MenuItem (android.view.MenuItem)1 OpenMenuAction (com.frostwire.android.gui.adapters.menu.OpenMenuAction)1 StopSeedingAction (com.frostwire.android.gui.adapters.menu.StopSeedingAction)1 TransferDetailsMenuAction (com.frostwire.android.gui.adapters.menu.TransferDetailsMenuAction)1 UIBittorrentDownload (com.frostwire.android.gui.transfers.UIBittorrentDownload)1 BTInfoAdditionalMetadataHolder (com.frostwire.bittorrent.BTInfoAdditionalMetadataHolder)1 Entry (com.frostwire.jlibtorrent.Entry)1 TransferItem (com.frostwire.transfers.TransferItem)1 NameHolder (com.limegroup.gnutella.gui.tables.NameHolder)1 SizeHolder (com.limegroup.gnutella.gui.tables.SizeHolder)1 IOException (java.io.IOException)1