Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9c00ae2 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed several bugs introduced by the new background views.

Also notifications are now limited to 4U again.
Bug: 14880580

Change-Id: I05d19981ad1bb06687bf6c994608e21ac925a759
parent e595504f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
    <Button
        android:id="@+id/veto"
        android:layout_width="48dp"
        android:layout_height="match_parent"
        android:layout_height="8dp"
        android:gravity="end"
        android:layout_marginEnd="-80dp"
        android:background="@null"
+23 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            = new PathInterpolator(0.6f, 0, 0.5f, 1);
    private static final Interpolator ACTIVATE_INVERSE_ALPHA_INTERPOLATOR
            = new PathInterpolator(0, 0, 0.5f, 1);
    private final int mMaxNotificationHeight;

    private boolean mDimmed;

@@ -80,6 +81,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
                AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in);
        mLinearOutSlowInInterpolator =
                AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in);
        mMaxNotificationHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
        setClipChildren(false);
        setClipToPadding(false);
    }
@@ -292,6 +294,27 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        }
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int newHeightSpec = MeasureSpec.makeMeasureSpec(mMaxNotificationHeight,
                MeasureSpec.AT_MOST);
        int maxChildHeight = 0;
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (child != mBackgroundDimmed && child != mBackgroundNormal) {
                child.measure(widthMeasureSpec, newHeightSpec);
                int childHeight = child.getMeasuredHeight();
                maxChildHeight = Math.max(maxChildHeight, childHeight);
            }
        }
        newHeightSpec = MeasureSpec.makeMeasureSpec(maxChildHeight, MeasureSpec.EXACTLY);
        mBackgroundDimmed.measure(widthMeasureSpec, newHeightSpec);
        mBackgroundNormal.measure(widthMeasureSpec, newHeightSpec);
        int width = MeasureSpec.getSize(widthMeasureSpec);
        setMeasuredDimension(width, maxChildHeight);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {

    @Override
    public void setActualHeight(int height, boolean notifyListeners) {
        mPrivateLayout.setActualHeight(height, notifyListeners);
        mPrivateLayout.setActualHeight(height);
        invalidate();
        super.setActualHeight(height, notifyListeners);
    }
+13 −3
Original line number Diff line number Diff line
@@ -20,12 +20,12 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.view.ViewGroup;

/**
 * An abstract view for expandable views.
 */
public abstract class ExpandableView extends FrameLayout {
public abstract class ExpandableView extends ViewGroup {

    private OnHeightChangedListener mOnHeightChangedListener;
    protected int mActualHeight;
@@ -38,7 +38,17 @@ public abstract class ExpandableView extends FrameLayout {

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        for (int i = 0; i < getChildCount(); i++) {
            View child = getChildAt(i);
            int height = child.getMeasuredHeight();
            int width = child.getMeasuredWidth();
            int center = getWidth() / 2;
            int childLeft = center - width / 2;
            child.layout(childLeft,
                    0,
                    childLeft + width,
                    height);
        }
        if (!mActualHeightInitialized && mActualHeight == 0) {
            mActualHeight = getInitialHeight();
        }
+7 −9
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;

import android.widget.FrameLayout;
import com.android.systemui.R;

/**
@@ -29,7 +30,7 @@ import com.android.systemui.R;
 * expanded layout. This class is responsible for clipping the content and and switching between the
 * expanded and contracted view depending on its clipped size.
 */
public class NotificationContentView extends ExpandableView {
public class NotificationContentView extends FrameLayout {

    private final Rect mClipBounds = new Rect();

@@ -37,6 +38,8 @@ public class NotificationContentView extends ExpandableView {
    private View mExpandedChild;

    private int mSmallHeight;
    private int mClipTopAmount;
    private int mActualHeight;

    public NotificationContentView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -69,28 +72,24 @@ public class NotificationContentView extends ExpandableView {
        selectLayout();
    }

    @Override
    public void setActualHeight(int actualHeight, boolean notifyListeners) {
        super.setActualHeight(actualHeight, notifyListeners);
    public void setActualHeight(int actualHeight) {
        mActualHeight = actualHeight;
        selectLayout();
        updateClipping();
    }

    @Override
    public int getMaxHeight() {

        // The maximum height is just the laid out height.
        return getHeight();
    }

    @Override
    public int getMinHeight() {
        return mSmallHeight;
    }

    @Override
    public void setClipTopAmount(int clipTopAmount) {
        super.setClipTopAmount(clipTopAmount);
        mClipTopAmount = clipTopAmount;
        updateClipping();
    }

@@ -127,7 +126,6 @@ public class NotificationContentView extends ExpandableView {
        selectLayout();
    }

    @Override
    public boolean isContentExpandable() {
        return mExpandedChild != null;
    }