Merge pull request #555 from iNotFlying/vtl-remaster && update from vtl-remaster branch

Remove dead VK code, update colors.xml
This commit is contained in:
aliveoutside
2022-08-01 19:09:53 +03:00
committed by GitHub
152 changed files with 2488 additions and 4959 deletions
@@ -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,13 +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){
scrobbleTrack(musicTrack.h, musicTrack.C, musicTrack.f, musicTrack.y1());
public static boolean play(MusicTrack musicTrack, List<MusicTrack> list, MusicPlaybackLaunchContext playerRefer) {
if (!isIntegrationEnabled()) {
return false;
}
@@ -57,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) {
@@ -74,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;
@@ -0,0 +1,35 @@
package com.vk.api.gifts;
import android.content.Context;
import com.vk.api.base.ApiRequest;
import com.vk.dto.gift.CatalogedGift;
import org.json.JSONException;
import org.json.JSONObject;
public class GiftGetByStickerId extends ApiRequest<GiftGetByStickerId.a> {
public static class a {
public final int a;
public final CatalogedGift b;
public a(int i, CatalogedGift catalogedGift) {
this.a = i;
this.b = catalogedGift;
}
}
public GiftGetByStickerId(Context context, int i) {
super("execute.getGiftByStickerId");
b("sticker_id", i);
c("no_inapp", "0");
b("force_payment", 1);
}
@Override // com.vk.api.sdk.o.VKRequest
public GiftGetByStickerId.a a(JSONObject jSONObject) throws JSONException {
JSONObject jSONObject2 = jSONObject.getJSONObject("response");
return new a(jSONObject2.optInt("balance"),
new CatalogedGift(jSONObject2.getJSONObject("gift")));
}
}
@@ -0,0 +1,37 @@
package com.vk.im.ui.components.common;
public enum DialogAction {
OPEN_USER_PROFILE,
OPEN_GROUP_PROFILE,
CHAT_SETTINGS,
SEARCH,
ADD_CHAT_MEMBER,
CREATE_SHORTCUT,
PINNED_MSG_HIDE,
PINNED_MSG_SHOW,
PINNED_MSG_DETACH,
SHOW_ATTACHES,
NOTIFICATIONS_ON,
NOTIFICATIONS_OFF,
GROUP_RECEIVE_MSGS_ENABLE,
GROUP_RECEIVE_MSGS_DISABLE,
GROUP_RECEIVE_NOTIFY_DISABLE,
CHANNEL_INVITE_LINK,
CLEAR_HISTORY,
CLEAR_HISTORY_AND_LEAVE,
LEAVE,
LEAVE_CHANNEL,
RETURN,
RETURN_TO_CHANNEL,
MARK_AS_READ,
AUDIO_BTN_AUDIO_CALL,
AUDIO_BTN_VIDEO_CALL,
VIDEO_BTN_VIDEO_CALL,
VIDEO_BTN_AUDIO_CALL,
DNR_ON,
DNR_OFF,
DNT_ON,
DNT_OFF,
pinmsg,
unpinmsg,
}
@@ -0,0 +1,148 @@
package com.vk.im.ui.components.common;
import com.vk.core.extensions.CollectionExt;
import com.vk.core.network.TimeProvider;
import com.vk.im.engine.ImConfig;
import com.vk.im.engine.models.MemberType;
import com.vk.im.engine.models.Profile;
import com.vk.im.engine.models.ProfilesSimpleInfo;
import com.vk.im.engine.models.dialogs.ChatSettings;
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.groups.Group;
import com.vk.im.engine.utils.DialogPermissionHelper;
import com.vk.im.ui.p.ImBridge7;
import java.util.ArrayList;
import java.util.List;
import ru.vtosters.lite.dnr.DNRInjector;
public final class DialogActionsHelper {
public static final DialogActionsHelper a = new DialogActionsHelper();
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();
boolean z = false;
boolean I1 = z1 != null && z1.I1();
ArrayList<DialogAction> arrayList = new ArrayList<>();
DNRInjector.inject(dialog, arrayList);
arrayList.add(DialogAction.SEARCH);
if (dialog.S1()) {
arrayList.add(DialogAction.SHOW_ATTACHES);
}
if (!I1 && !dialog.W1()) {
arrayList.add(DialogAction.CLEAR_HISTORY);
}
if (I1) {
arrayList.add(DialogAction.CHANNEL_INVITE_LINK);
}
if (dialog.K1() != null) {
CollectionExt.a(arrayList, DialogAction.PINNED_MSG_DETACH, !I1);
CollectionExt.a(arrayList, DialogAction.PINNED_MSG_SHOW, !dialog.L1());
CollectionExt.a(arrayList, DialogAction.PINNED_MSG_HIDE, dialog.L1());
}
if (dialog.a(MemberType.USER)) {
arrayList.add(DialogAction.OPEN_USER_PROFILE);
}
if (dialog.a(MemberType.GROUP)) {
arrayList.add(DialogAction.OPEN_GROUP_PROFILE);
Group group = profilesSimpleInfo.w1().get(dialog.I1());
if (group != null) {
if (group.v1()) {
arrayList.add(DialogAction.GROUP_RECEIVE_MSGS_DISABLE);
} else {
CollectionExt.a(arrayList, DialogAction.GROUP_RECEIVE_NOTIFY_DISABLE, group.w1());
CollectionExt.a(arrayList, DialogAction.GROUP_RECEIVE_MSGS_ENABLE, !group.w1());
}
}
}
if (dialog.W1()) {
DialogAction dialogAction = DialogAction.ADD_CHAT_MEMBER;
ChatSettings z12 = dialog.z1();
if (z12 != null) {
z = z12.y1();
}
CollectionExt.a(arrayList, dialogAction, z);
CollectionExt.a(arrayList, DialogAction.CHAT_SETTINGS, DialogPermissionHelper.a.a(dialog));
}
CollectionExt.a(arrayList, DialogAction.NOTIFICATIONS_ON, !dialog.b(b2));
CollectionExt.a(arrayList, DialogAction.NOTIFICATIONS_OFF, dialog.b(b2));
return arrayList;
}
return new ArrayList<>();
}
public final List<DialogAction> a(Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) {
long b2 = TimeProvider.f.b();
Profile profile = profilesSimpleInfo.get(dialog.getId());
if (!(profile instanceof Group)) {
profile = null;
}
Group group = (Group) profile;
ChatSettings z1 = dialog.z1();
ArrayList<DialogAction> arrayList = new ArrayList<>();
DNRInjector.inject(dialog, arrayList);
// if (dialog.hasUnread()) {
arrayList.add(DialogAction.MARK_AS_READ);
// }
if (!dialog.W1()) {
arrayList.add(DialogAction.CREATE_SHORTCUT);
arrayList.add(DialogAction.CLEAR_HISTORY);
CollectionExt.a(arrayList, DialogAction.NOTIFICATIONS_OFF, dialog.b(b2));
CollectionExt.a(arrayList, DialogAction.NOTIFICATIONS_ON, !dialog.b(b2));
}
if (dialog.a(MemberType.GROUP) && group != null) {
if (group.v1()) {
arrayList.add(DialogAction.GROUP_RECEIVE_MSGS_DISABLE);
} else {
CollectionExt.a(arrayList, DialogAction.GROUP_RECEIVE_NOTIFY_DISABLE, group.w1());
CollectionExt.a(arrayList, DialogAction.GROUP_RECEIVE_MSGS_ENABLE, !group.w1());
}
}
if (dialog.W1() && z1 != null) {
if (!z1.L1()) {
arrayList.add(DialogAction.CREATE_SHORTCUT);
CollectionExt.a(arrayList, DialogAction.NOTIFICATIONS_OFF, dialog.b(b2));
CollectionExt.a(arrayList, DialogAction.NOTIFICATIONS_ON, !dialog.b(b2));
}
CollectionExt.a(arrayList, DialogAction.CLEAR_HISTORY, z1.L1());
if (z1.I1()) {
CollectionExt.a(arrayList, DialogAction.LEAVE_CHANNEL, !z1.L1());
CollectionExt.a(arrayList, DialogAction.RETURN_TO_CHANNEL, z1.L1());
} else {
CollectionExt.a(arrayList, DialogAction.RETURN, z1.L1());
CollectionExt.a(arrayList, DialogAction.LEAVE, !z1.L1());
CollectionExt.a(arrayList, DialogAction.CLEAR_HISTORY_AND_LEAVE, !z1.L1());
}
}
return arrayList;
}
public final boolean a(Dialog dialog) {
if (dialog.V1() || !dialog.y1()) {
return false;
}
return !dialog.U1() || !ImBridge7.a().a();
}
}
@@ -0,0 +1,15 @@
package com.vk.im.ui.components.common;
public enum MsgAction {
RETRY,
REPLY,
FORWARD,
COPY,
EDIT,
DELETE,
SPAM,
PIN,
UNPIN,
TRANSLATE,
READTO
}
@@ -0,0 +1,43 @@
package com.vk.im.ui.components.common;
import com.vk.core.extensions.CollectionExt;
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.utils.MsgPermissionHelper;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public final class MsgActionHelper {
public static final MsgActionHelper a = new MsgActionHelper();
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) {
if (imConfig != null && dialog != null && collection != null) {
MsgPermissionHelper.a aVar = new MsgPermissionHelper.a(imConfig, dialog, collection);
ArrayList<MsgAction> arrayList = new ArrayList<>();
CollectionExt.a(arrayList, MsgAction.RETRY, MsgPermissionHelper.b.g(aVar));
CollectionExt.a(arrayList, MsgAction.REPLY, MsgPermissionHelper.b.f(aVar));
CollectionExt.a(arrayList, MsgAction.FORWARD, MsgPermissionHelper.b.d(aVar));
CollectionExt.a(arrayList, MsgAction.COPY, MsgPermissionHelper.b.a(aVar));
CollectionExt.a(arrayList, MsgAction.EDIT, MsgPermissionHelper.b.c(aVar));
CollectionExt.a(arrayList, MsgAction.DELETE, MsgPermissionHelper.b.b(aVar));
CollectionExt.a(arrayList, MsgAction.SPAM, MsgPermissionHelper.b.h(aVar));
CollectionExt.a(arrayList, MsgAction.PIN, MsgPermissionHelper.b.e(aVar));
CollectionExt.a(arrayList, MsgAction.UNPIN, MsgPermissionHelper.b.i(aVar));
CollectionExt.a(arrayList, MsgAction.TRANSLATE, true);
CollectionExt.a(arrayList, MsgAction.READTO, true);
return arrayList;
}
return new ArrayList<>();
}
}
@@ -4,18 +4,37 @@ import static ru.vtosters.lite.dnr.DNRModule.hookDNR;
import static ru.vtosters.lite.dnr.DNRModule.hookDNT;
import static ru.vtosters.lite.dnr.DNRModule.isDnrEnabledFor;
import static ru.vtosters.lite.dnr.DNRModule.isDntEnabledFor;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import android.content.Context;
import android.util.Log;
import com.vk.core.network.Network;
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.ui.components.common.DialogAction;
import com.vk.im.ui.components.common.MsgAction;
import com.vk.im.ui.components.viewcontrollers.popup.DelegateMsg;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import ru.vtosters.lite.ui.dialogs.Translate;
public class DNRInjector {
public static void inject(Dialog dialog, List<DialogAction> list) {
int peerId = dialog.getId();
list.add(DialogAction.valueOf("pinmsg"));
list.add(DialogAction.valueOf("unpinmsg"));
if (isDnrEnabledFor(peerId)) {
list.add(DialogAction.valueOf("DNR_OFF"));
} else {
@@ -34,6 +53,10 @@ public class DNRInjector {
hashMap.put(DialogAction.valueOf("DNR_OFF"), getIdentifier("DNR_OFF", "string"));
hashMap.put(DialogAction.valueOf("DNT_ON"), getIdentifier("DNT_ON", "string"));
hashMap.put(DialogAction.valueOf("DNT_OFF"), getIdentifier("DNT_OFF", "string"));
hashMap.put(DialogAction.valueOf("pinmsg"), getIdentifier("pinmsg", "string"));
hashMap.put(DialogAction.valueOf("unpinmsg"), getIdentifier("unpinmsg", "string"));
return hashMap;
}
@@ -60,9 +83,75 @@ public class DNRInjector {
return true;
}
if (action == DialogAction.valueOf("pinmsg")) {
pinnedMsg(id, true);
return true;
} else if (action == DialogAction.valueOf("unpinmsg")) {
pinnedMsg(id, false);
return true;
}
return false;
}
public static LinkedHashMap<MsgAction, DelegateMsg.a.a> injectToHashMapMsg(LinkedHashMap<MsgAction, DelegateMsg.a.a> hashMap) {
hashMap.put(MsgAction.valueOf("TRANSLATE"), new DelegateMsg.a.a(getIdentifier("translator", "string")));
hashMap.put(MsgAction.valueOf("READTO"), new DelegateMsg.a.a(getIdentifier("readto", "string")));
return hashMap;
}
public static boolean onClickMsg(Context context, MsgAction action, Msg msg) {
var text = ((MsgFromUser) msg).f();
var fullMsg = ((MsgFromUser) msg).j2(); // text + reply
var reply = fullMsg.substring(text.length() + 1);
if (action == MsgAction.valueOf("READTO")) {
DNRModule.hookReadStartMsgTo(msg);
return true;
}
var isTextExist = !text.isEmpty() && !text.equals(" ");
var isReplyExist = !reply.isEmpty() && !reply.equals(" ");
if (action == MsgAction.valueOf("TRANSLATE")) {
if (isTextExist && isReplyExist) {
Translate.showTranslatedText(context, text + "\n\nРеплай:\n" + reply);
} else if (isReplyExist) {
Translate.showTranslatedText(context, "Реплай:\n" + reply);
} else if (isTextExist) {
Translate.showTranslatedText(context, text);
} else {
sendToast("Нет текста для перевода");
}
}
return false;
}
public static void pinnedMsg(int dialogid, boolean needToBePinned) {
Thread thread = new Thread(() -> {
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"))
.a();
try {
var response = new OkHttpClient().a(request).execute().a().g();
Log.d("Pins", response);
} catch (IOException e) {
Log.e("Pins", "Error while pinning message", e);
}
} catch (Exception e) {
e.printStackTrace();
}
});
thread.start();
sendToast("Диалог успешно " + (needToBePinned ? "закреплен" : "откреплен"));
}
public static void setDnr(Dialog dialog, boolean value) {
hookDNR(dialog.getId());
}
@@ -4,8 +4,11 @@ import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.ProxyUtils.getApi;
import android.util.Log;
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.messages.Msg;
import java.util.List;
@@ -54,6 +57,12 @@ public class DNRModule {
});
}
public static void hookReadStartMsgTo(Msg dialog) {
Log.d("DNR", "hookReadStartMsgTo: " + dialog.C1() + " " + dialog.v1());
makeRequest("https://" + getApi() + "/method/messages.markAsRead?start_message_id=" + dialog.C1() + "&peer_id=" + dialog.v1() + "&v=5.119&access_token=" + getUserToken(), response -> {
});
}
public static void hookDNR(int peerId) {
mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId));
}
@@ -2,6 +2,7 @@ package ru.vtosters.lite.foaf;
import static android.widget.Toast.LENGTH_SHORT;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getString;
import static ru.vtosters.lite.utils.ProxyUtils.apiproxy;
@@ -100,7 +101,7 @@ public class FoafBase {
a2.setMessage(getString("foafid") + " " + i + getString("foafregdate") + " " + normalHumanDate + getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).setPositiveButton(17039370, null).create().show();
} catch (Exception e) {
e.printStackTrace();
makeText(context, getString("foaferr"), LENGTH_SHORT).show();
makeText(getGlobalContext(), getString("foaferr"), LENGTH_SHORT).show();
}
}
@@ -0,0 +1,39 @@
package ru.vtosters.lite.hooks;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import android.util.Log;
import java.util.Random;
public class DeviceInfoHook{
public static String getDeviceInfo(String input) {
Log.d("DeviceInfoHook", "getDeviceInfo: " + input);
if (getBoolValue("hideDeviceInfo", true)) return "";
return input;
}
public static String getDeviceId(String input) {
Log.d("DeviceInfoHook", "getDeviceId: " + input);
Log.d("DeviceInfoHook", "getDeviceId shuffled: " + shuffle(input));
if (getBoolValue("hideDeviceInfo", true)) return shuffle(input);
return input;
}
public static String shuffle(String string) {
StringBuilder sb = new StringBuilder(string.length());
double rnd;
for (char c: string.toCharArray()) {
rnd = Math.random();
if (rnd < 0.34)
sb.append(c);
else if (rnd < 0.67)
sb.insert(sb.length() / 2, c);
else
sb.insert(0, c);
sb.append(new Random().nextInt(10));
sb.deleteCharAt(0);
}
return sb.toString();
}
}
@@ -463,8 +463,7 @@ public class JsonInjectors {
oldItems = catalog.optJSONArray("sections");
}
if (oldItems != null) {
if (oldItems != null && oldItems.optJSONObject(0).optString("url").contains("general")) {
if (podcastcatalog()) {
var podcasts = fetchCatalogPodcast();
if (podcasts != null) {
@@ -0,0 +1,107 @@
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.savemsgsett;
import android.text.TextUtils;
import android.view.View;
import com.vk.api.internal.MethodCall;
import ru.vtosters.lite.translators.BaseTranslator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.ArrayList;
public class MessagesHook {
public static String injectOwnText(String oldText) {
if (!autotranslate() || TextUtils.isEmpty(oldText))
return oldText;
var instance = BaseTranslator.getInstance();
return replaceMentions(oldText, instance);
}
public static String injectOwnTextAll(String oldText) {
if (!autoalltranslate() || TextUtils.isEmpty(oldText)) {
return oldText;
}
var instance = BaseTranslator.getInstance();
return replaceMentions(oldText, instance);
}
public static String replaceMentions(String oldText, BaseTranslator instance) {
try {
var matcher = Pattern.compile("(\\[(?:club|id|public)\\d+\\|[^]]+\\])|(@[^\\s]+)").matcher(oldText);
var mentionsCount = 0;
var textBuff = new StringBuffer();
var mentions = new ArrayList<String>();
while (matcher.find()) {
mentions.add(matcher.group());
matcher.appendReplacement(textBuff, "vtl_mention" + mentionsCount + ""); ++mentionsCount;
}
matcher.appendTail(textBuff);
var translatedText = instance.getTranslation(textBuff.toString());
var matcherMentions = Pattern.compile("vtl_mention(\\d+)").matcher(translatedText);
var retTextBuff = new StringBuffer();
while (matcherMentions.find()) {
matcherMentions.appendReplacement(retTextBuff, mentions.get(
Integer.parseInt(matcherMentions.group(1))
));
}
matcherMentions.appendTail(retTextBuff);
return retTextBuff.toString();
} catch(Exception e) {
e.printStackTrace();
return instance.getTranslation(oldText);
}
}
public static void onLongClick(View view) {
view.setOnLongClickListener(v -> {
argDialog(v.getContext());
return true;
});
}
public static void injRequest(MethodCall.a req) {
var time = expireTime();
if (time > 0) {
req.a("expire_ttl", time);
if (!savemsgsett()) bombCount = "0";
}
if (isSilentEnabled) {
req.a("silent", 1);
if (!savemsgsett()) isSilentEnabled = false;
}
}
private static int expireTime() {
switch (bombCount) {
case "15s":
return 15;
case "1m":
return 60;
case "5m":
return 300;
case "1h":
return 3600;
case "24h":
return 86400;
default:
return 0;
}
}
}
@@ -3,6 +3,7 @@ package ru.vtosters.lite.hooks;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@@ -52,6 +53,7 @@ public class PhotoViewer {
return true;
}
@SuppressLint("UseCompatLoadingForDrawables")
public static void addMenuItems(AttachmentWithMedia attachment, ActionsPopup.b actionPopup, int i, boolean z) {
actionPopup.a(getIdentifier("search_photo_content", "string"),
ThemesUtils.isDarkTheme()
@@ -0,0 +1,67 @@
package ru.vtosters.lite.hooks;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.vk.newsfeed.holders.BaseFooterHolder;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.Preferences;
public class PostViewHook {
/**
* For displaying child elements with custom direction in rtl container we should remove their, set layout direction and add again */
private static void saveChildDirectionForRlt(ViewGroup container) {
var children = new View[container.getChildCount()];
for (int i = 0; i < container.getChildCount(); i++) {
var child = container.getChildAt(i);
child.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
children[i] = child;
}
container.removeAllViews();
for (View child : children) {
container.addView(child);
}
container.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
}
// res/layout/likes_panel.xml
public static void injectBaseFooterHolder(BaseFooterHolder baseFooterHolder) {
if (!Preferences.isLikesOnRightEnabled())
return;
try {
var container = (ViewGroup) ((RecyclerView.ViewHolder) baseFooterHolder).itemView;
saveChildDirectionForRlt((ViewGroup) container.getChildAt(1));
} catch (Exception e) {
e.printStackTrace();
}
}
// res/layout/photo_viewer_bottom.xml
public static void injectPhotoViewer(View container) {
if (!Preferences.isLikesOnRightEnabled())
return;
try {
var bottomPanel = (ViewGroup) container.findViewById(R.id.photo_viewer_bottom_panel);
saveChildDirectionForRlt(bottomPanel);
} catch (Exception e) {
e.printStackTrace();
}
}
// res/layout/video_bottom_view.xml
public static void injectVideoView(RelativeLayout container) {
if (!Preferences.isLikesOnRightEnabled())
return;
try {
var bottomBar = (ViewGroup) container.findViewById(R.id.bottom_bar);
saveChildDirectionForRlt(bottomBar);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,26 @@
package ru.vtosters.lite.hooks;
import static ru.vtosters.lite.utils.Preferences.dev;
import android.util.Log;
import com.vk.api.internal.MethodCall;
import java.util.LinkedHashMap;
public class RequestDumper{
public static void addParams(MethodCall.a paramslist, String method, LinkedHashMap params, String apiver) {
if (method.contains("execute.getGiftByStickerId")) {
apiver = "5.187";
}
if (dev()) {
Log.d("RequestDumper", "Method: " + method);
Log.d("RequestDumper", "API version: " + apiver);
Log.d("RequestDumper", "Params: " + params);
}
paramslist.a(method);
paramslist.a(params);
paramslist.b(apiver);
}
}
@@ -5,7 +5,6 @@ import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.milkshake;
import static ru.vtosters.lite.utils.Preferences.superapp;
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
import static ru.vtosters.lite.utils.Preferences.videonewcatalog;
import static ru.vtosters.lite.utils.Preferences.vkme;
@@ -34,6 +33,8 @@ import com.vtosters.lite.fragments.y2.VideosFragment;
import com.vtosters.lite.general.fragments.GamesFragment;
import com.vtosters.lite.general.fragments.PhotosFragment;
import ru.vtosters.lite.ui.fragments.VTSettings;
public class StartFragmentHook {
public static Class getStartFragment() {
if (vkme()) {
@@ -55,7 +56,7 @@ public class StartFragmentHook {
case "videos":
return videonewcatalog() ? VideoCatalogFragment.class : VideosFragment.class;
case "settings":
return useNewSettings();
return VTSettings.class;
case "apps":
return AppsFragment.class;
case "discover":
@@ -5,8 +5,10 @@ import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.lite.utils.ThemesUtils.getAttrId;
import static ru.vtosters.lite.utils.ThemesUtils.getBackgroundContent;
import static ru.vtosters.lite.utils.ThemesUtils.getBackgroundPage;
import static ru.vtosters.lite.utils.ThemesUtils.getColorFromAttr;
import static ru.vtosters.lite.utils.ThemesUtils.getHeaderBackground;
import static ru.vtosters.lite.utils.ThemesUtils.getHeaderText;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
@@ -59,8 +61,13 @@ public class VKUIHook {
.replace("%header_text%", hex(getHeaderText()))
.replace("%accent%", hex(getAccentColor()))
.replace("%background_page%", hex(getBackgroundPage()))
.replace("%content_tint_background%", hex(getColorFromAttr(getAttrId("content_tint_background"))))
.replace("%button_primary_background%", hex(getColorFromAttr(getAttrId("button_primary_background"))))
.replace("%button_outline_foreground%", hex(getColorFromAttr(getAttrId("button_outline_foreground"))))
.replace("%button_outline_border%", hex(getColorFromAttr(getAttrId("button_outline_border"))))
.replace("%text_primary%", hex(getTextAttr()));
loadedCSSAmoled = load("vt_ui_oled.css");
isLoaded = true;
}
@@ -1,5 +1,5 @@
package ru.vtosters.lite.music;
import static java.lang.String.*;
import static java.lang.String.valueOf;
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
@@ -9,6 +9,8 @@ import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import android.util.Log;
import com.vk.dto.music.MusicTrack;
import org.json.JSONException;
import org.json.JSONObject;
@@ -22,16 +24,15 @@ import ru.vtosters.lite.net.NetCallback;
import ru.vtosters.lite.net.NetClient;
import ru.vtosters.lite.net.NetRequest;
import ru.vtosters.lite.net.NetResponse;
import ru.vtosters.lite.utils.Preferences;
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,21 +60,35 @@ 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());
}
});
}
private static String signMD5(Map<String, String> map){
public static void grabMusicTrack(MusicTrack musictrack) {
var uid = musictrack.y1();
var artist = musictrack.C;
var title = musictrack.f;
var duration = musictrack.h;
if (uid.isEmpty() || artist == null || artist.isEmpty() || title == null || title.isEmpty() || duration == 0) {
Log.d("Scrobbler", "grabTrackInfo: " + "Empty track, info: " + artist + " - " + title + " - " + duration + " - " + uid);
return;
}
scrobbleTrack(duration, artist, title, uid);
}
private static String signMD5(Map<String, String> map) {
var sb = new StringBuilder();
for (Map.Entry<String, String> entry : map.entrySet()) {
@@ -86,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;
@@ -100,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);
@@ -120,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;
@@ -136,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;
@@ -0,0 +1,54 @@
package ru.vtosters.lite.translators;
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 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, String tl);
@NonNull
public final String getTranslation(String text) {
var val = cache.get(text);
if (val != null)
return val;
var translation = translate(text, getToLanguage());
cache.put(text, translation);
return translation;
}
public static String getToLanguage() {
var lang = preferences.getString("lang_target", "system");
var systemLang = Locale.getDefault().getLanguage();
if (lang.isEmpty() || lang.equals(systemLang) || lang.equals("system"))
return systemLang;
return lang;
}
public static BaseTranslator getInstance() {
switch (AndroidUtils.getPreferences().getInt("translator", 0)) {
case YANDEX:
return YandexTranslator.getInstance();
case GOOGLE:
return GoogleTranslator.getInstance();
case DEEPL:
return DeepLTranslator.getInstance();
}
return null;
}
}
@@ -0,0 +1,134 @@
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
public String translate(String text, String tl) {
try {
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
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,74 @@
package ru.vtosters.lite.translators;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import org.json.JSONObject;
import java.net.URLEncoder;
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
public String translate(String text, String tl) {
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=" + tl +
"&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;
}
}
@@ -0,0 +1,58 @@
package ru.vtosters.lite.translators;
import android.util.Log;
import androidx.annotation.NonNull;
import org.json.JSONObject;
import java.net.URLEncoder;
import java.util.UUID;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
public class YandexTranslator extends BaseTranslator {
private static final OkHttpClient client = new OkHttpClient();
private static final String uuid = UUID.randomUUID().toString().replace("-", "");
private static YandexTranslator instance;
public static YandexTranslator getInstance() {
if (instance == null)
instance = new YandexTranslator();
return instance;
}
@NonNull
@Override
public String translate(String text, String tl) {
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=" + tl + "&text=" + URLEncoder.encode(text, "UTF-8")))
.a();
var payload = client.a(request).execute().a().g();
var json = new JSONObject(payload);
if (!json.has("text") && json.has("message")) {
Log.d("YandexTranslator", json.getString("message"));
return text;
}
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 (Throwable e) {
e.printStackTrace();
}
return text;
}
}
@@ -5,7 +5,6 @@ import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.milkshake;
import static ru.vtosters.lite.utils.Preferences.superapp;
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
import static ru.vtosters.lite.utils.Preferences.videonewcatalog;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.Preferences.vkme_notifs;
@@ -43,6 +42,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import ru.vtosters.lite.ui.fragments.VTSettings;
import ru.vtosters.lite.ui.items.DockBarTab;
import ru.vtosters.lite.utils.AndroidUtils;
@@ -261,7 +261,7 @@ public class DockBarEditorManager {
R.drawable.ic_settings_outline_28,
R.string.menu_settings,
R.id.menu_settings,
useNewSettings());
VTSettings.class);
}
}
}
@@ -0,0 +1,132 @@
package ru.vtosters.lite.ui.dialogs;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.TypedValue;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.SwitchCompat;
import com.vk.core.dialogs.alert.VkAlertDialog;
import ru.vtosters.lite.utils.LayoutUtils;
public class MessageSettings {
public static Boolean isSilentEnabled = false;
public static String bombCount = "0";
@SuppressLint("SetTextI18n")
public static void argDialog(Context context) {
LinearLayout mContainer = new LinearLayout(context);
RadioGroup rg = new RadioGroup(context);
rg.setOrientation(LinearLayout.VERTICAL);
rg.setPadding(dp2px(18f), dp2px(12f), dp2px(18f), 0);
RadioButton zero = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton one = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton two = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton three = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton four = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton five = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
rg.addView(zero);
rg.addView(one);
rg.addView(two);
rg.addView(three);
rg.addView(four);
rg.addView(five);
zero.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
one.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
two.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
three.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
four.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
five.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
zero.setText("Отключить");
one.setText("15 секунд");
two.setText("1 минута");
three.setText("5 минут");
four.setText("1 час");
five.setText("24 часа");
zero.setTextColor(getTextAttr());
one.setTextColor(getTextAttr());
two.setTextColor(getTextAttr());
three.setTextColor(getTextAttr());
four.setTextColor(getTextAttr());
five.setTextColor(getTextAttr());
switch (bombCount) {
case "15s":
one.setChecked(true);
break;
case "1m":
two.setChecked(true);
break;
case "5m":
three.setChecked(true);
break;
case "1h":
four.setChecked(true);
break;
case "24h":
five.setChecked(true);
break;
default:
zero.setChecked(true);
break;
}
@SuppressLint("UseSwitchCompatOrMaterialCode")
var silentSwitch = new SwitchCompat(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_Switch));
silentSwitch.setText("Бесшумные сообщения");
silentSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
silentSwitch.setTextColor(getTextAttr());
silentSwitch.setChecked(isSilentEnabled);
silentSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
isSilentEnabled = isChecked;
});
silentSwitch.setPadding(dp2px(24f), dp2px(12f), dp2px(18f), dp2px(12f));
mContainer.setLayoutParams(LayoutUtils.createLinear(-1, -1));
mContainer.setOrientation(LinearLayout.VERTICAL);
mContainer.addView(rg, LayoutUtils.createLinear(-1, -2));
mContainer.addView(silentSwitch, LayoutUtils.createLinear(-1, -2));
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
builder.setTitle("Настройки отправки");
builder.setMessage("Выберите время исчезновения сообщения");
builder.setCancelable(true);
builder.setNegativeButton("Отмена", null);
builder.setView(mContainer);
builder.setPositiveButton("Применить", (dialog, which) -> {
var checked = rg.getCheckedRadioButtonId();
if (checked == zero.getId()) {
bombCount = "0";
} else if (checked == one.getId()) {
bombCount = "15s";
} else if (checked == two.getId()) {
bombCount = "1m";
} else if (checked == three.getId()) {
bombCount = "5m";
} else if (checked == four.getId()) {
bombCount = "1h";
} else if (checked == five.getId()) {
bombCount = "24h";
}
});
builder.show();
}
}
@@ -0,0 +1,44 @@
package ru.vtosters.lite.ui.dialogs;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.vk.core.dialogs.alert.VkAlertDialog;
import ru.vtosters.lite.translators.BaseTranslator;
public class Translate {
public static void showTranslatedText(Context context, String text) {
new Thread(() -> {
try {
var translation = BaseTranslator.getInstance().getTranslation(text);
new Handler(Looper.getMainLooper()).post(() -> {
showDialog(context, translation);
});
} catch (Exception e) {
Log.e("Translate", e + "");
}
}).start();
}
private static void showDialog(Context context, String text) {
VkAlertDialog.Builder alertDialog = new VkAlertDialog.Builder(context);
alertDialog.setTitle("Переводчик");
alertDialog.setMessage(text);
alertDialog.setPositiveButton("Закрыть", (dialog, which) -> {
dialog.cancel();
});
alertDialog.setNeutralButton("Скопировать", (dialog, which) -> {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("Copied Text", text);
clipboard.setPrimaryClip(clip);
sendToast("Скопировано в буфер обмена");
});
var alert = alertDialog.create();
alert.show();
}
}
@@ -1,6 +1,8 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.Preferences.copyright_post;
import static ru.vtosters.lite.utils.Preferences.offline;
import android.content.Context;
import android.content.Intent;
@@ -22,6 +24,13 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
private void prefs() {
findPreference("officialnewssett").setOnPreferenceClickListener(new openofficialsett());
findPreference("cringecopyright").setEnabled(!copyright_post());
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
findPreference("cringecopyright").setEnabled(!copyright_post());
return super.onPreferenceTreeClick(preference);
}
public class openofficialsett implements Preference.OnPreferenceClickListener {
@@ -20,6 +20,7 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
private void prefs() {
findPreference("stories").setOnPreferenceClickListener(new restart());
findPreference("swipe").setOnPreferenceClickListener(new restart());
findPreference("is_likes_on_right").setOnPreferenceClickListener(new restart());
}
public boolean restart(Preference preference) {
@@ -1,10 +1,12 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.music.Scrobbler.isLoggedIn;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.lite.utils.ThemesUtils.getAlertStyle;
@@ -15,6 +17,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.EditText;
@@ -25,10 +28,15 @@ import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.network.Network;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import java.io.IOException;
import java.util.Arrays;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import ru.vtosters.lite.downloaders.VideoDownloader;
import ru.vtosters.lite.music.Scrobbler;
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
@@ -107,6 +115,30 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(getAccentColor());
}
public static void deleteVideoHistory() {
Thread thread = new Thread(() -> {
try {
var request = new Request.a()
.b("https://api.vk.com/method/" + "video.clearViewingHistoryRecords" + "?https=1" + "&access_token=" + getUserToken() + "&v=5.187")
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"))
.a();
try {
var response = new OkHttpClient().a(request).execute().a().g();
Log.d("VideoHistory", response);
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
});
thread.start();
sendToast("История просмотра видео очищена");
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
@@ -116,6 +148,10 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
private void prefs() {
findPreference("download_video").setOnPreferenceClickListener(new MediaFragment.download());
findPreference("clearvideohistory").setOnPreferenceClickListener(preference -> {
deleteVideoHistory();
return true;
});
findPreference("dateformat").setOnPreferenceChangeListener(new MediaFragment.restart());
findPreference("lastfm_auth").setOnPreferenceClickListener(preference -> {
if (isLoggedIn()) {
@@ -1,17 +1,26 @@
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;
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 +36,37 @@ 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("autotranslate").setEnabled(!autoalltranslate());
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;
});
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
findPreference("autotranslate").setEnabled(!autoalltranslate());
return super.onPreferenceTreeClick(preference);
}
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,5 @@
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;
@@ -17,8 +15,6 @@ import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.CacheUtils.humanReadableByteCountBin;
import static ru.vtosters.lite.utils.GmsUtils.isGmsInstalled;
import static ru.vtosters.lite.utils.ImageUtils.getDrawableFromUrl;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
import static ru.vtosters.lite.utils.Preferences.DoNotUseOldIcons;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.devmenu;
import static ru.vtosters.lite.utils.Preferences.disableSettingsSumms;
@@ -50,7 +46,9 @@ import com.vk.balance.BalanceFragment;
import com.vk.navigation.Navigator;
import com.vk.notifications.settings.NotificationsSettingsFragment;
import com.vk.webapp.fragments.PrivacyFragment;
import com.vtosters.lite.MainActivity;
import com.vtosters.lite.auth.VKAccountManager;
import com.vtosters.lite.auth.VKAuth;
import com.vtosters.lite.fragments.money.music.control.subscription.MusicSubscriptionControlFragment;
import com.vtosters.lite.fragments.n2.SettingsDebugFragment;
import com.vtosters.lite.fragments.w2.BlacklistFragment;
@@ -149,14 +147,22 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
this.addPreferencesFromResource(vtosterXml);
addPreferenceDrawable(this, "", getUsername(), hasVerification() ? AndroidUtils.getString("thanksfordonate") : AndroidUtils.getString("getdonate"), getDrawableFromUrl(getUserPhoto(), "ic_user_circle_outline_28", true, true), preference -> {
logout();
restartApplication();
try {
VKAuth.a("logout", false);
} catch (Exception ignored) { }
var intent = new Intent(getContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
return false;
});
addPreferenceCategory(this, AndroidUtils.getString("vtsettdarktheme"));
addMaterialSwitchPreference(this, "isdark", AndroidUtils.getString("vtsettdarktheme"), "", !DoNotUseOldIcons() ? "ic_palette_24" : "ic_palette_outline_28", false, (preference, o) -> {
addMaterialSwitchPreference(this, "isdark", AndroidUtils.getString("vtsettdarktheme"), "", "ic_palette_outline_28", false, (preference, o) -> {
boolean value = (boolean) o;
if (!value) { // inverted
@@ -170,7 +176,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
if (Build.VERSION.SDK_INT >= 28 && false) { // TODO refactoring system theme
addMaterialSwitchPreference(this, "systemtheme", AndroidUtils.getString("appearance_theme_use_system"), AndroidUtils.getString("appearance_theme_use_system_summary"), !DoNotUseOldIcons() ? "ic_recent_24" : "ic_recent_outline_28", true, (preference, o) -> {
addMaterialSwitchPreference(this, "systemtheme", AndroidUtils.getString("appearance_theme_use_system"), AndroidUtils.getString("appearance_theme_use_system_summary"), "ic_recent_outline_28", true, (preference, o) -> {
boolean value = (boolean) o;
edit().putBoolean("systemtheme", value).commit();
@@ -191,7 +197,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (devmenu()) {
addPreferenceCategory(this, AndroidUtils.getString("sett_debug"));
addPreference(this, "", AndroidUtils.getString("sett_debug"), "", !DoNotUseOldIcons() ? "ic_bug_24" : "ic_bug_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("sett_debug"), "", "ic_bug_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(SettingsDebugFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -199,7 +205,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addMaterialSwitchPreference(this, "ssl", AndroidUtils.getString("debug_developer_force_ssl"), AndroidUtils.getString("debug_developer_force_ssl_summary"), !DoNotUseOldIcons() ? "ic_globe_20" : "ic_globe_outline_28", true, (preference, o) -> {
addMaterialSwitchPreference(this, "ssl", AndroidUtils.getString("debug_developer_force_ssl"), AndroidUtils.getString("debug_developer_force_ssl_summary"), "ic_globe_outline_28", true, (preference, o) -> {
boolean value = (boolean) o;
edit().putBoolean("ssl", value).commit();
return true;
@@ -208,7 +214,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("vtsettaccount"));
addPreference(this, "", AndroidUtils.getString("vkconnect"), "", !DoNotUseOldIcons() ? "ic_tags_24" : "ic_user_circle_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vkconnect"), "", "ic_user_circle_outline_28", preference -> {
Context context = getContext();
VKUIwrapper.officalLinks("account");
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
@@ -217,7 +223,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("privacy_settings"), "", !DoNotUseOldIcons() ? "ic_privacy_24" : "ic_privacy_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("privacy_settings"), "", "ic_privacy_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(PrivacyFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -225,7 +231,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("sett_account"), "", !DoNotUseOldIcons() ? "ic_user_24" : "ic_user_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("sett_account"), "", "ic_user_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(SettingsAccountFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -234,7 +240,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
if (isVKTester()) {
addPreference(this, "", AndroidUtils.getString("bugs"), "", !DoNotUseOldIcons() ? "ic_bug_24" : "ic_bug_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("bugs"), "", "ic_bug_outline_28", preference -> {
Context context = getContext();
VKUIwrapper.officalLinks("bugs");
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
@@ -244,7 +250,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
}
addPreference(this, "", AndroidUtils.getString("vtssfs"), ssfs, !DoNotUseOldIcons() ? "ic_link_24" : "ic_link_circle_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtssfs"), ssfs, "ic_link_circle_outline_28", preference -> {
Context context = getContext();
VKUIwrapper.setLink(SSFSUtils.getSSFSLink());
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
@@ -255,7 +261,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("notification_settings"));
addPreference(this, "", AndroidUtils.getString("sett_general"), "", !DoNotUseOldIcons() ? "ic_settings_24" : "ic_settings_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("sett_general"), "", "ic_settings_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(SettingsGeneralFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -263,7 +269,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("blacklist"), "", !DoNotUseOldIcons() ? "ic_users_24" : "ic_users_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("blacklist"), "", "ic_users_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(BlacklistFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -271,7 +277,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("sett_notifications"), "", !DoNotUseOldIcons() ? "ic_notification_24" : "ic_menu_notification_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("sett_notifications"), "", "ic_menu_notification_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(NotificationsSettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -280,7 +286,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
if (VKAccountManager.d().isMusicSubs()) {
addPreference(this, "", AndroidUtils.getString("subscription_music"), "", !DoNotUseOldIcons() ? "ic_music_24" : "ic_music_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("subscription_music"), "", "ic_music_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MusicSubscriptionControlFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -289,7 +295,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
}
addPreference(this, "", AndroidUtils.getString("votes"), "", !DoNotUseOldIcons() ? "ic_coins_24" : "ic_coins_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("votes"), "", "ic_coins_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(BalanceFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -300,7 +306,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("vtsettmod"));
if (!vkme()) {
addPreference(this, "", AndroidUtils.getString("vtlfeed"), feedsumm, !DoNotUseOldIcons() ? "ic_newsfeed_24" : "ic_newsfeed_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlfeed"), feedsumm, "ic_newsfeed_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(FeedFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -308,7 +314,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("dockbar_editor"), docksumm, !DoNotUseOldIcons() ? "ic_list_24" : "ic_list_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("dockbar_editor"), docksumm, "ic_list_outline_28", preference -> {
Context context = getContext();
Intent intent = new Navigator(DockBarEditorFragment.class).b(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -317,7 +323,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
if (milkshake() && superapp()) {
addPreference(this, "", "Редактор Superapp", superapp, "ic_explore_outline_28", (preference) -> {
addPreference(this, "", AndroidUtils.getString("superapp_editor"), superapp, "ic_services_outline_28", (preference) -> {
Context context = getContext();
Intent intent = new Navigator(SuperAppEditorFragment.class).b(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -326,7 +332,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
}
} else {
addPreference(this, "", "Внимание!", "Некоторые пункты настроек были скрыты из-за режима VK Me \n\nДля отключения режима перейдите в настройки Сообщений", !DoNotUseOldIcons() ? "ic_about_24" : "ic_about_outline_28", preference -> false);
addPreference(this, "", "Внимание!", "Некоторые пункты настроек были скрыты из-за режима VK Me \n\nДля отключения режима перейдите в настройки Сообщений", "ic_about_outline_28", preference -> false);
}
addPreference(this, "", AndroidUtils.getString("vtlmedia"), mediasumm, "ic_media_outline_28", preference -> {
@@ -337,7 +343,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtlmessages"), msgsumm, !DoNotUseOldIcons() ? "ic_message_24" : "ic_message_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlmessages"), msgsumm, "ic_message_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MessagesFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -345,7 +351,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtlactivity"), activitysumm, !DoNotUseOldIcons() ? "ic_write_24" : "ic_write_outline_28_new_accent", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlactivity"), activitysumm, "ic_write_outline_28_new_accent", preference -> {
Context context = getContext();
Intent a2 = new Navigator(ActivityFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -353,7 +359,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtlthemes"), themessumm, !DoNotUseOldIcons() ? "ic_palette_24" : "ic_write_outline_24", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlthemes"), themessumm, "ic_write_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(ThemesFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -361,7 +367,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtltgs"), tgssumm, !DoNotUseOldIcons() ? "ic_telegram_24" : "ic_telegram_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtltgs"), tgssumm, "ic_telegram_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(StickersFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -369,7 +375,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtlinterface"), interfacesumm, !DoNotUseOldIcons() ? "ic_interface_24" : "ic_interface_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlinterface"), interfacesumm, "ic_interface_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(InterfaceFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -377,7 +383,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtlproxy"), proxysumm, !DoNotUseOldIcons() ? "ic_globe_20" : "ic_globe_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlproxy"), proxysumm, "ic_globe_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(ProxySettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -385,7 +391,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("vtlother"), othersumm, !DoNotUseOldIcons() ? "ic_more_24" : "ic_more_horizontal_28", preference -> {
addPreference(this, "", AndroidUtils.getString("vtlother"), othersumm, "ic_more_horizontal_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(OtherFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -395,7 +401,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("vtsettaboutmod"));
addPreference(this, "", AndroidUtils.getString("menu_about"), about, !DoNotUseOldIcons() ? "ic_about_24" : "ic_about_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("menu_about"), about, "ic_about_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(AboutAppFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -403,17 +409,17 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return false;
});
addPreference(this, "", AndroidUtils.getString("opencommit"), "", !DoNotUseOldIcons() ? "ic_link_24" : "ic_link_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("opencommit"), "", "ic_link_outline_28", preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
return false;
});
addPreference(this, "", AndroidUtils.getString("vtfaq"), AndroidUtils.getString("vtfaqsumm"), !DoNotUseOldIcons() ? "ic_help_24" : "ic_help_outline_24", preference -> {
addPreference(this, "", AndroidUtils.getString("vtfaq"), AndroidUtils.getString("vtfaqsumm"), "ic_help_outline_28", preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
return false;
});
addPreference(this, "", AndroidUtils.getString("reportbug"), AndroidUtils.getString("reportbugsumm"), !DoNotUseOldIcons() ? "ic_bug_24" : "ic_bug_outline_28", preference -> {
addPreference(this, "", AndroidUtils.getString("reportbug"), AndroidUtils.getString("reportbugsumm"), "ic_bug_outline_28", preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
return false;
});
@@ -421,7 +427,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (isValidSignature()) {
addPreferenceCategory(this, AndroidUtils.getString("updates"));
addPreference(this, "", AndroidUtils.getString("checkforupdates"), "", "ic_download_outline_24", preference -> {
addPreference(this, "", AndroidUtils.getString("checkforupdates"), "", "ic_download_outline_28", preference -> {
OTADialog.checkUpdates(getActivity());
return false;
});
@@ -1,53 +1,36 @@
package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getApplicationName;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.VERSIONNAME;
import static ru.vtosters.lite.utils.Preferences.devmenu;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import static ru.vtosters.lite.utils.Preferences.oldabout;
import android.content.Context;
import com.vk.about.Items;
import com.vk.about.Items1;
import com.vk.about.Items2;
import android.view.View;
import java.io.IOException;
import java.util.List;
import java.util.Scanner;
public class About {
public static void injectAbout(List<Items2> list) {
list.clear();
list.add(new Items1());
if (!oldabout()) {
list.add(new Items(21, getIdentifier("opencommit", "string")));
list.add(new Items(8, getIdentifier("tgchannel", "string")));
list.add(new Items(9, getIdentifier("tgchat", "string")));
list.add(new Items(16, getIdentifier("vtfaq", "string")));
list.add(new Items(19, getIdentifier("vtsite", "string")));
list.add(new Items(20, getIdentifier("donate", "string")));
list.add(new Items(17, getIdentifier("vkgroup", "string")));
list.add(new Items(18, getIdentifier("sett_debug", "string")));
return;
}
list.add(new Items(0, getIdentifier("about_app_feedback", "string")));
list.add(new Items(1, getIdentifier("about_app_estimate", "string")));
list.add(new Items(2, getIdentifier("about_app_privacy", "string")));
list.add(new Items(5, getIdentifier("about_app_cookie", "string")));
list.add(new Items(3, getIdentifier("about_app_terms_to_use", "string")));
list.add(new Items(4, getIdentifier("about_app_license", "string")));
list.add(new Items(6, getIdentifier("about_app_data_protect", "string")));
list.add(new Items(8, getIdentifier("sett_debug", "string")));
}
public static String getBuildNumber() {
return getBuild(getGlobalContext(), "version.properties");
}
public static void injectToToolBar(View view) {
view.setOnLongClickListener(v -> {
if (devmenu()) {
sendToast("Меню для разработчиков уже активировано");
} else {
edit().putBoolean("devmenu", true).apply();
sendToast("Меню для разработчиков активировано");
}
return true;
});
}
public static String getCommitLink() {
return "https://git.maki.su/gdlbo/lite/commit/" + getBuild(getGlobalContext(), "version.properties"); // https://github.com/vtosters/lite/commit/ github repo
}
@@ -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);
@@ -44,7 +44,7 @@ public class CacheUtils {
size = IOUtils.getDirSize(getGlobalContext().getCacheDir());
if (size >= getSizeForDelete()) {
if (dev()) sendToast("Кэш очищен");
if (dev()) sendToast("Кеш очищен");
deleteCache();
size = 0;
}
@@ -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;
@@ -10,7 +10,6 @@ import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
import static ru.vtosters.lite.utils.ProxyUtils.setProxy;
import static ru.vtosters.lite.utils.SignatureChecker.validateAppSignature;
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
import static ru.vtosters.lite.utils.ThemesUtils.systemThemeChanger;
import static ru.vtosters.lite.utils.VTVerifications.isPrometheus;
import static ru.vtosters.lite.utils.VTVerifications.isVerified;
@@ -21,12 +20,9 @@ import android.content.pm.PackageManager;
import android.preference.PreferenceManager;
import com.vtosters.lite.data.Users;
import com.vtosters.lite.fragments.SettingsListFragment;
import java.security.NoSuchAlgorithmException;
import ru.vtosters.lite.ui.fragments.VTSettings;
public class Preferences {
public static SharedPreferences preferences = getGlobalContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
public static String VERSIONNAME = "Beta";
@@ -37,7 +33,6 @@ public class Preferences {
setProxy();
reloadMessagesList();
LifecycleUtils.registerActivities(application);
systemThemeChanger(null);
getInstance().autoCleaningCache();
} // VK Init
@@ -66,10 +61,6 @@ public class Preferences {
return getBoolValue("opusmodule", true);
}
public static boolean DoNotUseOldIcons() {
return true;
}
public static boolean systemtheme() {
return false; //getBoolValue("systemtheme", true) && VERSION.SDK_INT >= 28;
}
@@ -142,11 +133,6 @@ public class Preferences {
return getBoolValue("foaf", false);
}
public static Class useNewSettings() {
boolean bool = getBoolValue("useNewSettings", true);
return bool ? VTSettings.class : SettingsListFragment.class;
}
public static boolean VKUI_INJ() {
return getBoolValue("VKUI_INJ", true);
}
@@ -195,6 +181,10 @@ public class Preferences {
return getBoolValue("miniapps", true);
}
public static boolean savemsgsett() {
return getBoolValue("savemsgsett", false);
}
public static boolean friendsblock() {
return getBoolValue("friendsblock", false);
}
@@ -263,6 +253,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);
}
@@ -349,6 +348,10 @@ public class Preferences {
return isPrometheus(AccountManagerUtils.getUserId());
}
public static boolean isLikesOnRightEnabled() {
return getBoolValue("is_likes_on_right", false);
}
public static long getSizeForDelete() {
switch (getPrefsValue("clearcache")) {
case "100mb":
@@ -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();
}
}