Loading quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBubbleIconsFactory.kt 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.taskbar.bubbles import android.content.Context import android.graphics.Bitmap import android.graphics.drawable.Drawable import com.android.launcher3.icons.BaseIconFactory /** Bubble icons factory for the bubble bar. */ class BubbleBarBubbleIconsFactory(context: Context, bubbleSize: Int) : BaseIconFactory(context, context.resources.configuration.densityDpi, bubbleSize) { /** Creates shadowed icon for the bubble bar. */ fun createShadowedIconBitmap( icon: Drawable, scale: Float, ): Bitmap = super.createIconBitmap(icon, scale, MODE_WITH_SHADOW) } quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +0 −11 Original line number Diff line number Diff line Loading @@ -307,17 +307,6 @@ public class BubbleBarView extends FrameLayout { } } @Override public void setAlpha(float alpha) { super.setAlpha(alpha); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childView = getChildAt(i); if (!(childView instanceof BubbleView)) continue; ((BubbleView) childView).setProvideShadowOutline(alpha == 1f); } } /** * Sets new icon sizes and newBubbleBarPadding between icons and bubble bar borders. * Loading quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java +24 −30 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } Loading @@ -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); Loading Loading @@ -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); Loading @@ -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 Loading @@ -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)); } Loading Loading
quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBubbleIconsFactory.kt 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.taskbar.bubbles import android.content.Context import android.graphics.Bitmap import android.graphics.drawable.Drawable import com.android.launcher3.icons.BaseIconFactory /** Bubble icons factory for the bubble bar. */ class BubbleBarBubbleIconsFactory(context: Context, bubbleSize: Int) : BaseIconFactory(context, context.resources.configuration.densityDpi, bubbleSize) { /** Creates shadowed icon for the bubble bar. */ fun createShadowedIconBitmap( icon: Drawable, scale: Float, ): Bitmap = super.createIconBitmap(icon, scale, MODE_WITH_SHADOW) }
quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +0 −11 Original line number Diff line number Diff line Loading @@ -307,17 +307,6 @@ public class BubbleBarView extends FrameLayout { } } @Override public void setAlpha(float alpha) { super.setAlpha(alpha); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childView = getChildAt(i); if (!(childView instanceof BubbleView)) continue; ((BubbleView) childView).setProvideShadowOutline(alpha == 1f); } } /** * Sets new icon sizes and newBubbleBarPadding between icons and bubble bar borders. * Loading
quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java +24 −30 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } Loading @@ -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); Loading Loading @@ -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); Loading @@ -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 Loading @@ -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)); } Loading