Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed May 8, 2024
2 parents 8da97d6 + 72d2454 commit 742a716
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 256 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/com/wmods/wppenhacer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ protected void onCreate(Bundle savedInstanceState) {
getTheme().applyStyle(rikka.material.preference.R.style.ThemeOverlay_Rikka_Material3_Preference, true);
getTheme().applyStyle(R.style.ThemeOverlay, true);
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.mipmap.launcher);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.mipmap.launcher);
}
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment_activity_main);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.Nullable;
import androidx.preference.Preference;

import com.wmods.wppenhacer.R;
import com.wmods.wppenhacer.ui.fragments.base.BasePreFragment;
import com.wmods.wppenhacer.utils.RealPathUtil;

public class MediaFragment extends BasePreFragment {


private final String TAG = "MediaFragment";
private ActivityResultLauncher<Uri> mContract;

@Override
Expand All @@ -23,7 +25,10 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
mContract = registerForActivityResult(new ActivityResultContracts.OpenDocumentTree(), result -> {
if (result == null) return;
var realPath = RealPathUtil.getRealPathFromURI_API19(getContext(), result);
findPreference("localdownload").setSummary(realPath);
Preference preference = findPreference("localdownload");
if (preference != null) {
preference.setSummary(realPath);
}
mPrefs.edit().putString("localdownload", realPath).apply();
});
}
Expand All @@ -33,11 +38,14 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
super.onCreatePreferences(savedInstanceState, rootKey);
setPreferencesFromResource(R.xml.fragment_media, rootKey);
var localPref = findPreference("localdownload");
if (localPref == null) {
Log.e(TAG, "localPref is null!");
return;
}
localPref.setOnPreferenceClickListener((preference) -> {
mContract.launch(null);
return true;
});
localPref.setSummary(mPrefs.getString("localdownload", Environment.getExternalStorageDirectory().getPath()+"/Download"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ static void replace(ImageView view) {
view.setColorFilter(IColors.parseColor(sColorSub + newColor));
}
}
} else {
// XposedBridge.log("Image replacement: " + colorFilter.getClass().getName());
}
}/* else {
XposedBridge.log("Image replacement: " + colorFilter.getClass().getName());
}*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public static int getColor(Drawable drawable) {
} else if (drawable instanceof InsetDrawable insetDrawable) {
color = getInsetDrawableColor(insetDrawable);
}
if (colors.get(IColors.toString(color)) == null) {
// if (colors.get(IColors.toString(color)) == null) {
// XposedBridge.log("(getColor) Color: " + IColors.toString(color) + " / Class: " + drawable.getClass());
}
// }
return color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.widget.ListAdapter;
import android.widget.Scroller;

import androidx.annotation.NonNull;

import java.util.LinkedList;
import java.util.Queue;

Expand Down Expand Up @@ -289,18 +291,18 @@ protected boolean onDown(MotionEvent e) {
private final GestureDetector.OnGestureListener mOnGesture = new GestureDetector.SimpleOnGestureListener() {

@Override
public boolean onDown(MotionEvent e) {
public boolean onDown(@NonNull MotionEvent e) {
return HorizontalListView.this.onDown(e);
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
public boolean onFling(MotionEvent e1, @NonNull MotionEvent e2, float velocityX,
float velocityY) {
return HorizontalListView.this.onFling(e1, e2, velocityX, velocityY);
}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
public boolean onScroll(MotionEvent e1, @NonNull MotionEvent e2,
float distanceX, float distanceY) {

getParent().requestDisallowInterceptTouchEvent(true);
Expand All @@ -314,7 +316,7 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2,
}

@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
public boolean onSingleTapConfirmed(@NonNull MotionEvent e) {
XposedBridge.log("onSingleTapConfirmed");
Rect viewRect = new Rect();
for (int i = 0; i < getChildCount(); i++) {
Expand Down Expand Up @@ -346,7 +348,7 @@ public boolean onSingleTapConfirmed(MotionEvent e) {
}

@Override
public void onLongPress(MotionEvent e) {
public void onLongPress(@NonNull MotionEvent e) {
Rect viewRect = new Rect();
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ private static void registerReceivers() {
@Override
public void onReceive(Context context, Intent intent) {
if (context.getPackageName().equals(intent.getStringExtra("PKG"))) {
Toast.makeText(context, "Rebooting " + context.getPackageManager().getApplicationLabel(context.getApplicationInfo()) + "...", Toast.LENGTH_SHORT).show();
Utils.doRestart(context);
var appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo());
Toast.makeText(context, "Rebooting " + appName + "...", Toast.LENGTH_SHORT).show();
if (!Utils.doRestart(context))
Toast.makeText(context, "Unable to rebooting " + appName, Toast.LENGTH_SHORT).show();
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ public static Field loadSetEditMessageField(ClassLoader loader) throws Exception
return field.getFieldInstance(loader);
}
}
throw new RuntimeException("GetEditMessage method not found");
throw new RuntimeException("SetEditMessage method not found");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import de.robv.android.xposed.XSharedPreferences;
Expand Down Expand Up @@ -161,7 +162,9 @@ public void saveClass(String message, Class<?> messageClass) {
}

private String getKeyName() {
return Arrays.stream(Thread.currentThread().getStackTrace()).filter(stackTraceElement -> stackTraceElement.getClassName().equals(Unobfuscator.class.getName())).findFirst().get().getMethodName();
AtomicReference<String> keyName = new AtomicReference<>("");
Arrays.stream(Thread.currentThread().getStackTrace()).filter(stackTraceElement -> stackTraceElement.getClassName().equals(Unobfuscator.class.getName())).findFirst().ifPresent(stackTraceElement -> keyName.set(stackTraceElement.getMethodName()));
return keyName.get();
}

public Constructor getConstructor(ClassLoader loader, FunctionCall functionCall) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ public static Application getApplication() {
return MainFeatures.mApp;
}

public static void doRestart(Context context) {
public static boolean doRestart(Context context) {
PackageManager packageManager = context.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
if (intent == null)
return false;

ComponentName componentName = intent.getComponent();
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
mainIntent.setPackage(context.getPackageName());
context.startActivity(mainIntent);
Runtime.getRuntime().exit(0);
return true;
}

@SuppressLint("DiscouragedApi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -31,7 +32,8 @@ public void onActivityResumed(@NonNull Activity activity) {
new AlertDialogWpp(activity).
setMessage(activity.getString(ResId.string.restart_wpp)).
setPositiveButton(activity.getString(ResId.string.yes), (dialog, which) -> {
Utils.doRestart(activity);
if (!Utils.doRestart(activity))
Toast.makeText(activity, "Unable to rebooting activity", Toast.LENGTH_SHORT).show();
})
.setNegativeButton(activity.getString(ResId.string.no), null)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;

import androidx.annotation.Nullable;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -110,11 +112,14 @@ public static Object getContactManager() {
return mContactManager;
}

@Nullable
public static String getContactName(Object userJid) {
try {
var contact = getContactMethod.invoke(mContactManager, userJid);
var stringField = Arrays.stream(contact.getClass().getDeclaredFields()).filter(f -> f.getType().equals(String.class)).toArray(Field[]::new);
return (String) stringField[3].get(contact);
if (contact != null) {
var stringField = Arrays.stream(contact.getClass().getDeclaredFields()).filter(f -> f.getType().equals(String.class)).toArray(Field[]::new);
return (String) stringField[3].get(contact);
}
} catch (Exception e) {
XposedBridge.log(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void doHook() throws Exception {
if (!backgroundColor.equals("0")) {
switch (c) {
case "0b141a" -> colors.put(c, backgroundColor.substring(3));
case "#ff0b141a" -> colors.put(c, backgroundColor);
case "#ff111b21" -> colors.put(c, backgroundColor);
case "#ff0b141a", "#ff111b21" -> colors.put(c, backgroundColor);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,13 @@ private List filterChat(Object thiz, List chatsList) {
return editableChatList;
}

private void hookTabList(Class<?> home) throws Exception {
private void hookTabList(@NonNull Class<?> home) throws Exception {
var onCreateTabList = Unobfuscator.loadTabListMethod(loader);
logDebug(Unobfuscator.getMethodDescriptor(onCreateTabList));
var fieldTabsList = Arrays.stream(home.getDeclaredFields()).filter(f -> f.getType().equals(List.class)).findFirst().orElse(null);
if (fieldTabsList == null) {
throw new NullPointerException("fieldTabList is NULL!");
}
fieldTabsList.setAccessible(true);

XposedBridge.hookMethod(onCreateTabList, new XC_MethodHook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ private void showBottomDialog(ArrayList<MessageHistory.MessageItem> messages) {
int dip = Utils.dipToPixels(20);
linearLayout.setPadding(dip, dip, dip, 0);
Drawable bg = DesignUtils.createDrawable("rc_dialog_bg");
bg.setTint(DesignUtils.getPrimarySurfaceColor(ctx));
if (bg != null) {
bg.setTint(DesignUtils.getPrimarySurfaceColor(ctx));
}
linearLayout.setBackground(bg);

// Title View
Expand Down Expand Up @@ -204,8 +206,10 @@ private void showBottomDialog(ArrayList<MessageHistory.MessageItem> messages) {
linearLayout.addView(okButton);
nestedScrollView0.addView(linearLayout);
dialog.setContentView(nestedScrollView0);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000));
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
if (dialog.getWindow() != null) {
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000));
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
dialog.setCanceledOnTouchOutside(true);
dialog.show();
});
Expand Down
Loading

0 comments on commit 742a716

Please sign in to comment.