Search in sources :

Example 96 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_404Launcher by P-404.

the class RecentsView method updateDeadZoneRects.

private void updateDeadZoneRects() {
    // Get the deadzone rect surrounding the clear all button to not dismiss overview to home
    mClearAllButtonDeadZoneRect.setEmpty();
    if (mClearAllButton.getWidth() > 0) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.recents_clear_all_deadzone_vertical_margin);
        mClearAllButton.getHitRect(mClearAllButtonDeadZoneRect);
        mClearAllButtonDeadZoneRect.inset(-getPaddingRight() / 2, -verticalMargin);
    }
    // Get the deadzone rect between the task views
    mTaskViewDeadZoneRect.setEmpty();
    int count = getTaskViewCount();
    if (count > 0) {
        final View taskView = requireTaskViewAt(0);
        requireTaskViewAt(count - 1).getHitRect(mTaskViewDeadZoneRect);
        mTaskViewDeadZoneRect.union(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom());
    }
}
Also used : View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 97 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_404Launcher by P-404.

the class RecentsView method updateGridProperties.

/**
 * Updates TaskView and ClearAllButton scaling and translation required to turn into grid
 * layout.
 *
 * This method only calculates the potential position and depends on {@link #setGridProgress} to
 * apply the actual scaling and translation.
 *
 * @param isTaskDismissal    indicates if update was called due to task dismissal
 * @param startRebalanceAfter which view index to start rebalancing from. Use Integer.MAX_VALUE
 *                           to skip rebalance
 */
private void updateGridProperties(boolean isTaskDismissal, int startRebalanceAfter) {
    int taskCount = getTaskViewCount();
    if (taskCount == 0) {
        return;
    }
    int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
    int topRowWidth = 0;
    int bottomRowWidth = 0;
    float topAccumulatedTranslationX = 0;
    float bottomAccumulatedTranslationX = 0;
    // Contains whether the child index is in top or bottom of grid (for non-focused task)
    // Different from mTopRowIdSet, which contains the taskViewId of what task is in top row
    IntSet topSet = new IntSet();
    IntSet bottomSet = new IntSet();
    // Horizontal grid translation for each task
    float[] gridTranslations = new float[taskCount];
    int focusedTaskIndex = Integer.MAX_VALUE;
    int focusedTaskShift = 0;
    int focusedTaskWidthAndSpacing = 0;
    int snappedTaskRowWidth = 0;
    int snappedPage = getNextPage();
    TaskView snappedTaskView = getTaskViewAt(snappedPage);
    TaskView homeTaskView = getHomeTaskView();
    TaskView nextFocusedTaskView = null;
    if (!isTaskDismissal) {
        mTopRowIdSet.clear();
    }
    for (int i = 0; i < taskCount; i++) {
        TaskView taskView = requireTaskViewAt(i);
        int taskWidthAndSpacing = taskView.getLayoutParams().width + mPageSpacing;
        // the grid.
        if (taskView.isFocusedTask()) {
            topRowWidth += taskWidthAndSpacing;
            bottomRowWidth += taskWidthAndSpacing;
            focusedTaskIndex = i;
            focusedTaskWidthAndSpacing = taskWidthAndSpacing;
            gridTranslations[i] += focusedTaskShift;
            gridTranslations[i] += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing;
            // Center view vertically in case it's from different orientation.
            taskView.setGridTranslationY((mLastComputedTaskSize.height() + taskTopMargin - taskView.getLayoutParams().height) / 2f);
            if (taskView == snappedTaskView) {
                // If focused task is snapped, the row width is just task width and spacing.
                snappedTaskRowWidth = taskWidthAndSpacing;
            }
        } else {
            if (i > focusedTaskIndex) {
                // For tasks after the focused task, shift by focused task's width and spacing.
                gridTranslations[i] += mIsRtl ? focusedTaskWidthAndSpacing : -focusedTaskWidthAndSpacing;
            } else {
                // For task before the focused task, accumulate the width and spacing to
                // calculate the distance focused task need to shift.
                focusedTaskShift += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing;
            }
            int taskViewId = taskView.getTaskViewId();
            // Rebalance the grid starting after a certain index
            boolean isTopRow;
            if (isTaskDismissal) {
                if (i > startRebalanceAfter) {
                    mTopRowIdSet.remove(taskViewId);
                    isTopRow = topRowWidth <= bottomRowWidth;
                } else {
                    isTopRow = mTopRowIdSet.contains(taskViewId);
                }
            } else {
                isTopRow = topRowWidth <= bottomRowWidth;
            }
            if (isTopRow) {
                if (homeTaskView != null && nextFocusedTaskView == null) {
                    // TaskView will be focused when swipe up, don't count towards row width.
                    nextFocusedTaskView = taskView;
                } else {
                    topRowWidth += taskWidthAndSpacing;
                }
                topSet.add(i);
                mTopRowIdSet.add(taskViewId);
                taskView.setGridTranslationY(mTaskGridVerticalDiff);
                // Move horizontally into empty space.
                float widthOffset = 0;
                for (int j = i - 1; !topSet.contains(j) && j >= 0; j--) {
                    if (j == focusedTaskIndex) {
                        continue;
                    }
                    widthOffset += requireTaskViewAt(j).getLayoutParams().width + mPageSpacing;
                }
                float currentTaskTranslationX = mIsRtl ? widthOffset : -widthOffset;
                gridTranslations[i] += topAccumulatedTranslationX + currentTaskTranslationX;
                topAccumulatedTranslationX += currentTaskTranslationX;
            } else {
                bottomRowWidth += taskWidthAndSpacing;
                bottomSet.add(i);
                // Move into bottom row.
                taskView.setGridTranslationY(mTopBottomRowHeightDiff + mTaskGridVerticalDiff);
                // Move horizontally into empty space.
                float widthOffset = 0;
                for (int j = i - 1; !bottomSet.contains(j) && j >= 0; j--) {
                    if (j == focusedTaskIndex) {
                        continue;
                    }
                    widthOffset += requireTaskViewAt(j).getLayoutParams().width + mPageSpacing;
                }
                float currentTaskTranslationX = mIsRtl ? widthOffset : -widthOffset;
                gridTranslations[i] += bottomAccumulatedTranslationX + currentTaskTranslationX;
                bottomAccumulatedTranslationX += currentTaskTranslationX;
            }
            if (taskView == snappedTaskView) {
                snappedTaskRowWidth = isTopRow ? topRowWidth : bottomRowWidth;
            }
        }
    }
    // We need to maintain snapped task's page scroll invariant between quick switch and
    // overview, so we sure snapped task's grid translation is 0, and add a non-fullscreen
    // translationX that is the same as snapped task's full scroll adjustment.
    float snappedTaskNonGridScrollAdjustment = 0;
    float snappedTaskGridTranslationX = 0;
    if (snappedTaskView != null) {
        snappedTaskNonGridScrollAdjustment = snappedTaskView.getScrollAdjustment(/*fullscreenEnabled=*/
        true, /*gridEnabled=*/
        false);
        snappedTaskGridTranslationX = gridTranslations[snappedPage];
    }
    // Use the accumulated translation of the row containing the last task.
    float clearAllAccumulatedTranslation = topSet.contains(taskCount - 1) ? topAccumulatedTranslationX : bottomAccumulatedTranslationX;
    // If the last task is on the shorter row, ClearAllButton will embed into the shorter row
    // which is not what we want. Compensate the width difference of the 2 rows in that case.
    float shorterRowCompensation = 0;
    if (topRowWidth <= bottomRowWidth) {
        if (topSet.contains(taskCount - 1)) {
            shorterRowCompensation = bottomRowWidth - topRowWidth;
        }
    } else {
        if (bottomSet.contains(taskCount - 1)) {
            shorterRowCompensation = topRowWidth - bottomRowWidth;
        }
    }
    float clearAllShorterRowCompensation = mIsRtl ? -shorterRowCompensation : shorterRowCompensation;
    // If the total width is shorter than one grid's width, move ClearAllButton further away
    // accordingly. Update longRowWidth if ClearAllButton has been moved.
    float clearAllShortTotalCompensation = 0;
    int longRowWidth = Math.max(topRowWidth, bottomRowWidth);
    if (longRowWidth < mLastComputedGridSize.width()) {
        float shortTotalCompensation = mLastComputedGridSize.width() - longRowWidth;
        clearAllShortTotalCompensation = mIsRtl ? -shortTotalCompensation : shortTotalCompensation;
        longRowWidth = mLastComputedGridSize.width();
    }
    float clearAllTotalTranslationX = clearAllAccumulatedTranslation + clearAllShorterRowCompensation + clearAllShortTotalCompensation + snappedTaskNonGridScrollAdjustment;
    if (focusedTaskIndex < taskCount) {
        // Shift by focused task's width and spacing if a task is focused.
        clearAllTotalTranslationX += mIsRtl ? focusedTaskWidthAndSpacing : -focusedTaskWidthAndSpacing;
    }
    // of swiping up after quick switch.
    if (snappedTaskView != null) {
        int distanceFromClearAll = longRowWidth - snappedTaskRowWidth + mPageSpacing;
        // ClearAllButton should be off screen when snapped task is in its snapped position.
        int minimumDistance = mTaskWidth - snappedTaskView.getLayoutParams().width + (mLastComputedGridSize.width() - mTaskWidth) / 2;
        if (distanceFromClearAll < minimumDistance) {
            int distanceDifference = minimumDistance - distanceFromClearAll;
            snappedTaskGridTranslationX += mIsRtl ? distanceDifference : -distanceDifference;
        }
    }
    for (int i = 0; i < taskCount; i++) {
        TaskView taskView = requireTaskViewAt(i);
        taskView.setGridTranslationX(gridTranslations[i] - snappedTaskGridTranslationX + snappedTaskNonGridScrollAdjustment);
    }
    mClearAllButton.setGridTranslationPrimary(clearAllTotalTranslationX - snappedTaskGridTranslationX);
    mClearAllButton.setGridScrollOffset(mIsRtl ? mLastComputedTaskSize.left - mLastComputedGridSize.left : mLastComputedTaskSize.right - mLastComputedGridSize.right);
    setGridProgress(mGridProgress);
}
Also used : IntSet(com.android.launcher3.util.IntSet) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 98 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_404Launcher by P-404.

the class TaskView method onTaskListVisibilityChanged.

/**
 * See {@link TaskDataChanges}
 * @param visible If this task view will be visible to the user in overview or hidden
 */
public void onTaskListVisibilityChanged(boolean visible, @TaskDataChanges int changes) {
    if (mTask == null) {
        return;
    }
    cancelPendingLoadTasks();
    if (visible) {
        // These calls are no-ops if the data is already loaded, try and load the high
        // resolution thumbnail if the state permits
        RecentsModel model = RecentsModel.INSTANCE.get(getContext());
        TaskThumbnailCache thumbnailCache = model.getThumbnailCache();
        TaskIconCache iconCache = model.getIconCache();
        if (needsUpdate(changes, FLAG_UPDATE_THUMBNAIL)) {
            mThumbnailLoadRequest = thumbnailCache.updateThumbnailInBackground(mTask, thumbnail -> {
                mSnapshotView.setThumbnail(mTask, thumbnail);
            });
        }
        if (needsUpdate(changes, FLAG_UPDATE_ICON)) {
            mIconLoadRequest = iconCache.updateIconInBackground(mTask, (task) -> {
                setIcon(mIconView, task.icon);
                mDigitalWellBeingToast.initialize(mTask);
            });
        }
    } else {
        if (needsUpdate(changes, FLAG_UPDATE_THUMBNAIL)) {
            mSnapshotView.setThumbnail(null, null);
            // Reset the task thumbnail reference as well (it will be fetched from the cache or
            // reloaded next time we need it)
            mTask.thumbnail = null;
        }
        if (needsUpdate(changes, FLAG_UPDATE_ICON)) {
            setIcon(mIconView, null);
        }
    }
}
Also used : Rect(android.graphics.Rect) Task(com.android.systemui.shared.recents.model.Task) Arrays(java.util.Arrays) Bundle(android.os.Bundle) Utilities.getDescendantCoordRelativeToAncestor(com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor) NonNull(androidx.annotation.NonNull) TestProtocol(com.android.launcher3.testing.TestProtocol) FrameLayout(android.widget.FrameLayout) Animator(android.animation.Animator) LauncherSettings(com.android.launcher3.LauncherSettings) SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) Drawable(android.graphics.drawable.Drawable) TouchDelegate(android.view.TouchDelegate) FloatProperty(android.util.FloatProperty) ActivityOptions(android.app.ActivityOptions) AttributeSet(android.util.AttributeSet) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) Interpolators(com.android.launcher3.anim.Interpolators) TaskViewUtils(com.android.quickstep.TaskViewUtils) STAGE_POSITION_BOTTOM_OR_RIGHT(com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT) MAIN_EXECUTOR(com.android.launcher3.util.Executors.MAIN_EXECUTOR) View(android.view.View) TransformingTouchDelegate(com.android.launcher3.util.TransformingTouchDelegate) Log(android.util.Log) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) UI_HELPER_EXECUTOR(com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR) Interpolator(android.view.animation.Interpolator) ObjectAnimator(android.animation.ObjectAnimator) LAUNCHER_TASK_LAUNCH_TAP(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP) TaskUtils(com.android.quickstep.TaskUtils) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewGroup(android.view.ViewGroup) DeviceProfile(com.android.launcher3.DeviceProfile) Outline(android.graphics.Outline) List(java.util.List) Nullable(androidx.annotation.Nullable) Stream(java.util.stream.Stream) CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) IdRes(android.annotation.IdRes) RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) TYPE_TASK_MENU(com.android.launcher3.AbstractFloatingView.TYPE_TASK_MENU) ACCEL_DEACCEL(com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL) ActivityOptionsCompat(com.android.systemui.shared.system.ActivityOptionsCompat) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TaskThumbnailCache(com.android.quickstep.TaskThumbnailCache) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) SplitConfigurationOptions(com.android.launcher3.util.SplitConfigurationOptions) ViewOutlineProvider(android.view.ViewOutlineProvider) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) Intent(android.content.Intent) HashMap(java.util.HashMap) SystemUiProxy(com.android.quickstep.SystemUiProxy) IntDef(androidx.annotation.IntDef) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) RemoteAnimationTargets(com.android.quickstep.RemoteAnimationTargets) Retention(java.lang.annotation.Retention) Utilities.comp(com.android.launcher3.Utilities.comp) TransformParams(com.android.quickstep.util.TransformParams) ENABLE_QUICKSTEP_LIVE_TILE(com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE) MotionEvent(android.view.MotionEvent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) STAGE_POSITION_UNDEFINED(com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED) Toast(android.widget.Toast) AnimatorSet(android.animation.AnimatorSet) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) TaskOverlayFactory(com.android.quickstep.TaskOverlayFactory) SystemShortcut(com.android.launcher3.popup.SystemShortcut) TaskCornerRadius(com.android.quickstep.util.TaskCornerRadius) Reusable(com.android.launcher3.util.ViewPool.Reusable) StatefulActivity(com.android.launcher3.statemanager.StatefulActivity) TaskIconCache(com.android.quickstep.TaskIconCache) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState) Consumer(java.util.function.Consumer) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) OVERVIEW_SPLIT_SELECT(com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT) PreviewPositionHelper(com.android.quickstep.views.TaskThumbnailView.PreviewPositionHelper) R(com.android.launcher3.R) TestLogging(com.android.launcher3.testing.TestLogging) RecentsModel(com.android.quickstep.RecentsModel) ComponentKey(com.android.launcher3.util.ComponentKey) SOURCE(java.lang.annotation.RetentionPolicy.SOURCE) LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) RunnableList(com.android.launcher3.util.RunnableList) Collections(java.util.Collections) LENGTH_SHORT(android.widget.Toast.LENGTH_SHORT) RecentsModel(com.android.quickstep.RecentsModel) TaskThumbnailCache(com.android.quickstep.TaskThumbnailCache) TaskIconCache(com.android.quickstep.TaskIconCache)

Example 99 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_404Launcher by P-404.

the class FallbackRecentsTest method testOverview.

// b/143488140
// @NavigationModeSwitch
@Test
public void testOverview() {
    startAppFast(getAppPackageName());
    startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
    startTestActivity(2);
    Wait.atMost("Expected three apps in the task list", () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
    BaseOverview overview = mLauncher.getBackground().switchToOverview();
    executeOnRecents(recents -> {
        assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3);
    });
    // Test flinging forward and backward.
    overview.flingForward();
    final Integer currentTaskAfterFlingForward = getFromRecents(this::getCurrentOverviewPage);
    executeOnRecents(recents -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
    overview.flingBackward();
    executeOnRecents(recents -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(recents) < currentTaskAfterFlingForward));
    // Test opening a task.
    overview = pressHomeAndGoToOverview();
    OverviewTask task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (1)", task);
    assertNotNull("OverviewTask.open returned null", task.open());
    assertTrue("Test activity didn't open from Overview", TestHelpers.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
    // Test dismissing a task.
    overview = pressHomeAndGoToOverview();
    final Integer numTasks = getFromRecents(this::getTaskCount);
    task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (2)", task);
    task.dismiss();
    executeOnRecents(recents -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(recents)));
    // Test dismissing all tasks.
    pressHomeAndGoToOverview().dismissAllTasks();
    assertTrue("Fallback Launcher not visible", TestHelpers.wait(Until.hasObject(By.pkg(mOtherLauncherActivity.packageName)), WAIT_TIME_MS));
}
Also used : OverviewTask(com.android.launcher3.tapl.OverviewTask) BaseOverview(com.android.launcher3.tapl.BaseOverview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 100 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_404Launcher by P-404.

the class TaplTestsQuickstep method testOverviewActions.

/**
 * Smoke test for action buttons: Presses all the buttons and makes sure no crashes occur.
 */
@Test
@NavigationModeSwitch
@PortraitLandscape
// b/195673272
@ScreenRecord
public void testOverviewActions() throws Exception {
    // Experimenting for b/165029151:
    final Overview overview = mLauncher.pressHome().switchToOverview();
    if (overview.hasTasks())
        overview.dismissAllTasks();
    mLauncher.pressHome();
    // 
    startTestAppsWithCheck();
    OverviewActions actionsView = mLauncher.pressHome().switchToOverview().getOverviewActions();
    actionsView.clickAndDismissScreenshot();
}
Also used : OverviewActions(com.android.launcher3.tapl.OverviewActions) Overview(com.android.launcher3.tapl.Overview) ScreenRecord(com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) NavigationModeSwitch(com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch)

Aggregations

LauncherState (com.android.launcher3.LauncherState)53 Animator (android.animation.Animator)50 ValueAnimator (android.animation.ValueAnimator)42 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)41 RecentsView (com.android.quickstep.views.RecentsView)40 AnimatorSet (android.animation.AnimatorSet)38 Launcher (com.android.launcher3.Launcher)36 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)34 ObjectAnimator (android.animation.ObjectAnimator)30 LargeTest (androidx.test.filters.LargeTest)29 Test (org.junit.Test)29 Point (android.graphics.Point)24 View (android.view.View)22 DeviceProfile (com.android.launcher3.DeviceProfile)19 PendingAnimation (com.android.launcher3.anim.PendingAnimation)19 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)19 ItemInfo (com.android.launcher3.model.data.ItemInfo)18 DepthController (com.android.launcher3.statehandlers.DepthController)17 Task (com.android.systemui.shared.recents.model.Task)17 Rect (android.graphics.Rect)16