Search in sources :

Example 91 with DeviceProfile

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

the class FolderIcon method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (!mInfo.useIconMode(mLauncher) && isInAppDrawer()) {
        DeviceProfile grid = mLauncher.getDeviceProfile();
        int drawablePadding = grid.allAppsIconDrawablePaddingPx;
        Paint.FontMetrics fm = mFolderName.getPaint().getFontMetrics();
        int cellHeightPx = mFolderName.getIconSize() + drawablePadding + (int) Math.ceil(fm.bottom - fm.top);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        setPadding(getPaddingLeft(), (height - cellHeightPx) / 2, getPaddingRight(), getPaddingBottom());
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 92 with DeviceProfile

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

the class PreviewBackground method setup.

public void setup(Context context, ActivityContext activity, View invalidateDelegate, int availableSpaceX, int topPadding) {
    mInvalidateDelegate = invalidateDelegate;
    TypedArray ta = context.getTheme().obtainStyledAttributes(R.styleable.FolderIconPreview);
    mDotColor = ta.getColor(R.styleable.FolderIconPreview_folderDotColor, 0);
    mStrokeColor = ta.getColor(R.styleable.FolderIconPreview_folderIconBorderColor, 0);
    mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderFillColor, 0);
    ta.recycle();
    DeviceProfile grid = activity.getWallpaperDeviceProfile();
    previewSize = isInDrawer ? grid.allAppsFolderIconSizePx : grid.folderIconSizePx;
    basePreviewOffsetX = (availableSpaceX - previewSize) / 2;
    basePreviewOffsetY = topPadding + (isInDrawer ? grid.allAppsFolderIconOffsetYPx : grid.folderIconOffsetYPx);
    // Stroke width is 1dp
    mStrokeWidth = context.getResources().getDisplayMetrics().density;
    float radius = getScaledRadius();
    float shadowRadius = radius + mStrokeWidth;
    int shadowColor = Color.argb(SHADOW_OPACITY, 0, 0, 0);
    mShadowShader = new RadialGradient(0, 0, 1, new int[] { shadowColor, Color.TRANSPARENT }, new float[] { radius / shadowRadius, 1 }, Shader.TileMode.CLAMP);
    invalidate();
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) TypedArray(android.content.res.TypedArray) RadialGradient(android.graphics.RadialGradient) Paint(android.graphics.Paint)

Example 93 with DeviceProfile

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

the class WorkspacePageIndicator method setInsets.

@Override
public void setInsets(Rect insets) {
    DeviceProfile grid = mLauncher.getDeviceProfile();
    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
    if (grid.isVerticalBarLayout()) {
        Rect padding = grid.workspacePadding;
        lp.leftMargin = padding.left + grid.workspaceCellPaddingXPx;
        lp.rightMargin = padding.right + grid.workspaceCellPaddingXPx;
        lp.bottomMargin = padding.bottom;
    } else {
        lp.leftMargin = lp.rightMargin = 0;
        lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
        lp.bottomMargin = grid.hotseatBarSizePx + insets.bottom;
    }
    setLayoutParams(lp);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) FrameLayout(android.widget.FrameLayout)

Example 94 with DeviceProfile

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

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();
    float scaledHeight = scale * ws.getNormalChildHeight();
    float shrunkTop = insets.top + grid.dropTargetBarSizePx;
    float shrunkBottom = ws.getMeasuredHeight() - insets.bottom - 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)

Example 95 with DeviceProfile

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

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());
            mGestureController.setTouchDownPoint(mTouchDownPoint);
        }
        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.isTouchActive()) {
            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)

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