【问题标题】:Launcher icon Theming启动器图标主题
【发布时间】: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 来实现它??

【问题讨论】:

    标签: android launcher theming


    【解决方案1】:

    如果你想改变你的启动器图标,你应该看看我的项目就是这样。 https://github.com/slightfoot/android-launcher-badges

    【讨论】:

    • thnx,我会检查一下,但我正在尝试添加 ADW 的主题包兼容性:p 我已经添加了大部分,只是图标有问题:-/
    • 我在想,也许我会害怕,删除 iconcache 系统,然后像在 ADWLauncher 中那样做,但这是我最后的手段,因为它会影响应用程序的效率
    猜你喜欢
    • 2013-02-04
    • 1970-01-01
    • 2017-04-26
    • 2019-10-06
    • 1970-01-01
    • 2017-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多