some imp
This commit is contained in:
@@ -3,6 +3,8 @@ package ru.vtosters.lite.hooks;
|
||||
import static ru.vtosters.lite.ui.dialogs.MessageSettings.argDialog;
|
||||
import static ru.vtosters.lite.ui.dialogs.MessageSettings.bombCount;
|
||||
import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
|
||||
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.autotranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.savemsgsett;
|
||||
|
||||
@@ -15,11 +17,18 @@ import ru.vtosters.lite.translators.BaseTranslator;
|
||||
|
||||
public class MessagesHook {
|
||||
public static String injectOwnText(String oldText) {
|
||||
if (!getBoolValue("autotranslate", false) || TextUtils.isEmpty(oldText))
|
||||
if (!autotranslate() || TextUtils.isEmpty(oldText))
|
||||
return oldText;
|
||||
return BaseTranslator.getInstance().getTranslation(oldText);
|
||||
}
|
||||
|
||||
public static String injectOwnTextAll(String oldText) {
|
||||
if (!autoalltranslate() || TextUtils.isEmpty(oldText)) {
|
||||
return oldText;
|
||||
}
|
||||
return BaseTranslator.getInstance().getTranslation(oldText);
|
||||
}
|
||||
|
||||
public static void onLongClick(View view) {
|
||||
view.setOnLongClickListener(v -> {
|
||||
argDialog(v.getContext());
|
||||
|
||||
@@ -3,6 +3,8 @@ package ru.vtosters.lite.ui.fragments;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.offline;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -35,6 +37,8 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
findPreference("systememoji").setOnPreferenceClickListener(new MessagesFragment.restart());
|
||||
findPreference("wallpapers").setOnPreferenceClickListener(new MessagesFragment.openwp());
|
||||
|
||||
findPreference("autotranslate").setEnabled(!autoalltranslate());
|
||||
|
||||
findPreference("lang_service").setOnPreferenceClickListener(preference -> {
|
||||
var items = Arrays.asList(
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(getIdentifier("ic_yandex_translate_icon", "drawable"), "Yandex Translate"),
|
||||
@@ -59,6 +63,12 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
findPreference("autotranslate").setEnabled(!autoalltranslate());
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
public boolean restart(Preference preference) {
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
|
||||
@@ -261,6 +261,15 @@ public class Preferences {
|
||||
return getBoolValue("setoffline", false);
|
||||
}
|
||||
|
||||
public static boolean autotranslate() {
|
||||
if (autoalltranslate()) return true;
|
||||
return getBoolValue("autotranslate", false);
|
||||
}
|
||||
|
||||
public static boolean autoalltranslate() {
|
||||
return getBoolValue("autoalltranslate", false);
|
||||
}
|
||||
|
||||
public static boolean shortinfo() {
|
||||
return getBoolValue("shortinfo", true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user