前段时间做的一个Laucnher应用,因为可以在IconCache中修改应用图标。现在有需求需要修改应用的名字,但是在IconCache中修改已知都没法实现。
跟踪代码发现每次加载桌面时,都会执行BubbleTextView类中的applyFromShortcutInfo方法去设置应用的图标和名字。测试后发现在该方法中根据应用包名去设置应用的名字是可行的。
public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache,
boolean setDefaultPadding, boolean promiseStateChanged) {
Bitmap b = info.getIcon(iconCache);
LauncherAppState app = LauncherAppState.getInstance();
FastBitmapDrawable iconDrawable = Utilities.createIconDrawable(b);
iconDrawable.setGhostModeEnabled(info.isDisabled != 0);
setCompoundDrawables(null, iconDrawable, null, null);
if (setDefaultPadding) {
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
}
if (info.contentDescription != null) {
setContentDescription(info.contentDescription);
}
setText(info.title);
setTag(info);
//远程工具
if (info.getIntent().getComponent().getPackageName().equals(
"com.teamviewer.quicksupport.market")){
setText(mContext.getString(R.string.quicksupport));
}
}