Skip to content

Commit

Permalink
Experimental proguard config with hooks refactoring (#1323)
Browse files Browse the repository at this point in the history
fixed telegram stickers issue
speedup webview coloring
refactored VKUIHook
fixed duplication of eruda
added a check for duplication of adding styles for coloring vkui
  • Loading branch information
gdlbo authored May 22, 2023
1 parent 8244b31 commit 08dae9b
Show file tree
Hide file tree
Showing 549 changed files with 2,367 additions and 2,197 deletions.
4 changes: 3 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
-repackageclasses
-allowaccessmodification
-optimizations
-optimizationpasses 5
-keepattributes SourceFile, LineNumberTable

-keep,allowoptimization class ru.vtosters.lite.** {
-keep,allowoptimization class ru.vtosters.hooks.**, ru.vtosters.lite.utils.AndroidUtils, ru.vtosters.lite.utils.NetworkUtils, ru.vtosters.lite.utils.CrashReporter, ru.vtosters.lite.ui.activities.**, ru.vtosters.lite.services.**, ru.vtosters.lite.ui.fragments.**, ru.vtosters.lite.themes.**, ru.vtosters.lite.music.hook.**, ru.vtosters.lite.music.cache.injectors.**, ru.vtosters.lite.ui.wallpapers.NativeEffects, com.aefyr.tsg.g2.TelegramStickersService {
public <fields>;
public <methods>;
public <init>(...);
}

-keep class com.vtosters.lite.** { *; }
-keep class com.vk.** { *; }
-keep class bruhcollective.itaysonlab.libvkx.client.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import java.util.List;

import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
import static ru.vtosters.hooks.other.Preferences.isValidSignature;

public class LibVKXClient {
@SuppressLint("StaticFieldLeak")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/vk/api/audio/AudioGetLyrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.json.JSONObject;
import ru.vtosters.lite.music.Genius;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.hooks.other.Preferences;

import java.util.ArrayList;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/vk/core/extensions/TextViewExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import b.h.v.TextViewTextChangeEvent;
import b.h.v.TextViewTextChangeEventObservable;
import com.vk.core.util.ContextExtKt;
import ru.vtosters.lite.utils.ThemesUtils;
import ru.vtosters.hooks.other.ThemesUtils;

public final class TextViewExt {
public static void a(TextView textView, Drawable drawable) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/vk/core/utils/VerifyInfoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.vk.dto.common.VerifyInfo;
import com.vk.extensions.ViewExtKt;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.ThemesUtils;
import ru.vtosters.hooks.other.ThemesUtils;


public final class VerifyInfoHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.vk.im.engine.models.groups.Group;
import com.vk.im.engine.utils.DialogPermissionHelper;
import com.vk.im.ui.p.ImBridge7;
import ru.vtosters.lite.dialogs.DialogMenuInjectors;
import ru.vtosters.hooks.DialogMenuInjectors;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.vtosters.lite.R;
import kotlin.TypeCastException;
import kotlin.jvm.internal.Intrinsics;
import ru.vtosters.lite.hooks.CallsHook;
import ru.vtosters.hooks.CallsHook;

public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> {
public static final a I = new a();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.vk.im.ui.views.avatars.StoryBorderView;

import static com.vk.im.ui.d.vkim_administration_title;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.hooks.other.ThemesUtils.getAccentColor;

public class DialogItemView extends ViewGroup {
private final int B;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.graphics.Bitmap.CompressFormat;
import android.os.Build;
import android.util.Log;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.hooks.other.Preferences;

import java.io.File;
import java.io.FileOutputStream;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/vk/music/view/x/LyricsHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.vtosters.lite.ui.MusicErrorViewHelper;
import com.vtosters.lite.ui.holder.RecyclerHolder;
import ru.vtosters.lite.music.Genius;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.hooks.other.Preferences;

import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/vk/sharing/view/TargetImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import com.vk.navigation.NavigatorKeys;
import com.vtosters.lite.R;
import com.vtosters.lite.a0;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.hooks.other.Preferences;

import java.util.Arrays;

import static b.h.z.f.roboto_medium;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.hooks.other.ThemesUtils.getAccentColor;

@UiThread
public class TargetImageView extends VKMultiImageView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.vtosters.lite.R;
import me.grishka.appkit.utils.V;

import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.ThemesUtils.getCSTDock;
import static ru.vtosters.hooks.other.Preferences.vkme;
import static ru.vtosters.hooks.other.ThemesUtils.getCSTDock;

public class BottomNavigationItemView extends FrameLayout implements MenuView.ItemView {
private final TextView mSmallLabel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package ru.vtosters.lite.utils;
package ru.vtosters.hooks;

import android.view.View;
import com.vtosters.lite.R;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.VersionReader;

import static ru.vtosters.hooks.other.Preferences.devmenu;
import static ru.vtosters.hooks.other.Preferences.getBuildName;
import static ru.vtosters.lite.utils.AndroidUtils.getApplicationName;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.devmenu;
import static ru.vtosters.lite.utils.Preferences.getBuildName;

public class About {
public class AboutHook {
public static void inject(View view) {
view.setOnLongClickListener(v -> {
if (devmenu()) {
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/ru/vtosters/hooks/AdBlockHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ru.vtosters.hooks;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;

public class AdBlockHook {
public static JSONObject discoverInject(JSONObject json) throws JSONException {
return NewsFeedFiltersUtils.discoverInject(json);
}

public static JSONArray feedInject(JSONArray items) {
return NewsFeedFiltersUtils.feedInject(items);

}

public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) throws JSONException {
return NewsFeedFiltersUtils.storiesads(json, isDeleteFix);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ru.vtosters.lite.hooks;
package ru.vtosters.hooks;

import b.h.g.g.BuildInfo;

import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;

public class AppVerHook {
public static int appBuild() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.vtosters.lite.hooks;
package ru.vtosters.hooks;

import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;

public class BusinessNotifHook {
public static boolean hook(boolean i) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.vtosters.lite.hooks;
package ru.vtosters.hooks;

import android.content.Context;
import android.content.Intent;
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/ru/vtosters/hooks/CatalogsHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ru.vtosters.hooks;

import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.music.catalog.inject.CatalogJsonInjector;

public class CatalogsHook {
public static JSONObject injectCatalogGetAudio(JSONObject json) {
try {
return CatalogJsonInjector.music(json);
} catch (JSONException e) {
return json;
}
}

public static JSONObject injectCatalogGetAudioArtist(JSONObject json) {
try {
return CatalogJsonInjector.fixArtists(json);
} catch (JSONException e) {
return json;
}
}

public static JSONObject injectCatalogGetSection(JSONObject json) {
return CatalogJsonInjector.injectIntoCatalogs(json);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.vtosters.lite.hooks;
package ru.vtosters.hooks;

import android.app.Activity;
import android.content.Context;
Expand All @@ -17,11 +17,11 @@
import java.util.List;
import java.util.Objects;

import static ru.vtosters.lite.dialogs.DialogHeaderInjector.forceInvalidateDialogActions;
import static ru.vtosters.hooks.DialogHeaderInjector.forceInvalidateDialogActions;
import static ru.vtosters.hooks.other.ThemesUtils.getSTextAttr;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;

public class CryptImHook {
public static boolean isPrivateProcessor(int peerID) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.vtosters.lite.hooks;
package ru.vtosters.hooks;

import android.annotation.SuppressLint;
import com.vtosters.lite.R;
Expand All @@ -8,8 +8,8 @@
import java.util.Date;
import java.util.Locale;

import static ru.vtosters.hooks.other.Preferences.getString;
import static ru.vtosters.lite.utils.AndroidUtils.getStringDate;
import static ru.vtosters.lite.utils.Preferences.getString;

public class DateHook {
public static boolean fulltime() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.vtosters.lite.utils;
package ru.vtosters.hooks;

import android.annotation.SuppressLint;
import android.content.ContentValues;
Expand All @@ -12,18 +12,16 @@
import com.vk.libsqliteext.CustomSqliteExtensionsKt;
import io.requery.android.database.sqlite.SQLiteDatabase;
import io.requery.android.database.sqlite.SQLiteOpenHelper;
import ru.vtosters.lite.encryption.EncryptProvider;

import java.util.ArrayList;
import java.util.List;

import static ru.vtosters.hooks.other.Preferences.getBoolValue;
import static ru.vtosters.hooks.other.Preferences.getString;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.getString;

public class DeletedMessagesHandler {
public class DeletedMessagesHook {
private static List<Integer> sDeletedMessagesList = new ArrayList<>();

private static SQLiteDatabase sVKSQLiteDatabase;
private static int sBodyIndex = -1;
private static DeletedMessagesDBHelper sVTDatabase;
Expand Down Expand Up @@ -60,13 +58,13 @@ private static void checkForNestedMsg(List<NestedMsg> nestedMsgs) {
for (NestedMsg nestedMsg : nestedMsgs) {
if (!nestedMsg.w0().isEmpty()) checkForNestedMsg(nestedMsg.w0());

nestedMsg.d(EncryptProvider.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId()));
nestedMsg.d(EncryptionMessagesHook.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId()));
}
}

private static void editTextOfMsg(MsgFromUser msgFromUser) {
if (!msgFromUser.f().startsWith(getPrefixUndelete())) {
msgFromUser.d(getPrefixUndelete() + EncryptProvider.decryptMessage(msgFromUser));
msgFromUser.d(getPrefixUndelete() + EncryptionMessagesHook.decryptMessage(msgFromUser));
}
}

Expand All @@ -87,7 +85,7 @@ public static void updateDialog(MsgDeleteLpTask msgDeleteLpTask) throws NoSuchFi
@SuppressLint("Range")
int localId = cursor.getInt(cursor.getColumnIndex("local_id"));

var className = DeletedMessagesHandler.class.getSimpleName();
var className = DeletedMessagesHook.class.getSimpleName();
var imEnvironment = msgDeleteLpTask.b;
var cint = msgDeleteLpTask.c;
imEnvironment.a(className, new OnMsgUpdateEvent(className, cint, localId));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package ru.vtosters.lite.hooks;
package ru.vtosters.hooks;

import android.annotation.SuppressLint;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;

import static ru.vtosters.hooks.other.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;

public class DeviceInfoHook {
public static String getDeviceInfo(String input) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.vtosters.lite.dialogs;
package ru.vtosters.hooks;

import android.annotation.SuppressLint;
import android.os.Environment;
Expand All @@ -8,11 +8,11 @@
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.ui.components.common.DialogAction;
import com.vk.im.ui.views.dialog_actions.DialogActionsListView;
import ru.vtosters.lite.dialogs.Requests;
import ru.vtosters.lite.downloaders.messages.HtmlDialogDownloaderFormatProvider;
import ru.vtosters.lite.downloaders.messages.MessagesDownloader;
import ru.vtosters.lite.encryption.EncryptProvider;
import ru.vtosters.lite.encryption.base.IMProcessor;
import ru.vtosters.lite.hooks.CryptImHook;
import ru.vtosters.lite.utils.AndroidUtils;

import java.io.File;
Expand All @@ -35,12 +35,12 @@ public static boolean onClick(DialogAction action, Dialog dialog) { // header me
forceInvalidateDialogActions(dialog);
}
case DNR_ON, DNR_OFF -> {
DNRModule.hookDNR(peerId);
MessagesActivityHook.hookDNR(peerId);
forceInvalidateDialogActions(dialog);
return true;
}
case DNT_ON, DNT_OFF -> {
DNRModule.hookDNT(peerId);
MessagesActivityHook.hookDNT(peerId);
forceInvalidateDialogActions(dialog);
return true;
}
Expand Down Expand Up @@ -84,13 +84,13 @@ public static List<DialogAction> injectToListAccess(List<DialogAction> actions,

actions.add(DialogAction.DOWNLOAD);

if (DNRModule.isDnrEnabledFor(peerId)) {
if (MessagesActivityHook.isDnrEnabledFor(peerId)) {
actions.add(DialogAction.DNR_OFF);
} else {
actions.add(DialogAction.DNR_ON);
}

if (DNRModule.isDntEnabledFor(peerId)) {
if (MessagesActivityHook.isDntEnabledFor(peerId)) {
actions.add(DialogAction.DNT_OFF);
} else {
actions.add(DialogAction.DNT_ON);
Expand Down
Loading

0 comments on commit 08dae9b

Please sign in to comment.