Change shadow drawing for bubble bar icons.

Removed an outline provider for the BubbleView, so framework shadows are
not drawn. Use BubbleBarBubbleIconsFactory to generate icon with the
shadow so it looks consistent with the taskbar and the hotseat bar.

Fixes: 345490679
Flag: com.android.wm.shell.enable_bubble_bar
Test: manual, screenshot before fix:
https://screenshot.googleplex.com/86ZhQENANboZK87
screenshot after fix:
https://screenshot.googleplex.com/3hNboaSaS9tZ9DS

Change-Id: I9ae3624e652e4f609b29ae0f57a47d4a6d01e94b
This commit is contained in:
mpodolian committed 2024-07-29 16:25:54 -07:00
1 parent 369a5e749b
commit c10de368a2
3 files changed
+56 -41

No files matched your search

@@ -20,15 +20,13 @@ import android.app.Notification;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
@@ -36,7 +34,6 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import com.android.launcher3.R;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.IconNormalizer;
import com.android.wm.shell.animation.Interpolators;
import com.android.wm.shell.common.bubbles.BubbleBarLocation;
import com.android.wm.shell.common.bubbles.BubbleInfo;
@@ -78,9 +75,14 @@ public class BubbleView extends ConstraintLayout {
private BubbleBarItem mBubble;
private Bitmap mIcon;
@Nullable
private Controller mController;
@Nullable
private BubbleBarBubbleIconsFactory mIconFactory = null;
public BubbleView(Context context) {
this(context, null);
}
@@ -107,36 +109,14 @@ public class BubbleView extends ConstraintLayout {
setFocusable(true);
setClickable(true);
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
BubbleView.this.getOutline(outline);
}
});
}
//TODO(b/345490679) remove once proper shadow is applied
/** Set whether provide an outline. */
public void setProvideShadowOutline(boolean provideOutline) {
if (mProvideShadowOutline == provideOutline) return;
mProvideShadowOutline = provideOutline;
invalidateOutline();
}
private void getOutline(Outline outline) {
updateBubbleSizeAndDotRender();
final int normalizedSize = IconNormalizer.getNormalizedCircleSize(mBubbleSize);
final int inset = (mBubbleSize - normalizedSize) / 2;
if (mProvideShadowOutline) {
outline.setOval(inset, inset, inset + normalizedSize, inset + normalizedSize);
}
}
private void updateBubbleSizeAndDotRender() {
int updatedBubbleSize = Math.min(getWidth(), getHeight());
if (updatedBubbleSize == mBubbleSize) return;
mBubbleSize = updatedBubbleSize;
invalidateOutline();
mIconFactory = new BubbleBarBubbleIconsFactory(mContext, mBubbleSize);
updateBubbleIcon();
if (mBubble == null || mBubble instanceof BubbleBarOverflow) return;
Path dotPath = ((BubbleBarBubble) mBubble).getDotPath();
mDotRenderer = new DotRenderer(mBubbleSize, dotPath, DEFAULT_PATH_SIZE);
@@ -254,7 +234,8 @@ public class BubbleView extends ConstraintLayout {
/** Sets the bubble being rendered in this view. */
public void setBubble(BubbleBarBubble bubble) {
mBubble = bubble;
mBubbleIcon.setImageBitmap(bubble.getIcon());
mIcon = bubble.getIcon();
updateBubbleIcon();
mAppIcon.setImageBitmap(bubble.getBadge());
mDotColor = bubble.getDotColor();
mDotRenderer = new DotRenderer(mBubbleSize, bubble.getDotPath(), DEFAULT_PATH_SIZE);
@@ -270,6 +251,18 @@ public class BubbleView extends ConstraintLayout {
setContentDescription(contentDesc);
}
private void updateBubbleIcon() {
Bitmap icon = null;
if (mIcon != null) {
icon = mIcon;
if (mIconFactory != null) {
BitmapDrawable iconDrawable = new BitmapDrawable(getResources(), icon);
icon = mIconFactory.createShadowedIconBitmap(iconDrawable, /* scale = */ 1f);
}
}
mBubbleIcon.setImageBitmap(icon);
}
/**
* Sets that this bubble represents the overflow. The overflow appears in the list of bubbles
* but does not represent app content, instead it shows recent bubbles that couldn't fit into
@@ -278,7 +271,8 @@ public class BubbleView extends ConstraintLayout {
*/
public void setOverflow(BubbleBarOverflow overflow, Bitmap bitmap) {
mBubble = overflow;
mBubbleIcon.setImageBitmap(bitmap);
mIcon = bitmap;
updateBubbleIcon();
mAppIcon.setVisibility(GONE); // Overflow doesn't show the app badge
setContentDescription(getResources().getString(R.string.bubble_bar_overflow_description));
}