Skip to content

Commit

Permalink
Add support to WhatsApp 2.24.11.79~80
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed Jun 8, 2024
1 parent a2bfa36 commit 3716804
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ private void init(Context context) {

@Override
public void setTranslationY(float f) {
if(this.getHeight() > 0) {
int v = f > ((float)this.getHeight()) ? GONE : VISIBLE;
if(v == VISIBLE) {
if (this.getHeight() > 0) {
int v = f > ((float) this.getHeight()) ? GONE : VISIBLE;
if (v == VISIBLE) {
super.setTranslationY(f);
}
this.setVisibility(v);
Expand All @@ -45,6 +45,7 @@ public void setTranslationY(float f) {

public void updateList() {
post(() -> {
if (mStatusAdapter == null) return;
mStatusAdapter.notifyDataSetChanged();
this.invalidate();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static Method loadReceiptMethod(ClassLoader classLoader) throws Exception
});
}

public static Method loadReceiptMethod2(ClassLoader classLoader) throws Exception {
public static Method loadReceiptOutsideChat(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var method = loadReceiptMethod(classLoader);
if (method == null) throw new Exception("Receipt method not found");
Expand All @@ -188,12 +188,10 @@ public static Method loadReceiptMethod2(ClassLoader classLoader) throws Exceptio
});
}

public static Method loadReceiptMethod3(ClassLoader classLoader) throws Exception {
public static Method loadReceiptInChat(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var method = loadReceiptMethod(classLoader);
var classList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addUsingString("callCreatorJid")));
if (classList.isEmpty()) throw new Exception("Receipt method not found");
var methodDataList = dexkit.findMethod(new FindMethod().searchInClass(classList).matcher(new MethodMatcher().addInvoke(DexSignUtil.getMethodDescriptor(method))));
var methodDataList = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().addUsingString("callCreatorJid").addUsingString("reject").addUsingNumber(6175).addInvoke(DexSignUtil.getMethodDescriptor(method))));
if (methodDataList.isEmpty()) throw new Exception("Receipt method not found");
return methodDataList.get(0).getMethodInstance(classLoader);
});
Expand Down Expand Up @@ -883,7 +881,7 @@ public static Class<?> loadMessageStoreClass2(ClassLoader loader) throws Excepti

public static Method loadBlueOnReplayMessageJobMethod(ClassLoader loader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(loader, () -> {
var result = findFirstMethodUsingStrings(loader, StringMatchType.Contains, "SendE2EMessageJob/e2e message send job added");
var result = findFirstMethodUsingStrings(loader, StringMatchType.Contains, "SendE2EMessageJob/onRun");
if (result == null) throw new Exception("BlueOnReplayMessageJob method not found");
return result;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,13 @@ public Class<?> getClass(ClassLoader loader, FunctionCall functionCall) throws E
return XposedHelpers.findClass(value, loader);
}

@SuppressWarnings("ApplySharedPref")
public void saveField(String key, Field field) {
String value = field.getDeclaringClass().getName() + ":" + field.getName();
mShared.edit().putString(key, value).commit();
}

@SuppressWarnings("ApplySharedPref")
public void saveMethod(String key, Method method) {
String value = method.getDeclaringClass().getName() + ":" + method.getName();
if (method.getParameterTypes().length > 0) {
Expand All @@ -192,6 +194,7 @@ public void saveMethod(String key, Method method) {
mShared.edit().putString(key, value).commit();
}

@SuppressWarnings("ApplySharedPref")
public void saveClass(String message, Class<?> messageClass) {
mShared.edit().putString(message, messageClass.getName()).commit();
}
Expand Down Expand Up @@ -221,6 +224,7 @@ public Constructor getConstructor(ClassLoader loader, FunctionCall functionCall)
return XposedHelpers.findConstructorExact(cls);
}

@SuppressWarnings("ApplySharedPref")
private void saveConstructor(String key, Constructor constructor) {
String value = constructor.getDeclaringClass().getName();
if (constructor.getParameterTypes().length > 0) {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/wmods/wppenhacer/xposed/core/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public static String getDestination(SharedPreferences prefs, File file, String n
return filePath.getAbsolutePath() + "/" + (file == null ? "" : file.getName());
}

public static boolean copyFile(File srcFile, File destFile) {
if (srcFile == null || !srcFile.exists()) return false;
public static String copyFile(File srcFile, File destFile) {
if (srcFile == null || !srcFile.exists()) return "File not found or is null";

try (FileInputStream in = new FileInputStream(srcFile);
FileOutputStream out = new FileOutputStream(destFile)) {
Expand All @@ -148,13 +148,13 @@ public static boolean copyFile(File srcFile, File destFile) {
(path, uri) -> {
});

return true;
return "";
}
out.write(bArr, 0, read);
}
} catch (IOException e) {
XposedBridge.log(e.getMessage());
return false;
return e.getMessage();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public FilterGroups(@NonNull ClassLoader loader, @NonNull XSharedPreferences pre
@Override
public void doHook() throws Throwable {

if (!prefs.getBoolean("filtergroups", false)) return;
if (!prefs.getBoolean("filtergroups", false) || prefs.getBoolean("separategroups", false))
return;

var filterAdaperClass = Unobfuscator.loadFilterAdaperClass(loader);
methodSetFilter = ReflectionUtils.findMethodUsingFilter(filterAdaperClass, m -> m.getParameterCount() == 1 && m.getParameterTypes()[0].equals(int.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wmods.wppenhacer.xposed.features.general;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;

import android.app.Activity;
Expand All @@ -15,12 +14,13 @@

import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.DesignUtils;
import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.ResId;
import com.wmods.wppenhacer.xposed.core.Utils;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.components.AlertDialogWpp;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;

public class NewChat extends Feature {
Expand All @@ -32,21 +32,23 @@ public NewChat(@NonNull ClassLoader loader, @NonNull XSharedPreferences preferen
public void doHook() {
var homeActivity = findClass("com.whatsapp.HomeActivity", loader);
var newSettings = prefs.getBoolean("novaconfig", false);
if (!prefs.getBoolean("newchat", true))return;

findAndHookMethod(homeActivity, "onCreateOptionsMenu", Menu.class, new XC_MethodHook() {
if (!prefs.getBoolean("newchat", true)) return;
WppCore.addMenuItem(homeActivity, new WppCore.OnMenuCreate() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var home = (Activity) param.thisObject;
var menu = (Menu) param.args[0];

public void onAfterCreate(Activity activity, Menu menu) {
var item = menu.add(0, 0, 0, ResId.string.new_chat);
item.setIcon(Utils.getID("vec_ic_chat_add", "drawable"));
var drawable = DesignUtils.getDrawableByName("vec_ic_chat_add");

if (drawable != null) {
drawable.setTint(newSettings ? DesignUtils.getPrimaryTextColor() : 0xff8696a0);
item.setIcon(drawable);
}

if (newSettings) {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
item.setOnMenuItemClickListener(item1 -> {
var view = new LinearLayout(home);
var view = new LinearLayout(activity);
view.setGravity(Gravity.CENTER);
view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
var edt = new EditText(view.getContext());
Expand All @@ -56,25 +58,24 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
edt.setTransformationMethod(null);
edt.setHint(ResId.string.number_with_country_code);
view.addView(edt);
new AlertDialogWpp(home)
.setTitle(home.getString(ResId.string.new_chat))
new AlertDialogWpp(activity)
.setTitle(activity.getString(ResId.string.new_chat))
.setView(view)
.setPositiveButton(home.getString(ResId.string.message), (dialog, which) -> {
.setPositiveButton(activity.getString(ResId.string.message), (dialog, which) -> {
var number = edt.getText().toString();
var numberFomatted = number.replaceAll("[+\\-()/\\s]", "");
var intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://wa.me/" + numberFomatted));
intent.setPackage(Utils.getApplication().getPackageName());
home.startActivity(intent);
activity.startActivity(intent);
})
.setNegativeButton(home.getString(ResId.string.cancel), null)
.setNegativeButton(activity.getString(ResId.string.cancel), null)
.show();
return true;
});

super.afterHookedMethod(param);
}
});

}

@NonNull
Expand Down
Loading

0 comments on commit 3716804

Please sign in to comment.