|
| 1 | + |
| 2 | +package com.programminghoch10.AnimationScaleMod; |
| 3 | + |
| 4 | +import android.content.res.XModuleResources; |
| 5 | +import android.content.res.XResources; |
| 6 | + |
| 7 | +import java.util.Arrays; |
| 8 | + |
| 9 | +import de.robv.android.xposed.IXposedHookInitPackageResources; |
| 10 | +import de.robv.android.xposed.IXposedHookZygoteInit; |
| 11 | +import de.robv.android.xposed.callbacks.XC_InitPackageResources; |
| 12 | + |
| 13 | +public class ScaleHook implements IXposedHookInitPackageResources, IXposedHookZygoteInit { |
| 14 | + private static final String PACKAGE_SETTINGS = "com.android.settings"; |
| 15 | + private final static String[] arrayResourceNames = { |
| 16 | + "window_animation", |
| 17 | + "transition_animation", |
| 18 | + "animator_duration", |
| 19 | + }; |
| 20 | + private static String modulePath = null; |
| 21 | + |
| 22 | + @Override |
| 23 | + public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable { |
| 24 | + if (!resparam.packageName.equals(PACKAGE_SETTINGS)) return; |
| 25 | + XResources resources = resparam.res; |
| 26 | + XModuleResources moduleResources = XModuleResources.createInstance(modulePath, resources); |
| 27 | + for (String arrayResourceName : arrayResourceNames) { |
| 28 | + arrayResourceName += "_scale"; |
| 29 | + resources.setReplacement(PACKAGE_SETTINGS, "array", arrayResourceName + "_values", moduleResources.fwd(R.array.animation_scale_values)); |
| 30 | + String animationOff = resources.getStringArray(resources.getIdentifier(arrayResourceName + "_entries", "array", PACKAGE_SETTINGS))[0]; |
| 31 | + String[] entries = resources.getStringArray(resources.getIdentifier(arrayResourceName + "_values", "array", PACKAGE_SETTINGS)); |
| 32 | + entries = Arrays.stream(entries).map(entry -> Float.parseFloat(entry) + "x").toArray(String[]::new); |
| 33 | + entries[0] = animationOff; |
| 34 | + resources.setReplacement(PACKAGE_SETTINGS, "array", arrayResourceName + "_entries", entries); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public void initZygote(StartupParam startupParam) throws Throwable { |
| 40 | + modulePath = startupParam.modulePath; |
| 41 | + } |
| 42 | + |
| 43 | +} |
0 commit comments