Search in sources :

Example 26 with DeviceProfile

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

the class TaskView method setOrientationState.

public void setOrientationState(RecentsOrientedState orientationState) {
    PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
    boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
    LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
    DeviceProfile deviceProfile = mActivity.getDeviceProfile();
    snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
    int taskIconMargin = deviceProfile.overviewTaskMarginPx;
    int taskIconHeight = deviceProfile.overviewTaskIconSizePx;
    LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
    switch(orientationHandler.getRotation()) {
        case ROTATION_90:
            iconParams.gravity = (isRtl ? START : END) | CENTER_VERTICAL;
            iconParams.rightMargin = -taskIconHeight - taskIconMargin / 2;
            iconParams.leftMargin = 0;
            iconParams.topMargin = snapshotParams.topMargin / 2;
            break;
        case ROTATION_180:
            iconParams.gravity = BOTTOM | CENTER_HORIZONTAL;
            iconParams.bottomMargin = -snapshotParams.topMargin;
            iconParams.leftMargin = iconParams.rightMargin = 0;
            iconParams.topMargin = taskIconMargin;
            break;
        case ROTATION_270:
            iconParams.gravity = (isRtl ? END : START) | CENTER_VERTICAL;
            iconParams.leftMargin = -taskIconHeight - taskIconMargin / 2;
            iconParams.rightMargin = 0;
            iconParams.topMargin = snapshotParams.topMargin / 2;
            break;
        case Surface.ROTATION_0:
        default:
            iconParams.gravity = TOP | CENTER_HORIZONTAL;
            iconParams.leftMargin = iconParams.rightMargin = 0;
            iconParams.topMargin = taskIconMargin;
            break;
    }
    mSnapshotView.setLayoutParams(snapshotParams);
    iconParams.width = iconParams.height = taskIconHeight;
    mIconView.setLayoutParams(iconParams);
    mIconView.setRotation(orientationHandler.getDegreesRotated());
    snapshotParams.topMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
    mSnapshotView.setLayoutParams(snapshotParams);
    getThumbnail().getTaskOverlay().updateOrientationState(orientationState);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 27 with DeviceProfile

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

the class AnimatorControllerWithResistance method createForRecents.

/**
 * Applies resistance to recents when swiping up past its target position.
 * @param normalController The controller to run from 0 to 1 before this resistance applies.
 * @param context Used to compute start and end values.
 * @param recentsOrientedState Used to compute start and end values.
 * @param dp Used to compute start and end values.
 * @param scaleTarget The target for the scaleProperty.
 * @param scaleProperty Animate the value to change the scale of the window/recents view.
 * @param translationTarget The target for the translationProperty.
 * @param translationProperty Animate the value to change the translation of the recents view.
 */
public static <SCALE, TRANSLATION> AnimatorControllerWithResistance createForRecents(AnimatorPlaybackController normalController, Context context, RecentsOrientedState recentsOrientedState, DeviceProfile dp, SCALE scaleTarget, FloatProperty<SCALE> scaleProperty, TRANSLATION translationTarget, FloatProperty<TRANSLATION> translationProperty) {
    RecentsParams params = new RecentsParams(context, recentsOrientedState, dp, scaleTarget, scaleProperty, translationTarget, translationProperty);
    PendingAnimation resistAnim = createRecentsResistanceAnim(params);
    AnimatorPlaybackController resistanceController = resistAnim.createPlaybackController();
    return new AnimatorControllerWithResistance(normalController, resistanceController);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 28 with DeviceProfile

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

the class RecentsOrientedState method getLauncherDeviceProfile.

/**
 * Returns the device profile based on expected launcher rotation
 */
public DeviceProfile getLauncherDeviceProfile() {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext);
    Point currentSize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
    int width, height;
    if ((mRecentsActivityRotation == ROTATION_90 || mRecentsActivityRotation == ROTATION_270)) {
        width = Math.max(currentSize.x, currentSize.y);
        height = Math.min(currentSize.x, currentSize.y);
    } else {
        width = Math.min(currentSize.x, currentSize.y);
        height = Math.max(currentSize.x, currentSize.y);
    }
    DeviceProfile bestMatch = idp.supportedProfiles.get(0);
    float minDiff = Float.MAX_VALUE;
    for (DeviceProfile profile : idp.supportedProfiles) {
        float diff = Math.abs(profile.widthPx - width) + Math.abs(profile.heightPx - height);
        if (diff < minDiff) {
            minDiff = diff;
            bestMatch = profile;
        }
    }
    return bestMatch;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) Point(android.graphics.Point) Point(android.graphics.Point)

Example 29 with DeviceProfile

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

the class ClipIconView method setIcon.

/**
 * Sets the icon for this view as part of initial setup
 */
public void setIcon(@Nullable Drawable drawable, int iconOffset, MarginLayoutParams lp, boolean isOpening, boolean isVerticalBarLayout, DeviceProfile dp) {
    mIsAdaptiveIcon = drawable instanceof AdaptiveIconDrawable;
    if (mIsAdaptiveIcon) {
        boolean isFolderIcon = drawable instanceof FolderAdaptiveIcon;
        AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) drawable;
        Drawable background = adaptiveIcon.getBackground();
        if (background == null) {
            background = new ColorDrawable(Color.TRANSPARENT);
        }
        mBackground = background;
        Drawable foreground = adaptiveIcon.getForeground();
        if (foreground == null) {
            foreground = new ColorDrawable(Color.TRANSPARENT);
        }
        mForeground = foreground;
        final int originalHeight = lp.height;
        final int originalWidth = lp.width;
        int blurMargin = mBlurSizeOutline / 2;
        mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight);
        if (!isFolderIcon) {
            mFinalDrawableBounds.inset(iconOffset - blurMargin, iconOffset - blurMargin);
        }
        mForeground.setBounds(mFinalDrawableBounds);
        mBackground.setBounds(mFinalDrawableBounds);
        mStartRevealRect.set(0, 0, originalWidth, originalHeight);
        if (!isFolderIcon) {
            Utilities.scaleRectAboutCenter(mStartRevealRect, IconShape.getNormalizationScale());
        }
        if (isVerticalBarLayout) {
            lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio);
        } else {
            lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio);
        }
        int left = mIsRtl ? dp.widthPx - lp.getMarginStart() - lp.width : lp.leftMargin;
        layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height);
        float scale = Math.max((float) lp.height / originalHeight, (float) lp.width / originalWidth);
        float bgDrawableStartScale;
        if (isOpening) {
            bgDrawableStartScale = 1f;
            mOutline.set(0, 0, originalWidth, originalHeight);
        } else {
            bgDrawableStartScale = scale;
            mOutline.set(0, 0, lp.width, lp.height);
        }
        setBackgroundDrawableBounds(bgDrawableStartScale, isVerticalBarLayout);
        mEndRevealRect.set(0, 0, lp.width, lp.height);
        setOutlineProvider(new ViewOutlineProvider() {

            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRoundRect(mOutline, mTaskCornerRadius);
            }
        });
        setClipToOutline(true);
    } else {
        setBackground(drawable);
        setClipToOutline(false);
    }
    invalidate();
    invalidateOutline();
}
Also used : FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) ColorDrawable(android.graphics.drawable.ColorDrawable) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Outline(android.graphics.Outline) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View)

Example 30 with DeviceProfile

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

the class WidgetsEduView method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
    int widthUsed;
    if (mInsets.bottom > 0) {
        // Extra space between this view and mContent horizontally when the sheet is shown in
        // portrait mode.
        widthUsed = mInsets.left + mInsets.right;
    } else {
        // Extra space between this view and mContent horizontally when the sheet is shown in
        // landscape mode.
        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)

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