public static void initResources(XSharedPreferences prefs,InitPackageResourcesParam resparam) {
XModuleResources modRes = XModuleResources.createInstance(GravityBox.MODULE_PATH,resparam.res);
if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_SIGNAL_CLUSTER_HPLUS,false) &&
!Utils.isMtkDevice() && !Utils.isOxygenOs35Rom()) {
sQsHpResId = XResources.getFakeResId(modRes,R.drawable.ic_qs_signal_hp);
sSbHpResId = XResources.getFakeResId(modRes,R.drawable.stat_sys_data_fully_connected_hp);
resparam.res.setReplacement(sQsHpResId,modRes.fwd(R.drawable.ic_qs_signal_hp));
resparam.res.setReplacement(sSbHpResId,modRes.fwd(R.drawable.stat_sys_data_fully_connected_hp));
DATA_HP = new int[][]{
{sSbHpResId,sSbHpResId,sSbHpResId},{sSbHpResId,sSbHpResId}
};
QS_DATA_HP = new int[]{sQsHpResId,sQsHpResId};
if (DEBUG) log("H+ icon resources initialized");
}
String lteStyle = prefs.getString(GravityBoxSettings.PREF_KEY_SIGNAL_CLUSTER_LTE_STYLE,"DEFAULT");
if (!lteStyle.equals("DEFAULT")) {
resparam.res.setReplacement(ModStatusBar.PACKAGE_NAME,"bool","config_show4GForLTE",lteStyle.equals("4G"));
}
}
@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam initPackageResourcesParam) throws Throwable {
if (!HookEntry.PKG_COOLAPK.equals(initPackageResourcesParam.packageName))
return;
// 替换图标
final String PATH_CURRENT_ICON = prefs.getString(PREFS_ICON_SAVE_PATH,null);
if (PATH_CURRENT_ICON == null) {
XposedBridge.log(TAG + "Replace icon disabled,skipping");
return;
}
final File file = new File(PATH_CURRENT_ICON);
if (!file.exists()) {
XposedBridge.log(TAG + "Replace icon disabled,skipping");
} else {
XposedBridge.log(TAG + "Replacing icon...");
initPackageResourcesParam.res.setReplacement(HookEntry.PKG_COOLAPK,"mipmap","ic_launcher",new XResources.DrawableLoader() {
@Override
public Drawable newDrawable(XResources xResources,int i) throws Throwable {
return BitmapDrawable.createFromPath(PATH_CURRENT_ICON);
}
});
}
}
项目:GemXperiaXposed
文件:ModuleResources.java
public static ModuleResources createInstance(String modulePath,XResources origRes)
{
if(modulePath == null)
throw new IllegalArgumentException("modulePath must not be null");
AssetManager assets = (AssetManager)newInstance(AssetManager.class);
callMethod(assets,"addAssetPath",modulePath);
ModuleResources res;
if(origRes != null)
res = new ModuleResources(assets,origRes.getdisplayMetrics(),origRes.getConfiguration());
else
res = new ModuleResources(assets,null,null);
AndroidAppHelper.addActiveResource(modulePath,res.hashCode(),false,res);
return res;
}
项目:CleanLockscreen
文件:CleanLockscreen.java
@Override
public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {
XposedBridge.log("CleanLockscreen initZygote");
if(android.os.Build.VERSION.SDK_INT<=20)
packageName = "com.android.keyguard";
else
packageName = "com.android.systemUI";
MODULE_PATH = startupParam.modulePath;
if(MODULE_PATH == null){
XposedBridge.log("CleanLockscreen modulePath is null!");
}
prefs = new XSharedPreferences(CleanLockscreen.class.getPackage().getName());
// Remove emergency call text
if (prefs.getBoolean("remove_emergency",false)) {
XResources.setSystemWideReplacement("android:string/lockscreen_emergency_call","");
}
XposedBridge.log("CleanLockscreen initZygote complete");
}
项目:XHangouts
文件:UiColorize.java
private static void themeListItemView(XResources res,String layoutName,final boolean extraLine) {
res.hookLayout(HANGOUTS_RES_PKG_NAME,"layout",layoutName,new XC_LayoutInflated() {
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
((LinearLayout) liparam.view.findViewById(liparam.res.getIdentifier("icon","id",HANGOUTS_RES_PKG_NAME)).getParent()).setBackgroundColor(COLOR_GROUP_5);
((ImageView) liparam.view.findViewById(liparam.res.getIdentifier("icon",HANGOUTS_RES_PKG_NAME))).setColorFilter(COLOR_GROUP_1,PorterDuff.Mode.SRC_IN);
((TextView) liparam.view.findViewById(liparam.res.getIdentifier("text",HANGOUTS_RES_PKG_NAME))).setTextColor(COLOR_GROUP_1);
if (extraLine) {
((TextView) liparam.view.findViewById(liparam.res.getIdentifier("byline",HANGOUTS_RES_PKG_NAME))).setTextColor(COLOR_GROUP_2);
}
}
});
}
@InitZygote(summary = "自動輝度調整")
public static void initZygote(StartupParam startupParam,ModBrightnessSettingsGen mBrightnessSettings) throws Throwable {
// 自動輝度調整
if (StringUtils.isNotEmpty(mBrightnessSettings.configAutoBrightnessLevels)
&& StringUtils
.isNotEmpty(mBrightnessSettings.configAutoBrightnessLcdBacklightValues)) {
int[] autoBrightnessLevels = makeIntArray(mBrightnessSettings.configAutoBrightnessLevels);
int[] autoBrightnessLcdBacklightValues = makeIntArray(mBrightnessSettings.configAutoBrightnessLcdBacklightValues);
if ((autoBrightnessLevels.length + 1) != autoBrightnessLcdBacklightValues.length) {
throw new IllegalArgumentException("パラメータ数エラー");
}
XResources.setSystemWideReplacement("android","array","config_autoBrightnessLevels",autoBrightnessLevels);
XResources.setSystemWideReplacement("android","config_autoBrightnessLcdBacklightValues",autoBrightnessLcdBacklightValues);
XResources.setSystemWideReplacement("android","config_automatic_brightness_available",true);
}
}
public static void initResources(XSharedPreferences prefs,resparam.res);
mIconNotifResId = XResources.getFakeResId(modRes,R.drawable.ic_audio_notification);
resparam.res.setReplacement(mIconNotifResId,modRes.fwd(R.drawable.ic_audio_notification));
mIconNotifMuteResId = XResources.getFakeResId(modRes,R.drawable.ic_audio_notification_mute);
resparam.res.setReplacement(mIconNotifMuteResId,modRes.fwd(R.drawable.ic_audio_notification_mute));
}
项目:eui_moder
文件:MainClass.java
@Override
public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {
loadPrefs();
/*
// Tried changing dark theme as white,didn't work
XResources.setSystemWideReplacement("android","color","primary_text_default_material_dark",Color.parseColor("#de000000"));
XResources.setSystemWideReplacement("android","secondary_text_default_material_dark",Color.parseColor("#8a000000"));
*/
if(disABLE_EUI) {
XResources.setSystemWideReplacement("android","dimen","status_bar_icon_size",new XResources.DimensionReplacement(20,TypedValue.COMPLEX_UNIT_DIP));
}
}
@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resParam) throws Throwable {
XResources r = resParam.res;
navBarString = r.getString(r.getIdentifier("nav_bar",SYSUI_PKG_NAME));
colorAppearanceString = r.getString(r.getIdentifier("color_and_appearance",SYSUI_PKG_NAME));
useDarkThemeString = r.getString(r.getIdentifier("use_dark_theme",SYSUI_PKG_NAME));
nightModedisclaimer = r.getString(r.getIdentifier("night_mode_disclaimer",SYSUI_PKG_NAME));
}
项目:HTCAuthorizer
文件:X_Mod.java
private void replaceSystemWideThemes() {
Logger.v("Replacing system-wide Theme resources.");
Logger.logTheme(mSettings);
XResources.setSystemWideReplacement("android","material_blue_grey_900",mSettings.getPrimaryColor());
XResources.setSystemWideReplacement("android","primary_material_dark",mSettings.getPrimaryColor());
// XResources.setSystemWideReplacement("android","primary_material_light",// Common.enlightColor(mSettings.getPrimaryColor(),2.25f));
XResources.setSystemWideReplacement("android","material_blue_grey_950",mSettings.getPrimaryDarkColor());
XResources.setSystemWideReplacement("android","primary_dark_material_dark",mSettings.getPrimaryDarkColor());
// XResources.setSystemWideReplacement("android","primary_dark_material_light",1.65f));
XResources.setSystemWideReplacement("android","material_deep_teal_500",mSettings.getAccentColor());
XResources.setSystemWideReplacement("android","accent_material_dark","accent_material_light","material_deep_teal_200",Common.enlightColor(mSettings.getAccentColor(),1.5f));
Logger.v("Theme resources replaced.");
}
项目:LollipopPowerMenu
文件:LollipopPowerMenu.java
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
prefs = new XSharedPreferences(LollipopPowerMenu.class.getPackage()
.getName());
prefs.makeWorldReadable();
ArrayList<String> itemsList = new ArrayList<String>();
if (isEnabled(GLOBAL_ACTION_KEY_POWER,true)) {
itemsList.add(GLOBAL_ACTION_KEY_POWER);
}
if (isEnabled(GLOBAL_ACTION_KEY_AIRPLANE,false)) {
itemsList.add(GLOBAL_ACTION_KEY_AIRPLANE);
}
if (isEnabled(GLOBAL_ACTION_KEY_SILENT,false)) {
itemsList.add(GLOBAL_ACTION_KEY_SILENT);
}
if (isEnabled(GLOBAL_ACTION_KEY_USERS,false)) {
itemsList.add(GLOBAL_ACTION_KEY_USERS);
}
if (isEnabled(GLOBAL_ACTION_KEY_SETTINGS,false)) {
itemsList.add(GLOBAL_ACTION_KEY_SETTINGS);
}
if (isEnabled(GLOBAL_ACTION_KEY_LOCKDOWN,false)) {
itemsList.add(GLOBAL_ACTION_KEY_LOCKDOWN);
}
String[] powerMenuItems = itemsList
.toArray(new String[itemsList.size()]);
XResources.setSystemWideReplacement("android","config_globalActionsList",powerMenuItems);
}
项目:GemXperiaXposed
文件:XposedMain.java
@Override
public void initZygote(IXposedHookZygoteInit.StartupParam param) throws Throwable
{
systemUIResources.initFlags();
MODULE_PATH = param.modulePath;
prefs = new XSharedPreferences(XposedMain.class.getPackage().getName());
prefs.makeWorldReadable();
if(JELLYBEAN && prefs.getBoolean("key_hide_shortcuts",false))
{
XResources.setSystemWideReplacement("android","drawable","ic_lockscreen_camera_hint",0);
XResources.setSystemWideReplacement("android","ic_lockscreen_other_widgets_hint",0);
}
}
项目:qcthemer
文件:Module.java
@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resParam) throws Throwable {
if(!resParam.packageName.equals("com.lge.appwidget.clock") && !resParam.packageName.equals("com.lge.clock"))
return;
final String moduleName = QuickcirclemodSettings.class.getPackage().getName();
final Clock c = getActiveClock();
if(c == null)
return;
String resourcetype;
if(Build.DEVICE.equals("g2")) {
resourcetype = "drawable";
} else {
resourcetype = "raw";
}
for(final String file : c.getFiles()) {
try {
resParam.res.setReplacement(resParam.packageName,resourcetype,removeExtension(file),new XResources.DrawableLoader() {
@Override
public Drawable newDrawable(XResources xResources,int i) throws Throwable {
BitmapDrawable drawable = new BitmapDrawable("/data/data/" + moduleName + "/files/" + c.getId() + "/" + file);
drawable.setTargetDensity(c.getDevice() == Clock.Device.G2 ? 480 : 640);
return drawable;
}
});
} catch (Throwable ex) {
XposedBridge.log(ex);
}
}
}
项目:XHangouts
文件:UiColorize.java
private static void replaceAvatarColor(XResources res,String name,int customresId,int dpi,int color) {
int existingResID = res.getIdentifier(name,HANGOUTS_RES_PKG_NAME);
final Bitmap customBitmap;
{
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inMutable = true;
customBitmap = BitmapFactory.decodeResource(res,existingResID,options);
Canvas canvas = new Canvas(customBitmap);
canvas.setDensity(dpi);
canvas.drawColor(color);
// BitmapFactory.decodeResource doesn't work here
// noinspection ConstantConditions
Bitmap avatar = ((BitmapDrawable) res.getDrawable(customresId)).getBitmap();
canvas.drawBitmap(avatar,null);
avatar.recycle();
}
res.setReplacement(existingResID,new XResources.DrawableLoader() {
@Override
public Drawable newDrawable(XResources xResources,int i) throws Throwable {
// If copies aren't made then Hangouts sometimes force closes
return new BitmapDrawable(xResources,customBitmap.copy(Bitmap.Config.ARGB_8888,false));
}
});
}
项目:XHangouts
文件:UiColorize.java
private static void replaceLayoutBackgroundColor(XResources res,final String ResId,final int color) {
res.hookLayout(HANGOUTS_RES_PKG_NAME,new XC_LayoutInflated() {
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
if (ResId == null) {
liparam.view.setBackgroundColor(color);
} else {
liparam.view.findViewById(liparam.res.getIdentifier(ResId,HANGOUTS_RES_PKG_NAME))
.setBackgroundColor(color);
}
}
});
}
项目:XHangouts
文件:UiColorize.java
项目:XHangouts
文件:UiVersionNotice.java
public static void handleInitPackageResources(Config config,XResources res) {
if (!config.modEnabled) {
return;
}
XModuleResources moduleRes = XModuleResources.createInstance(XHangouts.modulePath,res);
dialogTitleId = res.addResource(moduleRes,R.string.hangouts_vdialog_title);
dialogMsgid = res.addResource(moduleRes,R.string.hangouts_vdialog_msg);
dialogUpgradeId = res.addResource(moduleRes,R.string.hangouts_vdialog_upgrade);
dialogDowngradeId = res.addResource(moduleRes,R.string.hangouts_vdialog_downgrade);
dialogButtonId = res.addResource(moduleRes,R.string.hangouts_vdialog_button);
}
项目:XHangouts
文件:UiQuickSettings.java
public static void handleInitPackageResources(Config config,XResources res) {
if (!config.modEnabled) {
return;
}
// Get the resources for this module
XModuleResources moduleRes = XModuleResources.createInstance(XHangouts.modulePath,res);
// Add a new "fake" resource and instantly replace it with the string we actually want
res.setReplacement(res.addResource(moduleRes,R.string.hangouts_menu_title),ACTUAL_TITLE);
// Add the desired menu icon to the Google Hangouts resources for use like above
hangoutsResMenuIcon = res.getIdentifier(HANGOUTS_UNUSED_ICON,null);
res.setReplacement(hangoutsResMenuIcon,moduleRes.fwd(R.drawable.ic_hangouts_menu));
}
@InitZygote(summary = "最低輝度")
public static void minBrightness(StartupParam startupParam,ModBrightnessSettingsGen mBrightnessSettings) throws Throwable {
XResources.setSystemWideReplacement("android","integer","config_screenBrightnessDim",mBrightnessSettings.minBrightness);
if (VersionUtil.isJBmr1OrLater()) {
XResources.setSystemWideReplacement("android","config_screenBrightnessSettingMinimum",mBrightnessSettings.minBrightness);
}
}
@InitZygote(summary = "ActionMenuのテキスト表示")
public static void setConfigAllowActionMenuItemTextWithIcon(StartupParam startupParam,ModotherUtilitiesSettingsGen mOtherUtilitiesSettings) throws Throwable {
XResources.setSystemWideReplacement("android","config_allowActionMenuItemTextWithIcon",mOtherUtilitiesSettings.configAllowActionMenuItemTextWithIcon);
}
public static void initResources(final XSharedPreferences prefs) {
try {
Resources systemRes = XResources.getSystem();
int translucentDecor = Integer.valueOf(prefs.getString(GravityBoxSettings.PREF_KEY_TRANSLUCENT_DECOR,"0"));
if (translucentDecor != 0) {
XResources.setSystemWideReplacement("android","config_enableTranslucentDecor",translucentDecor == 1);
}
if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_NAVBAR_OVERRIDE,false)) {
XResources.setSystemWideReplacement("android","config_showNavigationBar",prefs.getBoolean(GravityBoxSettings.PREF_KEY_NAVBAR_ENABLE,SystemPropertyProvider.getSystemConfigBool(systemRes,"config_showNavigationBar")));
}
XResources.setSystemWideReplacement("android","config_unplugTurnsOnScreen",prefs.getBoolean(GravityBoxSettings.PREF_KEY_UNPLUG_TURNS_ON_SCREEN,"config_unplugTurnsOnScreen")));
if (!Utils.isverneeApolloDevice()) {
int pulseNotificationDelay = prefs.getInt(GravityBoxSettings.PREF_KEY_pulse_NOTIFICATION_DELAY,-1);
if (pulseNotificationDelay != -1) {
XResources.setSystemWideReplacement("android","config_defaultNotificationLedOff",(pulseNotificationDelay));;
}
}
XResources.setSystemWideReplacement("android","config_sip_wifi_only",false);
if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_BRIGHTnesS_MASTER_SWITCH,false)) {
int brightnessMin = prefs.getInt(GravityBoxSettings.PREF_KEY_BRIGHTnesS_MIN,20);
XResources.setSystemWideReplacement(
"android",brightnessMin);
if (DEBUG) log("Minimum brightness value set to: " + brightnessMin);
int screenDim = prefs.getInt(GravityBoxSettings.PREF_KEY_SCREEN_DIM_LEVEL,10);
XResources.setSystemWideReplacement(
"android",screenDim);
if (DEBUG) log("Screen dim level set to: " + screenDim);
}
// Safe media volume
Utils.TriState triState = Utils.TriState.valueOf(prefs.getString(
GravityBoxSettings.PREF_KEY_SAFE_MEDIA_VOLUME,"DEFAULT"));
if (DEBUG) log(GravityBoxSettings.PREF_KEY_SAFE_MEDIA_VOLUME + ": " + triState);
if (triState != Utils.TriState.DEFAULT) {
XResources.setSystemWideReplacement("android","config_safe_media_volume_enabled",triState == Utils.TriState.ENABLED);
if (DEBUG) log("config_safe_media_volume_enabled: " + (triState == Utils.TriState.ENABLED));
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
项目:QuoteLock
文件:XSafeModuleResources.java
public static XSafeModuleResources createInstance(String path,XResources origRes) {
XModuleResources moduleRes = XModuleResources.createInstance(path,origRes);
return new XSafeModuleResources(moduleRes);
}
项目:XposedAppLocale
文件:XposedMod.java
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
loadPrefs();
try {
XposedHelpers.findAndHookMethod(
Resources.class,"updateConfiguration",Configuration.class,displayMetrics.class,"android.content.res.CompatibilityInfo",new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (param.args[0] == null) {
return;
}
String packageName;
Resources res = ((Resources) param.thisObject);
if (res instanceof XResources) {
packageName = ((XResources) res).getPackageName();
} else if (res instanceof XModuleResources) {
return;
} else {
try {
packageName = XResources.getPackageNameDuringConstruction();
} catch (IllegalStateException e) {
return;
}
}
String hostPackageName = AndroidAppHelper.currentPackageName();
boolean isActiveApp = hostPackageName.equals(packageName);
Configuration newConfig = null;
if (packageName != null) {
Locale loc = getPackageSpecificLocale(packageName);
if (loc != null) {
newConfig = new Configuration((Configuration) param.args[0]);
setConfigurationLocale(newConfig,loc);
if (isActiveApp) {
Locale.setDefault(loc);
}
}
}
if (newConfig != null) {
param.args[0] = newConfig;
}
}
}
);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
项目:ForceDoze
文件:XposedModule.java
项目:eui_moder
文件:MainClass.java
@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
// replacements only for systemUI
if (resparam.packageName.equals("com.android.systemUI")) {
loadPrefs();
if (DARK_MATERIAL_COLOR) {
// Set dark material background for notification (color taken from ASOP)
resparam.res.setReplacement("com.android.systemUI","notification_material_background_color",Color.parseColor("#ff303030"));
}
if (disABLE_EUI) {
resparam.res.setReplacement("com.android.systemUI","status_bar_icon_padding",new XResources.DimensionReplacement(0,TypedValue.COMPLEX_UNIT_DIP));
resparam.res.setReplacement("com.android.systemUI","status_bar_icon_drawing_size",new XResources.DimensionReplacement(12,"status_bar_icon_width",TypedValue.COMPLEX_UNIT_DIP));
}
/*
// White Notification bar from ASOP (Theme should be material light to work)
resparam.res.setReplacement("com.android.systemUI",Color.parseColor("#fffafafa"));
resparam.res.setReplacement("com.android.systemUI","notification_material_background_dimmed_color",Color.parseColor("#d4ffffff"));
resparam.res.setReplacement("com.android.systemUI","notification_material_background_low_priority_color",Color.parseColor("#ffdcdcdc"));
resparam.res.setReplacement("com.android.systemUI","notification_ripple_untinted_color",Color.parseColor("#20000000"));
resparam.res.setReplacement("com.android.systemUI","notification_ripple_tinted_color",Color.parseColor("#30ffffff"));
*/
/*
// Trial and error,didn't work as expected
resparam.res.setReplacement("com.android.systemUI","notification_guts_bg_color",Color.parseColor("#1a000000"));
resparam.res.setReplacement("com.android.systemUI","notification_guts_title_color",Color.parseColor("#ff000000"));
resparam.res.setReplacement("com.android.systemUI","notification_guts_text_color",Color.parseColor("#b2000000"));
resparam.res.setReplacement("com.android.systemUI","notification_guts_btn_color",Color.parseColor("#ff000000"));
*/
}
/* else if(resparam.packageName.equals("com.android.settings")){
XposedBridge.log("Inside settings");
// resparam.res.setReplacement("com.android.settings","leui_status_bar_background",Color.parseColor("#ff000000"));
// resparam.res.setReplacement("com.android.settings","status_bar",Color.parseColor("#ffff0000"));
// resparam.res.setReplacement("com.android.settings","leui_activity_background",Color.parseColor("#ff00ff00"));
}*/
}
项目:xposed-art
文件:XC_LayoutInflated.java
@Override
public void unhook() {
XResources.unhookLayout(resDir,id,XC_LayoutInflated.this);
}
项目:xposed-flow
文件:ResourceXposerImpl.java
@Override
public Drawable newDrawable(XResources res,int id) throws Throwable {
return drawable;
}
项目:XHangouts
文件:UiColorize.java
private static void replaceColor(XResources res,int color) {
res.setReplacement(HANGOUTS_RES_PKG_NAME,name,color);
}