Search in sources :

Example 96 with DeviceProfile

use of com.android.launcher3.DeviceProfile in project Neo-Launcher by NeoApplications.

the class ScrimView method updateDragHandleBounds.

protected void updateDragHandleBounds() {
    DeviceProfile grid = mLauncher.getDeviceProfile();
    final int left;
    final int width = getMeasuredWidth();
    final int top = getMeasuredHeight() - mDragHandleSize - grid.getInsets().bottom;
    final int topMargin;
    if (grid.isVerticalBarLayout()) {
        topMargin = grid.workspacePadding.bottom;
        if (grid.isSeascape()) {
            left = width - grid.getInsets().right - mDragHandleSize;
        } else {
            left = mDragHandleSize + grid.getInsets().left;
        }
    } else {
        left = (width - mDragHandleSize) / 2;
        topMargin = grid.hotseatBarSizePx;
    }
    mDragHandleBounds.offsetTo(left, top - topMargin);
    mHitRect.set(mDragHandleBounds);
    float inset = -mDragHandleSize / 2;
    mHitRect.inset(inset, inset);
    if (mDragHandle != null) {
        mDragHandle.setBounds(mDragHandleBounds);
    }
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Paint(android.graphics.Paint)

Example 97 with DeviceProfile

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

the class TaskOverlayFactory method addSplitOptions.

/**
 * Does NOT add split options in the following scenarios:
 * * The taskView to add split options is already showing split screen tasks
 * * There aren't at least 2 tasks in overview to show split options for
 * * Device is in "Lock task mode"
 * * The taskView to show split options for is the focused task AND we haven't started
 *   scrolling in overview (if we haven't scrolled, there's a split overview action button so
 *   we don't need this menu option)
 */
private static void addSplitOptions(List<SystemShortcut> outShortcuts, BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
    RecentsView recentsView = taskView.getRecentsView();
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    int[] taskViewTaskIds = taskView.getTaskIds();
    boolean taskViewHasMultipleTasks = taskViewTaskIds[0] != -1 && taskViewTaskIds[1] != -1;
    boolean notEnoughTasksToSplit = recentsView.getTaskViewCount() < 2;
    boolean isFocusedTask = deviceProfile.overviewShowAsGrid && taskView.isFocusedTask();
    boolean isTaskInExpectedScrollPosition = recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
    ActivityManager activityManager = (ActivityManager) taskView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
    boolean isLockTaskMode = activityManager.isInLockTaskMode();
    if (taskViewHasMultipleTasks || notEnoughTasksToSplit || isLockTaskMode || (isFocusedTask && isTaskInExpectedScrollPosition)) {
        return;
    }
    List<SplitPositionOption> positions = orientationHandler.getSplitPositionOptions(deviceProfile);
    for (SplitPositionOption option : positions) {
        outShortcuts.add(new SplitSelectSystemShortcut(activity, taskView, option));
    }
}
Also used : SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) RecentsView(com.android.quickstep.views.RecentsView) ActivityManager(android.app.ActivityManager) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)

Example 98 with DeviceProfile

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

the class TaskOverlayFactory method getEnabledShortcuts.

public static List<SystemShortcut> getEnabledShortcuts(TaskView taskView, DeviceProfile deviceProfile, TaskIdAttributeContainer taskContainer) {
    final ArrayList<SystemShortcut> shortcuts = new ArrayList<>();
    final BaseDraggingActivity activity = BaseActivity.fromContext(taskView.getContext());
    boolean hasMultipleTasks = taskView.getTaskIds()[1] != -1;
    for (TaskShortcutFactory menuOption : MENU_OPTIONS) {
        if (hasMultipleTasks && !menuOption.showForSplitscreen()) {
            continue;
        }
        SystemShortcut shortcut = menuOption.getShortcut(activity, taskContainer);
        if (shortcut == null) {
            continue;
        }
        if (menuOption == TaskShortcutFactory.SPLIT_SCREEN && FeatureFlags.ENABLE_SPLIT_SELECT.get()) {
            addSplitOptions(shortcuts, activity, taskView, deviceProfile);
        } else {
            shortcuts.add(shortcut);
        }
    }
    RecentsOrientedState orientedState = taskView.getRecentsView().getPagedViewOrientedState();
    boolean canLauncherRotate = orientedState.isRecentsActivityRotationAllowed();
    boolean isInLandscape = orientedState.getTouchRotation() != ROTATION_0;
    // Add overview actions to the menu when in in-place rotate landscape mode.
    if (!canLauncherRotate && isInLandscape) {
        // Add screenshot action to task menu.
        SystemShortcut screenshotShortcut = TaskShortcutFactory.SCREENSHOT.getShortcut(activity, taskContainer);
        if (screenshotShortcut != null) {
            shortcuts.add(screenshotShortcut);
        }
        // Add modal action only if display orientation is the same as the device orientation.
        if (orientedState.getDisplayRotation() == ROTATION_0) {
            SystemShortcut modalShortcut = TaskShortcutFactory.MODAL.getShortcut(activity, taskContainer);
            if (modalShortcut != null) {
                shortcuts.add(modalShortcut);
            }
        }
    }
    return shortcuts;
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) SystemShortcut(com.android.launcher3.popup.SystemShortcut) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut) ArrayList(java.util.ArrayList) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState)

Example 99 with DeviceProfile

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

the class ShortcutAndWidgetContainer method measureChild.

public void measureChild(View child) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
    final DeviceProfile dp = mActivity.getDeviceProfile();
    if (child instanceof NavigableAppWidgetHostView) {
        ((NavigableAppWidgetHostView) child).getWidgetInset(dp, mTempRect);
        lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY, dp.appWidgetScale.x, dp.appWidgetScale.y, mBorderSpace, mTempRect);
    } else {
        lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY, mBorderSpace, null);
        // Center the icon/folder
        int cHeight = getCellContentHeight();
        int cellPaddingY = dp.isScalableGrid && mContainerType == WORKSPACE ? dp.cellYPaddingPx : (int) Math.max(0, ((lp.height - cHeight) / 2f));
        // No need to add padding when cell layout border spacing is present.
        boolean noPaddingX = (dp.cellLayoutBorderSpacePx.x > 0 && mContainerType == WORKSPACE) || (dp.folderCellLayoutBorderSpacePx.x > 0 && mContainerType == FOLDER);
        int cellPaddingX = noPaddingX ? 0 : mContainerType == WORKSPACE ? dp.workspaceCellPaddingXPx : (int) (dp.edgeMarginPx / 2f);
        child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0);
    }
    int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
    int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
    child.measure(childWidthMeasureSpec, childheightMeasureSpec);
}
Also used : NavigableAppWidgetHostView(com.android.launcher3.widget.NavigableAppWidgetHostView) Point(android.graphics.Point)

Example 100 with DeviceProfile

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

the class ShortcutAndWidgetContainer method layoutChild.

/**
 * Core logic to layout a child for this ViewGroup.
 */
public void layoutChild(View child) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
    if (child instanceof NavigableAppWidgetHostView) {
        NavigableAppWidgetHostView nahv = (NavigableAppWidgetHostView) child;
        // Scale and center the widget to fit within its cells.
        DeviceProfile profile = mActivity.getDeviceProfile();
        float scaleX = profile.appWidgetScale.x;
        float scaleY = profile.appWidgetScale.y;
        nahv.setScaleToFit(Math.min(scaleX, scaleY));
        nahv.setTranslationForCentering(-(lp.width - (lp.width * scaleX)) / 2.0f, -(lp.height - (lp.height * scaleY)) / 2.0f);
    }
    int childLeft = lp.x;
    int childTop = lp.y;
    child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height);
    if (lp.dropped) {
        lp.dropped = false;
        final int[] cellXY = mTmpCellXY;
        getLocationOnScreen(cellXY);
        mWallpaperManager.sendWallpaperCommand(getWindowToken(), WallpaperManager.COMMAND_DROP, cellXY[0] + childLeft + lp.width / 2, cellXY[1] + childTop + lp.height / 2, 0, null);
    }
}
Also used : NavigableAppWidgetHostView(com.android.launcher3.widget.NavigableAppWidgetHostView) Point(android.graphics.Point)

Aggregations

DeviceProfile (com.android.launcher3.DeviceProfile)333 Rect (android.graphics.Rect)123 Point (android.graphics.Point)83 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)61 Paint (android.graphics.Paint)40 ArrayList (java.util.ArrayList)38 View (android.view.View)31 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)31 Context (android.content.Context)28 SuppressLint (android.annotation.SuppressLint)27 Size (android.util.Size)25 DragLayer (com.android.launcher3.dragndrop.DragLayer)25 ViewGroup (android.view.ViewGroup)23 Launcher (com.android.launcher3.Launcher)23 RecentsView (com.android.quickstep.views.RecentsView)23 RectF (android.graphics.RectF)22 PendingAnimation (com.android.launcher3.anim.PendingAnimation)22 FrameLayout (android.widget.FrameLayout)21 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)21 Drawable (android.graphics.drawable.Drawable)20