[XDA-University] grorg:
[MENTION=5290145]hamzahrmalik[/MENTION], please help me. I just try to make a module to replace drawables in com.htc.resources package.

package jamgrorg.gmail.com.sense5flatgreentheme;

import android.content.res.XModuleResources;
import android.content.res.XResources;

import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;

/**
* Created by roman on 30.07.2014.
*/
public class ThemeEngine implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
private static String MODULE_PATH = null;

@Override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}

@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.htc"))
return;

XposedBridge.log("sense5fgt: --------------------------------------------------------------------------");
XposedBridge.log("sense5fgt: Ok, com.htc.resources found!");

XposedBridge.log("sense5fgt: Trying to change resources...");
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
XResources.setSystemWideReplacement("com.htc", "drawable", "automotive_common_app_bkg_top_src", modRes.fwd(R.drawable.automotive_common_app_bkg_top_src));
XResources.setSystemWideReplacement("com.htc", "drawable", "automotive_common_scroller", modRes.fwd(R.drawable.automotive_common_scroller));
XResources.setSystemWideReplacement("com.htc", "drawable", "automotive_common_scroller_grip", modRes.fwd(R.drawable.automotive_common_scroller_grip));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_app_bkg_down_src", modRes.fwd(R.drawable.common_app_bkg_down_src));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_app_bkg_top_src", modRes.fwd(R.drawable.common_app_bkg_top_src));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_btn", modRes.fwd(R.drawable.common_btn));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_footer", modRes.fwd(R.drawable.common_footer));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_header", modRes.fwd(R.drawable.common_header));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_scroller", modRes.fwd(R.drawable.common_scroller));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_scroller_grip", modRes.fwd(R.drawable.common_scroller_grip));
XResources.setSystemWideReplacement("com.htc", "drawable", "common_tab", modRes.fwd(R.drawable.common_tab));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_bottom_left", modRes.fwd(R.drawable.tips_arrow_bottom_left));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_bottom_right", modRes.fwd(R.drawable.tips_arrow_bottom_right));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_down", modRes.fwd(R.drawable.tips_arrow_down));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_rearrange", modRes.fwd(R.drawable.tips_arrow_rearrange));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_top_left", modRes.fwd(R.drawable.tips_arrow_top_left));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_top_right", modRes.fwd(R.drawable.tips_arrow_top_right));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_up", modRes.fwd(R.drawable.tips_arrow_up));
XResources.setSystemWideReplacement("com.htc", "drawable", "tips_arrow_down", modRes.fwd(R.drawable.tips_arrow_down));

XposedBridge.log("sense5fgt: Ok, resources were changed!");
XposedBridge.log("sense5fgt: --------------------------------------------------------------------------");
}
}

Module works, but not correct. Resources are changed selectively not in every app that are uses them.

When I was modified com.htc.resources.apk by replacing png in apk file it changes everywhere in the system.