Instance fixes when not available
This commit is contained in:
parent
8975b09175
commit
ce05666038
|
@ -88,7 +88,7 @@ dependencies {
|
||||||
implementation "com.github.chrisbanes:PhotoView:$photoViewLibraryVersion"
|
implementation "com.github.chrisbanes:PhotoView:$photoViewLibraryVersion"
|
||||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||||
implementation 'com.github.stom79:country-picker-android:1.2.0'
|
implementation 'com.github.stom79:country-picker-android:1.2.0'
|
||||||
implementation 'com.github.stom79:mytransl:1.5'
|
implementation 'com.github.stom79:mytransl:2.0'
|
||||||
implementation 'com.github.stom79:SparkButton:1.0.13'
|
implementation 'com.github.stom79:SparkButton:1.0.13'
|
||||||
implementation "com.koushikdutta.async:androidasync:2.+"
|
implementation "com.koushikdutta.async:androidasync:2.+"
|
||||||
implementation 'com.vanniktech:emoji-one:0.6.0'
|
implementation 'com.vanniktech:emoji-one:0.6.0'
|
||||||
|
|
|
@ -1065,6 +1065,8 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
et = MyTransL.translatorEngine.YANDEX;
|
et = MyTransL.translatorEngine.YANDEX;
|
||||||
} else if (trans == Helper.TRANS_DEEPL) {
|
} else if (trans == Helper.TRANS_DEEPL) {
|
||||||
et = MyTransL.translatorEngine.DEEPL;
|
et = MyTransL.translatorEngine.DEEPL;
|
||||||
|
}else if (trans == Helper.TRANS_SYSTRAN) {
|
||||||
|
et = MyTransL.translatorEngine.SYSTRAN;
|
||||||
}
|
}
|
||||||
final MyTransL myTransL = MyTransL.getInstance(et);
|
final MyTransL myTransL = MyTransL.getInstance(et);
|
||||||
myTransL.setObfuscation(true);
|
myTransL.setObfuscation(true);
|
||||||
|
@ -1074,6 +1076,9 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
} else if (trans == Helper.TRANS_DEEPL) {
|
} else if (trans == Helper.TRANS_DEEPL) {
|
||||||
api_key = sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "");
|
api_key = sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "");
|
||||||
myTransL.setDeeplAPIKey(api_key);
|
myTransL.setDeeplAPIKey(api_key);
|
||||||
|
} else if (trans == Helper.TRANS_SYSTRAN) {
|
||||||
|
api_key = sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, "");
|
||||||
|
myTransL.setSystranAPIKey(api_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4073,13 +4073,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||||
MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX;
|
MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX;
|
||||||
String api_key = null;
|
String api_key;
|
||||||
|
|
||||||
|
|
||||||
if (trans == Helper.TRANS_YANDEX) {
|
if (trans == Helper.TRANS_YANDEX) {
|
||||||
et = MyTransL.translatorEngine.YANDEX;
|
et = MyTransL.translatorEngine.YANDEX;
|
||||||
} else if (trans == Helper.TRANS_DEEPL) {
|
} else if (trans == Helper.TRANS_DEEPL) {
|
||||||
et = MyTransL.translatorEngine.DEEPL;
|
et = MyTransL.translatorEngine.DEEPL;
|
||||||
|
} else if (trans == Helper.TRANS_SYSTRAN) {
|
||||||
|
et = MyTransL.translatorEngine.SYSTRAN;
|
||||||
}
|
}
|
||||||
final MyTransL myTransL = MyTransL.getInstance(et);
|
final MyTransL myTransL = MyTransL.getInstance(et);
|
||||||
myTransL.setObfuscation(true);
|
myTransL.setObfuscation(true);
|
||||||
|
@ -4089,6 +4091,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
} else if (trans == Helper.TRANS_DEEPL) {
|
} else if (trans == Helper.TRANS_DEEPL) {
|
||||||
api_key = sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "");
|
api_key = sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "");
|
||||||
myTransL.setDeeplAPIKey(api_key);
|
myTransL.setDeeplAPIKey(api_key);
|
||||||
|
} else if (trans == Helper.TRANS_SYSTRAN) {
|
||||||
|
api_key = sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, "");
|
||||||
|
myTransL.setSystranAPIKey(api_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4097,7 +4102,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||||
else
|
else
|
||||||
//noinspection deprecation
|
|
||||||
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
|
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
|
||||||
//TODO: removes the replaceAll once fixed with the lib
|
//TODO: removes the replaceAll once fixed with the lib
|
||||||
myTransL.translate(statusToTranslate, myTransL.getLocale(), new Results() {
|
myTransL.translate(statusToTranslate, myTransL.getLocale(), new Results() {
|
||||||
|
|
|
@ -716,6 +716,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
||||||
store = Helper.SET_YANDEX_API_KEY;
|
store = Helper.SET_YANDEX_API_KEY;
|
||||||
else if (translatore == Helper.TRANS_DEEPL)
|
else if (translatore == Helper.TRANS_DEEPL)
|
||||||
store = Helper.SET_DEEPL_API_KEY;
|
store = Helper.SET_DEEPL_API_KEY;
|
||||||
|
else if (translatore == Helper.TRANS_SYSTRAN)
|
||||||
|
store = Helper.SET_SYSTRAN_API_KEY;
|
||||||
if (store != null)
|
if (store != null)
|
||||||
if (s != null && s.length() > 0)
|
if (s != null && s.length() > 0)
|
||||||
editor.putString(store, s.toString().trim());
|
editor.putString(store, s.toString().trim());
|
||||||
|
@ -1833,8 +1835,13 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
||||||
your_api_key.setVisibility(View.VISIBLE);
|
your_api_key.setVisibility(View.VISIBLE);
|
||||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
|
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
|
||||||
break;
|
break;
|
||||||
case Helper.TRANS_NONE:
|
case Helper.TRANS_SYSTRAN:
|
||||||
positionSpinnerTrans = 2;
|
positionSpinnerTrans = 2;
|
||||||
|
your_api_key.setVisibility(View.VISIBLE);
|
||||||
|
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
|
||||||
|
break;
|
||||||
|
case Helper.TRANS_NONE:
|
||||||
|
positionSpinnerTrans = 3;
|
||||||
your_api_key.setVisibility(View.GONE);
|
your_api_key.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1853,17 +1860,25 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
||||||
your_api_key.setVisibility(View.VISIBLE);
|
your_api_key.setVisibility(View.VISIBLE);
|
||||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
if (sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, null) != null)
|
if (sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, null) != null)
|
||||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
|
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, null));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
your_api_key.setVisibility(View.VISIBLE);
|
your_api_key.setVisibility(View.VISIBLE);
|
||||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL);
|
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
if (sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, null) != null)
|
if (sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, null) != null)
|
||||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, null));
|
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
your_api_key.setVisibility(View.VISIBLE);
|
||||||
|
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_SYSTRAN);
|
||||||
|
editor.apply();
|
||||||
|
if (sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, null) != null)
|
||||||
|
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
your_api_key.setVisibility(View.GONE);
|
your_api_key.setVisibility(View.GONE);
|
||||||
set_trans_forced.isChecked();
|
set_trans_forced.isChecked();
|
||||||
editor.putBoolean(Helper.SET_TRANS_FORCED, false);
|
editor.putBoolean(Helper.SET_TRANS_FORCED, false);
|
||||||
|
|
|
@ -416,7 +416,8 @@ public class Helper {
|
||||||
|
|
||||||
public static final int TRANS_YANDEX = 0;
|
public static final int TRANS_YANDEX = 0;
|
||||||
public static final int TRANS_DEEPL = 1;
|
public static final int TRANS_DEEPL = 1;
|
||||||
public static final int TRANS_NONE = 2;
|
public static final int TRANS_NONE = 3;
|
||||||
|
public static final int TRANS_SYSTRAN = 2;
|
||||||
|
|
||||||
public static final int ACTION_SILENT = 0;
|
public static final int ACTION_SILENT = 0;
|
||||||
public static final int ACTION_ACTIVE = 1;
|
public static final int ACTION_ACTIVE = 1;
|
||||||
|
@ -515,6 +516,7 @@ public class Helper {
|
||||||
public static final String USER_AGENT = System.getProperty("http.agent");
|
public static final String USER_AGENT = System.getProperty("http.agent");
|
||||||
public static final String SET_YANDEX_API_KEY = "set_yandex_api_key";
|
public static final String SET_YANDEX_API_KEY = "set_yandex_api_key";
|
||||||
public static final String SET_DEEPL_API_KEY = "set_deepl_api_key";
|
public static final String SET_DEEPL_API_KEY = "set_deepl_api_key";
|
||||||
|
public static final String SET_SYSTRAN_API_KEY = "set_systran_api_key";
|
||||||
public static final String VIDEO_ID = "video_id_update";
|
public static final String VIDEO_ID = "video_id_update";
|
||||||
public static final Pattern urlPattern = Pattern.compile(
|
public static final Pattern urlPattern = Pattern.compile(
|
||||||
"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))",
|
"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))",
|
||||||
|
|
|
@ -337,6 +337,7 @@
|
||||||
<string-array name="settings_translation">
|
<string-array name="settings_translation">
|
||||||
<item>Yandex</item>
|
<item>Yandex</item>
|
||||||
<item>DeepL</item>
|
<item>DeepL</item>
|
||||||
|
<item>Systran</item>
|
||||||
<item>No</item>
|
<item>No</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue