【发布时间】:2014-09-22 19:50:28
【问题描述】:
伙计们,我在启动器图标主题方面再次需要一点帮助:p
这是在ADWLauncher中更改LauncherModel.java中图标的方法
static Drawable getIcon(PackageManager manager, Context context, ActivityInfo activityInfo) {
String themePackage=AlmostNexusSettingsHelper.getThemePackageName(context, Launcher.THEME_DEFAULT);
Drawable icon = null;
if(themePackage.equals(Launcher.THEME_DEFAULT)){
icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
}else{
// get from theme
Resources themeResources = null;
if(AlmostNexusSettingsHelper.getThemeIcons(context)){
activityInfo.name=activityInfo.name.toLowerCase().replace(".", "_");
try {
themeResources = manager.getResourcesForApplication(themePackage);
} catch (NameNotFoundException e) {
//e.printStackTrace();
}
if(themeResources!=null){
int resource_id = themeResources.getIdentifier(activityInfo.name, "drawable", themePackage);
if(resource_id!=0){
icon=themeResources.getDrawable(resource_id);
}
// use IconShader
if(icon==null){
if (compiledIconShaderName==null ||
compiledIconShaderName.compareTo(themePackage)!=0){
compiledIconShader = null;
resource_id = themeResources.getIdentifier("shader", "xml", themePackage);
if(resource_id!=0){
XmlResourceParser xpp = themeResources.getXml(resource_id);
compiledIconShader = IconShader.parseXml(xpp);
}
}
if(compiledIconShader!=null){
icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
try {
icon = IconShader.processIcon(icon, compiledIconShader);
} catch (Exception e) {}
}
}
}
}
if(icon==null){
icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
}else{
icon = Utilities.createIconThumbnail(icon, context);
}
}
return icon;
}
但 LauncherModel 中没有这样的方法,而是在 IconCache 内部(不在 ADWLauncher 中)(https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/IconCache.java) 我如何编辑 iconcache.java 来实现它??
【问题讨论】: