Search in sources :

Example 1 with CustomInfoProvider

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);
    }
}
Also used : OmegaLauncher(com.saggitt.omega.OmegaLauncher) CustomInfoProvider(com.saggitt.omega.override.CustomInfoProvider) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon) FolderInfo(com.android.launcher3.FolderInfo) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Aggregations

ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FolderInfo (com.android.launcher3.FolderInfo)1 ItemInfo (com.android.launcher3.ItemInfo)1 ItemInfoWithIcon (com.android.launcher3.ItemInfoWithIcon)1 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)1 OmegaLauncher (com.saggitt.omega.OmegaLauncher)1 CustomInfoProvider (com.saggitt.omega.override.CustomInfoProvider)1