use of com.saggitt.omega.override.CustomInfoProvider in project Neo-Launcher by NeoApplications.
the class CustomBottomSheet method populateAndShow.
@Override
public void populateAndShow(ItemInfo itemInfo) {
super.populateAndShow(itemInfo);
mItemInfo = itemInfo;
mInfoProvider = CustomInfoProvider.Companion.forItem(getContext(), mItemInfo);
TextView title = findViewById(R.id.title);
title.setText(itemInfo.title);
((PrefsFragment) mFragmentManager.findFragmentById(R.id.sheet_prefs)).loadForApp(itemInfo, this::setForceOpen, this::unsetForceOpen, this::reopen);
boolean allowTitleEdit = true;
if (itemInfo instanceof ItemInfoWithIcon || mInfoProvider.supportsIcon()) {
ImageView icon = findViewById(R.id.icon);
if (itemInfo instanceof WorkspaceItemInfo && ((WorkspaceItemInfo) itemInfo).customIcon != null) {
icon.setImageBitmap(((WorkspaceItemInfo) itemInfo).customIcon);
} else if (itemInfo instanceof ItemInfoWithIcon) {
icon.setImageBitmap(((ItemInfoWithIcon) itemInfo).iconBitmap);
} else if (itemInfo instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) itemInfo;
icon.setImageDrawable(folderInfo.getIcon(mLauncher));
// Drawer folder
if (folderInfo.container == ItemInfo.NO_ID) {
// TODO: Allow editing title for drawer folder & sync with group backend
allowTitleEdit = false;
}
}
if (mInfoProvider != null) {
OmegaLauncher launcher = OmegaLauncher.getLauncher(getContext());
icon.setOnClickListener(v -> {
ItemInfo editItem;
if (mItemInfo instanceof FolderInfo && ((FolderInfo) mItemInfo).isCoverMode()) {
editItem = ((FolderInfo) mItemInfo).getCoverInfo();
} else {
editItem = mItemInfo;
}
CustomInfoProvider editProvider = CustomInfoProvider.Companion.forItem(getContext(), editItem);
if (editProvider != null) {
launcher.startEditIcon(editItem, editProvider);
}
});
}
}
if (mInfoProvider != null && allowTitleEdit) {
mPreviousTitle = mInfoProvider.getCustomTitle(mItemInfo);
if (mPreviousTitle == null)
mPreviousTitle = "";
mEditTitle = findViewById(R.id.edit_title);
mEditTitle.setHint(mInfoProvider.getDefaultTitle(mItemInfo));
mEditTitle.setText(mPreviousTitle);
mEditTitle.setVisibility(VISIBLE);
title.setVisibility(View.GONE);
}
}
Aggregations