安卓11 手动生成的文件夹,默认是没有名字的,怎样修改呢?
alps/packages/apps/Launcher3/src/com/android/launcher3/folder/FolderIcon.java
public static FolderIcon inflateIcon(int resId, ActivityContext activity, ViewGroup group,
FolderInfo folderInfo) {
@SuppressWarnings("all") // suppress dead code warning
final boolean error = INITIAL_ITEM_ANIMATION_DURATION >= DROP_IN_ANIMATION_DURATION;
if (error) {
throw new IllegalStateException("DROP_IN_ANIMATION_DURATION must be greater than " +
"INITIAL_ITEM_ANIMATION_DURATION, as sequencing of adding first two items " +
"is dependent on this");
}
DeviceProfile grid = activity.getDeviceProfile();
FolderIcon icon = (FolderIcon) LayoutInflater.from(group.getContext())
.inflate(resId, group, false);
icon.setClipToPadding(false);
icon.mFolderName = icon.findViewById(R.id.folder_icon_name);
// Add +++++++++++++++++++++++++ start
if (TextUtils.isEmpty(folderInfo.title) && activity instanceof Launcher) {
folderInfo.setTitle(group.getResources().getString(R.string.folder_hint_text), ((Launcher) activity).getModelWriter());
}
// Add ++++++++++++++++++++++++++++ end
icon.mFolderName.setText(folderInfo.title);
icon.mFolderName.setCompoundDrawablePadding(0);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) icon.mFolderName.getLayoutParams();
lp.topMargin = grid.iconSizePx + grid.iconDrawablePaddingPx;
icon.setTag(folderInfo);
icon.setOnClickListener(ItemClickHandler.INSTANCE);
icon.mInfo = folderInfo;
icon.mActivity = activity;
}
判断显示为空的时候,我们默认添加一个就行,字符串自己添加。