diff --git a/app/src/main/java/ps/reso/instaeclipse/Xposed/Module.java b/app/src/main/java/ps/reso/instaeclipse/Xposed/Module.java index 0acf2a4a..b9449ab8 100644 --- a/app/src/main/java/ps/reso/instaeclipse/Xposed/Module.java +++ b/app/src/main/java/ps/reso/instaeclipse/Xposed/Module.java @@ -8,6 +8,9 @@ import org.luckypray.dexkit.DexKitBridge; +import java.util.Arrays; +import java.util.List; + import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.IXposedHookZygoteInit; import de.robv.android.xposed.XC_MethodHook; @@ -42,6 +45,28 @@ public class Module implements IXposedHookLoadPackage, IXposedHookZygoteInit { private static String moduleSourceDir; private static String moduleLibDir; + // List of supported Instagram package names + private static final List SUPPORTED_PACKAGES = Arrays.asList( + CommonUtils.IG_PACKAGE_NAME, // Original package name + "com.instagram.android", + "com.instagold.android", + "com.instaflux.app", + "com.myinsta.android", + "cc.honista.app", + "com.instaprime.android", + "com.instafel.android", + "com.instadm.android", + "com.dfistagram.android", + "com.Instander.android", + "com.aero.instagram", + "com.instapro.android", + "com.instaflow.android", + "com.instagram1.android", + "com.instagram2.android", + "com.instagramclone.android", + "com.instaclone.android" + ); + // for dev usage /* public static void showToast(final String text) { @@ -102,27 +127,27 @@ public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) { } } - // Hook into Instagram - if (lpparam.packageName.equals(CommonUtils.IG_PACKAGE_NAME)) { + // Hook into Instagram and its clones + if (SUPPORTED_PACKAGES.contains(lpparam.packageName)) { try { if (dexKitBridge == null) { // Load the .so file from your module (if not already loaded) System.load(moduleLibDir + "/libdexkit.so"); // XposedBridge.log("libdexkit.so loaded successfully."); - // Initialize DexKitBridge with Instagram's APK + // Initialize DexKitBridge with the target app's APK dexKitBridge = DexKitBridge.create(lpparam.appInfo.sourceDir); - // XposedBridge.log("DexKitBridge initialized with Instagram's APK: " + lpparam.appInfo.sourceDir); + // XposedBridge.log("DexKitBridge initialized with target APK: " + lpparam.appInfo.sourceDir); } - // Use Instagram's ClassLoader + // Use the target app's ClassLoader hostClassLoader = lpparam.classLoader; - // Call the method to hook Instagram + // Call the method to hook the target app hookInstagram(lpparam); } catch (Exception e) { - XposedBridge.log("(InstaEclipse): Failed to initialize DexKitBridge for Instagram: " + e.getMessage()); + XposedBridge.log("(InstaEclipse): Failed to initialize DexKitBridge for " + lpparam.packageName + ": " + e.getMessage()); } } } @@ -144,7 +169,7 @@ private void hookInstagram(XC_LoadPackage.LoadPackageParam lpparam) { @Override protected void afterHookedMethod(MethodHookParam param) { - XposedBridge.log("InstaEclipse: Settings loaded via Application.attach"); + XposedBridge.log("InstaEclipse: Settings loaded via Application.attach for " + lpparam.packageName); // Setup context, preferences Context context = (Context) param.args[0]; @@ -155,7 +180,7 @@ protected void afterHookedMethod(MethodHookParam param) { UIHookManager instagramUI = new UIHookManager(); instagramUI.mainActivity(hostClassLoader); - XposedBridge.log("(InstaEclipse): Instagram package detected. Starting feature hooks..."); + XposedBridge.log("(InstaEclipse): " + lpparam.packageName + " package detected. Starting feature hooks..."); Interceptor interceptor = new Interceptor(); @@ -263,7 +288,7 @@ protected void afterHookedMethod(MethodHookParam param) { }); } catch (Exception e) { - XposedBridge.log("(InstaEclipse): Failed to hook Instagram: " + e.getMessage()); + XposedBridge.log("(InstaEclipse): Failed to hook " + lpparam.packageName + ": " + e.getMessage()); } } -} \ No newline at end of file +} diff --git a/app/src/main/java/ps/reso/instaeclipse/utils/dialog/DialogUtils.java b/app/src/main/java/ps/reso/instaeclipse/utils/dialog/DialogUtils.java index 9fc4739f..fcccd7c1 100644 --- a/app/src/main/java/ps/reso/instaeclipse/utils/dialog/DialogUtils.java +++ b/app/src/main/java/ps/reso/instaeclipse/utils/dialog/DialogUtils.java @@ -116,7 +116,7 @@ private static LinearLayout buildMainMenuLayout(Context context) { mainLayout.addView(createClickableSection(context, "â„šī¸ About", () -> showAboutDialog(context))); // 6 - Restart Instagram => OPEN PAGE - mainLayout.addView(createClickableSection(context, "🔁 Restart Instagram", () -> showRestartSection(context))); + mainLayout.addView(createClickableSection(context, "🔁 Restart App", () -> showRestartSection(context))); mainLayout.addView(createDivider(context)); @@ -256,39 +256,58 @@ private static View createDivider(Context context) { return divider; } - private static void restartInstagram(Context context) { // Restart Instagram and Remove its cache + /** + * Clears the application's cache and restarts it. + * Works for any package name this module is running in. + * + * @param context The application context. + */ + private static void restartApp(Context context) { try { - Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.instagram.android"); - clearInstagramCache(context); + String packageName = context.getPackageName(); + Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); + if (intent != null) { + clearAppCache(context); // Clear cache first intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); + // Forcibly kill the current process to ensure a clean restart Runtime.getRuntime().exit(0); } else { - Toast.makeText(context, "Instagram not found", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "Could not find the app to restart.", Toast.LENGTH_SHORT).show(); } } catch (Exception e) { - XposedBridge.log("InstaEclipse: Restart failed - " + e.getMessage()); + String packageName = context.getPackageName(); + XposedBridge.log("InstaEclipse: Restart failed for " + packageName + " - " + e.getMessage()); Toast.makeText(context, "Restart failed: " + e.getMessage(), Toast.LENGTH_LONG).show(); } } - private static void clearInstagramCache(Context context) { // Clear Instagram Cache + /** + * Clears the cache directory for the current application. + * + * @param context The application context. + */ + private static void clearAppCache(Context context) { try { File cacheDir = context.getCacheDir(); - if (cacheDir != null && cacheDir.exists()) { - XposedBridge.log(""); + if (cacheDir != null && cacheDir.isDirectory()) { deleteRecursive(cacheDir); - XposedBridge.log("InstaEclipse: Cache cleared"); + XposedBridge.log("InstaEclipse: Cache cleared for " + context.getPackageName()); } else { - XposedBridge.log("InstaEclipse: Cache dir not found"); + XposedBridge.log("InstaEclipse: Cache directory not found for " + context.getPackageName()); } } catch (Exception e) { - XposedBridge.log("InstaEclipse: Failed to clear cache - " + e.getMessage()); + XposedBridge.log("InstaEclipse: Failed to clear cache for " + context.getPackageName() + " - " + e.getMessage()); } } - private static void deleteRecursive(File fileOrDirectory) { // Helper method + /** + * Recursively deletes a file or directory. + * + * @param fileOrDirectory The file or directory to delete. + */ + private static void deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) { File[] children = fileOrDirectory.listFiles(); if (children != null) { @@ -297,9 +316,11 @@ private static void deleteRecursive(File fileOrDirectory) { // Helper method } } } + // A direct result for a file or an empty directory fileOrDirectory.delete(); } + // ==== SECTIONS ==== @SuppressLint("SetTextI18n") @@ -755,7 +776,7 @@ private static void showRestartSection(Context context) { layout.setGravity(Gravity.CENTER_HORIZONTAL); TextView message = new TextView(context); - message.setText("âš ī¸ Restart Instagram and remove its cache?!"); + message.setText("âš ī¸ Clear app cache and restart?"); message.setTextColor(Color.WHITE); message.setTextSize(18f); message.setGravity(Gravity.CENTER); @@ -766,12 +787,12 @@ private static void showRestartSection(Context context) { restartButton.setTextColor(Color.WHITE); restartButton.setPadding(40, 20, 40, 20); - restartButton.setOnClickListener(v -> restartInstagram(context)); + restartButton.setOnClickListener(v -> restartApp(context)); layout.addView(message); layout.addView(restartButton); - showSectionDialog(context, "Restart Instagram", layout, () -> { + showSectionDialog(context, "Restart App", layout, () -> { }); } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 7854d8fb..d3bc9963 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -2,5 +2,21 @@ com.instagram.android + com.instagold.android + com.instaflux.app + com.myinsta.android + cc.honista.app + com.instaprime.android + com.instafel.android + com.instadm.android + com.dfistagram.android + com.Instander.android + com.aero.instagram + com.instapro.android + com.instaflow.android + com.instagram1.android + com.instagram2.android + com.instagramclone.android + com.instaclone.android \ No newline at end of file