Search in sources :

Example 16 with DividerSnapAlgorithm

use of com.android.internal.policy.DividerSnapAlgorithm in project android_frameworks_base by AOSPA.

the class ShortcutKeyDispatcher method handleDockKey.

private void handleDockKey(long shortcutCode) {
    try {
        int dockSide = mWindowManagerService.getDockedStackSide();
        if (dockSide == WindowManager.DOCKED_INVALID) {
            // If there is no window docked, we dock the top-most window.
            Recents recents = getComponent(Recents.class);
            int dockMode = (shortcutCode == SC_DOCK_LEFT) ? ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT : ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
            recents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE, dockMode, null, MetricsEvent.WINDOW_DOCK_SHORTCUTS);
        } else {
            // If there is already a docked window, we respond by resizing the docking pane.
            DividerView dividerView = getComponent(Divider.class).getView();
            DividerSnapAlgorithm snapAlgorithm = dividerView.getSnapAlgorithm();
            int dividerPosition = dividerView.getCurrentPosition();
            DividerSnapAlgorithm.SnapTarget currentTarget = snapAlgorithm.calculateNonDismissingSnapTarget(dividerPosition);
            int increment = (shortcutCode == SC_DOCK_LEFT) ? -1 : 1;
            DividerSnapAlgorithm.SnapTarget target = snapAlgorithm.cycleNonDismissTarget(currentTarget, increment);
            dividerView.startDragging(true, /* animate */
            false);
            dividerView.stopDragging(target.position, 0f, true, /* avoidDismissStart */
            true);
        }
    } catch (RemoteException e) {
        Log.e(TAG, "handleDockKey() failed.");
    }
}
Also used : Recents(com.android.systemui.recents.Recents) DividerView(com.android.systemui.stackdivider.DividerView) DividerSnapAlgorithm(com.android.internal.policy.DividerSnapAlgorithm) RemoteException(android.os.RemoteException) Divider(com.android.systemui.stackdivider.Divider)

Example 17 with DividerSnapAlgorithm

use of com.android.internal.policy.DividerSnapAlgorithm in project android_frameworks_base by crdroidandroid.

the class TaskStack method snapDockedStackAfterRotation.

/**
     * Snaps the bounds after rotation to the closest snap target for the docked stack.
     */
private void snapDockedStackAfterRotation(Rect outBounds) {
    // Calculate the current position.
    final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
    final int dividerSize = mService.getDefaultDisplayContentLocked().getDockedDividerController().getContentWidth();
    final int dockSide = getDockSide(outBounds);
    final int dividerPosition = DockedDividerUtils.calculatePositionForBounds(outBounds, dockSide, dividerSize);
    final int displayWidth = mDisplayContent.getDisplayInfo().logicalWidth;
    final int displayHeight = mDisplayContent.getDisplayInfo().logicalHeight;
    // Snap the position to a target.
    final int rotation = displayInfo.rotation;
    final int orientation = mService.mCurConfiguration.orientation;
    mService.mPolicy.getStableInsetsLw(rotation, displayWidth, displayHeight, outBounds);
    final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm(mService.mContext.getResources(), displayWidth, displayHeight, dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds);
    final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition);
    // Recalculate the bounds based on the position of the target.
    DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, outBounds, displayInfo.logicalWidth, displayInfo.logicalHeight, dividerSize);
}
Also used : DisplayInfo(android.view.DisplayInfo) DividerSnapAlgorithm(com.android.internal.policy.DividerSnapAlgorithm) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Aggregations

DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)17 DisplayInfo (android.view.DisplayInfo)8 RemoteException (android.os.RemoteException)5 Recents (com.android.systemui.recents.Recents)5 Divider (com.android.systemui.stackdivider.Divider)5 DividerView (com.android.systemui.stackdivider.DividerView)5 Context (android.content.Context)4 Configuration (android.content.res.Configuration)4 SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)4