Search in sources :

Example 16 with DeviceProfile

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

the class TaskViewUtils method composeRecentsLaunchAnimator.

public static void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, @NonNull RemoteAnimationTargetCompat[] appTargets, @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, @NonNull RemoteAnimationTargetCompat[] nonAppTargets, boolean launcherClosing, @NonNull StateManager stateManager, @NonNull RecentsView recentsView, @NonNull DepthController depthController) {
    boolean skipLauncherChanges = !launcherClosing;
    TaskView taskView = findTaskViewToLaunch(recentsView, v, appTargets);
    PendingAnimation pa = new PendingAnimation(RECENTS_LAUNCH_DURATION);
    createRecentsWindowAnimator(taskView, skipLauncherChanges, appTargets, wallpaperTargets, nonAppTargets, depthController, pa);
    Animator childStateAnimation = null;
    // Found a visible recents task that matches the opening app, lets launch the app from there
    Animator launcherAnim;
    final AnimatorListenerAdapter windowAnimEndListener;
    if (launcherClosing) {
        Context context = v.getContext();
        DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
        launcherAnim = dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get() ? ObjectAnimator.ofFloat(recentsView, RecentsView.CONTENT_ALPHA, 0) : recentsView.createAdjacentPageAnimForTaskLaunch(taskView);
        launcherAnim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
        launcherAnim.setDuration(RECENTS_LAUNCH_DURATION);
        // Make sure recents gets fixed up by resetting task alphas and scales, etc.
        windowAnimEndListener = new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                recentsView.finishRecentsAnimation(false, /* toRecents */
                () -> {
                    recentsView.post(() -> {
                        stateManager.moveToRestState();
                        stateManager.reapplyState();
                    });
                });
            }
        };
    } else {
        AnimatorPlaybackController controller = stateManager.createAnimationToNewWorkspace(NORMAL, RECENTS_LAUNCH_DURATION);
        controller.dispatchOnStart();
        childStateAnimation = controller.getTarget();
        launcherAnim = controller.getAnimationPlayer().setDuration(RECENTS_LAUNCH_DURATION);
        windowAnimEndListener = new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                recentsView.finishRecentsAnimation(false, /* toRecents */
                () -> stateManager.goToState(NORMAL, false));
            }
        };
    }
    pa.add(launcherAnim);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) {
        pa.addOnFrameCallback(recentsView::redrawLiveTile);
    }
    anim.play(pa.buildAnim());
    // Set the current animation first, before adding windowAnimEndListener. Setting current
    // animation adds some listeners which need to be called before windowAnimEndListener
    // (the ordering of listeners matter in this case).
    stateManager.setCurrentAnimation(anim, childStateAnimation);
    anim.addListener(windowAnimEndListener);
}
Also used : Context(android.content.Context) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DeviceProfile(com.android.launcher3.DeviceProfile) TaskView(com.android.quickstep.views.TaskView) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 17 with DeviceProfile

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

the class LauncherTaskbarUIController method alignRealHotseatWithTaskbar.

/**
 * Pads the Hotseat to line up exactly with Taskbar's copy of the Hotseat.
 */
@Override
public void alignRealHotseatWithTaskbar() {
    Rect hotseatBounds = new Rect();
    DeviceProfile grid = mLauncher.getDeviceProfile();
    int hotseatHeight = grid.workspacePadding.bottom + grid.taskbarSize;
    int taskbarOffset = mLauncher.getHotseat().getTaskbarOffsetY();
    int hotseatTopDiff = hotseatHeight - grid.taskbarSize - taskbarOffset;
    int hotseatBottomDiff = taskbarOffset;
    RectF hotseatBoundsF = mTaskbarView.getHotseatBounds();
    Utilities.scaleRectFAboutPivot(hotseatBoundsF, getTaskbarScaleOnHome(), mTaskbarView.getPivotX(), mTaskbarView.getPivotY());
    hotseatBoundsF.round(hotseatBounds);
    mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top + hotseatTopDiff, mTaskbarView.getWidth() - hotseatBounds.right, mTaskbarView.getHeight() - hotseatBounds.bottom + hotseatBottomDiff);
}
Also used : RectF(android.graphics.RectF) DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect)

Example 18 with DeviceProfile

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

the class QuickstepLauncher method onStateOrResumeChanging.

/**
 * Recents logic that triggers when launcher state changes or launcher activity stops/resumes.
 */
private void onStateOrResumeChanging(boolean inTransition) {
    LauncherState state = getStateManager().getState();
    boolean started = ((getActivityFlags() & ACTIVITY_STATE_STARTED)) != 0;
    if (started) {
        DeviceProfile profile = getDeviceProfile();
        boolean willUserBeActive = (getActivityFlags() & ACTIVITY_STATE_USER_WILL_BE_ACTIVE) != 0;
        boolean visible = (state == NORMAL || state == OVERVIEW) && (willUserBeActive || isUserActive()) && !profile.isVerticalBarLayout() && profile.isPhone && !profile.isLandscape;
        UiThreadHelper.runAsyncCommand(this, SET_SHELF_HEIGHT, visible ? 1 : 0, profile.hotseatBarSizePx);
    }
    if (state == NORMAL && !inTransition) {
        ((RecentsView) getOverviewPanel()).setSwipeDownShouldLaunchApp(false);
    }
}
Also used : LauncherState(com.android.launcher3.LauncherState) DeviceProfile(com.android.launcher3.DeviceProfile) RecentsView(com.android.quickstep.views.RecentsView)

Example 19 with DeviceProfile

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

the class SecondaryDragLayer method onMeasure.

/**
 * {@inheritDoc}
 */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    setMeasuredDimension(width, height);
    DeviceProfile grid = mActivity.getDeviceProfile();
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child == mAppsView) {
            int padding = 2 * (grid.desiredWorkspaceLeftRightMarginPx + grid.cellLayoutPaddingLeftRightPx);
            int maxWidth = grid.allAppsCellWidthPx * grid.numShownAllAppsColumns + padding;
            int appsWidth = Math.min(width, maxWidth);
            int maxHeight = grid.allAppsCellHeightPx * grid.numShownAllAppsColumns + padding;
            int appsHeight = Math.min(height, maxHeight);
            mAppsView.measure(makeMeasureSpec(appsWidth, EXACTLY), makeMeasureSpec(appsHeight, EXACTLY));
        } else if (child == mAllAppsButton) {
            int appsButtonSpec = makeMeasureSpec(grid.iconSizePx, EXACTLY);
            mAllAppsButton.measure(appsButtonSpec, appsButtonSpec);
        } else if (child == mWorkspace) {
            measureChildWithMargins(mWorkspace, widthMeasureSpec, 0, heightMeasureSpec, grid.iconSizePx + grid.edgeMarginPx);
        } else {
            measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
        }
    }
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) GridView(android.widget.GridView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView)

Example 20 with DeviceProfile

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

the class SpringLoadedState method getWorkspaceScaleAndTranslation.

@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
    DeviceProfile grid = launcher.getDeviceProfile();
    Workspace ws = launcher.getWorkspace();
    if (ws.getChildCount() == 0) {
        return super.getWorkspaceScaleAndTranslation(launcher);
    }
    if (grid.isVerticalBarLayout()) {
        float scale = grid.workspaceSpringLoadShrinkFactor;
        return new ScaleAndTranslation(scale, 0, 0);
    }
    float scale = grid.workspaceSpringLoadShrinkFactor;
    Rect insets = launcher.getDragLayer().getInsets();
    int insetsBottom = grid.isTaskbarPresent ? grid.taskbarSize : insets.bottom;
    float scaledHeight = scale * ws.getNormalChildHeight();
    float shrunkTop = insets.top + grid.dropTargetBarSizePx;
    float shrunkBottom = ws.getMeasuredHeight() - insetsBottom - grid.workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace;
    float totalShrunkSpace = shrunkBottom - shrunkTop;
    float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
    float halfHeight = ws.getHeight() / 2;
    float myCenter = ws.getTop() + halfHeight;
    float cellTopFromCenter = halfHeight - ws.getChildAt(0).getTop();
    float actualCellTop = myCenter - cellTopFromCenter * scale;
    return new ScaleAndTranslation(scale, 0, (desiredCellTop - actualCellTop) / scale);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) Workspace(com.android.launcher3.Workspace)

Aggregations

DeviceProfile (com.android.launcher3.DeviceProfile)52 Rect (android.graphics.Rect)19 Point (android.graphics.Point)13 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)10 ArrayList (java.util.ArrayList)7 Paint (android.graphics.Paint)5 Size (android.util.Size)5 SuppressLint (android.annotation.SuppressLint)4 Drawable (android.graphics.drawable.Drawable)4 View (android.view.View)4 Context (android.content.Context)3 Resources (android.content.res.Resources)3 RectF (android.graphics.RectF)3 FrameLayout (android.widget.FrameLayout)3 PendingAnimation (com.android.launcher3.anim.PendingAnimation)3 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ObjectAnimator (android.animation.ObjectAnimator)2 ComponentName (android.content.ComponentName)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2