Skip to content

Commit

Permalink
- make default download continuation time user-configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Aug 11, 2024
1 parent 403e055 commit e422ffc
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- **FEATURE:** Die Filter werden nun über einen eigenen Button umbenannt und nicht mehr durch Eingabe in der ComboBox.
- **FEATURE:** Bei der Lucene-Suche dürfen Wildcards nun auch am Anfang des Suchtexts verwendet werden.
- **FEATURE:** Die Datenbank der gesehenen Filme kann nun über das Menü *"Hilfe/Hilfsmittel/History-Datenbank optimieren..."* von eventuell vorhandenen Duplikaten befreit werden. Dies kann die Performance des Programms bei einer großen (und älteren) Datenbank positiv beeinflussen.
- **FEATURE:** Der Default-Wert zum automatischen Weiterführen von Downloads kann nun in den Einstellungen unter "Download" angepasst werden (Wertebereich 1-60).
- Network Timeout wurde auf 10 Sekunden erhöht. Dies sollte bei schlechten Netzwerkverbindungen etwas Abhilfe schaffen.


Expand Down
5 changes: 4 additions & 1 deletion src/main/java/mediathek/config/Konstanten.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public class Konstanten {

public static final byte MAX_DOWNLOAD_RESTARTS = 2;
public static final byte MAX_EXTERNAL_STARTS = 3;
public static final byte CONTINUE_DOWNLOAD = 60; //seconds
/**
* Default time for automatic continuation of existing downloads.
*/
public static final byte DOWNLOAD_CONTINUATION_DEFAULT_TIME = 60; //seconds
public static final byte DOWNLOAD_ERROR_DISPLAY_DURATION = 60;

// MediathekView URLs
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/mediathek/gui/dialog/DialogContinueDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import mediathek.config.Konstanten;
import mediathek.daten.DatenDownload;
import mediathek.tool.ApplicationConfiguration;
import mediathek.tool.EscapeKeyHandler;
import mediathek.tool.MVMessageDialog;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.concurrent.TimeUnit;

public class DialogContinueDownload extends JDialog {
public enum DownloadResult {
Expand Down Expand Up @@ -133,24 +135,31 @@ private void beenden() {
*/
private class CountdownAction implements ActionListener {

private int w = Konstanten.CONTINUE_DOWNLOAD;
private int countdown;

public CountdownAction() {
countdown = ApplicationConfiguration.getConfiguration().getInt(ApplicationConfiguration.DOWNLOAD_CONTINUATION_TIME, Konstanten.DOWNLOAD_CONTINUATION_DEFAULT_TIME);
}

@Override
public void actionPerformed(ActionEvent e) {
if (w > 0) {
String msg;
if (countdown > 0) {
if (!direkterDownload) {
jButtonWeiter.setText("Überschreiben in " + w + 's');
msg = String.format("Überschreiben in %ds", countdown);
} else {
jButtonWeiter.setText("Weiterführen in " + w + 's');
msg = String.format("Weiterführen in %ds", countdown);
}
jButtonWeiter.setText(msg);

if (countdownTimer != null) {
countdownTimer.setDelay(1000);
countdownTimer.setDelay((int) TimeUnit.MILLISECONDS.convert(1, TimeUnit.SECONDS));
}
} else {
result = DownloadResult.CONTINUE;
beenden();
}
w--;
countdown--;
}
}

Expand Down
30 changes: 30 additions & 0 deletions src/main/java/mediathek/gui/dialogEinstellungen/PanelDownload.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mediathek.gui.dialogEinstellungen;

import mediathek.config.Konstanten;
import mediathek.config.MVConfig;
import mediathek.tool.ApplicationConfiguration;
import net.miginfocom.layout.AC;
Expand All @@ -26,6 +27,16 @@ public PanelDownload() {
cbFetchMissingFileSize.addActionListener(l -> config.setProperty(ApplicationConfiguration.DOWNLOAD_FETCH_FILE_SIZE, cbFetchMissingFileSize.isSelected()));

jButtonBeep.addActionListener(ae -> Toolkit.getDefaultToolkit().beep());

var countdown = ApplicationConfiguration.getConfiguration().getInt(ApplicationConfiguration.DOWNLOAD_CONTINUATION_TIME, Konstanten.DOWNLOAD_CONTINUATION_DEFAULT_TIME);
if (countdown < 1 || countdown > Konstanten.DOWNLOAD_CONTINUATION_DEFAULT_TIME) {
countdown = Konstanten.DOWNLOAD_CONTINUATION_DEFAULT_TIME;
}
spDefaultDownloadContinuation.setValue(countdown);
spDefaultDownloadContinuation.addChangeListener(e -> {
int val = (int)spDefaultDownloadContinuation.getValue();
config.setProperty(ApplicationConfiguration.DOWNLOAD_CONTINUATION_TIME, val);
});
}

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
Expand All @@ -36,6 +47,9 @@ private void initComponents() {
jCheckBoxBeep = new JCheckBox();
jButtonBeep = new JButton();
cbFetchMissingFileSize = new JCheckBox();
var panel1 = new JPanel();
var label1 = new JLabel();
spDefaultDownloadContinuation = new JSpinner();

//======== this ========
setLayout(new BorderLayout());
Expand All @@ -52,6 +66,7 @@ private void initComponents() {
new AC()
.fill().gap()
.fill().gap()
.gap()
));

//---- cbkDownloadError ----
Expand All @@ -69,6 +84,20 @@ private void initComponents() {
//---- cbFetchMissingFileSize ----
cbFetchMissingFileSize.setText("Fehlende Filmgr\u00f6\u00dfe nachladen"); //NON-NLS
jPanel2.add(cbFetchMissingFileSize, new CC().cell(0, 2));

//======== panel1 ========
{
panel1.setLayout(new FlowLayout(FlowLayout.LEFT));

//---- label1 ----
label1.setText("Standard-Wert f\u00fcr automatische Weiterf\u00fchrung:"); //NON-NLS
panel1.add(label1);

//---- spDefaultDownloadContinuation ----
spDefaultDownloadContinuation.setModel(new SpinnerNumberModel(1, 1, 60, 1));
panel1.add(spDefaultDownloadContinuation);
}
jPanel2.add(panel1, new CC().cell(0, 3, 2, 1));
}
add(jPanel2, BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
Expand All @@ -80,5 +109,6 @@ private void initComponents() {
private JCheckBox jCheckBoxBeep;
private JButton jButtonBeep;
private JCheckBox cbFetchMissingFileSize;
private JSpinner spDefaultDownloadContinuation;
// End of variables declaration//GEN-END:variables
}
28 changes: 26 additions & 2 deletions src/main/java/mediathek/gui/dialogEinstellungen/PanelDownload.jfd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JFDML JFormDesigner: "8.1.1.0.298" Java: "17.0.8.1" encoding: "UTF-8"
JFDML JFormDesigner: "8.2.4.0.393" Java: "21.0.3" encoding: "UTF-8"

new FormModel {
contentType: "form/swing"
Expand All @@ -8,7 +8,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 5,hidemode 3,gap 5 5"
"$columnConstraints": "[left][fill]"
"$rowConstraints": "[fill][fill][]"
"$rowConstraints": "[fill][fill][][]"
} ) {
name: "jPanel2"
auxiliary() {
Expand Down Expand Up @@ -38,6 +38,30 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) {
"alignment": 0
} ) {
name: "panel1"
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "Standard-Wert für automatische Weiterführung:"
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner1"
"model": new javax.swing.SpinnerNumberModel( 1, 1, 60, 1 )
auxiliary() {
"JavaCodeGenerator.variableName": "spDefaultDownloadContinuation"
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3 2 1"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mediathek/tool/ApplicationConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class ApplicationConfiguration {
public static final String DOWNLOAD_SHOW_DESCRIPTION = "download.show_description";
public static final String DOWNLOAD_MAX_SIMULTANEOUS_NUM = "download.max_simultaneous.number";
public static final String DOWNLOAD_FETCH_FILE_SIZE = "download.fetch_file_size";
public static final String DOWNLOAD_CONTINUATION_TIME = "download.continuation.time";
public static final String SEARCH_USE_FILM_DESCRIPTIONS =
"searchfield.film.search_through_description";
public static final String FILM_SHOW_DESCRIPTION = "film.show_description";
Expand Down

0 comments on commit e422ffc

Please sign in to comment.