diff --git a/app/src/main/java/com/wmods/wppenhacer/WppXposed.java b/app/src/main/java/com/wmods/wppenhacer/WppXposed.java index 8d2c1ad1..3d60f6cd 100644 --- a/app/src/main/java/com/wmods/wppenhacer/WppXposed.java +++ b/app/src/main/java/com/wmods/wppenhacer/WppXposed.java @@ -69,6 +69,7 @@ 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()) { @@ -76,6 +77,11 @@ public void handleInitPackageResources(XC_InitPackageResources.InitPackageResour 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))); diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java index c63cbac1..41135792 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java @@ -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; @@ -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; @@ -74,6 +77,8 @@ public class MainFeatures { public final static String PACKAGE_BUSINESS = "com.whatsapp.w4b"; private static final ArrayList list = new ArrayList<>(); + private static List supportedVersions; + private static String currentVersion; public static void start(@NonNull ClassLoader loader, @NonNull XSharedPreferences pref, String sourceDir) { @@ -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]"); @@ -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))); @@ -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() { diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java index 51b5838c..8e6c3ca6 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java @@ -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; + } } diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/WppCore.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/WppCore.java index 22a3c4eb..d5bf8399 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/WppCore.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/WppCore.java @@ -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; @@ -142,7 +141,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { // Load wa database loadDatabase(); - FMessageWpp.init(loader); + } public static void loadDatabase() { diff --git a/changelog.txt b/changelog.txt index 76120882..9cb055ca 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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) \ No newline at end of file