Allows setting max lines and max line length, enables DeepL, adds user setup bridge

This commit is contained in:
Guillaume Tâche
2024-08-20 21:31:10 +02:00
parent 273a6e996f
commit 44c317f207
49 changed files with 752 additions and 298 deletions

View File

@@ -13,6 +13,9 @@ import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import javax.inject.Singleton;
import java.util.prefs.Preferences;
/**
* Dagger module for Core
*/
@@ -53,4 +56,22 @@ public abstract class CoreModule {
static String providesExecutableExtension(final OS os) {
return os == OS.WINDOWS ? ".exe" : "";
}
@Provides
@Singleton
static Preferences providesPreferences() {
return Preferences.userRoot().node("/com/github/gtache/autosubtitle");
}
@Provides
@MaxLineLength
static int providesMaxLineLength() {
return 40;
}
@Provides
@MaxLines
static int providesMaxLines() {
return 1;
}
}

View File

@@ -0,0 +1,16 @@
package com.github.gtache.autosubtitle.modules.impl;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Qualifier
@Documented
@Retention(RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
public @interface MaxLineLength {
}

View File

@@ -0,0 +1,16 @@
package com.github.gtache.autosubtitle.modules.impl;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Qualifier
@Documented
@Retention(RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
public @interface MaxLines {
}

View File

@@ -1,12 +1,12 @@
package com.github.gtache.autosubtitle.subtitle.converter.impl;
import com.github.gtache.autosubtitle.Translator;
import com.github.gtache.autosubtitle.subtitle.Subtitle;
import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverter;
import com.github.gtache.autosubtitle.subtitle.impl.SubtitleCollectionImpl;
import com.github.gtache.autosubtitle.subtitle.impl.SubtitleImpl;
import com.github.gtache.autosubtitle.translation.Translator;
import javax.inject.Inject;
import java.util.Arrays;

View File

@@ -7,6 +7,7 @@ module com.github.gtache.autosubtitle.core {
requires transitive java.net.http;
requires transitive javax.inject;
requires org.apache.logging.log4j;
requires java.prefs;
exports com.github.gtache.autosubtitle.impl;
exports com.github.gtache.autosubtitle.archive.impl;

View File

@@ -1,10 +1,10 @@
package com.github.gtache.autosubtitle.subtitle.converter.impl;
import com.github.gtache.autosubtitle.Language;
import com.github.gtache.autosubtitle.Translator;
import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
import com.github.gtache.autosubtitle.subtitle.impl.SubtitleCollectionImpl;
import com.github.gtache.autosubtitle.subtitle.impl.SubtitleImpl;
import com.github.gtache.autosubtitle.translation.Translator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;