private void checkLastSeenVersion() { final String lastSeenVersion = ConfigurationManager.instance().getString(Constants.PREF_KEY_CORE_LAST_SEEN_VERSION); if (StringUtils.isNullOrEmpty(lastSeenVersion)) { // fresh install ConfigurationManager.instance() .setString(Constants.PREF_KEY_CORE_LAST_SEEN_VERSION, Constants.FROSTWIRE_VERSION_STRING); UXStats.instance().log(UXAction.CONFIGURATION_WIZARD_FIRST_TIME); } else if (!Constants.FROSTWIRE_VERSION_STRING.equals(lastSeenVersion)) { // just updated. ConfigurationManager.instance() .setString(Constants.PREF_KEY_CORE_LAST_SEEN_VERSION, Constants.FROSTWIRE_VERSION_STRING); UXStats.instance().log(UXAction.CONFIGURATION_WIZARD_AFTER_UPDATE); } }
public void performAction(ActionEvent e) { BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders(); for (int i = 0; i < downloaders.length; i++) { downloaders[i].pause(); } UXStats.instance().log(UXAction.DOWNLOAD_PAUSE); }
public void handleActionKey() { LibraryFilesTableDataLine line = DATA_MODEL.get(TABLE.getSelectedRow()); if (line == null || line.getFile() == null) { return; } if (getMediaType().equals(MediaType.getAudioMediaType()) && MediaPlayer.isPlayableFile(line.getFile())) { MediaPlayer.instance() .asyncLoadMedia(new MediaSource(line.getFile()), true, false, true, null, getFilesView()); UXStats.instance().log(UXAction.LIBRARY_PLAY_AUDIO_FROM_FILE); return; } int[] rows = TABLE.getSelectedRows(); // LibraryTableModel ltm = DATA_MODEL; // File file; for (int i = 0; i < rows.length; i++) { // file = ltm.getFile(rows[i]); // if it's a directory try to select it in the library tree // if it could be selected return // if (file.isDirectory() // && LibraryMediator.setSelectedDirectory(file)) // return; } launch(true); }
private void labelPartialDownload_mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (searchResult.getSearchResult() instanceof CrawlableSearchResult) { searchResult.download(true); UXStats.instance().log(UXAction.SEARCH_RESULT_DETAIL_VIEW); } } }
private void uxLogMediaPreview() { MediaType mediaType = MediaType.getMediaTypeForExtension(searchResult.getExtension()); if (mediaType != null) { boolean isVideo = mediaType.equals(MediaType.getVideoMediaType()); UXStats.instance() .log( isVideo ? UXAction.SEARCH_RESULT_VIDEO_PREVIEW : UXAction.SEARCH_RESULT_AUDIO_PREVIEW); } }
private void uxLogSelection() { try { File file = new File(selectedPath); boolean isInternalMemory = SystemUtils.isPrimaryExternalPath(file); UXStats.instance() .log( isInternalMemory ? UXAction.SETTINGS_SET_STORAGE_INTERNAL_MEMORY : UXAction.SETTINGS_SET_STORAGE_SD_CARD); } catch (Throwable t) { // we tried. } }
/** * Updates the Table based on the selection of the given table. Perform lookups to remove any * store files from the shared folder view and to only display store files in the store view */ void updateTableFiles(DirectoryHolder dirHolder) { if (dirHolder == null) { return; } if (dirHolder instanceof MediaTypeSavedFilesDirectoryHolder) { MediaType mediaType = ((MediaTypeSavedFilesDirectoryHolder) dirHolder).getMediaType(); setMediaType(mediaType); if (mediaType.equals(MediaType.getAudioMediaType())) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_AUDIO); } else if (mediaType == MediaType.getImageMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_PICTURES); } else if (mediaType == MediaType.getDocumentMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_DOCUMENTS); } else if (mediaType == MediaType.getVideoMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_VIDEOS); } else if (mediaType == MediaType.getTorrentMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_TORRENTS); } else if (mediaType == MediaType.getProgramMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_APPLICATIONS); } } else { setMediaType(MediaType.getAnyTypeMediaType()); } clearTable(); List<List<File>> partitionedFiles = split(100, Arrays.asList(dirHolder.getFiles())); for (List<File> partition : partitionedFiles) { final List<File> fPartition = partition; BackgroundExecutorService.schedule( new Runnable() { @Override public void run() { for (final File file : fPartition) { GUIMediator.safeInvokeLater( new Runnable() { public void run() { addUnsorted(file); } }); } GUIMediator.safeInvokeLater( new Runnable() { public void run() { LibraryMediator.instance().getLibrarySearch().addResults(fPartition.size()); } }); } }); } forceResort(); }
/** Launches the associated applications for each selected file in the library if it can. */ void launch(boolean playAudio) { int[] rows = TABLE.getSelectedRows(); if (rows.length == 0) { return; } File selectedFile = DATA_MODEL.getFile(rows[0]); if (OSUtils.isWindows()) { if (selectedFile.isDirectory()) { GUIMediator.launchExplorer(selectedFile); return; } else if (!MediaPlayer.isPlayableFile(selectedFile)) { String extension = FilenameUtils.getExtension(selectedFile.getName()); if (extension != null && extension.equals("torrent")) { GUIMediator.instance().openTorrentFile(selectedFile, true); } else { GUIMediator.launchFile(selectedFile); } return; } } LaunchableProvider[] providers = new LaunchableProvider[rows.length]; boolean stopAudio = false; for (int i = 0; i < rows.length; i++) { try { MediaType mt = MediaType.getMediaTypeForExtension( FilenameUtils.getExtension(DATA_MODEL.getFile(rows[i]).getName())); if (mt.equals(MediaType.getVideoMediaType())) { stopAudio = true; } } catch (Throwable e) { // ignore } providers[i] = new FileProvider(DATA_MODEL.getFile(rows[i])); } if (stopAudio || !playAudio) { MediaPlayer.instance().stop(); } if (playAudio) { GUILauncher.launch(providers); UXStats.instance() .log(stopAudio ? UXAction.LIBRARY_VIDEO_PLAY : UXAction.LIBRARY_PLAY_AUDIO_FROM_FILE); } else { GUIMediator.launchFile(selectedFile); } }
@Override public void download(boolean partial) { if (sr instanceof TorrentCrawledSearchResult) { GUIMediator.instance() .openTorrentSearchResult(sr, ((TorrentCrawledSearchResult) sr).getRelativePath()); } else { GUIMediator.instance().openTorrentSearchResult(sr, partial); } showDetails(false); UXStats.instance() .log( (sr instanceof TorrentCrawledSearchResult) ? UXAction.DOWNLOAD_PARTIAL_TORRENT_FILE : UXAction.DOWNLOAD_FULL_TORRENT_FILE); }
@Override protected void onClick(Context context) { if (Ref.alive(poRef)) { PaymentOptions po = poRef.get(); if (po.paypalUrl == null) { return; } try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(po.paypalUrl)); context.startActivity(intent); } catch (Throwable e) { UIUtils.showLongMessage(getContext(), R.string.issue_with_tip_donation_uri); } } UXStats.instance().log(UXAction.DOWNLOAD_CLICK_PAYPAL_PAYMENT); }
public void performAction(ActionEvent e) { if (_deleteData) { DialogOption result = GUIMediator.showYesNoMessage( I18n.tr( "Are you sure you want to remove the data files from your computer?\n\nYou won't be able to recover the files."), I18n.tr("Are you sure?"), JOptionPane.QUESTION_MESSAGE); if (result != DialogOption.YES) return; } BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders(); for (int i = 0; i < downloaders.length; i++) { downloaders[i].setDeleteTorrentWhenRemove(_deleteTorrent); downloaders[i].setDeleteDataWhenRemove(_deleteData); } BTDownloadMediator.instance().removeSelection(); UXStats.instance().log(UXAction.DOWNLOAD_REMOVE); }
public void performAction(ActionEvent e) { boolean oneIsCompleted = false; BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders(); for (int i = 0; i < downloaders.length; i++) { if (downloaders[i].isCompleted()) { oneIsCompleted = true; break; } } boolean allowedToResume = true; DialogOption answer = null; if (oneIsCompleted && !SharingSettings.SEED_FINISHED_TORRENTS.getValue()) { String message1 = (downloaders.length > 1) ? I18n.tr( "One of the transfers is complete and resuming will cause it to start seeding") : I18n.tr( "This transfer is already complete, resuming it will cause it to start seeding"); String message2 = I18n.tr("Do you want to enable torrent seeding?"); answer = GUIMediator.showYesNoMessage(message1 + "\n\n" + message2, DialogOption.YES); allowedToResume = answer.equals(DialogOption.YES); if (allowedToResume) { SharingSettings.SEED_FINISHED_TORRENTS.setValue(true); } } if (allowedToResume) { for (int i = 0; i < downloaders.length; i++) { downloaders[i].resume(); } } UXStats.instance().log(UXAction.DOWNLOAD_RESUME); }
@Override protected void onNewIntent(Intent intent) { if (isShutdown(intent)) { return; } String action = intent.getAction(); // onResumeFragments(); if (action != null && action.equals(Constants.ACTION_SHOW_TRANSFERS)) { controller.showTransfers(TransferStatus.ALL); } else if (action != null && action.equals(Constants.ACTION_OPEN_TORRENT_URL)) { // Open a Torrent from a URL or from a local file :), say from Astro File Manager. /** * TODO: Ask @aldenml the best way to plug in NewTransferDialog. I've refactored this dialog * so that it is forced (no matter if the setting to not show it again has been used) and when * that happens the checkbox is hidden. * * <p>However that dialog requires some data about the download, data which is not obtained * until we have instantiated the Torrent object. * * <p>I'm thinking that we can either: a) Pass a parameter to the transfer manager, but this * would probably not be cool since the transfer manager (I think) should work independently * from the UI thread. * * <p>b) Pass a "listener" to the transfer manager, once the transfer manager has the torrent * it can notify us and wait for the user to decide whether or not to continue with the * transfer * * <p>c) Forget about showing that dialog, and just start the download, the user can cancel * it. */ // Show me the transfer tab Intent i = new Intent(this, MainActivity.class); i.setAction(Constants.ACTION_SHOW_TRANSFERS); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(i); // go! final String uri = intent.getDataString(); if (uri != null) { TransferManager.instance().downloadTorrent(uri); } else { LOG.warn( "MainActivity.onNewIntent(): Couldn't start torrent download from Intent's URI, intent.getDataString() -> null"); LOG.warn("(maybe URI is coming in another property of the intent object - #fragmentation)"); } } // When another application wants to "Share" a file and has chosen FrostWire to do so. // We make the file "Shared" so it's visible for other FrostWire devices on the local network. else if (action != null && (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE))) { controller.handleSendAction(intent); intent.setAction(null); } else if (action != null && action.equals(Constants.ACTION_START_TRANSFER_FROM_PREVIEW)) { if (Ref.alive(NewTransferDialog.srRef)) { SearchFragment.startDownload( this, NewTransferDialog.srRef.get(), getString(R.string.download_added_to_queue)); UXStats.instance().log(UXAction.DOWNLOAD_CLOUD_FILE_FROM_PREVIEW); } } if (intent.hasExtra(Constants.EXTRA_DOWNLOAD_COMPLETE_NOTIFICATION)) { controller.showTransfers(TransferStatus.COMPLETED); TransferManager.instance().clearDownloadsToReview(); try { ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .cancel(Constants.NOTIFICATION_DOWNLOAD_TRANSFER_FINISHED); Bundle extras = intent.getExtras(); if (extras.containsKey(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH)) { File file = new File(extras.getString(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH)); if (file.isFile()) { UIUtils.openFile(this, file.getAbsoluteFile()); } } } catch (Throwable e) { LOG.warn("Error handling download complete notification", e); } } }
private void labelDownload_mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { searchResult.download(false); UXStats.instance().log(UXAction.SEARCH_RESULT_ROW_BUTTON_DOWNLOAD); } }