Unable to replace animator resources #2676
-
I'm trying to replace the The XML resource in my package <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" /> My code: package stevenxxiu.animation_remover;
import android.content.res.XModuleResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.XposedBridge;
public class AppAdAway implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
private static String MODULE_PATH = null;
@Override
public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) {
MODULE_PATH = startupParam.modulePath;
}
@Override
public void handleInitPackageResources(InitPackageResourcesParam resParam) {
if (!resParam.packageName.equals("org.adaway")) {
return;
}
XposedBridge.log("Init app resources: " + resParam.packageName);
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resParam.res);
resParam.res.setReplacement("org.adaway", "animator", "fragment_open_enter", modRes.fwd(R.animator.fragment_empty));
resParam.res.setReplacement("org.adaway", "animator", "fragment_open_exit", modRes.fwd(R.animator.fragment_empty));
resParam.res.setReplacement("org.adaway", "animator", "fragment_close_enter", modRes.fwd(R.animator.fragment_empty));
resParam.res.setReplacement("org.adaway", "animator", "fragment_close_exit", modRes.fwd(R.animator.fragment_empty));
}
} Checking that the resource does exist: XposedBridge.log(String.valueOf(resParam.res.getIdentifier("fragment_open_enter", "animator", "org.adaway"))); I tried the latest nightly build as well.
I was also thinking of trying the new API, but there's no examples on how to replace resources. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It turns out this wasn't what causes the animation. The cause is Maybe LSPosed did replace the resource correctly then. The solution is as follows: package stevenxxiu.animation_remover;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
public class AppAdAway implements IXposedHookLoadPackage {
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpParam) {
if (!lpParam.packageName.equals("org.adaway")) {
return;
}
findAndHookMethod(
"androidx.customview.widget.ViewDragHelper",
lpParam.classLoader,
"computeAxisDuration",
int.class,
int.class,
int.class,
XC_MethodReplacement.returnConstant(0)
);
}
} |
Beta Was this translation helpful? Give feedback.
It turns out this wasn't what causes the animation. The cause is
com.google.android.material.bottomsheet.BottomSheetBehavior
animating by default. The animation duration is computed byandroidx.customview.widget.ViewDragHelper.computeAxisDuration()
. Patching this works.Maybe LSPosed did replace the resource correctly then.
The solution is as follows: