Merge branch 'vtosters:vtl-remaster' into vtl-remaster
This commit is contained in:
@@ -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")));
|
||||
}
|
||||
}
|
||||
@@ -98,9 +98,9 @@ public final class DialogActionsHelper {
|
||||
|
||||
DNRInjector.inject(dialog, arrayList);
|
||||
|
||||
if (dialog.hasUnread()) {
|
||||
arrayList.add(DialogAction.MARK_AS_READ);
|
||||
}
|
||||
// if (dialog.hasUnread()) {
|
||||
arrayList.add(DialogAction.MARK_AS_READ);
|
||||
// }
|
||||
|
||||
if (!dialog.W1()) {
|
||||
arrayList.add(DialogAction.CREATE_SHORTCUT);
|
||||
|
||||
@@ -10,5 +10,6 @@ public enum MsgAction {
|
||||
SPAM,
|
||||
PIN,
|
||||
UNPIN,
|
||||
TRANSLATE
|
||||
TRANSLATE,
|
||||
READTO
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public final class MsgActionHelper {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class DNRInjector {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -104,6 +105,11 @@ public class DNRInjector {
|
||||
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(" ");
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import static ru.vtosters.lite.ui.dialogs.MessageSettings.bombCount;
|
||||
import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
|
||||
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.autotranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.savemsgsett;
|
||||
|
||||
import android.text.TextUtils;
|
||||
@@ -15,18 +14,56 @@ 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;
|
||||
return BaseTranslator.getInstance().getTranslation(oldText);
|
||||
var instance = BaseTranslator.getInstance();
|
||||
|
||||
return replaceMentions(oldText, instance);
|
||||
}
|
||||
|
||||
public static String injectOwnTextAll(String oldText) {
|
||||
if (!autoalltranslate() || TextUtils.isEmpty(oldText)) {
|
||||
return oldText;
|
||||
}
|
||||
return BaseTranslator.getInstance().getTranslation(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) {
|
||||
|
||||
@@ -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,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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -348,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":
|
||||
|
||||
Reference in New Issue
Block a user