Search in sources :

Example 71 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class FocusHelper method handleNextPageFirstItem.

private static View handleNextPageFirstItem(Workspace workspace, CellLayout hotseatLayout, int pageIndex, boolean isRtl) {
    if (pageIndex + 1 >= workspace.getPageCount()) {
        return null;
    }
    CellLayout workspaceLayout = (CellLayout) workspace.getChildAt(pageIndex + 1);
    View newIcon = getFirstFocusableIconInReadingOrder(workspaceLayout, isRtl);
    if (newIcon == null) {
        // Check the hotseat if no focusable item was found on the workspace.
        newIcon = getFirstFocusableIconInReadingOrder(hotseatLayout, isRtl);
        workspace.snapToPage(pageIndex + 1);
    }
    return newIcon;
}
Also used : View(android.view.View) FolderPagedView(com.android.launcher3.folder.FolderPagedView)

Example 72 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class AppWidgetResizeFrame method showForWidget.

public static void showForWidget(LauncherAppWidgetHostView widget, CellLayout cellLayout) {
    Launcher launcher = Launcher.getLauncher(cellLayout.getContext());
    AbstractFloatingView.closeAllOpenViews(launcher);
    DragLayer dl = launcher.getDragLayer();
    AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater().inflate(R.layout.app_widget_resize_frame, dl, false);
    frame.setupForWidget(widget, cellLayout, dl);
    ((DragLayer.LayoutParams) frame.getLayoutParams()).customPosition = true;
    dl.addView(frame);
    frame.mIsOpen = true;
    frame.snapToWidget(false);
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer)

Example 73 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class FocusLogic method createSparseMatrix.

/**
 * Returns a matrix of size same as the {@link CellLayout} dimension that is initialized with the
 * index of the child view.
 */
// TODO: get rid of the dynamic matrix creation
public static int[][] createSparseMatrix(CellLayout layout) {
    ShortcutAndWidgetContainer parent = layout.getShortcutsAndWidgets();
    final int m = layout.getCountX();
    final int n = layout.getCountY();
    final boolean invert = parent.invertLayoutHorizontally();
    int[][] matrix = createFullMatrix(m, n);
    // Iterate thru the children.
    for (int i = 0; i < parent.getChildCount(); i++) {
        View cell = parent.getChildAt(i);
        if (!cell.isFocusable()) {
            continue;
        }
        int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX;
        int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY;
        int x = invert ? (m - cx - 1) : cx;
        if (x < m && cy < n) {
            // check if view fits into matrix, else skip
            matrix[x][cy] = i;
        }
    }
    if (DEBUG) {
        printMatrix(matrix);
    }
    return matrix;
}
Also used : ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) View(android.view.View)

Example 74 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class QuickstepAtomicAnimationFactory method prepareForAtomicAnimation.

@Override
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, StateAnimationConfig config) {
    if (toState == NORMAL && fromState == OVERVIEW) {
        config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
        config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
        config.setInterpolator(ANIM_ALL_APPS_FADE, ACCEL);
        config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
        if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
            config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
        } else {
            config.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
        }
        Workspace workspace = mActivity.getWorkspace();
        // Start from a higher workspace scale, but only if we're invisible so we don't jump.
        boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE;
        if (isWorkspaceVisible) {
            CellLayout currentChild = (CellLayout) workspace.getChildAt(workspace.getCurrentPage());
            isWorkspaceVisible = currentChild.getVisibility() == VISIBLE && currentChild.getShortcutsAndWidgets().getAlpha() > 0;
        }
        if (!isWorkspaceVisible) {
            workspace.setScaleX(0.92f);
            workspace.setScaleY(0.92f);
        }
        Hotseat hotseat = mActivity.getHotseat();
        boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0;
        if (!isHotseatVisible) {
            hotseat.setScaleX(0.92f);
            hotseat.setScaleY(0.92f);
            if (ENABLE_OVERVIEW_ACTIONS.get()) {
                AllAppsContainerView qsbContainer = mActivity.getAppsView();
                View qsb = qsbContainer.getSearchView();
                boolean qsbVisible = qsb.getVisibility() == VISIBLE && qsb.getAlpha() > 0;
                if (!qsbVisible) {
                    qsbContainer.setScaleX(0.92f);
                    qsbContainer.setScaleY(0.92f);
                }
            }
        }
    } else if (toState == NORMAL && fromState == OVERVIEW_PEEK) {
        // Keep fully visible until the very end (when overview is offscreen) to make invisible.
        config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
    } else if (toState == OVERVIEW_PEEK && fromState == NORMAL) {
        config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
        config.setInterpolator(ANIM_OVERVIEW_SCRIM_FADE, FAST_OUT_SLOW_IN);
    } else if ((fromState == NORMAL || fromState == HINT_STATE) && toState == OVERVIEW) {
        if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
            config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
            config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
        } else {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
            config.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
            // Scale up the recents, if it is not coming from the side
            RecentsView overview = mActivity.getOverviewPanel();
            if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) {
                RECENTS_SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE);
            }
        }
        config.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_ALL_APPS_FADE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_DEPTH, OVERSHOOT_1_2);
        Interpolator translationInterpolator = ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(mActivity) ? OVERSHOOT_1_2 : OVERSHOOT_1_7;
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, translationInterpolator);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, translationInterpolator);
    } else if (fromState == HINT_STATE && toState == NORMAL) {
        config.setInterpolator(ANIM_DEPTH, DEACCEL_3);
        if (mHintToNormalDuration == -1) {
            ValueAnimator va = getSpringScaleAnimator(mActivity, mActivity.getWorkspace(), toState.getWorkspaceScaleAndTranslation(mActivity).scale);
            mHintToNormalDuration = (int) va.getDuration();
        }
        config.duration = Math.max(config.duration, mHintToNormalDuration);
    }
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Hotseat(com.android.launcher3.Hotseat) CellLayout(com.android.launcher3.CellLayout) RecentsView(com.android.quickstep.views.RecentsView) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) RecentsView(com.android.quickstep.views.RecentsView) Workspace(com.android.launcher3.Workspace)

Example 75 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatEduController method migrateHotseatWhole.

/**
 * This migration option attempts to move the entire hotseat up to the first workspace that
 * has space to host items. If no such page is found, it moves items to a new page.
 *
 * @return pageId where items are migrated
 */
private int migrateHotseatWhole() {
    Workspace workspace = mLauncher.getWorkspace();
    int pageId = -1;
    int toRow = 0;
    for (int i = 0; i < workspace.getPageCount(); i++) {
        CellLayout target = workspace.getScreenWithId(workspace.getScreenIdForPageIndex(i));
        if (target.makeSpaceForHotseatMigration(true)) {
            toRow = mLauncher.getDeviceProfile().inv.numRows - 1;
            pageId = i;
            break;
        }
    }
    if (pageId == -1) {
        pageId = LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_SCREEN_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
        mNewScreens = IntArray.wrap(pageId);
    }
    for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
        View child = mHotseat.getChildAt(i, 0);
        if (child == null || child.getTag() == null)
            continue;
        ItemInfo tag = (ItemInfo) child.getTag();
        if (tag.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION)
            continue;
        mLauncher.getModelWriter().moveItemInDatabase(tag, LauncherSettings.Favorites.CONTAINER_DESKTOP, pageId, i, toRow);
        mNewItems.add(tag);
    }
    return pageId;
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrowTipView(com.android.launcher3.views.ArrowTipView) View(android.view.View) Workspace(com.android.launcher3.Workspace)

Aggregations

CellLayout (com.android.launcher3.CellLayout)178 View (android.view.View)169 SuppressLint (android.annotation.SuppressLint)126 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)124 AppWidgetHostView (android.appwidget.AppWidgetHostView)105 Point (android.graphics.Point)95 DragView (com.android.launcher3.dragndrop.DragView)91 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)87 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)73 BubbleTextView (com.android.launcher3.BubbleTextView)62 Rect (android.graphics.Rect)60 FolderIcon (com.android.launcher3.folder.FolderIcon)52 DragLayer (com.android.launcher3.dragndrop.DragLayer)50 ArrayList (java.util.ArrayList)48 FolderInfo (com.android.launcher3.model.data.FolderInfo)45 Workspace (com.android.launcher3.Workspace)43 DraggableView (com.android.launcher3.dragndrop.DraggableView)43 Animator (android.animation.Animator)42 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40