Search in sources :

Example 61 with DeviceProfile

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

the class AllAppsContainerView method setInsets.

@Override
public void setInsets(Rect insets) {
    mInsets.set(insets);
    DeviceProfile grid = mLauncher.getDeviceProfile();
    int leftRightPadding = grid.desiredWorkspaceLeftRightMarginPx + grid.cellLayoutPaddingLeftRightPx;
    for (int i = 0; i < mAH.length; i++) {
        mAH[i].padding.bottom = insets.bottom;
        mAH[i].padding.left = mAH[i].padding.right = leftRightPadding;
        mAH[i].applyPadding();
    }
    ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
    mlp.leftMargin = insets.left;
    mlp.rightMargin = insets.right;
    setLayoutParams(mlp);
    if (grid.isVerticalBarLayout()) {
        setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
    } else {
        setPadding(0, 0, 0, 0);
    }
    InsettableFrameLayout.dispatchInsets(this, insets);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) ViewGroup(android.view.ViewGroup) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 62 with DeviceProfile

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

the class AllAppsEduView method init.

private void init(Launcher launcher) {
    mLauncher = launcher;
    mTouchController = new AllAppsEduTouchController(mLauncher);
    int accentColor = Themes.getColorAccent(launcher);
    mGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, Themes.getAttrBoolean(launcher, R.attr.isMainColorDark) ? new int[] { 0xB3FFFFFF, 0x00FFFFFF } : new int[] { ColorUtils.setAlphaComponent(accentColor, 127), ColorUtils.setAlphaComponent(accentColor, 0) });
    float r = mWidthPx / 2f;
    mGradient.setCornerRadii(new float[] { r, r, r, r, 0, 0, 0, 0 });
    int top = mMaxHeightPx - mCircleSizePx + mPaddingPx;
    mCircle.setBounds(mPaddingPx, top, mPaddingPx + mCircleSizePx, top + mCircleSizePx);
    mGradient.setBounds(0, mMaxHeightPx - mCircleSizePx, mWidthPx, mMaxHeightPx);
    DeviceProfile grid = launcher.getDeviceProfile();
    DragLayer.LayoutParams lp = new DragLayer.LayoutParams(mWidthPx, mMaxHeightPx);
    lp.ignoreInsets = true;
    lp.leftMargin = (grid.widthPx - mWidthPx) / 2;
    lp.topMargin = grid.heightPx - grid.hotseatBarSizePx - mMaxHeightPx;
    setLayoutParams(lp);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) DragLayer(com.android.launcher3.dragndrop.DragLayer) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 63 with DeviceProfile

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

the class PortraitPagedViewHandler method getSplitPositionOptions.

@Override
public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) {
    List<SplitPositionOption> options = new ArrayList<>(1);
    // TODO: Add in correct icons
    if (dp.isTablet && dp.isLandscape) {
        options.add(new SplitPositionOption(R.drawable.ic_split_screen, R.string.split_screen_position_right, STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN));
        options.add(new SplitPositionOption(R.drawable.ic_split_screen, R.string.split_screen_position_left, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
    } else {
        if (dp.isSeascape()) {
            // Add left/right options
            options.add(new SplitPositionOption(R.drawable.ic_split_screen, R.string.split_screen_position_right, STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN));
        } else if (dp.isLandscape) {
            options.add(new SplitPositionOption(R.drawable.ic_split_screen, R.string.split_screen_position_left, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
        } else {
            // Only add top option
            options.add(new SplitPositionOption(R.drawable.ic_split_screen, R.string.split_screen_position_top, STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
        }
    }
    return options;
}
Also used : SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) ArrayList(java.util.ArrayList)

Example 64 with DeviceProfile

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

the class WorkspaceTouchListener method onTouch.

@Override
public boolean onTouch(View view, MotionEvent ev) {
    mGestureDetector.onTouchEvent(ev);
    int action = ev.getActionMasked();
    if (action == ACTION_DOWN) {
        // Check if we can handle long press.
        boolean handleLongPress = canHandleLongPress();
        if (handleLongPress) {
            // Check if the event is not near the edges
            DeviceProfile dp = mLauncher.getDeviceProfile();
            DragLayer dl = mLauncher.getDragLayer();
            Rect insets = dp.getInsets();
            mTempRect.set(insets.left, insets.top, dl.getWidth() - insets.right, dl.getHeight() - insets.bottom);
            mTempRect.inset(dp.edgeMarginPx, dp.edgeMarginPx);
            handleLongPress = mTempRect.contains((int) ev.getX(), (int) ev.getY());
        }
        if (handleLongPress) {
            mLongPressState = STATE_REQUESTED;
            mTouchDownPoint.set(ev.getX(), ev.getY());
        }
        mWorkspace.onTouchEvent(ev);
        // Return true to keep receiving touch events
        return true;
    }
    if (mLongPressState == STATE_PENDING_PARENT_INFORM) {
        // Inform the workspace to cancel touch handling
        ev.setAction(ACTION_CANCEL);
        mWorkspace.onTouchEvent(ev);
        ev.setAction(action);
        mLongPressState = STATE_COMPLETED;
    }
    final boolean result;
    if (mLongPressState == STATE_COMPLETED) {
        // We have handled the touch, so workspace does not need to know anything anymore.
        result = true;
    } else if (mLongPressState == STATE_REQUESTED) {
        mWorkspace.onTouchEvent(ev);
        if (mWorkspace.isHandlingTouch()) {
            cancelLongPress();
        } else if (action == ACTION_MOVE && PointF.length(mTouchDownPoint.x - ev.getX(), mTouchDownPoint.y - ev.getY()) > mTouchSlop) {
            cancelLongPress();
        }
        result = true;
    } else {
        // We don't want to handle touch, let workspace handle it as usual.
        result = false;
    }
    if (action == ACTION_UP || action == ACTION_POINTER_UP) {
        if (!mWorkspace.isHandlingTouch()) {
            final CellLayout currentPage = (CellLayout) mWorkspace.getChildAt(mWorkspace.getCurrentPage());
            if (currentPage != null) {
                mWorkspace.onWallpaperTap(ev);
            }
        }
    }
    if (action == ACTION_UP || action == ACTION_CANCEL) {
        cancelLongPress();
    }
    return result;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) CellLayout(com.android.launcher3.CellLayout)

Example 65 with DeviceProfile

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

the class AddItemWidgetsBottomSheet method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
    int widthUsed;
    if (mInsets.bottom > 0) {
        widthUsed = mInsets.left + mInsets.right;
    } else {
        Rect padding = deviceProfile.workspacePadding;
        widthUsed = Math.max(padding.left + padding.right, 2 * (mInsets.left + mInsets.right));
    }
    int heightUsed = mInsets.top + deviceProfile.edgeMarginPx;
    measureChildWithMargins(mContent, widthMeasureSpec, widthUsed, heightMeasureSpec, heightUsed);
    setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) SuppressLint(android.annotation.SuppressLint)

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