Skip to content

Commit

Permalink
Merge branch 'Dev4Mod:master' into theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Strange-IPmart authored Jan 6, 2025
2 parents e6aed77 + 085d695 commit 826f972
Show file tree
Hide file tree
Showing 31 changed files with 521 additions and 153 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
permissions: write-all
runs-on: ubuntu-latest
if: github.event_name == 'push'
if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Merge')
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
Expand Down Expand Up @@ -58,11 +58,14 @@ jobs:
curl "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Foutput%22%2C%22caption%22:${ESCAPED}%7D%5D" -F output="@$output"
fi
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV

- name: Upload to release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: WaEnhancer ${{ github.sha }}
name: WaEnhancer ${{ env.SHORT_SHA }}
body_path: changelog.txt
files: app/build/outputs/apk/debug/app-debug.apk
tag_name: pre-release-${{ github.sha }}
tag_name: pre-release-${{ env.SHORT_SHA }}
9 changes: 6 additions & 3 deletions .github/workflows/business.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
permissions: write-all
runs-on: ubuntu-latest
if: github.event_name == 'push'
if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Merge')
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
Expand Down Expand Up @@ -49,11 +49,14 @@ jobs:
name: Wa Enhancer ${{ steps.version.outputs.builddate }}
path: app/build/outputs/apk/debug/app-debug.apk

- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV

- name: Upload to release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: WaEnhancer Business ${{ github.sha }}
name: WaEnhancer Business ${{ env.SHORT_SHA }}
body_path: changelog.txt
files: app/build/outputs/apk/debug/app-debug.apk
tag_name: pre-release-business-${{ github.sha }}
tag_name: pre-release-business-${{ env.SHORT_SHA }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.wmods.wppenhacer.adapter;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.wmods.wppenhacer.xposed.utils.DesignUtils;
import com.wmods.wppenhacer.xposed.utils.Utils;

import java.util.List;

public class CustomPrivacyAdapter extends ArrayAdapter {

private final Class<?> contactClass;
private final SharedPreferences prefs;
private final Class<?> groupClass;
private final List<Item> items;

public CustomPrivacyAdapter(Context context, SharedPreferences preferences, List<Item> mlist, Class<?> contactClass, Class<?> groupClass) {
super(context, 0);
this.contactClass = contactClass;
this.groupClass = groupClass;
this.items = mlist;
this.prefs = preferences;
}

@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
Item item = items.get(position);
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = createLayout(holder);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.textView.setText(item.name);
convertView.setOnClickListener(v -> {
// Only Groups
if (item.number.length() > 15) {
Intent intent = new Intent(getContext(), groupClass);
intent.putExtra("gid", item.number + "@g.us");
getContext().startActivity(intent);
return;
}
Intent intent = new Intent(getContext(), contactClass);
intent.putExtra("jid", item.number + "@s.whatsapp.net");
getContext().startActivity(intent);
});
holder.button.setOnClickListener(v -> {
items.remove(position);
this.prefs.edit().remove(item.key).apply();
notifyDataSetChanged();
});

return convertView;
}

@Override
public int getCount() {
return items.size();
}

private ViewGroup createLayout(ViewHolder holder) {
LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setPadding(Utils.dipToPixels(25), 0, Utils.dipToPixels(25), 0);

TextView textView = new TextView(getContext());
var layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.weight = 1;
textView.setLayoutParams(layoutParams);
layout.addView(textView);
holder.textView = textView;

Button button = new Button(getContext());
var buttonParams = new LinearLayout.LayoutParams(Utils.dipToPixels(40), Utils.dipToPixels(40));
button.setLayoutParams(buttonParams);
var drawable = DesignUtils.createDrawable("stroke_border", Color.BLACK);
button.setBackground(DesignUtils.alphaDrawable(drawable, DesignUtils.getPrimaryTextColor(), 25));
button.setText("X");
layout.addView(button);
holder.button = button;

return layout;
}

static class ViewHolder {
TextView textView;
Button button;
}

public static class Item {
public String name;
public String number;
public String key;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ public static Activity getCurrentConversation() {
return null;
}

public static SharedPreferences getPrivPrefs() {
return privPrefs;
}

@SuppressLint("ApplySharedPref")
public static void setPrivString(String key, String value) {
privPrefs.edit().putString(key, value).commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,10 @@ public synchronized static Method getFilterInitMethod(ClassLoader loader) throws

// for 20.xx, it returned with 2 parameter count
if (method.getParamCount() == 2) {
method = method.getDeclaredClass().findMethod(FindMethod.create().matcher(new MethodMatcher().addInvoke(DexSignUtil.getMethodDescriptor(method.getMethodInstance(loader))))).singleOrNull();
if (method == null) throw new RuntimeException("FilterInit method not found 3");
var callers = method.getCallers();
method = callers.stream().filter(methodData -> methodData.isMethod() && methodData.getDeclaredClassName().equals(cFrag.getName())).findAny().orElse(null);
if (method == null)
throw new RuntimeException("FilterInit method not found 3");
}
return method.getMethodInstance(loader);
});
Expand Down Expand Up @@ -1654,6 +1656,14 @@ public synchronized static Method loadBubbleDrawableMethod(ClassLoader classLoad
});
}

public synchronized static Method loadDateWrapper(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var methodData = dexkit.findMethod(FindMethod.create().matcher(MethodMatcher.create().name("getDateWrapperBackground")));
if (methodData.isEmpty()) throw new Exception("LoadDateWrapper method not found");
return methodData.get(0).getMethodInstance(classLoader);
});
}

public static synchronized Method[] loadRootDetector(ClassLoader classLoader) {
var methods = findAllMethodUsingStrings(classLoader, StringMatchType.Contains, "/system/bin/su");
if (methods.length == 0) throw new RuntimeException("RootDetector method not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.components.FMessageWpp;
import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator;
import com.wmods.wppenhacer.xposed.utils.DesignUtils;
import com.wmods.wppenhacer.xposed.utils.Utils;
Expand All @@ -20,6 +21,7 @@
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

public class BubbleColors extends Feature {
public BubbleColors(ClassLoader loader, XSharedPreferences preferences) {
Expand Down Expand Up @@ -88,6 +90,24 @@ public void doHook() throws Exception {
}
}

var dateWrapper = Unobfuscator.loadDateWrapper(classLoader);
XposedBridge.hookMethod(dateWrapper, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var fmessageObject = XposedHelpers.callMethod(param.thisObject, "getFMessage");
if (fmessageObject == null) return;
var view = (Drawable) param.getResult();
var fmessage = new FMessageWpp(fmessageObject);
if (fmessage.getKey().isFromMe) {
if (bubbleRightColor == 0) return;
view.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
} else {
if (bubbleLeftColor == 0) return;
view.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
}

}
});

var bubbleDrawableMethod = Unobfuscator.loadBubbleDrawableMethod(classLoader);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void hookColors() throws Exception {
backgroundColor = backgroundColorInt == 0 ? "0" : IColors.toString(backgroundColorInt);
}

if (prefs.getBoolean("changecolor", false) || Objects.equals(properties.getProperty("change_colors"), "true")) {
if (prefs.getBoolean("changecolor", false) || (Objects.equals(properties.getProperty("change_colors"), "true") && prefs.getBoolean("custom_filters", false))) {
for (var c : IColors.colors.keySet()) {
if (!primaryColor.equals("0") && DesignUtils.isValidColor(primaryColor)) {
primaryColor = primaryColor.length() == 9 ? primaryColor : "#ff" + primaryColor.substring(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public void doHook() throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var activity = (Activity) param.thisObject;
View rootView = activity.getWindow().getDecorView().getRootView();
rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> CompletableFuture.runAsync(() -> registerCssRules(activity, (ViewGroup) rootView, sheet)));
rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> CompletableFuture.runAsync(() -> registerCssRules(activity, (ViewGroup) rootView, sheet), Utils.getExecutor()));


}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Exception {
var fMessage = new FMessageWpp(param.args[0]);
var messageKey = fMessage.getKey();
var deviceJid = fMessage.getDeviceJid();
var id = fMessage.getRowId();
var messageID = (String) XposedHelpers.getObjectField(fMessage.getObject(), "A01");
// Caso o proprio usuario tenha deletado o status
if (WppCore.getPrivBoolean(messageID + "_delpass", false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void doHook() throws Exception {
var filterChats = prefs.getString("chatfilter", null);
var strokeButtons = prefs.getBoolean("strokebuttons", false);
var outlinedIcons = prefs.getBoolean("outlinedicons", false);
var filterSeen = prefs.getBoolean("filterseen", false);
var fbstyle = Integer.parseInt(prefs.getString("facebookstyle", "0"));
var metaai = prefs.getBoolean("metaai", false);
var topnav = prefs.getBoolean("topnav", false);
Expand All @@ -76,7 +77,7 @@ public void doHook() throws Exception {
var animationEmojis = prefs.getBoolean("animation_emojis", false);

propsInteger.put(3877, oldStatus ? igstatus ? 2 : 0 : 2);
propsBoolean.put(5171, true);
propsBoolean.put(5171, filterSeen); // filtros de chat e grupos
propsBoolean.put(4524, novoTema);
propsBoolean.put(4497, menuWIcons);
propsBoolean.put(4023, newSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void doHook() throws Throwable {
XposedBridge.hookMethod(onCallReceivedMethod, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Object callinfo = null;
Object callinfo;
Class<?> callInfoClass = XposedHelpers.findClass("com.whatsapp.voipcalling.CallInfo", classLoader);
if (param.args[0] instanceof Message) {
callinfo = ((Message) param.args[0]).obj;
Expand Down Expand Up @@ -99,12 +99,11 @@ public CallPrivacy(@NonNull ClassLoader loader, @NonNull XSharedPreferences pref
}

public boolean checkCallBlock(Object userJid, PrivacyType type) throws IllegalAccessException, InvocationTargetException {
var jid = WppCore.stripJID(WppCore.getRawString(userJid));
logDebug("checkCallBlock: " + jid);
logDebug("checkCallBlock: " + type);
if (jid == null) return false;
var phoneNumber = WppCore.stripJID(WppCore.getRawString(userJid));

var customprivacy = CustomPrivacy.getJSON(jid);
if (phoneNumber == null) return false;

var customprivacy = CustomPrivacy.getJSON(phoneNumber);

if (type == PrivacyType.ALL_BLOCKED) {
return customprivacy.optBoolean("BlockCall", true);
Expand All @@ -114,21 +113,18 @@ public boolean checkCallBlock(Object userJid, PrivacyType type) throws IllegalAc
return customprivacy.optBoolean("BlockCall", false);
}

if (type == PrivacyType.ONLY_UNKNOWN && customprivacy.optBoolean("BlockCall", false)) {
return true;
}

switch (type) {
case ONLY_UNKNOWN:
jid += "@s.whatsapp.net";
var contactName = WppCore.getSContactName(WppCore.createUserJid(jid), true);
logDebug("contactName: " + contactName);
return TextUtils.isEmpty(contactName) || contactName.equals(jid);
if (customprivacy.optBoolean("BlockCall", false)) return true;
phoneNumber += "@s.whatsapp.net";
var contactName = WppCore.getSContactName(WppCore.createUserJid(phoneNumber), true);
return TextUtils.isEmpty(contactName) || contactName.equals(phoneNumber);
case BACKLIST:
if (customprivacy.optBoolean("BlockCall", true)) return true;
var callBlockList = prefs.getString("call_block_contacts", "[]");
var blockList = Arrays.stream(callBlockList.substring(1, callBlockList.length() - 1).split(", ")).map(String::trim).collect(Collectors.toCollection(ArrayList::new));
for (var blockNumber : blockList) {
if (!TextUtils.isEmpty(blockNumber) && jid.contains(blockNumber)) {
if (!TextUtils.isEmpty(blockNumber) && phoneNumber.contains(blockNumber)) {
return true;
}
}
Expand All @@ -137,7 +133,7 @@ public boolean checkCallBlock(Object userJid, PrivacyType type) throws IllegalAc
var callWhiteList = prefs.getString("call_white_contacts", "[]");
var whiteList = Arrays.stream(callWhiteList.substring(1, callWhiteList.length() - 1).split(", ")).map(String::trim).collect(Collectors.toCollection(ArrayList::new));
for (var whiteNumber : whiteList) {
if (!TextUtils.isEmpty(whiteNumber) && jid.contains(whiteNumber)) {
if (!TextUtils.isEmpty(whiteNumber) && phoneNumber.contains(whiteNumber)) {
return false;
}
}
Expand Down
Loading

0 comments on commit 826f972

Please sign in to comment.