Search in sources :

Example 71 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Trebuchet by LineageOS.

the class FolderPagedView method unbindItems.

/**
 * Removes all the icons from the folder
 */
public void unbindItems() {
    for (int i = getChildCount() - 1; i >= 0; i--) {
        CellLayout page = (CellLayout) getChildAt(i);
        ShortcutAndWidgetContainer container = page.getShortcutsAndWidgets();
        for (int j = container.getChildCount() - 1; j >= 0; j--) {
            container.getChildAt(j).setVisibility(View.VISIBLE);
            mViewCache.recycleView(R.layout.folder_application, container.getChildAt(j));
        }
        page.removeAllViews();
        mViewCache.recycleView(R.layout.folder_page, page);
    }
    removeAllViews();
    mViewsBound = false;
}
Also used : CellLayout(com.android.launcher3.CellLayout) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) SuppressLint(android.annotation.SuppressLint)

Example 72 with Folder

use of com.android.launcher3.tapl.Folder 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)

Example 73 with Folder

use of com.android.launcher3.tapl.Folder in project Neo-Launcher by NeoApplications.

the class FocusHelper method handleHotseatButtonKeyEvent.

/**
 * Handles key events in the workspace hotseat (bottom of the screen).
 * <p>Currently we don't special case for the phone UI in different orientations, even though
 * the hotseat is on the side in landscape mode. This is to ensure that accessibility
 * consistency is maintained across rotations.
 */
static boolean handleHotseatButtonKeyEvent(View v, int keyCode, KeyEvent e) {
    boolean consume = FocusLogic.shouldConsume(keyCode);
    if (e.getAction() == KeyEvent.ACTION_UP || !consume) {
        return consume;
    }
    final Launcher launcher = Launcher.getLauncher(v.getContext());
    final DeviceProfile profile = launcher.getDeviceProfile();
    if (DEBUG) {
        Log.v(TAG, String.format("Handle HOTSEAT BUTTONS keyevent=[%s] on hotseat buttons, isVertical=%s", KeyEvent.keyCodeToString(keyCode), profile.isVerticalBarLayout()));
    }
    // Initialize the variables.
    final Workspace workspace = (Workspace) v.getRootView().findViewById(R.id.workspace);
    final ShortcutAndWidgetContainer hotseatParent = (ShortcutAndWidgetContainer) v.getParent();
    final CellLayout hotseatLayout = (CellLayout) hotseatParent.getParent();
    final ItemInfo itemInfo = (ItemInfo) v.getTag();
    int pageIndex = workspace.getNextPage();
    int pageCount = workspace.getChildCount();
    int iconIndex = hotseatParent.indexOfChild(v);
    int iconRank = ((CellLayout.LayoutParams) hotseatLayout.getShortcutsAndWidgets().getChildAt(iconIndex).getLayoutParams()).cellX;
    final CellLayout iconLayout = (CellLayout) workspace.getChildAt(pageIndex);
    if (iconLayout == null) {
        // animation.)
        return consume;
    }
    final ViewGroup iconParent = iconLayout.getShortcutsAndWidgets();
    ViewGroup parent = null;
    int[][] matrix = null;
    if (keyCode == KeyEvent.KEYCODE_DPAD_UP && !profile.isVerticalBarLayout()) {
        matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
        iconIndex += iconParent.getChildCount();
        parent = iconParent;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && profile.isVerticalBarLayout()) {
        matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
        iconIndex += iconParent.getChildCount();
        parent = iconParent;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && profile.isVerticalBarLayout()) {
        keyCode = KeyEvent.KEYCODE_PAGE_DOWN;
    } else {
        // For other KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT navigation, do not use the
        // matrix extended with hotseat.
        matrix = FocusLogic.createSparseMatrix(hotseatLayout);
        parent = hotseatParent;
    }
    // Process the focus.
    int newIconIndex = FocusLogic.handleKeyEvent(keyCode, matrix, iconIndex, pageIndex, pageCount, Utilities.isRtl(v.getResources()));
    View newIcon = null;
    switch(newIconIndex) {
        case FocusLogic.NEXT_PAGE_FIRST_ITEM:
            parent = getCellLayoutChildrenForIndex(workspace, pageIndex + 1);
            newIcon = parent.getChildAt(0);
            // TODO(hyunyoungs): handle cases where the child is not an icon but
            // a folder or a widget.
            workspace.snapToPage(pageIndex + 1);
            break;
        case FocusLogic.PREVIOUS_PAGE_FIRST_ITEM:
            parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
            newIcon = parent.getChildAt(0);
            // TODO(hyunyoungs): handle cases where the child is not an icon but
            // a folder or a widget.
            workspace.snapToPage(pageIndex - 1);
            break;
        case FocusLogic.PREVIOUS_PAGE_LAST_ITEM:
            parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
            newIcon = parent.getChildAt(parent.getChildCount() - 1);
            // TODO(hyunyoungs): handle cases where the child is not an icon but
            // a folder or a widget.
            workspace.snapToPage(pageIndex - 1);
            break;
        case FocusLogic.PREVIOUS_PAGE_LEFT_COLUMN:
        case FocusLogic.PREVIOUS_PAGE_RIGHT_COLUMN:
            // Go to the previous page but keep the focus on the same hotseat icon.
            workspace.snapToPage(pageIndex - 1);
            break;
        case FocusLogic.NEXT_PAGE_LEFT_COLUMN:
        case FocusLogic.NEXT_PAGE_RIGHT_COLUMN:
            // Go to the next page but keep the focus on the same hotseat icon.
            workspace.snapToPage(pageIndex + 1);
            break;
    }
    if (parent == iconParent && newIconIndex >= iconParent.getChildCount()) {
        newIconIndex -= iconParent.getChildCount();
    }
    if (parent != null) {
        if (newIcon == null && newIconIndex >= 0) {
            newIcon = parent.getChildAt(newIconIndex);
        }
        if (newIcon != null) {
            newIcon.requestFocus();
            playSoundEffect(keyCode, v);
        }
    }
    return consume;
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) FolderPagedView(com.android.launcher3.folder.FolderPagedView)

Example 74 with Folder

use of com.android.launcher3.tapl.Folder in project Neo-Launcher by NeoApplications.

the class FolderInfo method getFolderIcon.

public Drawable getFolderIcon(Launcher launcher) {
    int iconSize = launcher.mDeviceProfile.iconSizePx;
    FrameLayout dummy = new FrameLayout(launcher, null);
    FolderIcon icon = FolderIcon.fromXml(R.layout.folder_icon, launcher, dummy, this);
    icon.isCustomIcon = false;
    icon.getFolderBackground().setStartOpacity(1f);
    Bitmap b = BitmapRenderer.createHardwareBitmap(iconSize, iconSize, out -> {
        out.translate(iconSize / 2f, 0);
        // TODO: make folder icons more visible in front of the bottom sheet
        // out.drawColor(Color.RED);
        icon.draw(out);
    });
    icon.unbind();
    return new BitmapDrawable(launcher.getResources(), b);
}
Also used : Bitmap(android.graphics.Bitmap) FolderIcon(com.android.launcher3.folder.FolderIcon) FrameLayout(android.widget.FrameLayout) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 75 with Folder

use of com.android.launcher3.tapl.Folder in project Neo-Launcher by NeoApplications.

the class LauncherProvider method deleteEmptyFolders.

/**
 * Deletes any empty folder from the DB.
 * @return Ids of deleted folders.
 */
private IntArray deleteEmptyFolders() {
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    try (SQLiteTransaction t = new SQLiteTransaction(db)) {
        // Select folders whose id do not match any container value.
        String selection = LauncherSettings.Favorites.ITEM_TYPE + " = " + LauncherSettings.Favorites.ITEM_TYPE_FOLDER + " AND " + LauncherSettings.Favorites._ID + " NOT IN (SELECT " + LauncherSettings.Favorites.CONTAINER + " FROM " + Favorites.TABLE_NAME + ")";
        IntArray folderIds = LauncherDbUtils.queryIntArray(db, Favorites.TABLE_NAME, Favorites._ID, selection, null, null);
        if (!folderIds.isEmpty()) {
            db.delete(Favorites.TABLE_NAME, Utilities.createDbSelectionQuery(LauncherSettings.Favorites._ID, folderIds), null);
        }
        t.commit();
        return folderIds;
    } catch (SQLException ex) {
        Log.e(TAG, ex.getMessage(), ex);
        return new IntArray();
    }
}
Also used : IntArray(com.android.launcher3.util.IntArray) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) SQLException(android.database.SQLException) SQLiteTransaction(com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction)

Aggregations

View (android.view.View)119 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)112 FolderInfo (com.android.launcher3.model.data.FolderInfo)93 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 Point (android.graphics.Point)83 FolderIcon (com.android.launcher3.folder.FolderIcon)83 Folder (com.android.launcher3.folder.Folder)82 AppWidgetHostView (android.appwidget.AppWidgetHostView)80 SuppressLint (android.annotation.SuppressLint)73 DragView (com.android.launcher3.dragndrop.DragView)64 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)64 Rect (android.graphics.Rect)63 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)61 BubbleTextView (com.android.launcher3.BubbleTextView)56 ArrayList (java.util.ArrayList)49 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 Animator (android.animation.Animator)40 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 Drawable (android.graphics.drawable.Drawable)37 CellLayout (com.android.launcher3.CellLayout)37