launcher- 第三方应用图标替换

有时候我们感觉第三方应用的icon不美观,或者跟我们主题风格不一致,这时候我们希望换成我们想要的icon,那我们可以这么做(以更换QQ应用icon为例):

1.首先我们当然要根据自己的需要做一张替换icon了(图片我们不妨命名为qq)

2.接下来我们需要得到第三方应用的信息,可以通过GetDftlayoutXml.apk 工具获得

具体步骤如下

1)网上下载想要替换icon的第三方应用

2)安装GetDftlayoutXml.apk工具

这个工具存在 git/vanzo_team/xulei/cooee_tool/目录下,我们直接push到手机system/app下进行了

 安装工具:cd ~/git/vanzo_team/xulei/cooee_tool/;adb remoung;adb push GetDftlayoutXml.apk system/app;

3)获取应用信息(主要存在于通过工具生成的uin_default_auto.xml文件中)  

   点击安装的程序GetDftlayoutXml,进入界面选择uni,这时候就会在手机sdcard/cooee/ 目录下生成uin_default_auto.xml文件

4)  导出文件:adb pull /sdcard/cooee/uni_default_layout_auto.xml ~/Desktop;

3.查看应用信息

打开我们得到的uni_default_layout_auto.xml 文件,可以看到如下信息

vim uni_default_layout_auto.xml;

内容如下:

 

<shortcutgroup id="2" locate="workspace" locate_value="2">
    <item id="0" name="Google 设置" cellX="0" cellY="4" image="" pkgname="com.google.android.gms" componentName="com.google.android.gms.app.settings.GoogleSettingsActivity" />
    <item id="1" name="Play 商店" cellX="1" cellY="4" image="" pkgname="com.android.vending" componentName="com.android.vending.AssetBrowserActivity" />
    <item id="2" name="安卓市场" cellX="2" cellY="4" image="" pkgname="com.my.appstore" componentName="com.my.appstore.activity.MainActivity" />
    <item id="3" name="Dev Tools" cellX="3" cellY="4" image="" pkgname="com.android.development" componentName="com.android.development.Development" />
    <item id="4" name="GetDftlayoutXml" cellX="0" cellY="3" image="" pkgname="com.cool.getdftlayoutxml" componentName="com.cool.getdftlayoutxml.MainActivity" />
    <item id="5" name="腾讯视频" cellX="1" cellY="3" image="" pkgname="com.tencent.qqlive" componentName="com.tencent.qqlive.activity.WelcomeActivity" />
    <item id="6" name="百度" cellX="2" cellY="3" image="" pkgname="com.baidu.searchbox" componentName="com.baidu.searchbox.MainActivity" />
    <item id="7" name="QQ浏览器" cellX="3" cellY="3" image="" pkgname="com.tencent.mtt" componentName="com.tencent.mtt.SplashActivity" />
    <item id="8" name="豌豆荚" cellX="0" cellY="2" image="" pkgname="com.wandoujia.phoenix2" componentName="com.wandoujia.p4.activity.ExploreActivity" />
    <item id="9" name="1号店" cellX="1" cellY="2" image="" pkgname="com.thestore.main" componentName="com.thestore.main.LoadingActivity" />
    <item id="10" name="360手机助手" cellX="2" cellY="2" image="" pkgname="com.qihoo.appstore" componentName="com.qihoo.appstore.activities.LauncherActivity" />
    <item id="11" name=" 360卫士" cellX="3" cellY="2" image="" pkgname="com.qihoo360.mobilesafe" componentName="com.qihoo360.mobilesafe.ui.index.AppEnterActivity" />
    <item id="12" name="优酷" cellX="0" cellY="1" image="" pkgname="com.youku.phone" componentName="com.youku.phone.ActivityWelcome" />
    <item id="13" name="暴风影音" cellX="1" cellY="1" image="" pkgname="com.storm.smart" componentName="com.storm.smart.LogoActivity" />
    <item id="14" name="网易新闻" cellX="2" cellY="1" image="" pkgname="com.netease.newsreader.activity" componentName="com.netease.nr.biz.ad.AdActivity" />
    <item id="15" name="百度视频" cellX="3" cellY="1" image="" pkgname="com.baidu.video" componentName="com.baidu.video.ui.WelcomActivity" />
    <item id="16" name="搜狗浏览器" cellX="0" cellY="0" image="" pkgname="sogou.mobile.explorer" componentName="sogou.mobile.explorer.NoDisplayActivity" />
    <item id="17" name="今日头条" cellX="1" cellY="0" image="" pkgname="com.ss.android.article.news" componentName="com.ss.android.article.news.activity.SplashActivity" />
    <item id="18" name="去哪儿旅行" cellX="2" cellY="0" image="" pkgname="com.Qunar" componentName="com.Qunar.NoteActivity" />
    <item id="19" name="唯品会" cellX="3" cellY="0" image="" pkgname="com.achievo.vipshop" componentName="com.achievo.vipshop.activity.LodingActivity" />
    <item id="20" name="QQ" cellX="1" cellY="4" image="" pkgname="com.tencent.mobileqq" componentName="com.tencent.mobileqq.activity.SplashActivity" />

 

 

 

这里面就是我们手机里面安装的应用信息

 解释:

<shortcutgroup id="2" locate="workspace" locate_value="2">:屏幕序号
<item id="9" name="1号店" cellX="1" cellY="2" image="" pkgname="com.thestore.main" componentName="com.thestore.main.LoadingActivity" />:应用信息

4.  拷贝信息:

在我们项目的vendor/tmobile/launcher/ 目录下,有一个文件uni_default_layout.xml 

可以看到他的内容如下

 <shortcutgroup id="1" locate="workspace" locate_value="1">
    <item id="0" name="备份与恢复" cellX="1" cellY="2" image="" pkgname="com.mediatek.datatransfer" componentName="com.mediatek.datatransfer.MainActivity" />
    <item id="1" name="手电筒" cellX="2" cellY="4" image="" pkgname="net.cactii.flash2" componentName="net.cactii.flash2.MainActivity" />
    <item id="2" name="壁纸" cellX="0" cellY="4" image="" pkgname="com.android.wallpaper.multipicker" componentName="com.android.wallpaper.multipicker.WallpaperChooser" />
    <item id="3" name="系统升级" cellX="1" cellY="4" image="" pkgname="com.mediatek.updatesystem" componentName="com.mediatek.updatesystem.UpdateSystem" />
    <item id="5" name="录音机" cellX="1" cellY="3" image="" pkgname="com.android.soundrecorder" componentName="com.android.soundrecorder.SoundRecorder" />
    <item id="6" name="视频" cellX="2" cellY="3" image="" pkgname="com.mediatek.videoplayer" componentName="com.mediatek.videoplayer.MovieListActivity" />
    <item id="7" name="下载" cellX="3" cellY="3" image="" pkgname="com.android.providers.downloads.ui" componentName="com.android.providers.downloads.ui.DownloadList" />
    <item id="8" name="SIM卡应用" cellX="0" cellY="2" image="" pkgname="com.mediatek.stkselection" componentName="com.mediatek.stkselection.StkSelection" />
    <item id="9" name="收音机" cellX="0" cellY="3" image="" pkgname="com.mediatek.fmradio" componentName="com.mediatek.fmradio.FMRadioActivity" />
    <item id="10" name="电子邮件" cellX="3" cellY="4" image="" pkgname="com.android.email" componentName="com.android.email.activity.Welcome" />
    <item id="11" name="空" cellX="3" cellY="2" image="" pkgname="" componentName="" />
    <item id="12" name="空" cellX="0" cellY="1" image="" pkgname="" componentName="" />
    <item id="13" name="空" cellX="1" cellY="1" image="" pkgname="" componentName="" />
    <item id="14" name="空" cellX="2" cellY="1" image="" pkgname="" componentName="" />
    <item id="15" name="空" cellX="3" cellY="1" image="" pkgname="" componentName="" />
    <item id="16" name="空" cellX="0" cellY="0" image="" pkgname="" componentName="" />
    <item id="17" name="空" cellX="1" cellY="0" image="" pkgname="" componentName="" />
    <item id="18" name="空" cellX="2" cellY="0" image="" pkgname="" componentName="" />
    <item id="19" name="空" cellX="3" cellY="0" image="" pkgname="" componentName="" />
 </shortcutgroup>

    <!-- 替换launcher中应用的图标,将需要替换的图标放到system/launcher/icon这个路径下,参考下面的范例,配置包名,类名和图片名称即可替换应用图片 -->
    <!-- 
    <icon
        name="360卫士"
        componentName="com.qihoo360.mobilesafe.ui.index.AppEnterActivity"
        image="360Guard.png"
        pkgname="com.qihoo360.mobilesafe" />
    -->
    <icon name="文件管理" image="folder.png" pkgname="com.mediatek.filemanager" componentName="com.mediatek.filemanager.FileManagerOperationActivity" />
    <icon name="计算器" image="calculator.png" pkgname="com.android.calculator2" componentName="com.android.calculator2.Calculator" />
    <icon name="时钟" image="clock.png" pkgname="com.android.deskclock" componentName="com.android.deskclock.DeskClock" />
    <icon name="日历" image="calendar.png" pkgname="com.android.calendar" componentName="com.android.calendar.AllInOneActivity" />
    <icon name="设置" image="settings.png" pkgname="com.android.settings" componentName="com.android.settings.Settings" />
    <icon name="音乐" image="music.png" pkgname="com.v5music" componentName="com.v5music.view.activity.MainActivity;com.v5music.view.activity.SplashActivity" />
    <icon name="相机" image="camera.png" pkgname="com.android.gallery3d" componentName="com.android.camera.CameraLauncher" />
    <icon name="图库" image="gallery.png" pkgname="com.android.gallery3d" componentName="com.vz.gallery3d.VzGalleryActivity" />
    <icon name="备份与恢复" image="backandrestore.png" pkgname="com.mediatek.datatransfer" componentName="com.mediatek.datatransfer.MainActivity" />

    <icon name="安卓市场" image="androidmarket.png" pkgname="com.my.appstore" componentName="com.my.appstore.activity.MainActivity" />
    <icon name="壁纸" image="wallpaper.png" pkgname="com.android.wallpaper.multipicker" componentName="com.android.wallpaper.multipicker.WallpaperChooser" />
    <icon name="今日头条" image="jinritoutiao.png" pkgname="com.ss.android.article.news" componentName="com.ss.android.article.news.activity.SplashActivity" />
    <icon name="掌阅ireader" image="zhangyue.png" pkgname="com.chaozh.iReaderFree" componentName="com.chaozh.iReader.ui.activity.WelcomeActivity" />
    <icon name="百度" image="baidu.png" pkgname="com.baidu.searchbox" componentName="com.baidu.searchbox.MainActivity" />

 

这时候我们只需要把我们在uni_default_layout_auto.xml  文件下得到的关于 qq 的应用信息(

<item id="20" name="QQ" cellX="1" cellY="4" image="" pkgname="com.tencent.mobileqq" componentName="com.tencent.mobileqq.activity.SplashActivity" />

),添加到  uni_default_layout.xml 里来就行了

这时候要注意

1)把<item..  更改为<icon

2)cellx celly id 三项删除掉

3)在image=""中写入自己想要替换的icon资源名称

(也就是完全按照uni_default_layout.xml 上的格式写就对了

<icon name="QQ" image="qq" pkgname="com.tencent.mobileqq" componentName="com.tencent.mobileqq.activity.SplashActivity" />

4)别忘了把图片资源拷贝到

vendor/tmobile/launcher/cooee_icon/icon/drawable-xxhdpi 和vendor/tmobile/launcher/default_icon/icon 文件夹下(两个都要添加)

 

5.验证效果

  1)把修改后的文件导入手机system/launcher下:adb push uni_default_layout.xml system/launcher;adb push cooee_icon/icon system/launcher/

  2)进入手机设置->应用管理,清空oos应用数据,重新进入桌面看图标效果就行了

 

遇到问题

1.有一次图标没有替换成功,后来发现是因为图片忘了引用了,然后自己做了更改,但是,当验证的时候,手机会死机,最终重新烧录了才解决。然后就开始寻找问题的原因

-----原来是自己把<icon name="文件管理" image="folder.png" pkgname="com.mediatek.filemanager" componentName="com.mediatek.filemanager.FileManagerOperationActivity" />

写成了<item name="文件管理" image="folder.png" pkgname="com.mediatek.filemanager" componentName="com.mediatek.filemanager.FileManagerOperationActivity" />

2.还有一次,好多的应用图标突然就不起作用了,后来同事给的建议是,使用hierarchyView ,点进应用里面去看包名。这个方法试了好久都不起作用,后来

-----重新用工具抓包名,发现包名更改非常大,至于原因,不知道,难道是跟应用版本有关?

3.当执行adb push cooee_icon/icon system/launcher/icon 命令的时候,一直报错,说是找不到文件夹,如下

zhangshuli@zhangshuli-MS-7817:~/PROJECT/PROJECT_V5/new_52_kangjia_kk/vendor/tmobile/launcher$ adb push cooee_icon/icon system/launcher/zhang
push: cooee_icon/icon/drawable-xxhdpi/weather.png -> system/launcher/zhang/drawable-xxhdpi/weather.png
failed to copy 'cooee_icon/icon/drawable-xxhdpi/weather.png' to 'system/launcher/icon/drawable-xxhdpi/weather.png': No such file or directory
zhangshuli@zhangshuli-MS-7817:~/PROJECT/PROJECT_V5/new_52_kangjia_kk/vendor/tmobile/launcher$

 

后来才明白,原来,手机目录下,并不支持自动创建不存在的文件夹,这时候必须先创建icon才行

mkdir icon

然后在push

posted @ 2015-01-13 09:47  小白屋  阅读(3894)  评论(0编辑  收藏  举报