Search in sources :

Example 56 with ViewGroup

use of android.view.ViewGroup in project platform_frameworks_base by android.

the class NotificationStackScrollLayout method onChildDismissed.

@Override
public void onChildDismissed(View v) {
    ExpandableNotificationRow row = (ExpandableNotificationRow) v;
    if (!row.isDismissed()) {
        handleChildDismissed(v);
    }
    ViewGroup transientContainer = row.getTransientContainer();
    if (transientContainer != null) {
        transientContainer.removeTransientView(v);
    }
}
Also used : ViewGroup(android.view.ViewGroup) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 57 with ViewGroup

use of android.view.ViewGroup in project platform_frameworks_base by android.

the class NotificationHeaderViewWrapper method updateCropToPaddingForImageViews.

/**
     * Since we are deactivating the clipping when transforming the ImageViews don't get clipped
     * anymore during these transitions. We can avoid that by using
     * {@link ImageView#setCropToPadding(boolean)} on all ImageViews.
     */
private void updateCropToPaddingForImageViews() {
    Stack<View> stack = new Stack<>();
    stack.push(mView);
    while (!stack.isEmpty()) {
        View child = stack.pop();
        if (child instanceof ImageView) {
            ((ImageView) child).setCropToPadding(true);
        } else if (child instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) child;
            for (int i = 0; i < group.getChildCount(); i++) {
                stack.push(group.getChildAt(i));
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TransformableView(com.android.systemui.statusbar.TransformableView) NotificationPanelView(com.android.systemui.statusbar.phone.NotificationPanelView) View(android.view.View) NotificationHeaderView(android.view.NotificationHeaderView) Stack(java.util.Stack)

Example 58 with ViewGroup

use of android.view.ViewGroup in project platform_frameworks_base by android.

the class TransformState method setClippingDeactivated.

public static void setClippingDeactivated(final View transformedView, boolean deactivated) {
    if (!(transformedView.getParent() instanceof ViewGroup)) {
        return;
    }
    ViewGroup view = (ViewGroup) transformedView.getParent();
    while (true) {
        ArraySet<View> clipSet = (ArraySet<View>) view.getTag(CLIP_CLIPPING_SET);
        if (clipSet == null) {
            clipSet = new ArraySet<>();
            view.setTag(CLIP_CLIPPING_SET, clipSet);
        }
        Boolean clipChildren = (Boolean) view.getTag(CLIP_CHILDREN_TAG);
        if (clipChildren == null) {
            clipChildren = view.getClipChildren();
            view.setTag(CLIP_CHILDREN_TAG, clipChildren);
        }
        Boolean clipToPadding = (Boolean) view.getTag(CLIP_TO_PADDING);
        if (clipToPadding == null) {
            clipToPadding = view.getClipToPadding();
            view.setTag(CLIP_TO_PADDING, clipToPadding);
        }
        ExpandableNotificationRow row = view instanceof ExpandableNotificationRow ? (ExpandableNotificationRow) view : null;
        if (!deactivated) {
            clipSet.remove(transformedView);
            if (clipSet.isEmpty()) {
                view.setClipChildren(clipChildren);
                view.setClipToPadding(clipToPadding);
                view.setTag(CLIP_CLIPPING_SET, null);
                if (row != null) {
                    row.setClipToActualHeight(true);
                }
            }
        } else {
            clipSet.add(transformedView);
            view.setClipChildren(false);
            view.setClipToPadding(false);
            if (row != null && row.isChildInGroup()) {
                // We still want to clip to the parent's height
                row.setClipToActualHeight(false);
            }
        }
        if (row != null && !row.isChildInGroup()) {
            return;
        }
        final ViewParent parent = view.getParent();
        if (parent instanceof ViewGroup) {
            view = (ViewGroup) parent;
        } else {
            return;
        }
    }
}
Also used : ArraySet(android.util.ArraySet) ViewGroup(android.view.ViewGroup) ViewParent(android.view.ViewParent) ImageView(android.widget.ImageView) TransformableView(com.android.systemui.statusbar.TransformableView) TextView(android.widget.TextView) View(android.view.View) NotificationHeaderView(android.view.NotificationHeaderView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 59 with ViewGroup

use of android.view.ViewGroup in project platform_frameworks_base by android.

the class NavigationBarInflaterView method inflateButton.

@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape, int indexInParent) {
    LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
    float size = extractSize(buttonSpec);
    String button = extractButton(buttonSpec);
    View v = null;
    if (HOME.equals(button)) {
        v = inflater.inflate(R.layout.home, parent, false);
        if (landscape && isSw600Dp()) {
            setupLandButton(v);
        }
    } else if (BACK.equals(button)) {
        v = inflater.inflate(R.layout.back, parent, false);
        if (landscape && isSw600Dp()) {
            setupLandButton(v);
        }
    } else if (RECENT.equals(button)) {
        v = inflater.inflate(R.layout.recent_apps, parent, false);
        if (landscape && isSw600Dp()) {
            setupLandButton(v);
        }
    } else if (MENU_IME.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime, parent, false);
    } else if (NAVSPACE.equals(button)) {
        v = inflater.inflate(R.layout.nav_key_space, parent, false);
    } else if (CLIPBOARD.equals(button)) {
        v = inflater.inflate(R.layout.clipboard, parent, false);
    } else if (button.startsWith(KEY)) {
        String uri = extractImage(button);
        int code = extractKeycode(button);
        v = inflater.inflate(R.layout.custom_key, parent, false);
        ((KeyButtonView) v).setCode(code);
        if (uri != null) {
            ((KeyButtonView) v).loadAsync(uri);
        }
    } else {
        return null;
    }
    if (size != 0) {
        ViewGroup.LayoutParams params = v.getLayoutParams();
        params.width = (int) (params.width * size);
    }
    parent.addView(v);
    addToDispatchers(v, landscape);
    View lastView = landscape ? mLastRot90 : mLastRot0;
    if (lastView != null) {
        v.setAccessibilityTraversalAfter(lastView.getId());
    }
    if (landscape) {
        mLastRot90 = v;
    } else {
        mLastRot0 = v;
    }
    return v;
}
Also used : KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) Nullable(android.annotation.Nullable)

Example 60 with ViewGroup

use of android.view.ViewGroup in project platform_frameworks_base by android.

the class ChangeBounds method createAnimator.

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    Map<String, Object> startParentVals = startValues.values;
    Map<String, Object> endParentVals = endValues.values;
    ViewGroup startParent = (ViewGroup) startParentVals.get(PROPNAME_PARENT);
    ViewGroup endParent = (ViewGroup) endParentVals.get(PROPNAME_PARENT);
    if (startParent == null || endParent == null) {
        return null;
    }
    final View view = endValues.view;
    if (parentMatches(startParent, endParent)) {
        Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
        Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
        final int startLeft = startBounds.left;
        final int endLeft = endBounds.left;
        final int startTop = startBounds.top;
        final int endTop = endBounds.top;
        final int startRight = startBounds.right;
        final int endRight = endBounds.right;
        final int startBottom = startBounds.bottom;
        final int endBottom = endBounds.bottom;
        final int startWidth = startRight - startLeft;
        final int startHeight = startBottom - startTop;
        final int endWidth = endRight - endLeft;
        final int endHeight = endBottom - endTop;
        Rect startClip = (Rect) startValues.values.get(PROPNAME_CLIP);
        Rect endClip = (Rect) endValues.values.get(PROPNAME_CLIP);
        int numChanges = 0;
        if ((startWidth != 0 && startHeight != 0) || (endWidth != 0 && endHeight != 0)) {
            if (startLeft != endLeft || startTop != endTop)
                ++numChanges;
            if (startRight != endRight || startBottom != endBottom)
                ++numChanges;
        }
        if ((startClip != null && !startClip.equals(endClip)) || (startClip == null && endClip != null)) {
            ++numChanges;
        }
        if (numChanges > 0) {
            Animator anim;
            if (!mResizeClip) {
                view.setLeftTopRightBottom(startLeft, startTop, startRight, startBottom);
                if (numChanges == 2) {
                    if (startWidth == endWidth && startHeight == endHeight) {
                        Path topLeftPath = getPathMotion().getPath(startLeft, startTop, endLeft, endTop);
                        anim = ObjectAnimator.ofObject(view, POSITION_PROPERTY, null, topLeftPath);
                    } else {
                        final ViewBounds viewBounds = new ViewBounds(view);
                        Path topLeftPath = getPathMotion().getPath(startLeft, startTop, endLeft, endTop);
                        ObjectAnimator topLeftAnimator = ObjectAnimator.ofObject(viewBounds, TOP_LEFT_PROPERTY, null, topLeftPath);
                        Path bottomRightPath = getPathMotion().getPath(startRight, startBottom, endRight, endBottom);
                        ObjectAnimator bottomRightAnimator = ObjectAnimator.ofObject(viewBounds, BOTTOM_RIGHT_PROPERTY, null, bottomRightPath);
                        AnimatorSet set = new AnimatorSet();
                        set.playTogether(topLeftAnimator, bottomRightAnimator);
                        anim = set;
                        set.addListener(new AnimatorListenerAdapter() {

                            // We need a strong reference to viewBounds until the
                            // animator ends.
                            private ViewBounds mViewBounds = viewBounds;
                        });
                    }
                } else if (startLeft != endLeft || startTop != endTop) {
                    Path topLeftPath = getPathMotion().getPath(startLeft, startTop, endLeft, endTop);
                    anim = ObjectAnimator.ofObject(view, TOP_LEFT_ONLY_PROPERTY, null, topLeftPath);
                } else {
                    Path bottomRight = getPathMotion().getPath(startRight, startBottom, endRight, endBottom);
                    anim = ObjectAnimator.ofObject(view, BOTTOM_RIGHT_ONLY_PROPERTY, null, bottomRight);
                }
            } else {
                int maxWidth = Math.max(startWidth, endWidth);
                int maxHeight = Math.max(startHeight, endHeight);
                view.setLeftTopRightBottom(startLeft, startTop, startLeft + maxWidth, startTop + maxHeight);
                ObjectAnimator positionAnimator = null;
                if (startLeft != endLeft || startTop != endTop) {
                    Path topLeftPath = getPathMotion().getPath(startLeft, startTop, endLeft, endTop);
                    positionAnimator = ObjectAnimator.ofObject(view, POSITION_PROPERTY, null, topLeftPath);
                }
                final Rect finalClip = endClip;
                if (startClip == null) {
                    startClip = new Rect(0, 0, startWidth, startHeight);
                }
                if (endClip == null) {
                    endClip = new Rect(0, 0, endWidth, endHeight);
                }
                ObjectAnimator clipAnimator = null;
                if (!startClip.equals(endClip)) {
                    view.setClipBounds(startClip);
                    clipAnimator = ObjectAnimator.ofObject(view, "clipBounds", sRectEvaluator, startClip, endClip);
                    clipAnimator.addListener(new AnimatorListenerAdapter() {

                        private boolean mIsCanceled;

                        @Override
                        public void onAnimationCancel(Animator animation) {
                            mIsCanceled = true;
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            if (!mIsCanceled) {
                                view.setClipBounds(finalClip);
                                view.setLeftTopRightBottom(endLeft, endTop, endRight, endBottom);
                            }
                        }
                    });
                }
                anim = TransitionUtils.mergeAnimators(positionAnimator, clipAnimator);
            }
            if (view.getParent() instanceof ViewGroup) {
                final ViewGroup parent = (ViewGroup) view.getParent();
                parent.suppressLayout(true);
                TransitionListener transitionListener = new TransitionListenerAdapter() {

                    boolean mCanceled = false;

                    @Override
                    public void onTransitionCancel(Transition transition) {
                        parent.suppressLayout(false);
                        mCanceled = true;
                    }

                    @Override
                    public void onTransitionEnd(Transition transition) {
                        if (!mCanceled) {
                            parent.suppressLayout(false);
                        }
                    }

                    @Override
                    public void onTransitionPause(Transition transition) {
                        parent.suppressLayout(false);
                    }

                    @Override
                    public void onTransitionResume(Transition transition) {
                        parent.suppressLayout(true);
                    }
                };
                addListener(transitionListener);
            }
            return anim;
        }
    } else {
        sceneRoot.getLocationInWindow(tempLocation);
        int startX = (Integer) startValues.values.get(PROPNAME_WINDOW_X) - tempLocation[0];
        int startY = (Integer) startValues.values.get(PROPNAME_WINDOW_Y) - tempLocation[1];
        int endX = (Integer) endValues.values.get(PROPNAME_WINDOW_X) - tempLocation[0];
        int endY = (Integer) endValues.values.get(PROPNAME_WINDOW_Y) - tempLocation[1];
        // TODO: also handle size changes: check bounds and animate size changes
        if (startX != endX || startY != endY) {
            final int width = view.getWidth();
            final int height = view.getHeight();
            Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            view.draw(canvas);
            final BitmapDrawable drawable = new BitmapDrawable(bitmap);
            drawable.setBounds(startX, startY, startX + width, startY + height);
            final float transitionAlpha = view.getTransitionAlpha();
            view.setTransitionAlpha(0);
            sceneRoot.getOverlay().add(drawable);
            Path topLeftPath = getPathMotion().getPath(startX, startY, endX, endY);
            PropertyValuesHolder origin = PropertyValuesHolder.ofObject(DRAWABLE_ORIGIN_PROPERTY, null, topLeftPath);
            ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(drawable, origin);
            anim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    sceneRoot.getOverlay().remove(drawable);
                    view.setTransitionAlpha(transitionAlpha);
                }
            });
            return anim;
        }
    }
    return null;
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) ObjectAnimator(android.animation.ObjectAnimator) Canvas(android.graphics.Canvas) AnimatorSet(android.animation.AnimatorSet) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View) Bitmap(android.graphics.Bitmap) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Aggregations

ViewGroup (android.view.ViewGroup)2327 View (android.view.View)1300 TextView (android.widget.TextView)452 ImageView (android.widget.ImageView)282 ArrayList (java.util.ArrayList)204 ViewParent (android.view.ViewParent)185 ListView (android.widget.ListView)159 LayoutInflater (android.view.LayoutInflater)127 FrameLayout (android.widget.FrameLayout)127 Paint (android.graphics.Paint)126 AdapterView (android.widget.AdapterView)118 LinearLayout (android.widget.LinearLayout)113 AbsListView (android.widget.AbsListView)106 RecyclerView (android.support.v7.widget.RecyclerView)100 Drawable (android.graphics.drawable.Drawable)95 Animator (android.animation.Animator)94 AnimatedView (carbon.animation.AnimatedView)88 ComponentView (carbon.component.ComponentView)88 RippleView (carbon.drawable.ripple.RippleView)88 ShadowView (carbon.shadow.ShadowView)88