Merge "Fix weird shelf truncation when only media can show." into tm-qpr-dev am: 0db8b1deb6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21321907 Change-Id: Ia9d18fd7c3cfd731c406c9503e464bee61ac030d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.MathUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -52,6 +53,9 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll
|
||||
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm;
|
||||
import com.android.systemui.statusbar.notification.stack.ViewState;
|
||||
import com.android.systemui.statusbar.phone.NotificationIconContainer;
|
||||
import com.android.systemui.util.DumpUtilsKt;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* A notification shelf view that is placed inside the notification scroller. It manages the
|
||||
@@ -86,7 +90,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
private boolean mInteractive;
|
||||
private boolean mAnimationsEnabled = true;
|
||||
private boolean mShowNotificationShelf;
|
||||
private float mFirstElementRoundness;
|
||||
private Rect mClipRect = new Rect();
|
||||
private int mIndexOfFirstViewInShelf = -1;
|
||||
private float mCornerAnimationDistance;
|
||||
@@ -263,8 +266,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
final float actualWidth = mAmbientState.isOnKeyguard()
|
||||
? MathUtils.lerp(shortestWidth, getWidth(), fractionToShade)
|
||||
: getWidth();
|
||||
ActivatableNotificationView anv = (ActivatableNotificationView) this;
|
||||
anv.setBackgroundWidth((int) actualWidth);
|
||||
setBackgroundWidth((int) actualWidth);
|
||||
if (mShelfIcons != null) {
|
||||
mShelfIcons.setActualLayoutWidth((int) actualWidth);
|
||||
}
|
||||
@@ -365,9 +367,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
boolean expandingAnimated = mAmbientState.isExpansionChanging()
|
||||
&& !mAmbientState.isPanelTracking();
|
||||
int baseZHeight = mAmbientState.getBaseZHeight();
|
||||
int backgroundTop = 0;
|
||||
int clipTopAmount = 0;
|
||||
float firstElementRoundness = 0.0f;
|
||||
|
||||
for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
|
||||
ExpandableView child = mHostLayoutController.getChildAt(i);
|
||||
@@ -420,18 +420,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
if (notGoneIndex != 0 || !aboveShelf) {
|
||||
expandableRow.setAboveShelf(false);
|
||||
}
|
||||
if (notGoneIndex == 0) {
|
||||
StatusBarIconView icon = expandableRow.getEntry().getIcons().getShelfIcon();
|
||||
NotificationIconContainer.IconState iconState = getIconState(icon);
|
||||
// The icon state might be null in rare cases where the notification is actually
|
||||
// added to the layout, but not to the shelf. An example are replied messages,
|
||||
// since they don't show up on AOD
|
||||
if (iconState != null && iconState.clampedAppearAmount == 1.0f) {
|
||||
// only if the first icon is fully in the shelf we want to clip to it!
|
||||
backgroundTop = (int) (child.getTranslationY() - getTranslationY());
|
||||
firstElementRoundness = expandableRow.getTopRoundness();
|
||||
}
|
||||
}
|
||||
|
||||
previousColor = ownColorUntinted;
|
||||
notGoneIndex++;
|
||||
@@ -467,8 +455,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
|
||||
// TODO(b/172289889) transition last icon in shelf to notification icon and vice versa.
|
||||
setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE);
|
||||
setBackgroundTop(backgroundTop);
|
||||
setFirstElementRoundness(firstElementRoundness);
|
||||
mShelfIcons.setSpeedBumpIndex(mHostLayoutController.getSpeedBumpIndex());
|
||||
mShelfIcons.calculateIconXTranslations();
|
||||
mShelfIcons.applyIconStates();
|
||||
@@ -570,12 +556,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
}
|
||||
}
|
||||
|
||||
private void setFirstElementRoundness(float firstElementRoundness) {
|
||||
if (mFirstElementRoundness != firstElementRoundness) {
|
||||
mFirstElementRoundness = firstElementRoundness;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIconClipAmount(ExpandableNotificationRow row) {
|
||||
float maxTop = row.getTranslationY();
|
||||
if (getClipTopAmount() != 0) {
|
||||
@@ -1011,6 +991,18 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
||||
expandableView.requestRoundnessReset(LegacySourceType.OnScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pwOriginal, String[] args) {
|
||||
IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal);
|
||||
super.dump(pw, args);
|
||||
if (DUMP_VERBOSE) {
|
||||
DumpUtilsKt.withIncreasedIndent(pw, () -> {
|
||||
pw.println("mActualWidth: " + mActualWidth);
|
||||
pw.println("mStatusBarHeight: " + mStatusBarHeight);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class ShelfState extends ExpandableViewState {
|
||||
private boolean hasItemsInStableShelf;
|
||||
private ExpandableView firstViewInShelf;
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.MathUtils;
|
||||
import android.view.Choreographer;
|
||||
import android.view.MotionEvent;
|
||||
@@ -43,7 +44,9 @@ import com.android.systemui.statusbar.notification.NotificationUtils;
|
||||
import com.android.systemui.statusbar.notification.SourceType;
|
||||
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
|
||||
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
|
||||
import com.android.systemui.util.DumpUtilsKt;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -651,11 +654,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
mBackgroundNormal.setRadius(topRadius, bottomRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setBackgroundTop(int backgroundTop) {
|
||||
mBackgroundNormal.setBackgroundTop(backgroundTop);
|
||||
}
|
||||
|
||||
protected abstract View getContentView();
|
||||
|
||||
public int calculateBgColor() {
|
||||
@@ -819,6 +817,22 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
mOnDetachResetRoundness.add(sourceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pwOriginal, String[] args) {
|
||||
IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal);
|
||||
super.dump(pw, args);
|
||||
if (DUMP_VERBOSE) {
|
||||
DumpUtilsKt.withIncreasedIndent(pw, () -> {
|
||||
pw.println("mBackgroundNormal: " + mBackgroundNormal);
|
||||
if (mBackgroundNormal != null) {
|
||||
DumpUtilsKt.withIncreasedIndent(pw, () -> {
|
||||
mBackgroundNormal.dump(pw, args);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnActivatedListener {
|
||||
void onActivated(ActivatableNotificationView view);
|
||||
void onActivationReset(ActivatableNotificationView view);
|
||||
|
||||
@@ -24,12 +24,16 @@ import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.notification.RoundableState;
|
||||
import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer;
|
||||
import com.android.systemui.util.DumpUtilsKt;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Like {@link ExpandableView}, but setting an outline for the height and clipping.
|
||||
@@ -43,7 +47,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
private float mOutlineAlpha = -1f;
|
||||
private boolean mAlwaysRoundBothCorners;
|
||||
private Path mTmpPath = new Path();
|
||||
private int mBackgroundTop;
|
||||
|
||||
/**
|
||||
* {@code false} if the children views of the {@link ExpandableOutlineView} are translated when
|
||||
@@ -59,7 +62,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
// Only when translating just the contents, does the outline need to be shifted.
|
||||
int translation = !mDismissUsingRowTranslationX ? (int) getTranslation() : 0;
|
||||
int left = Math.max(translation, 0);
|
||||
int top = mClipTopAmount + mBackgroundTop;
|
||||
int top = mClipTopAmount;
|
||||
int right = getWidth() + Math.min(translation, 0);
|
||||
int bottom = Math.max(getActualHeight() - mClipBottomAmount, top);
|
||||
outline.setRect(left, top, right, bottom);
|
||||
@@ -92,7 +95,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
? (int) getTranslation() : 0;
|
||||
int halfExtraWidth = (int) (mExtraWidthForClipping / 2.0f);
|
||||
left = Math.max(translation, 0) - halfExtraWidth;
|
||||
top = mClipTopAmount + mBackgroundTop;
|
||||
top = mClipTopAmount;
|
||||
right = getWidth() + halfExtraWidth + Math.min(translation, 0);
|
||||
// If the top is rounded we want the bottom to be at most at the top roundness, in order
|
||||
// to avoid the shadow changing when scrolling up.
|
||||
@@ -228,13 +231,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
super.applyRoundnessAndInvalidate();
|
||||
}
|
||||
|
||||
protected void setBackgroundTop(int backgroundTop) {
|
||||
if (mBackgroundTop != backgroundTop) {
|
||||
mBackgroundTop = backgroundTop;
|
||||
invalidateOutline();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDensityOrFontScaleChanged() {
|
||||
initDimens();
|
||||
applyRoundnessAndInvalidate();
|
||||
@@ -350,4 +346,18 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
||||
public Path getCustomClipPath(View child) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pwOriginal, String[] args) {
|
||||
IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal);
|
||||
super.dump(pw, args);
|
||||
DumpUtilsKt.withIncreasedIndent(pw, () -> {
|
||||
pw.println("Roundness: " + getRoundableState().debugString());
|
||||
if (DUMP_VERBOSE) {
|
||||
pw.println("mCustomOutline: " + mCustomOutline + " mOutlineRect: " + mOutlineRect);
|
||||
pw.println("mOutlineAlpha: " + mOutlineAlpha);
|
||||
pw.println("mAlwaysRoundBothCorners: " + mAlwaysRoundBothCorners);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class ExpandableView extends FrameLayout implements Dumpable, Roundable {
|
||||
private static final String TAG = "ExpandableView";
|
||||
/** whether the dump() for this class should include verbose details */
|
||||
protected static final boolean DUMP_VERBOSE = false;
|
||||
|
||||
private RoundableState mRoundableState = null;
|
||||
protected OnHeightChangedListener mOnHeightChangedListener;
|
||||
@@ -825,6 +827,14 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
|
||||
viewState.dump(pw, args);
|
||||
pw.println();
|
||||
}
|
||||
if (DUMP_VERBOSE) {
|
||||
pw.println("mClipTopAmount: " + mClipTopAmount);
|
||||
pw.println("mClipBottomAmount " + mClipBottomAmount);
|
||||
pw.println("mClipToActualHeight: " + mClipToActualHeight);
|
||||
pw.println("mExtraWidthForClipping: " + mExtraWidthForClipping);
|
||||
pw.println("mMinimumHeightForClipping: " + mMinimumHeightForClipping);
|
||||
pw.println("getClipBounds(): " + getClipBounds());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,16 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A view that can be used for both the dimmed and normal background of an notification.
|
||||
*/
|
||||
public class NotificationBackgroundView extends View {
|
||||
public class NotificationBackgroundView extends View implements Dumpable {
|
||||
|
||||
private final boolean mDontModifyCorners;
|
||||
private Drawable mBackground;
|
||||
@@ -42,7 +46,6 @@ public class NotificationBackgroundView extends View {
|
||||
private int mTintColor;
|
||||
private final float[] mCornerRadii = new float[8];
|
||||
private boolean mBottomIsRounded;
|
||||
private int mBackgroundTop;
|
||||
private boolean mBottomAmountClips = true;
|
||||
private int mActualHeight = -1;
|
||||
private int mActualWidth = -1;
|
||||
@@ -60,8 +63,7 @@ public class NotificationBackgroundView extends View {
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mClipTopAmount + mClipBottomAmount < getActualHeight() - mBackgroundTop
|
||||
|| mExpandAnimationRunning) {
|
||||
if (mClipTopAmount + mClipBottomAmount < getActualHeight() || mExpandAnimationRunning) {
|
||||
canvas.save();
|
||||
if (!mExpandAnimationRunning) {
|
||||
canvas.clipRect(0, mClipTopAmount, getWidth(),
|
||||
@@ -74,7 +76,7 @@ public class NotificationBackgroundView extends View {
|
||||
|
||||
private void draw(Canvas canvas, Drawable drawable) {
|
||||
if (drawable != null) {
|
||||
int top = mBackgroundTop;
|
||||
int top = 0;
|
||||
int bottom = getActualHeight();
|
||||
if (mBottomIsRounded
|
||||
&& mBottomAmountClips
|
||||
@@ -261,11 +263,6 @@ public class NotificationBackgroundView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundTop(int backgroundTop) {
|
||||
mBackgroundTop = backgroundTop;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/** Set the current expand animation size. */
|
||||
public void setExpandAnimationSize(int width, int height) {
|
||||
mExpandAnimationHeight = height;
|
||||
@@ -291,4 +288,16 @@ public class NotificationBackgroundView extends View {
|
||||
public void setPressedAllowed(boolean allowed) {
|
||||
mIsPressedAllowed = allowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pw, String[] args) {
|
||||
pw.println("mDontModifyCorners: " + mDontModifyCorners);
|
||||
pw.println("mClipTopAmount: " + mClipTopAmount);
|
||||
pw.println("mClipBottomAmount: " + mClipBottomAmount);
|
||||
pw.println("mCornerRadii: " + Arrays.toString(mCornerRadii));
|
||||
pw.println("mBottomIsRounded: " + mBottomIsRounded);
|
||||
pw.println("mBottomAmountClips: " + mBottomAmountClips);
|
||||
pw.println("mActualWidth: " + mActualWidth);
|
||||
pw.println("mActualHeight: " + mActualHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user