Skip to content

Commit

Permalink
Ensure thread-safety of right-click menu and download log
Browse files Browse the repository at this point in the history
Move collections from util to util.collection
Assorted bug fixes
  • Loading branch information
hstr0100 committed Nov 20, 2024
1 parent 919f95b commit f651cdd
Show file tree
Hide file tree
Showing 21 changed files with 497 additions and 211 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
exports net.brlns.gdownloader.ui.themes;
exports net.brlns.gdownloader.updater;
exports net.brlns.gdownloader.util;
exports net.brlns.gdownloader.util.collection;

uses javax.imageio.spi.ImageInputStreamSpi;
uses javax.imageio.spi.ImageOutputStreamSpi;
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/net/brlns/gdownloader/GDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
// TODO Tabs in settings for the different downloaders
// TODO Crawl for valid links that can be consumed by direct-http
// TODO Toolbar button to toggle different downloaders
// TODO Two column layout when in full screen
/**
* GDownloader - GUI wrapper for yt-dlp
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,41 +104,33 @@ public void tickClipboard() {
}
}

public void copyTextToClipboard(@NonNull String text) {
copyTextToClipboard(List.of(text));
}

public void copyTextToClipboard(@NonNull List<String> texts) {
if (texts.isEmpty()) {
return;
}

invalidateClipboard();
clipboardLock.lock();
try {
clipboard.setContents(new StringSelection(String.join(System.lineSeparator(), texts)), null);

clipboard.setContents(new StringSelection(String.join(System.lineSeparator(), texts)), null);
invalidateClipboard();

String lastText = texts.get(texts.size() - 1);
main.getGuiManager().showMessage(
l10n("gui.copied_to_clipboard.notification_title"),
lastText,
2000,
GUIManager.MessageType.INFO,
false
);
}
String displayText = texts.size() == 1 ? texts.get(texts.size() - 1)
: l10n("gui.copied_to_clipboard.lines", texts.size());

public void copyTextToClipboard(@NonNull String text) {
if (text.isEmpty()) {
return;
main.getGuiManager().showMessage(
l10n("gui.copied_to_clipboard.notification_title"),
displayText,
2000,
GUIManager.MessageType.INFO,
false);
} finally {
clipboardLock.unlock();
}

invalidateClipboard();

clipboard.setContents(new StringSelection(text), null);

main.getGuiManager().showMessage(
l10n("gui.copied_to_clipboard.notification_title"),
text,
2000,
GUIManager.MessageType.INFO,
false
);
}

public boolean tryHandleDnD(@Nullable Transferable transferable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public boolean isMainDownloader() {

@Override
protected boolean canConsumeUrl(String inputUrl) {
return !(inputUrl.contains("ytimg")
return main.getConfig().isDirectHttpEnabled()
&& !(inputUrl.contains("ytimg")
|| inputUrl.contains("ggpht")
|| inputUrl.endsWith("youtube.com/"));
}
Expand Down
Loading

0 comments on commit f651cdd

Please sign in to comment.