Search in sources :

Example 11 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskView method setContextualChip.

/**
 * Sets the contextual chip.
 *
 * @param view Wrapper view containing contextual chip.
 */
public void setContextualChip(View view) {
    if (mContextualChipWrapper != null) {
        removeView(mContextualChipWrapper);
    }
    if (view != null) {
        mContextualChipWrapper = view;
        LayoutParams layoutParams = new LayoutParams(((View) getParent()).getMeasuredWidth(), LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = BOTTOM | CENTER_HORIZONTAL;
        int expectedChipHeight = getExpectedViewHeight(view);
        float chipOffset = getResources().getDimension(R.dimen.chip_hint_vertical_offset);
        layoutParams.bottomMargin = -expectedChipHeight - (int) chipOffset;
        mContextualChipWrapper.setScaleX(0f);
        mContextualChipWrapper.setScaleY(0f);
        addView(view, getChildCount(), layoutParams);
        if (mContextualChipWrapper != null) {
            float scale = comp(mModalness);
            mContextualChipWrapper.animate().scaleX(scale).scaleY(scale).setDuration(50);
            mChipTouchDelegate = new TransformingTouchDelegate(mContextualChipWrapper);
        }
    }
}
Also used : TransformingTouchDelegate(com.android.launcher3.util.TransformingTouchDelegate)

Example 12 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams 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 13 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.

the class FloatingSurfaceView method updateIconLocation.

private void updateIconLocation() {
    if (mContract == null) {
        return;
    }
    View icon = mLauncher.getWorkspace().getFirstMatchForAppClose(-1, mContract.componentName.getPackageName(), mContract.user);
    boolean iconChanged = mIcon != icon;
    if (iconChanged) {
        setCurrentIconVisible(true);
        mIcon = icon;
        setCurrentIconVisible(false);
    }
    if (icon != null && icon.isAttachedToWindow()) {
        getLocationBoundsForView(mLauncher, icon, false, mTmpPosition, mIconBounds);
        if (!mTmpPosition.equals(mIconPosition)) {
            mIconPosition.set(mTmpPosition);
            sendIconInfo();
            LayoutParams lp = (LayoutParams) mSurfaceView.getLayoutParams();
            lp.width = Math.round(mIconPosition.width());
            lp.height = Math.round(mIconPosition.height());
            lp.leftMargin = Math.round(mIconPosition.left);
            lp.topMargin = Math.round(mIconPosition.top);
        }
    }
    if (iconChanged && !mIconBounds.isEmpty()) {
        // Record the icon display
        setCurrentIconVisible(true);
        Canvas c = mPicture.beginRecording(mIconBounds.width(), mIconBounds.height());
        c.translate(-mIconBounds.left, -mIconBounds.top);
        mIcon.draw(c);
        mPicture.endRecording();
        setCurrentIconVisible(false);
        drawOnSurface();
    }
}
Also used : Canvas(android.graphics.Canvas) SurfaceView(android.view.SurfaceView) FloatingIconView.getLocationBoundsForView(com.android.launcher3.views.FloatingIconView.getLocationBoundsForView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 14 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.

the class BaseDragLayer method onLayout.

protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
        if (flp instanceof LayoutParams) {
            final LayoutParams lp = (LayoutParams) flp;
            if (lp.customPosition) {
                child.layout(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height);
            }
        }
    }
}
Also used : FrameLayout(android.widget.FrameLayout) InsettableFrameLayout(com.android.launcher3.InsettableFrameLayout) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 15 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by AOSPA.

the class PredictionRowView method applyPredictionApps.

private void applyPredictionApps() {
    if (getChildCount() != mNumPredictedAppsPerRow) {
        while (getChildCount() > mNumPredictedAppsPerRow) {
            removeViewAt(0);
        }
        LayoutInflater inflater = mLauncher.getAppsView().getLayoutInflater();
        while (getChildCount() < mNumPredictedAppsPerRow) {
            BubbleTextView icon = (BubbleTextView) inflater.inflate(R.layout.all_apps_icon, this, false);
            icon.setOnClickListener(ItemClickHandler.INSTANCE);
            icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
            icon.setLongPressTimeoutFactor(1f);
            icon.setOnFocusChangeListener(mFocusHelper);
            LayoutParams lp = (LayoutParams) icon.getLayoutParams();
            // Ensure the all apps icon height matches the workspace icons in portrait mode.
            lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
            lp.width = 0;
            lp.weight = 1;
            addView(icon);
        }
    }
    int predictionCount = mPredictedApps.size();
    for (int i = 0; i < getChildCount(); i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        if (predictionCount > i) {
            icon.setVisibility(View.VISIBLE);
            icon.applyFromWorkspaceItem(mPredictedApps.get(i));
        } else {
            icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
        }
    }
    boolean predictionsEnabled = predictionCount > 0;
    if (predictionsEnabled != mPredictionsEnabled) {
        mPredictionsEnabled = predictionsEnabled;
        mLauncher.reapplyUi(false);
        updateVisibility();
    }
    mParent.onHeightUpdated();
}
Also used : LayoutInflater(android.view.LayoutInflater) BubbleTextView(com.android.launcher3.BubbleTextView)

Aggregations

View (android.view.View)79 SuppressLint (android.annotation.SuppressLint)61 Paint (android.graphics.Paint)59 Point (android.graphics.Point)58 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)49 DraggableView (com.android.launcher3.dragndrop.DraggableView)40 CellAndSpan (com.android.launcher3.util.CellAndSpan)35 Rect (android.graphics.Rect)23 BubbleTextView (com.android.launcher3.BubbleTextView)21 ItemInfo (com.android.launcher3.model.data.ItemInfo)17 Animator (android.animation.Animator)16 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)16 ObjectAnimator (android.animation.ObjectAnimator)15 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)15 FrameLayout (android.widget.FrameLayout)13 DeviceProfile (com.android.launcher3.DeviceProfile)13 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)10 ValueAnimator (android.animation.ValueAnimator)9 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)8 TimeInterpolator (android.animation.TimeInterpolator)7