added new translators and choicing of that
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package bruhcollective.itaysonlab.libvkx.client;
|
||||
|
||||
import static ru.vtosters.lite.music.Scrobbler.scrobbleTrack;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
@@ -16,23 +15,23 @@ import java.util.List;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
|
||||
|
||||
public class LibVKXClient{
|
||||
public class LibVKXClient {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static LibVKXClientImpl impl;
|
||||
|
||||
public static LibVKXClientImpl getInstance(Context context){
|
||||
public static LibVKXClientImpl getInstance(Context context) {
|
||||
if (impl == null) {
|
||||
impl = new LibVKXClientImpl(context);
|
||||
}
|
||||
return impl;
|
||||
}
|
||||
|
||||
public static LibVKXClientImpl getInstance(){
|
||||
public static LibVKXClientImpl getInstance() {
|
||||
LibVKXClientImpl libVKXClientImpl = impl;
|
||||
return libVKXClientImpl == null ? getInstance(getGlobalContext()) : libVKXClientImpl;
|
||||
}
|
||||
|
||||
public static boolean isVkxInstalled(){
|
||||
public static boolean isVkxInstalled() {
|
||||
try {
|
||||
getGlobalContext().getPackageManager().getPackageInfo("ua.itaysonlab.vkx", 0);
|
||||
return true;
|
||||
@@ -41,11 +40,11 @@ public class LibVKXClient{
|
||||
}
|
||||
} // VKX check
|
||||
|
||||
public static boolean isIntegrationEnabled(){
|
||||
public static boolean isIntegrationEnabled() {
|
||||
return getBoolValue("libvkx_integration", false) && isVkxInstalled();
|
||||
}
|
||||
|
||||
public static boolean play(MusicTrack musicTrack, List<MusicTrack> list, MusicPlaybackLaunchContext playerRefer){
|
||||
public static boolean play(MusicTrack musicTrack, List<MusicTrack> list, MusicPlaybackLaunchContext playerRefer) {
|
||||
if (!isIntegrationEnabled()) {
|
||||
return false;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public class LibVKXClient{
|
||||
return getInstance().runOnService(action);
|
||||
}
|
||||
|
||||
public static void lambdaplay(List<MusicTrack> list, MusicTrack musicTrack, ILibVkxService iLibVkxService){
|
||||
public static void lambdaplay(List<MusicTrack> list, MusicTrack musicTrack, ILibVkxService iLibVkxService) {
|
||||
int indexOf = list.indexOf(musicTrack);
|
||||
var ids = new ArrayList<String>();
|
||||
for (var track : list) {
|
||||
@@ -72,7 +71,7 @@ public class LibVKXClient{
|
||||
}
|
||||
}
|
||||
|
||||
private static String asId(MusicTrack musicTrack){
|
||||
private static String asId(MusicTrack musicTrack) {
|
||||
String str = musicTrack.e + "_" + musicTrack.d;
|
||||
if (musicTrack.O == null || musicTrack.O.equals("")) {
|
||||
return str;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.vk.im.ui.components.common;
|
||||
public enum DialogAction{
|
||||
|
||||
public enum DialogAction {
|
||||
OPEN_USER_PROFILE,
|
||||
OPEN_GROUP_PROFILE,
|
||||
CHAT_SETTINGS,
|
||||
|
||||
@@ -17,10 +17,10 @@ import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.dnr.DNRInjector;
|
||||
|
||||
public final class DialogActionsHelper{
|
||||
public final class DialogActionsHelper {
|
||||
public static final DialogActionsHelper a = new DialogActionsHelper();
|
||||
|
||||
public final List<DialogAction> a(ImConfig imConfig, Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo){
|
||||
public final List<DialogAction> a(ImConfig imConfig, Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) {
|
||||
if (dialog != null && profilesSimpleInfo != null) {
|
||||
long b2 = TimeProvider.f.b();
|
||||
ChatSettings z1 = dialog.z1();
|
||||
@@ -84,7 +84,7 @@ public final class DialogActionsHelper{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public final List<DialogAction> a(Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo){
|
||||
public final List<DialogAction> a(Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) {
|
||||
long b2 = TimeProvider.f.b();
|
||||
Profile profile = profilesSimpleInfo.get(dialog.getId());
|
||||
|
||||
@@ -138,7 +138,7 @@ public final class DialogActionsHelper{
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public final boolean a(Dialog dialog){
|
||||
public final boolean a(Dialog dialog) {
|
||||
if (dialog.V1() || !dialog.y1()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.vk.im.ui.components.common;
|
||||
|
||||
public enum MsgAction{
|
||||
public enum MsgAction {
|
||||
RETRY,
|
||||
REPLY,
|
||||
FORWARD,
|
||||
|
||||
@@ -5,22 +5,20 @@ import com.vk.im.engine.ImConfig;
|
||||
import com.vk.im.engine.ImEngine;
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.models.messages.MsgFromUser;
|
||||
import com.vk.im.engine.utils.MsgPermissionHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public final class MsgActionHelper{
|
||||
public final class MsgActionHelper {
|
||||
public static final MsgActionHelper a = new MsgActionHelper();
|
||||
|
||||
public final List<MsgAction> a(ImEngine imEngine, Dialog dialog, Collection<? extends Msg> collection){
|
||||
public final List<MsgAction> a(ImEngine imEngine, Dialog dialog, Collection<? extends Msg> collection) {
|
||||
return a(imEngine != null ? imEngine.g() : null, dialog, collection);
|
||||
}
|
||||
|
||||
public final List<MsgAction> a(ImConfig imConfig, Dialog dialog, Collection<? extends Msg> collection){
|
||||
public final List<MsgAction> a(ImConfig imConfig, Dialog dialog, Collection<? extends Msg> collection) {
|
||||
if (imConfig != null && dialog != null && collection != null) {
|
||||
MsgPermissionHelper.a aVar = new MsgPermissionHelper.a(imConfig, dialog, collection);
|
||||
ArrayList<MsgAction> arrayList = new ArrayList<>();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class DNRInjector {
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public static boolean onClick(Dialog dialog, DialogAction action){
|
||||
public static boolean onClick(Dialog dialog, DialogAction action) {
|
||||
var id = dialog.getId();
|
||||
|
||||
if (action == DialogAction.valueOf("MARK_AS_READ")) {
|
||||
@@ -109,9 +109,9 @@ public class DNRInjector {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void pinnedMsg(int dialogid, boolean needToBePinned){
|
||||
public static void pinnedMsg(int dialogid, boolean needToBePinned) {
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
try {
|
||||
var request = new Request.a()
|
||||
.b("https://api.vk.com/method/" + (needToBePinned ? "messages.pinConversation" : "messages.unpinConversation") + "?peer_id=" + dialogid + "&access_token=" + getUserToken() + "&v=5.119")
|
||||
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"))
|
||||
|
||||
@@ -3,45 +3,23 @@ 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.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
|
||||
import com.vk.api.internal.MethodCall;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import ru.vtosters.lite.translators.BaseTranslator;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
|
||||
public class MessagesHook{
|
||||
public static String injectOwnText(String oldText){
|
||||
var translator = BaseTranslator.getInstance();
|
||||
if (!TextUtils.isEmpty(oldText) && getBoolValue("autotranslate", false)) {
|
||||
return translator.translate(oldText);
|
||||
}
|
||||
return oldText;
|
||||
public class MessagesHook {
|
||||
public static String injectOwnText(String oldText) {
|
||||
if (!getBoolValue("autotranslate", false) || TextUtils.isEmpty(oldText))
|
||||
return oldText;
|
||||
return BaseTranslator.getInstance().getTranslation(oldText);
|
||||
}
|
||||
|
||||
public static void onLongClick(View view){
|
||||
public static void onLongClick(View view) {
|
||||
view.setOnLongClickListener(v -> {
|
||||
argDialog(v.getContext());
|
||||
return true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.music;
|
||||
|
||||
import static java.lang.String.valueOf;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
@@ -24,14 +25,14 @@ import ru.vtosters.lite.net.NetClient;
|
||||
import ru.vtosters.lite.net.NetRequest;
|
||||
import ru.vtosters.lite.net.NetResponse;
|
||||
|
||||
public class Scrobbler{
|
||||
public class Scrobbler {
|
||||
private static final String key = "5965d63402414776c54c266db0211746";
|
||||
private static final String keysecret = "d982180eed13275bb948e41cf225f88f";
|
||||
private static final String url = "https://ws.audioscrobbler.com/2.0/";
|
||||
private static final NetClient client = new NetClient.Builder().build();
|
||||
private static final ArrayList<String> scrobbled = new ArrayList<>();
|
||||
|
||||
public static void scrobbleTrack(long duration, String artist, String title, String uid){
|
||||
public static void scrobbleTrack(long duration, String artist, String title, String uid) {
|
||||
var string = getDefaultPrefs().getString("sessionKey", null);
|
||||
var timestamp = System.currentTimeMillis() / 1000;
|
||||
|
||||
@@ -59,14 +60,14 @@ public class Scrobbler{
|
||||
treeMap.put("api_sig", signMD5(treeMap));
|
||||
treeMap.put("format", "json");
|
||||
|
||||
client.newCall(new NetRequest.Builder().url(url).post().params(treeMap).build()).enqueue(new NetCallback(){
|
||||
client.newCall(new NetRequest.Builder().url(url).post().params(treeMap).build()).enqueue(new NetCallback() {
|
||||
@Override
|
||||
public void onFailure(NetCall call, IOException e){
|
||||
public void onFailure(NetCall call, IOException e) {
|
||||
Log.d("Scrobbler", "Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(NetCall call, NetResponse response){
|
||||
public void onResponse(NetCall call, NetResponse response) {
|
||||
Log.d("Scrobbler", "Scrobbled: " + artist + " - " + title);
|
||||
Log.d("Scrobbler", "Response scrobble: " + response.getDataString());
|
||||
}
|
||||
@@ -87,7 +88,7 @@ public class Scrobbler{
|
||||
scrobbleTrack(duration, artist, title, uid);
|
||||
}
|
||||
|
||||
private static String signMD5(Map<String, String> map){
|
||||
private static String signMD5(Map<String, String> map) {
|
||||
var sb = new StringBuilder();
|
||||
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
@@ -100,7 +101,7 @@ public class Scrobbler{
|
||||
return MD5(sb.toString());
|
||||
}
|
||||
|
||||
public static void auth(String login, String pass){
|
||||
public static void auth(String login, String pass) {
|
||||
if (login == null || pass == null) {
|
||||
sendToast("Логин или пароль не заданы");
|
||||
return;
|
||||
@@ -114,15 +115,15 @@ public class Scrobbler{
|
||||
treeMap.put("api_sig", signMD5(treeMap));
|
||||
treeMap.put("format", "json");
|
||||
|
||||
client.newCall(new NetRequest.Builder().url(url).post().params(treeMap).build()).enqueue(new NetCallback(){
|
||||
client.newCall(new NetRequest.Builder().url(url).post().params(treeMap).build()).enqueue(new NetCallback() {
|
||||
@Override
|
||||
public void onFailure(NetCall call, IOException e){
|
||||
public void onFailure(NetCall call, IOException e) {
|
||||
Log.d("Scrobbler", "Auth failed", e);
|
||||
sendToast("Ошибка входа");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(NetCall call, NetResponse response){
|
||||
public void onResponse(NetCall call, NetResponse response) {
|
||||
try {
|
||||
var jSONObject = new JSONObject(response.getDataString());
|
||||
sessionFetcher(jSONObject);
|
||||
@@ -134,7 +135,7 @@ public class Scrobbler{
|
||||
});
|
||||
}
|
||||
|
||||
public static void sessionFetcher(JSONObject jsonObject) throws JSONException{
|
||||
public static void sessionFetcher(JSONObject jsonObject) throws JSONException {
|
||||
if (!jsonObject.has("session")) {
|
||||
Log.d("Scrobbler", "Auth failed - no session");
|
||||
return;
|
||||
@@ -150,26 +151,26 @@ public class Scrobbler{
|
||||
Log.d("Scrobbler", "Auth success as " + name + ", key " + key);
|
||||
}
|
||||
|
||||
public static void logout(){
|
||||
public static void logout() {
|
||||
edit().remove("username").apply();
|
||||
edit().remove("sessionKey").apply();
|
||||
scrobbled.clear();
|
||||
sendToast("Вы успешно вышли из учетной записи");
|
||||
}
|
||||
|
||||
public static boolean needToBeScrobble(String uid){
|
||||
public static boolean needToBeScrobble(String uid) {
|
||||
return isLoggedIn() && isScrobblingEnabled() && !scrobbled.contains(uid);
|
||||
}
|
||||
|
||||
public static boolean isLoggedIn(){
|
||||
public static boolean isLoggedIn() {
|
||||
return getDefaultPrefs().getString("sessionKey", null) != null;
|
||||
}
|
||||
|
||||
public static boolean isScrobblingEnabled(){
|
||||
public static boolean isScrobblingEnabled() {
|
||||
return getPreferences().getBoolean("lastfm_enabled", false);
|
||||
}
|
||||
|
||||
public static String getUserName(){
|
||||
public static String getUserName() {
|
||||
return getDefaultPrefs().getString("username", null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package ru.vtosters.lite.net;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -1,20 +1,36 @@
|
||||
package ru.vtosters.lite.translators;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.collection.LruCache;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public abstract class BaseTranslator {
|
||||
private static final int YANDEX_CODE = 0;
|
||||
|
||||
private final LruCache<String, String> cache = new LruCache<>(200);
|
||||
|
||||
private static final int YANDEX = 0;
|
||||
private static final int GOOGLE = 1;
|
||||
private static final int DEEPL = 2;
|
||||
|
||||
@NonNull
|
||||
public abstract String translate(String text);
|
||||
abstract String translate(String text);
|
||||
|
||||
public static Object target(){
|
||||
@NonNull
|
||||
public final String getTranslation(String text) {
|
||||
var val = cache.get(text);
|
||||
if (val != null)
|
||||
return val;
|
||||
var translation = translate(text);
|
||||
cache.put(text, translation);
|
||||
return translation;
|
||||
}
|
||||
|
||||
public static String getToLanguage() {
|
||||
var lang = preferences.getString("lang_target", "system");
|
||||
var systemLang = Locale.getDefault().getLanguage();
|
||||
|
||||
@@ -26,8 +42,12 @@ public abstract class BaseTranslator {
|
||||
|
||||
public static BaseTranslator getInstance() {
|
||||
switch (AndroidUtils.getPreferences().getInt("translator", 0)) {
|
||||
case YANDEX_CODE:
|
||||
case YANDEX:
|
||||
return YandexTranslator.getInstance();
|
||||
case GOOGLE:
|
||||
return GoogleTranslator.getInstance();
|
||||
case DEEPL:
|
||||
return DeepLTranslator.getInstance();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package ru.vtosters.lite.translators;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class DeepLTranslator extends BaseTranslator {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final Pattern pattern = Pattern.compile("[i]");
|
||||
private static final String REQUEST_BODY_FORMAT = "{\n" +
|
||||
" \"method\": \"LMT_handle_texts\",\n" +
|
||||
" \"id\": %s,\n" +
|
||||
" \"jsonrpc\": \"2.0\",\n" +
|
||||
" \"params\": {\n" +
|
||||
" \"splitting\": \"newlines\",\n" +
|
||||
" \"texts\": [{\n" +
|
||||
" \"requestAlternatives\": 0,\n" +
|
||||
" \"text\": \"%s\"\n" +
|
||||
" }],\n" +
|
||||
" \"lang\": {\n" +
|
||||
" \"target_lang\": \"%s\",\n" +
|
||||
" \"source_lang_user_selected\": \"\"\n" +
|
||||
" },\n" +
|
||||
" \"commonJobParams\": {\n" +
|
||||
" \"regionalVariant\": null,\n" +
|
||||
" \"wasSpoken\": false,\n" +
|
||||
" \"formality\": \"informal\"\n" +
|
||||
" },\n" +
|
||||
" \"timestamp\": %s\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
|
||||
private static DeepLTranslator instance;
|
||||
|
||||
public static DeepLTranslator getInstance() {
|
||||
if (instance == null)
|
||||
instance = new DeepLTranslator();
|
||||
return instance;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
String translate(String text) {
|
||||
try {
|
||||
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
|
||||
|
||||
var tl = getToLanguage();
|
||||
if (tl.contains("-"))
|
||||
tl = tl.toUpperCase();
|
||||
|
||||
var i = 1;
|
||||
while (pattern.matcher(text).find()) {
|
||||
i++;
|
||||
}
|
||||
|
||||
var id = new AtomicLong(ThreadLocalRandom.current().nextLong(Long.parseLong("10000000000")));
|
||||
|
||||
var requestBody = String.format(REQUEST_BODY_FORMAT,
|
||||
id.incrementAndGet(),
|
||||
text,
|
||||
tl,
|
||||
getTimestamp(i)
|
||||
);
|
||||
|
||||
requestBody = (id.get() + 3) % 13 == 0 || (id.get() + 5) % 29 == 0
|
||||
? requestBody.replace("hod\":\"", "hod\" : \"")
|
||||
: requestBody.replace("hod\":\"", "hod\": \"");
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
var request = new Request.a()
|
||||
.b("https://www2.deepl.com/jsonrpc")
|
||||
.a("referer", "https://www.deepl.com/")
|
||||
.a("user-agent", "DeepL-Android/VersionName(name=1.0.1) Android 10 (aarch64)")
|
||||
.a("x-app-os-name", "Android")
|
||||
.a("x-app-os-version", "10")
|
||||
.a("x-app-version", "1.0.1")
|
||||
.a("x-app-build", "13")
|
||||
.a("x-app-device", "Pixel 5")
|
||||
.a("x-app-instance-id", uuid)
|
||||
.a("accept-encoding", "gzip")
|
||||
.a(RequestBody.a(MediaType.a("application/json; charset=utf-8"), requestBody.getBytes(StandardCharsets.UTF_8)))
|
||||
.a();
|
||||
|
||||
var response = client.a(request).execute();
|
||||
var payload = response.a().g();
|
||||
|
||||
Log.d("DeepL", response.toString());
|
||||
Log.d("DeepL", payload);
|
||||
|
||||
|
||||
if (!TextUtils.isEmpty(payload)) {
|
||||
var json = new JSONObject(payload);
|
||||
if (!json.has("result"))
|
||||
return text;
|
||||
var result = json.getJSONObject("result");
|
||||
if (!result.has("texts"))
|
||||
return text;
|
||||
var sb = new StringBuilder();
|
||||
var texts = result.getJSONArray("texts");
|
||||
for (int j = 0; j < texts.length(); j++) {
|
||||
var value = texts.getJSONObject(j).getString("text");
|
||||
Log.d("DeepL", value);
|
||||
sb.append(value);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
return text;
|
||||
} catch (Throwable e) {
|
||||
Log.d("DeepL", e + "");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static Long getTimestamp(int iNumber) {
|
||||
var now = System.currentTimeMillis();
|
||||
return Long.valueOf((((long) iNumber) + now) - (now % ((long) iNumber)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package ru.vtosters.lite.translators;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Locale;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class GoogleTranslator extends BaseTranslator {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final String[] devices = new String[]{
|
||||
"Linux; U; Android 10; Pixel 4",
|
||||
"Linux; U; Android 10; Pixel 4 XL",
|
||||
"Linux; U; Android 10; Pixel 4a",
|
||||
"Linux; U; Android 10; Pixel 4a XL",
|
||||
"Linux; U; Android 11; Pixel 4",
|
||||
"Linux; U; Android 11; Pixel 4 XL",
|
||||
"Linux; U; Android 11; Pixel 4a",
|
||||
"Linux; U; Android 11; Pixel 4a XL",
|
||||
"Linux; U; Android 11; Pixel 5",
|
||||
"Linux; U; Android 11; Pixel 5a",
|
||||
"Linux; U; Android 12; Pixel 4",
|
||||
"Linux; U; Android 12; Pixel 4 XL",
|
||||
"Linux; U; Android 12; Pixel 4a",
|
||||
"Linux; U; Android 12; Pixel 4a XL",
|
||||
"Linux; U; Android 12; Pixel 5",
|
||||
"Linux; U; Android 12; Pixel 5a",
|
||||
"Linux; U; Android 12; Pixel 6",
|
||||
"Linux; U; Android 12; Pixel 6 Pro",
|
||||
};
|
||||
|
||||
private static GoogleTranslator instance;
|
||||
|
||||
public static GoogleTranslator getInstance() {
|
||||
if (instance == null)
|
||||
instance = new GoogleTranslator();
|
||||
return instance;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
String translate(String text) {
|
||||
try {
|
||||
var request = new Request.a()
|
||||
.b("https://translate.googleapis.com/translate_a/single?dj=1" +
|
||||
"&q=" + URLEncoder.encode(text, "UTF-8") +
|
||||
"&sl=auto" +
|
||||
"&tl=" + Locale.getDefault().getLanguage() +
|
||||
"&ie=UTF-8&oe=UTF-8&client=at&dt=t&otf=2")
|
||||
.a("User-Agent",
|
||||
"GoogleTranslate/6.28.0.05.421483610 (" + devices[(int) Math.round(Math.random() * (devices.length - 1))] + ")")
|
||||
.a();
|
||||
var payload = client.a(request).execute().a().g();
|
||||
if (!TextUtils.isEmpty(payload)) {
|
||||
var sb = new StringBuilder();
|
||||
var object = new JSONObject(payload);
|
||||
var array = object.getJSONArray("sentences");
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
sb.append(array.getJSONObject(i).getString("trans"));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,9 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
@@ -21,10 +17,10 @@ import okhttp3.RequestBody;
|
||||
public class YandexTranslator extends BaseTranslator {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static YandexTranslator instance;
|
||||
|
||||
private static final String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
private static YandexTranslator instance;
|
||||
|
||||
public static YandexTranslator getInstance() {
|
||||
if (instance == null)
|
||||
instance = new YandexTranslator();
|
||||
@@ -32,12 +28,14 @@ public class YandexTranslator extends BaseTranslator {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String translate(String text) {
|
||||
@Override
|
||||
String translate(String text) {
|
||||
try {
|
||||
var request = new Request.a()
|
||||
.b("https://translate.yandex.net/api/v1/tr.json/translate?&srv=android&id=" + uuid + "-0-0")
|
||||
.a("User-Agent", "ru.yandex.translate/21.15.4.21402814 (Xiaomi Redmi K20 Pro; Android 11)")
|
||||
.a(RequestBody.a(MediaType.a("application/x-www-form-urlencoded"),
|
||||
"lang=" + target() + "&text=" + URLEncoder.encode(text, "UTF-8")))
|
||||
"lang=" + getToLanguage() + "&text=" + URLEncoder.encode(text, "UTF-8")))
|
||||
.a();
|
||||
var payload = client.a(request).execute().a().g();
|
||||
var json = new JSONObject(payload);
|
||||
@@ -45,14 +43,14 @@ public class YandexTranslator extends BaseTranslator {
|
||||
Log.d("YandexTranslator", json.getString("message"));
|
||||
return text;
|
||||
}
|
||||
JSONArray array = json.getJSONArray("text");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int length = array.length();
|
||||
var array = json.getJSONArray("text");
|
||||
var sb = new StringBuilder();
|
||||
var length = array.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
sb.append(array.getString(i));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (IOException | JSONException e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return text;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
@@ -17,12 +18,12 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
|
||||
public class MessageSettings{
|
||||
public class MessageSettings {
|
||||
public static Boolean isSilentEnabled = false;
|
||||
public static String bombCount = "0";
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static void argDialog(Context context){
|
||||
public static void argDialog(Context context) {
|
||||
LinearLayout mContainer = new LinearLayout(context);
|
||||
|
||||
RadioGroup rg = new RadioGroup(context);
|
||||
@@ -64,7 +65,7 @@ public class MessageSettings{
|
||||
four.setTextColor(getTextAttr());
|
||||
five.setTextColor(getTextAttr());
|
||||
|
||||
switch(bombCount) {
|
||||
switch (bombCount) {
|
||||
case "15s":
|
||||
one.setChecked(true);
|
||||
break;
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -16,7 +15,7 @@ public class Translate {
|
||||
public static void showTranslatedText(Context context, String text) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
var translation = BaseTranslator.getInstance().translate(text);
|
||||
var translation = BaseTranslator.getInstance().getTranslation(text);
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
showDialog(context, translation);
|
||||
});
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
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 android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.ui.wallpapers.WallpaperMenuFragment;
|
||||
|
||||
public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
@@ -27,6 +34,29 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
findPreference("vkme_notifs").setOnPreferenceClickListener(new MessagesFragment.restart());
|
||||
findPreference("systememoji").setOnPreferenceClickListener(new MessagesFragment.restart());
|
||||
findPreference("wallpapers").setOnPreferenceClickListener(new MessagesFragment.openwp());
|
||||
|
||||
findPreference("lang_service").setOnPreferenceClickListener(preference -> {
|
||||
var items = Arrays.asList(
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(getIdentifier("ic_yandex_translate_icon", "drawable"), "Yandex Translate"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(getIdentifier("ic_google_translate_logo", "drawable"), "Google Translate"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(getIdentifier("ic_deepl_logo_icon", "drawable"), "DeepL")
|
||||
);
|
||||
|
||||
var alert = new VkAlertDialog.Builder(getActivity())
|
||||
.create();
|
||||
|
||||
var listView = (ListView) LayoutInflater.from(getContext()).inflate(com.vtosters.lite.R.layout.abc_select_dialog_material, null, false);
|
||||
var adapter = new ImagineArrayAdapter(getContext(), items, i -> {
|
||||
getPreferences().edit().putInt("translator", i).apply();
|
||||
alert.dismiss();
|
||||
});
|
||||
adapter.setSelected(getPreferences().getInt("translator", 0));
|
||||
listView.setAdapter(adapter);
|
||||
alert.setView(listView);
|
||||
alert.show();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public boolean restart(Preference preference) {
|
||||
|
||||
@@ -11,10 +11,8 @@ import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.CacheUtils.deleteCache;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -22,7 +20,6 @@ import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
@@ -34,7 +31,6 @@ import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -43,7 +39,6 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.util.ToastUtils;
|
||||
import com.vk.im.engine.ImEngine1;
|
||||
import com.vk.im.engine.ImEngineExt;
|
||||
import com.vk.im.engine.models.Sticker;
|
||||
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
|
||||
import com.vk.im.ui.providers.audiomsg.PlayerActionSources;
|
||||
import com.vk.imageloader.VKImageLoader;
|
||||
@@ -58,7 +53,6 @@ import com.vtosters.lite.im.ImEngineProvider;
|
||||
import java.io.IOException;
|
||||
|
||||
import b.h.g.m.FileUtils;
|
||||
import ru.vtosters.lite.music.Scrobbler;
|
||||
import ru.vtosters.lite.ui.activities.VKAdminTokenActivity;
|
||||
import ru.vtosters.lite.ui.components.BackupManager;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
@@ -102,7 +96,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
var pref = getDefaultPrefs().getString("autoclearcache", "Default");
|
||||
switch(pref) {
|
||||
switch (pref) {
|
||||
case "Default":
|
||||
findPreference("autoclearcache").setSummary("Не включено");
|
||||
break;
|
||||
@@ -228,47 +222,47 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
private void cacheCleanDialog() {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(getContext());
|
||||
builder.setTitle("Выберите что вы хотите очистить");
|
||||
builder.setItems(new String[]{"Очистить весь кэш", "Очистить кеш стикеров", "Очистить кеш изображений", "Очистить кеш видео", "Очистить кеш сообщений", "Очистить кеш WebView" }, (dialog, which) -> {
|
||||
switch(which) {
|
||||
case 0: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
new WebView(getActivity()).clearCache(true);
|
||||
VKImageLoader.e();
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
FileUtils.l();
|
||||
Stickers.l.c();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
deleteCache();
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
Stickers.l.c();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
VKImageLoader.e();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
break;
|
||||
case 3:
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
break;
|
||||
case 4:
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
break;
|
||||
case 5:
|
||||
new WebView(getActivity()).clearCache(true);
|
||||
break;
|
||||
builder.setItems(new String[]{"Очистить весь кэш", "Очистить кеш стикеров", "Очистить кеш изображений", "Очистить кеш видео", "Очистить кеш сообщений", "Очистить кеш WebView"}, (dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
new WebView(getActivity()).clearCache(true);
|
||||
VKImageLoader.e();
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
FileUtils.l();
|
||||
Stickers.l.c();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
deleteCache();
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
Stickers.l.c();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
VKImageLoader.e();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
break;
|
||||
case 3:
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
break;
|
||||
case 4:
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
break;
|
||||
case 5:
|
||||
new WebView(getActivity()).clearCache(true);
|
||||
break;
|
||||
}
|
||||
|
||||
Toast.makeText(getContext(), "Кеш очищен", LENGTH_SHORT).show();
|
||||
});
|
||||
@@ -341,6 +335,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class saveprefs implements Preference.OnPreferenceClickListener {
|
||||
saveprefs() {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static com.vk.bridges.AuthBridge.logout;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addListPreferenceIcon;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addMaterialSwitchPreference;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addPreference;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceCategory;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class AndroidUtils {
|
||||
Toast.makeText(getGlobalContext(), text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static String MD5(String s){
|
||||
public static String MD5(String s) {
|
||||
try {
|
||||
var messageDigest = MessageDigest.getInstance("MD5");
|
||||
var sb = new StringBuilder();
|
||||
@@ -126,7 +126,7 @@ public class AndroidUtils {
|
||||
byte[] digest = messageDigest.digest();
|
||||
for (byte b : digest) {
|
||||
String hexString = Integer.toHexString(b & 255);
|
||||
while(hexString.length() < 2) {
|
||||
while (hexString.length() < 2) {
|
||||
hexString = "0" + hexString;
|
||||
}
|
||||
sb.append(hexString);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
|
||||
import static ru.vtosters.lite.utils.StringUtils.isEmpty;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
|
||||
@@ -53,9 +53,9 @@ public class ReflectionUtils {
|
||||
public static <T> T getObjectField(Class<?> clz, String fieldName, Object instance) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getField(fieldName);
|
||||
field = getField(clz, fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field = getDeclaredField(clz, fieldName);
|
||||
}
|
||||
return (T) field.get(instance);
|
||||
}
|
||||
@@ -76,9 +76,9 @@ public class ReflectionUtils {
|
||||
public static void setObjectField(Class<?> clz, String fieldName, Object instance, Object value) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getField(fieldName);
|
||||
field = getField(clz, fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field = getDeclaredField(clz, fieldName);
|
||||
}
|
||||
field.set(instance, value);
|
||||
}
|
||||
@@ -112,9 +112,9 @@ public class ReflectionUtils {
|
||||
public static void setObjectFinalField(Class<?> clz, String fieldName, Object instance, Object value) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getField(fieldName);
|
||||
field = getField(clz, fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field = getDeclaredField(clz, fieldName);
|
||||
}
|
||||
|
||||
if (!Modifier.isFinal(field.getModifiers())) return;
|
||||
@@ -143,9 +143,9 @@ public class ReflectionUtils {
|
||||
public static void setObjectStaticField(Class<?> clz, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getField(fieldName);
|
||||
field = getField(clz, fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field = getDeclaredField(clz, fieldName);
|
||||
}
|
||||
field.set(null, value);
|
||||
}
|
||||
@@ -166,9 +166,9 @@ public class ReflectionUtils {
|
||||
public static void setObjectFinalStaticField(Class<?> clz, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getField(fieldName);
|
||||
field = getField(clz, fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field = getDeclaredField(clz, fieldName);
|
||||
}
|
||||
|
||||
if (!Modifier.isFinal(field.getModifiers())) return;
|
||||
@@ -197,9 +197,9 @@ public class ReflectionUtils {
|
||||
public static <T> T getObjectField(Class<?> clz, String fieldName) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getField(fieldName);
|
||||
field = getField(clz, fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field = getDeclaredField(clz, fieldName);
|
||||
}
|
||||
return (T) field.get(null);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.getSTextColor;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.isEmpty();
|
||||
}
|
||||
}
|
||||
+8
@@ -2110,6 +2110,10 @@
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-static {v2}, Lru/vtosters/lite/hooks/MessagesHook;->injectOwnText(Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-virtual {v1, v2}, Lcom/vk/im/ui/components/viewcontrollers/msg_list/entry/MsgTextBuilder;->a(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
||||
|
||||
move-result-object v1
|
||||
@@ -2517,6 +2521,10 @@
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-static {v2}, Lru/vtosters/lite/hooks/MessagesHook;->injectOwnText(Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-virtual {v1, v2}, Lcom/vk/im/ui/components/viewcontrollers/msg_list/entry/MsgTextBuilder;->a(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
+8
@@ -306,6 +306,10 @@
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-static {v4}, Lru/vtosters/lite/hooks/MessagesHook;->injectOwnText(Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-virtual {v3, v4}, Lcom/vk/im/ui/components/viewcontrollers/msg_list/entry/MsgTextBuilder;->a(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
||||
|
||||
move-result-object v3
|
||||
@@ -674,6 +678,10 @@
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-static {v2}, Lru/vtosters/lite/hooks/MessagesHook;->injectOwnText(Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-virtual {v1, v2}, Lcom/vk/im/ui/components/viewcontrollers/msg_list/entry/MsgTextBuilder;->a(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
Reference in New Issue
Block a user