启动器图标主题

时间:2014-09-22 19:50:28

标签: android launcher theming

guyz我需要再次使用启动器图标主题: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来实现?

1 个答案:

答案 0 :(得分:0)

如果你想更改你的启动器图标,你应该检查我的项目。 https://github.com/slightfoot/android-launcher-badges