Add deepl support

This commit is contained in:
Thomas 2022-12-27 16:50:08 +01:00
parent b9eca58ccb
commit 4be595ea54
11 changed files with 237 additions and 156 deletions

View file

@ -21,14 +21,12 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
@ -44,15 +42,8 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.preference.PreferenceManager;
import androidx.viewpager.widget.ViewPager;
import com.github.stom79.mytransl.MyTransL;
import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.Params;
import com.github.stom79.mytransl.translate.Translate;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -63,6 +54,7 @@ import app.fedilab.android.client.entities.api.Status;
import app.fedilab.android.databinding.ActivityMediaPagerBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MediaHelper;
import app.fedilab.android.helper.TranslateHelper;
import app.fedilab.android.interfaces.OnDownloadInterface;
import app.fedilab.android.ui.fragment.media.FragmentMedia;
import es.dmoral.toasty.Toasty;
@ -157,40 +149,14 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
binding.mediaDescription.setText(description);
binding.translate.setOnClickListener(v -> {
String descriptionToTranslate = attachments.get(mediaPosition - 1).description;
MyTransL.translatorEngine et = MyTransL.translatorEngine.LIBRETRANSLATE;
final MyTransL myTransL = MyTransL.getInstance(et);
myTransL.setObfuscation(true);
Params params = new Params();
params.setSplit_sentences(false);
params.setFormat(Params.fType.TEXT);
params.setSource_lang("auto");
myTransL.setLibretranslateDomain("translate.fedilab.app");
String statusToTranslate;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
statusToTranslate = Html.fromHtml(descriptionToTranslate, Html.FROM_HTML_MODE_LEGACY).toString();
else
statusToTranslate = Html.fromHtml(descriptionToTranslate).toString();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(MediaActivity.this);
String translate = sharedpreferences.getString(getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
if (translate != null && translate.equalsIgnoreCase("default")) {
translate = MyTransL.getLocale();
}
myTransL.translate(statusToTranslate, translate, params, new Results() {
@Override
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
attachments.get(mediaPosition - 1).translation = translate.getTranslatedContent();
binding.mediaDescriptionTranslated.setText(translate.getTranslatedContent());
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
binding.mediaDescription.setVisibility(View.GONE);
} else {
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException httpsConnectionException) {
TranslateHelper.translate(MediaActivity.this, descriptionToTranslate, translated -> {
if (translated != null) {
attachments.get(mediaPosition - 1).translation = translated;
binding.mediaDescriptionTranslated.setText(translated);
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
binding.mediaDescription.setVisibility(View.GONE);
} else {
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
});
@ -222,40 +188,14 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
}
binding.translate.setOnClickListener(v -> {
String descriptionToTranslate = attachments.get(position).description;
MyTransL.translatorEngine et = MyTransL.translatorEngine.LIBRETRANSLATE;
final MyTransL myTransL = MyTransL.getInstance(et);
myTransL.setObfuscation(true);
Params params = new Params();
params.setSplit_sentences(false);
params.setFormat(Params.fType.TEXT);
params.setSource_lang("auto");
myTransL.setLibretranslateDomain("translate.fedilab.app");
String statusToTranslate;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
statusToTranslate = Html.fromHtml(descriptionToTranslate, Html.FROM_HTML_MODE_LEGACY).toString();
else
statusToTranslate = Html.fromHtml(descriptionToTranslate).toString();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(MediaActivity.this);
String translate = sharedpreferences.getString(getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
if (translate != null && translate.equalsIgnoreCase("default")) {
translate = MyTransL.getLocale();
}
myTransL.translate(statusToTranslate, translate, params, new Results() {
@Override
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
attachments.get(position).translation = translate.getTranslatedContent();
binding.mediaDescriptionTranslated.setText(translate.getTranslatedContent());
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
binding.mediaDescription.setVisibility(View.GONE);
} else {
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException httpsConnectionException) {
TranslateHelper.translate(MediaActivity.this, descriptionToTranslate, translated -> {
if (translated != null) {
attachments.get(position).translation = translated;
binding.mediaDescriptionTranslated.setText(translated);
binding.mediaDescriptionTranslated.setVisibility(View.VISIBLE);
binding.mediaDescription.setVisibility(View.GONE);
} else {
Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
});

View file

@ -124,14 +124,17 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
import java.util.regex.Matcher;
@ -1236,7 +1239,8 @@ public class Helper {
counter++;
Date now = new Date();
attachment.filename = formatter.format(now) + "." + extension;
if (attachment.mimeType.startsWith("image")) {
Set<String> imageType = new HashSet<>(Arrays.asList("image/png", "image/jpeg", "image/jpg"));
if (imageType.contains(attachment.mimeType)) {
final File certCacheDir = new File(context.getCacheDir(), TEMP_MEDIA_DIRECTORY);
boolean isCertCacheDirExists = certCacheDir.exists();
if (!isCertCacheDirExists) {

View file

@ -0,0 +1,91 @@
package app.fedilab.android.helper;
/* Copyright 2022 Thomas Schneider
*
* This file is a part of Fedilab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.text.Html;
import android.widget.Toast;
import androidx.preference.PreferenceManager;
import com.github.stom79.mytransl.MyTransL;
import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.Params;
import app.fedilab.android.R;
import es.dmoral.toasty.Toasty;
public class TranslateHelper {
public static void translate(Context context, String toTranslate, Translate callback) {
String statusToTranslate;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
statusToTranslate = Html.fromHtml(toTranslate, Html.FROM_HTML_MODE_LEGACY).toString();
else
statusToTranslate = Html.fromHtml(toTranslate).toString();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
String translator = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR), "FEDILAB");
MyTransL.translatorEngine et;
if (translator.compareToIgnoreCase("FEDILAB") == 0) {
et = MyTransL.translatorEngine.LIBRETRANSLATE;
} else {
et = MyTransL.translatorEngine.DEEPL;
}
final MyTransL myTransL = MyTransL.getInstance(et);
myTransL.setObfuscation(true);
Params params = new Params();
params.setSplit_sentences(false);
params.setFormat(Params.fType.TEXT);
params.setSource_lang("auto");
if (translator.compareToIgnoreCase("FEDILAB") == 0) {
myTransL.setLibretranslateDomain("translate.fedilab.app");
} else {
String translatorVersion = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_VERSION), "PRO");
params.setPro(translatorVersion.equals("PRO"));
String apikey = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_API_KEY), null);
myTransL.setDeeplAPIKey(apikey.trim());
}
String translate = sharedpreferences.getString(context.getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
if (translate.equalsIgnoreCase("default")) {
translate = MyTransL.getLocale();
}
myTransL.translate(statusToTranslate, translate, params, new Results() {
@Override
public void onSuccess(com.github.stom79.mytransl.translate.Translate translate) {
if (translate.getTranslatedContent() != null) {
callback.onTranslate(translate.getTranslatedContent());
} else {
callback.onTranslate("");
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException httpsConnectionException) {
callback.onTranslate("");
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
}
public interface Translate {
void onTranslate(String translated);
}
}

View file

@ -16,28 +16,21 @@ package app.fedilab.android.ui.drawer;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.RecyclerView;
import com.github.stom79.mytransl.MyTransL;
import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.Params;
import com.github.stom79.mytransl.translate.Translate;
import java.util.List;
import java.util.Locale;
import app.fedilab.android.R;
import app.fedilab.android.client.entities.app.ReleaseNote;
import app.fedilab.android.databinding.DrawerReleaseNoteBinding;
import app.fedilab.android.helper.TranslateHelper;
import es.dmoral.toasty.Toasty;
@ -81,37 +74,14 @@ public class ReleaseNoteAdapter extends RecyclerView.Adapter<ReleaseNoteAdapter.
holder.binding.containerTrans.setVisibility(View.GONE);
holder.binding.translate.setVisibility(View.VISIBLE);
}
holder.binding.translate.setOnClickListener(v -> {
MyTransL.translatorEngine et = MyTransL.translatorEngine.LIBRETRANSLATE;
final MyTransL myTransL = MyTransL.getInstance(et);
myTransL.setObfuscation(true);
Params params = new Params();
params.setSplit_sentences(false);
params.setFormat(Params.fType.TEXT);
params.setSource_lang("auto");
myTransL.setLibretranslateDomain("translate.fedilab.app");
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
String translate = sharedpreferences.getString(context.getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
if (translate != null && translate.equalsIgnoreCase("default")) {
translate = MyTransL.getLocale();
holder.binding.translate.setOnClickListener(v -> TranslateHelper.translate(context, note.note, translated -> {
if (translated != null) {
note.noteTranslated = translated;
notifyItemChanged(holder.getBindingAdapterPosition());
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
myTransL.translate(note.note, translate, params, new Results() {
@Override
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
note.noteTranslated = translate.getTranslatedContent();
notifyItemChanged(holder.getBindingAdapterPosition());
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException httpsConnectionException) {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
});
}));
}

View file

@ -87,10 +87,6 @@ import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.github.stom79.mytransl.MyTransL;
import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.Params;
import com.github.stom79.mytransl.translate.Translate;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.EmojiPopup;
import com.vanniktech.emoji.one.EmojiOneProvider;
@ -145,6 +141,7 @@ import app.fedilab.android.helper.MediaHelper;
import app.fedilab.android.helper.SpannableHelper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.helper.TimelineHelper;
import app.fedilab.android.helper.TranslateHelper;
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonContext;
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
import app.fedilab.android.viewmodel.mastodon.SearchVM;
@ -1982,6 +1979,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
private static void translate(Context context, Status statusToDeal,
StatusViewHolder holder,
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
@ -1990,40 +1988,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
statusToTranslate = Html.fromHtml(statusToDeal.content, Html.FROM_HTML_MODE_LEGACY).toString();
else
statusToTranslate = Html.fromHtml(statusToDeal.content).toString();
int countMorseChar = ComposeAdapter.countMorseChar(statusToTranslate);
if (countMorseChar < 4) {
MyTransL.translatorEngine et = MyTransL.translatorEngine.LIBRETRANSLATE;
final MyTransL myTransL = MyTransL.getInstance(et);
myTransL.setObfuscation(true);
Params params = new Params();
params.setSplit_sentences(false);
params.setFormat(Params.fType.TEXT);
params.setSource_lang("auto");
myTransL.setLibretranslateDomain("translate.fedilab.app");
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
String translate = sharedpreferences.getString(context.getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());
if (translate != null && translate.equalsIgnoreCase("default")) {
translate = MyTransL.getLocale();
}
myTransL.translate(statusToTranslate, translate, params, new Results() {
@Override
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
statusToDeal.translationShown = true;
statusToDeal.translationContent = translate.getTranslatedContent();
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException httpsConnectionException) {
TranslateHelper.translate(context, statusToDeal.content, translated -> {
if (translated != null) {
statusToDeal.translationShown = true;
statusToDeal.translationContent = translated;
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
} else {

View file

@ -17,9 +17,11 @@ package app.fedilab.android.ui.fragment.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import app.fedilab.android.R;
import app.fedilab.android.helper.Helper;
@ -33,10 +35,31 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
}
private void createPref() {
getPreferenceScreen().removeAll();
addPreferencesFromResource(R.xml.pref_timelines);
PreferenceScreen preferenceScreen = getPreferenceScreen();
ListPreference SET_LOAD_MEDIA_TYPE = findPreference(getString(R.string.SET_LOAD_MEDIA_TYPE));
if (SET_LOAD_MEDIA_TYPE != null) {
SET_LOAD_MEDIA_TYPE.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_TRANSLATOR = findPreference(getString(R.string.SET_TRANSLATOR));
if (SET_TRANSLATOR != null) {
SET_TRANSLATOR.getContext().setTheme(Helper.dialogStyle());
}
ListPreference SET_TRANSLATOR_VERSION = findPreference(getString(R.string.SET_TRANSLATOR_VERSION));
if (SET_TRANSLATOR_VERSION != null) {
SET_TRANSLATOR_VERSION.getContext().setTheme(Helper.dialogStyle());
}
EditTextPreference SET_TRANSLATOR_API_KEY = findPreference(getString(R.string.SET_TRANSLATOR_API_KEY));
if (SET_TRANSLATOR != null && SET_TRANSLATOR.getValue().equals("FEDILAB")) {
if (SET_TRANSLATOR_API_KEY != null) {
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_API_KEY");
}
if (SET_TRANSLATOR_VERSION != null) {
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_VERSION");
}
}
}
@Override
@ -44,8 +67,10 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
if (getActivity() != null) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.apply();
if (key.compareToIgnoreCase(getString(R.string.SET_TRANSLATOR)) == 0) {
createPref();
}
}
}

View file

@ -766,6 +766,26 @@
<item>Wifi only</item>
<item>Ask</item>
</string-array>
<string-array name="set_translator_values" translatable="false">
<item>Fedilab</item>
<item>DeepL</item>
</string-array>
<string-array name="set_translator_version_values">
<item>Free</item>
<item>Pro</item>
</string-array>
<string-array name="SET_TRANSLATOR_VALUES" translatable="false">
<item>FEDILAB</item>
<item>DEEPL</item>
</string-array>
<string-array name="SET_TRANSLATOR_VERSION_VALUES" translatable="false">
<item>FREE</item>
<item>PRO</item>
</string-array>
<string-array name="set_notification_delay_values">
<item>15 minutes</item>
<item>30 minutes</item>
@ -1400,6 +1420,12 @@
<string name="SET_NOTIF_VALIDATION" translatable="false">SET_NOTIF_VALIDATION</string>
<string name="SET_DISPLAY_BOOKMARK" translatable="false">SET_DISPLAY_BOOKMARK</string>
<string name="SET_DISPLAY_TRANSLATE" translatable="false">SET_DISPLAY_TRANSLATE</string>
<string name="SET_TRANSLATOR" translatable="false">SET_TRANSLATOR</string>
<string name="SET_TRANSLATOR_VERSION" translatable="false">SET_TRANSLATOR_VERSION</string>
<string name="SET_TRANSLATOR_API_KEY" translatable="false">SET_TRANSLATOR_API_KEY</string>
<string name="SET_NOTIF_VALIDATION_FAV" translatable="false">SET_NOTIF_VALIDATION_FAV</string>
<string name="SET_DISPLAY_COUNTER_FAV_BOOST" translatable="false">SET_DISPLAY_COUNTER_FAV_BOOST</string>
<string name="SET_REMOVE_LEFT_MARGIN" translatable="false">SET_REMOVE_LEFT_MARGIN</string>
@ -2116,4 +2142,9 @@
<string name="manage_accounts">Manage accounts</string>
<string name="set_remove_left_margin_title">Remove left margin</string>
<string name="set_remove_left_margin">Remove the left margin in timelines to make messages more compact</string>
<string name="translator">Translator</string>
<string name="set_translator">Translator</string>
<string name="api_key">Translator API key</string>
<string name="version">Version</string>
<string name="set_translator_version">Translator version</string>
</resources>

View file

@ -54,6 +54,32 @@
app:singleLineTitle="false"
app:title="@string/set_display_translate_indication" />
<ListPreference
app:defaultValue="FEDILAB"
app:dialogTitle="@string/translator"
app:entries="@array/set_translator_values"
app:entryValues="@array/SET_TRANSLATOR_VALUES"
app:iconSpaceReserved="false"
app:key="@string/SET_TRANSLATOR"
app:title="@string/set_translator"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:dependency="@string/SET_TRANSLATOR"
app:iconSpaceReserved="false"
app:key="@string/SET_TRANSLATOR_API_KEY"
app:title="@string/api_key"
app:useSimpleSummaryProvider="true" />
<ListPreference
app:defaultValue="PRO"
app:dialogTitle="@string/version"
app:entries="@array/set_translator_version_values"
app:entryValues="@array/SET_TRANSLATOR_VERSION_VALUES"
app:iconSpaceReserved="false"
app:key="@string/SET_TRANSLATOR_VERSION"
app:title="@string/set_translator_version"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
app:defaultValue="true"
app:iconSpaceReserved="false"

View file

@ -28,7 +28,8 @@ public class Helper {
private static final String YANDEX_BASE_URL = "https://translate.yandex.net/api/v1.5/tr.json/translate?";
private static final String DEEPL_BASE_URL = "https://api.deepl.com/v1/translate?";
private static final String DEEPL_BASE_URL = "https://free.deepl.com/v2/translate?";
private static final String DEEPL_BASE_FREE_URL = "https://api-free.deepl.com/v2/translate?";
private static final String SYSTRAN_BASE_URL = "https://api-platform.systran.net/translation/text/translate?";
private static final String[] deeplAvailableLang = {"EN", "DE", "FR", "ES", "IT", "NL", "PL"};
@ -98,8 +99,11 @@ public class Helper {
if (deepLParams.getNon_splitting_tags() != null)
params += "&tag_handling=" + deepLParams.getNon_splitting_tags();
return Helper.DEEPL_BASE_URL + text + lang + params + key;
if (deepLParams.isPro()) {
return Helper.DEEPL_BASE_URL + text + lang + params + key;
} else {
return Helper.DEEPL_BASE_FREE_URL + text + lang + params + key;
}
}

View file

@ -25,6 +25,7 @@ public class Params {
private String ignore_tags;
private boolean split_sentences = true;
private boolean preserve_formatting = false;
private boolean isPro = true;
private Params.fType format;
public Params.fType getFormat() {
@ -86,6 +87,15 @@ public class Params {
this.preserve_formatting = preserve_formatting;
}
public boolean isPro() {
return isPro;
}
public void setPro(boolean pro) {
this.isPro = pro;
}
public enum fType {
@SerializedName("TEXT")
TEXT("text"),

View file

@ -0,0 +1,7 @@
Added:
- DeepL translation support free/pro keys
Changed:
Fixed:
- GIF loaded as static images