Search in sources :

Example 26 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by crdroidandroid.

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);
    if (widget.hasEnforcedCornerRadius()) {
        float enforcedCornerRadius = widget.getEnforcedCornerRadius();
        ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
        Drawable d = imageView.getDrawable();
        if (d instanceof GradientDrawable) {
            GradientDrawable gd = (GradientDrawable) d.mutate();
            gd.setCornerRadius(enforcedCornerRadius);
        }
    }
    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) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ImageView(android.widget.ImageView) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 27 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by AOSPA.

the class QuickstepAtomicAnimationFactory method prepareForAtomicAnimation.

@Override
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, StateAnimationConfig config) {
    RecentsView overview = mActivity.getOverviewPanel();
    if (toState == NORMAL && fromState == OVERVIEW) {
        config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR, 0, 0.25f));
        config.setInterpolator(ANIM_SCRIM_FADE, LINEAR);
        config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
        config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
        if (SysUINavigationMode.getMode(mActivity).hasGestures && overview.getTaskViewCount() > 0) {
            // Overview is going offscreen, so keep it at its current scale and opacity.
            config.setInterpolator(ANIM_OVERVIEW_SCALE, FINAL_FRAME);
            config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, clampToProgress(FAST_OUT_SLOW_IN, 0, 0.75f));
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, FINAL_FRAME);
        } else {
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
            config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
            config.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
        }
        // Scroll RecentsView to page 0 as it goes offscreen, if necessary.
        int numPagesToScroll = overview.getNextPage() - DEFAULT_PAGE;
        long scrollDuration = Math.min(MAX_PAGE_SCROLL_DURATION, numPagesToScroll * PER_PAGE_SCROLL_DURATION);
        config.duration = Math.max(config.duration, scrollDuration);
        overview.snapToPage(DEFAULT_PAGE, Math.toIntExact(config.duration));
        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(WORKSPACE_PREPARE_SCALE);
            workspace.setScaleY(WORKSPACE_PREPARE_SCALE);
        }
        Hotseat hotseat = mActivity.getHotseat();
        boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0;
        if (!isHotseatVisible) {
            hotseat.setScaleX(WORKSPACE_PREPARE_SCALE);
            hotseat.setScaleY(WORKSPACE_PREPARE_SCALE);
        }
    } else if ((fromState == NORMAL || fromState == HINT_STATE || fromState == HINT_STATE_TWO_BUTTON) && toState == OVERVIEW) {
        if (SysUINavigationMode.getMode(mActivity).hasGestures) {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
            config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
            // Scrolling in tasks, so show straight away
            if (overview.getTaskViewCount() > 0) {
                config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
            } else {
                config.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
            }
        } 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
            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);
        config.setInterpolator(ANIM_SCRIM_FADE, t -> {
            // Animate at the same rate until reaching progress 1, and skip the overshoot.
            return Math.min(1, OVERSHOOT_1_2.getInterpolation(t));
        });
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, OVERSHOOT_1_2);
    } 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);
    } else if (fromState == ALL_APPS && toState == NORMAL) {
        config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD, 1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
        config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD, 1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
    }
}
Also used : ANIM_OVERVIEW_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE) ANIM_WORKSPACE_TRANSLATE(com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE) Interpolators.clampToProgress(com.android.launcher3.anim.Interpolators.clampToProgress) DEACCEL(com.android.launcher3.anim.Interpolators.DEACCEL) ANIM_OVERVIEW_TRANSLATE_X(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) INSTANT(com.android.launcher3.anim.Interpolators.INSTANT) OVERSHOOT_1_2(com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2) ANIM_OVERVIEW_TRANSLATE_Y(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y) DEACCEL_1_7(com.android.launcher3.anim.Interpolators.DEACCEL_1_7) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) ALL_APPS_SCRIM_VISIBLE_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_VISIBLE_THRESHOLD) ANIM_OVERVIEW_SCALE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE) Interpolators(com.android.launcher3.anim.Interpolators) VISIBLE(android.view.View.VISIBLE) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD) QuickstepLauncher(com.android.launcher3.uioverrides.QuickstepLauncher) ANIM_WORKSPACE_SCALE(com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE) ANIM_OVERVIEW_ACTIONS_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_ACTIONS_FADE) DEACCEL_3(com.android.launcher3.anim.Interpolators.DEACCEL_3) RecentsAtomicAnimationFactory(com.android.quickstep.util.RecentsAtomicAnimationFactory) CellLayout(com.android.launcher3.CellLayout) LauncherState(com.android.launcher3.LauncherState) WorkspaceStateTransitionAnimation.getSpringScaleAnimator(com.android.launcher3.WorkspaceStateTransitionAnimation.getSpringScaleAnimator) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) Hotseat(com.android.launcher3.Hotseat) ANIM_DEPTH(com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) RECENTS_SCALE_PROPERTY(com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY) FINAL_FRAME(com.android.launcher3.anim.Interpolators.FINAL_FRAME) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) ANIM_WORKSPACE_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE) ANIM_ALL_APPS_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE) RecentsView(com.android.quickstep.views.RecentsView) ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD) Workspace(com.android.launcher3.Workspace) ANIM_SCRIM_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) ALL_APPS_SCRIM_OPAQUE_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_OPAQUE_THRESHOLD) NORMAL(com.android.launcher3.LauncherState.NORMAL) HINT_STATE_TWO_BUTTON(com.android.launcher3.LauncherState.HINT_STATE_TWO_BUTTON) ACCEL(com.android.launcher3.anim.Interpolators.ACCEL) ACCEL_DEACCEL(com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL) ValueAnimator(android.animation.ValueAnimator) Hotseat(com.android.launcher3.Hotseat) CellLayout(com.android.launcher3.CellLayout) RecentsView(com.android.quickstep.views.RecentsView) ValueAnimator(android.animation.ValueAnimator) Workspace(com.android.launcher3.Workspace)

Example 28 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by AOSPA.

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);
    }
    boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
    int hotseatItemsNum = mLauncher.getDeviceProfile().numShownHotseatIcons;
    for (int i = 0; i < hotseatItemsNum; i++) {
        int x = isPortrait ? i : 0;
        int y = isPortrait ? 0 : hotseatItemsNum - i - 1;
        View child = mHotseat.getChildAt(x, y);
        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) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) Workspace(com.android.launcher3.Workspace)

Example 29 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatEduController method showEdu.

void showEdu() {
    int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
    CellLayout cellLayout = mLauncher.getWorkspace().getScreenWithId(Workspace.FIRST_SCREEN_ID);
    // hotseat is already empty and does not require migration. show edu tip
    boolean requiresMigration = IntStream.range(0, childCount).anyMatch(i -> {
        View v = mHotseat.getShortcutsAndWidgets().getChildAt(i);
        return v != null && v.getTag() != null && ((ItemInfo) v.getTag()).container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
    });
    boolean canMigrateToFirstPage = cellLayout.makeSpaceForHotseatMigration(false);
    if (requiresMigration && canMigrateToFirstPage) {
        showDialog();
    } else {
        if (showHotseatArrowTip(requiresMigration, mLauncher.getString(requiresMigration ? R.string.hotseat_tip_no_empty_slots : R.string.hotseat_auto_enrolled))) {
            mLauncher.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_ONLY_TIP);
        }
        finishOnboarding();
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Example 30 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatEduController method placeFoldersInWorkspace.

private int placeFoldersInWorkspace(ArrayDeque<FolderInfo> folders) {
    if (folders.isEmpty())
        return 0;
    Workspace workspace = mLauncher.getWorkspace();
    InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
    GridOccupancy[] occupancyList = new GridOccupancy[workspace.getChildCount()];
    for (int i = 0; i < occupancyList.length; i++) {
        occupancyList[i] = ((CellLayout) workspace.getChildAt(i)).cloneGridOccupancy();
    }
    // scan every screen to find available spots to place folders
    int occupancyIndex = 0;
    int[] itemXY = new int[2];
    while (occupancyIndex < occupancyList.length && !folders.isEmpty()) {
        GridOccupancy occupancy = occupancyList[occupancyIndex];
        if (occupancy.findVacantCell(itemXY, 1, 1)) {
            FolderInfo info = folders.poll();
            mLauncher.getModelWriter().moveItemInDatabase(info, LauncherSettings.Favorites.CONTAINER_DESKTOP, workspace.getScreenIdForPageIndex(occupancyIndex), itemXY[0], itemXY[1]);
            occupancy.markCells(info, true);
        } else {
            occupancyIndex++;
        }
    }
    if (folders.isEmpty())
        return workspace.getScreenIdForPageIndex(occupancyIndex);
    int screenId = LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_SCREEN_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
    // if all screens are full and we still have folders left, put those on a new page
    FolderInfo folderInfo;
    int col = 0;
    while ((folderInfo = folders.poll()) != null) {
        mLauncher.getModelWriter().moveItemInDatabase(folderInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId, col++, idp.numRows - 1);
    }
    mNewScreens = IntArray.wrap(screenId);
    return workspace.getPageCount();
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) GridOccupancy(com.android.launcher3.util.GridOccupancy) FolderInfo(com.android.launcher3.model.data.FolderInfo) Workspace(com.android.launcher3.Workspace)

Aggregations

CellLayout (com.android.launcher3.CellLayout)149 View (android.view.View)145 SuppressLint (android.annotation.SuppressLint)108 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)105 AppWidgetHostView (android.appwidget.AppWidgetHostView)90 Point (android.graphics.Point)81 DragView (com.android.launcher3.dragndrop.DragView)78 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)75 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)71 ItemInfo (com.android.launcher3.model.data.ItemInfo)60 Rect (android.graphics.Rect)51 BubbleTextView (com.android.launcher3.BubbleTextView)51 FolderIcon (com.android.launcher3.folder.FolderIcon)44 DragLayer (com.android.launcher3.dragndrop.DragLayer)42 ArrayList (java.util.ArrayList)40 FolderInfo (com.android.launcher3.model.data.FolderInfo)37 Workspace (com.android.launcher3.Workspace)36 DraggableView (com.android.launcher3.dragndrop.DraggableView)36 Animator (android.animation.Animator)35 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)33