Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed Jun 22, 2024
1 parent 70b513f commit dc8b013
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/wmods/wppenhacer/WppXposed.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@ public void handleInitPackageResources(XC_InitPackageResources.InitPackageResour

if (!packageName.equals(MainFeatures.PACKAGE_WPP) && !packageName.equals(MainFeatures.PACKAGE_BUSINESS))
return;

XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);

for (var field : ResId.string.class.getFields()) {
var field1 = R.string.class.getField(field.getName());
field.set(null, resparam.res.addResource(modRes, field1.getInt(null)));
}

for (var field : ResId.array.class.getFields()) {
var field1 = R.array.class.getField(field.getName());
field.set(null, resparam.res.addResource(modRes, field1.getInt(null)));
}

for (var field : ResId.drawable.class.getFields()) {
var field1 = R.drawable.class.getField(field.getName());
field.set(null, resparam.res.addResource(modRes, field1.getInt(null)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.wmods.wppenhacer.BuildConfig;
import com.wmods.wppenhacer.xposed.core.components.AlertDialogWpp;
import com.wmods.wppenhacer.xposed.core.components.FMessageWpp;
import com.wmods.wppenhacer.xposed.features.customization.BubbleColors;
import com.wmods.wppenhacer.xposed.features.customization.CustomTheme;
import com.wmods.wppenhacer.xposed.features.customization.CustomTime;
Expand Down Expand Up @@ -61,6 +62,8 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
Expand All @@ -74,6 +77,8 @@ public class MainFeatures {
public final static String PACKAGE_BUSINESS = "com.whatsapp.w4b";

private static final ArrayList<ErrorItem> list = new ArrayList<>();
private static List<String> supportedVersions;
private static String currentVersion;

public static void start(@NonNull ClassLoader loader, @NonNull XSharedPreferences pref, String sourceDir) {

Expand All @@ -91,19 +96,23 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
pref.registerOnSharedPreferenceChangeListener((sharedPreferences, s) -> pref.reload());
PackageInfo packageInfo = packageManager.getPackageInfo(mApp.getPackageName(), 0);
XposedBridge.log(packageInfo.versionName);
currentVersion = packageInfo.versionName;
supportedVersions = Arrays.asList(mApp.getResources().getStringArray(Objects.equals(mApp.getPackageName(), MainFeatures.PACKAGE_WPP) ? ResId.array.supported_versions_wpp : ResId.array.supported_versions_business));
try {
DesignUtils.setPrefs(pref);
UnobfuscatorCache.init(mApp, pref);
WppDatabase.Initialize(loader, pref);
WppCore.Initialize(loader);
if (!supportedVersions.contains(packageInfo.versionName)) {
throw new Exception("Unsupported version: " + packageInfo.versionName);
}
DesignUtils.setPrefs(pref);
WppDatabase.Initialize(loader, pref);
initComponents(loader, pref);
plugins(loader, pref, packageInfo.versionName);
registerReceivers();
mApp.registerActivityLifecycleCallbacks(new WaCallback());
sendEnabledBroadcast(mApp);
// if (Feature.DEBUG)
// XposedHelpers.setStaticIntField(XposedHelpers.findClass("com.whatsapp.util.Log", loader), "level", 5);
} catch (Exception e) {
// XposedHelpers.setStaticIntField(XposedHelpers.findClass("com.whatsapp.util.Log", loader), "level", 5);
} catch (Throwable e) {
XposedBridge.log(e);
var error = new ErrorItem();
error.setPluginName("MainFeatures[Critical]");
Expand All @@ -123,7 +132,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var activity = (Activity) param.thisObject;
new AlertDialogWpp(activity)
.setTitle(activity.getString(ResId.string.error_detected))
.setMessage(activity.getString(ResId.string.version_error) + String.join("\n", list.stream().map(ErrorItem::getPluginName).toArray(String[]::new)))
.setMessage(activity.getString(ResId.string.version_error) + String.join("\n", list.stream().map(ErrorItem::getPluginName).toArray(String[]::new)) + "\n\nCurrent Version: " + currentVersion + "\nSupported Versions:\n" + String.join("\n", supportedVersions))
.setPositiveButton(activity.getString(ResId.string.copy_to_clipboard), (dialog, which) -> {
var clipboard = (ClipboardManager) mApp.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("text", String.join("\n", list.stream().map(ErrorItem::toString).toArray(String[]::new)));
Expand All @@ -137,8 +146,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
});
}

private static void initComponents(ClassLoader loader, XSharedPreferences pref) {
private static void initComponents(ClassLoader loader, XSharedPreferences pref) throws Exception {
AlertDialogWpp.initDialog(loader);
FMessageWpp.init(loader);
}

private static void registerReceivers() {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public static class string {
public static int delete_for_me;
}

public class array {
public static int supported_versions_wpp;
public static int supported_versions_business;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.wmods.wppenhacer.xposed.core.components.FMessageWpp;
import com.wmods.wppenhacer.xposed.utils.ReflectionUtils;

import java.io.File;
Expand Down Expand Up @@ -142,7 +141,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// Load wa database
loadDatabase();

FMessageWpp.init(loader);

}

public static void loadDatabase() {
Expand Down
24 changes: 9 additions & 15 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
[WA ENHANCER]
* Adicionado botão de resetar as configurações
* Os backups agora vai ter data no nome
* Corrigido erros nos backups para a lista de bloqueios(backups antigos não será suportado)
* Todos os modulos foi atualizados para facilitar a manutenção
* Added reset button to settings
* Backups will now have a date in the name
* Fixed errors in backups for the block list(old backups will not be supported)
* All modules have been updated to facilitate maintenance

[STATUS DOWNLOADER]
* Os nomes do arquivo salvo agora tera o nome do usuario, numero do telefone e data (Ex: Mary_12345678_20240622-181400.jpg)

[VIEW ONCE DOWNLOADER]
* Os nomes do arquivo salvo agora tera o nome do usuario, numero do telefone e data (Ex: Mary_12345678_20240622-181400.jpg)

[PROFILE PICTURE DOWNLOADER]
* Os nomes do arquivo salvo agora tera o nome do usuario, numero do telefone e data (Ex: Mary_12345678_20240622-181400.jpg)
[STATUS DOWNLOADER | VIEW ONCE DOWNLOADER | PROFILE PICTURE DOWNLOADER]
* The saved file names will now have the user name, phone number and date (Ex: Mary_12345678_20240622-181400.jpg)

[TASKER]
* Adicionado variavel %name aos eventos
* Added %name variable to events

[WHATSAPP]
* Adicionado suporte para a versão 2.24.12.78

* Added support for version 2.24.12.78
* Unsupported versions will no longer be applied to the features (Avoid reporting an unsupported version and downgrading the version)

0 comments on commit dc8b013

Please sign in to comment.