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;
}
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);
}
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;
}
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);
}
}
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);
}
Aggregations