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

Commit 736e0176 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Using common bubble creation info

Bug: 432486566
Test: Screenshot tests
Flag: EXEMPT refactor

Change-Id: If31ffb9a9a78235045b37500025cde6066be239e
parent 1053c1a0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -19,12 +19,13 @@ package com.android.wm.shell.bubbles
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Process
import com.android.wm.shell.bubbles.appinfo.BubbleAppInfo
import com.android.wm.shell.bubbles.appinfo.BubbleAppInfoProvider

/** A fake implementation of [BubbleAppInfoProvider]. */
class FakeBubbleAppInfoProvider : BubbleAppInfoProvider {
    override fun resolveAppInfo(context: Context, bubble: Bubble): BubbleAppInfo {
        return BubbleAppInfo("app name", ColorDrawable(Color.RED), ColorDrawable(Color.BLUE))
        return BubbleAppInfo("app name", ColorDrawable(Color.RED), Process.myUserHandle())
    }
}
+5 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.annotation.DrawableRes;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.PointF;
@@ -35,6 +34,7 @@ import android.widget.ImageView;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.DotRenderer.IconShapeInfo;
import com.android.wm.shell.R;
@@ -159,7 +159,8 @@ public class BadgedImageView extends ConstraintLayout {
    public void setRenderedBubble(BubbleViewProvider bubble) {
        mBubble = bubble;
        mBubbleIcon.setImageBitmap(bubble.getBubbleIcon());
        mAppIcon.setImageBitmap(bubble.getAppBadge());
        BitmapInfo appBadgeInfo = bubble.getAppBadge();
        mAppIcon.setImageDrawable(appBadgeInfo == null ? null : appBadgeInfo.newIcon(getContext()));
        if (mDotSuppressionFlags.contains(SuppressionFlag.BEHIND_STACK)) {
            hideBadge();
        } else {
@@ -335,7 +336,7 @@ public class BadgedImageView extends ConstraintLayout {
    }

    void showBadge() {
        Bitmap appBadgeBitmap = mBubble.getAppBadge();
        BitmapInfo appBadgeBitmap = mBubble.getAppBadge();
        final boolean showAppBadge = (mBubble instanceof Bubble)
                && ((Bubble) mBubble).showAppBadge();
        if (appBadgeBitmap == null || !showAppBadge) {
@@ -345,7 +346,7 @@ public class BadgedImageView extends ConstraintLayout {

        int translationX;
        if (mBadgeOnLeft) {
            translationX = -(mBubble.getBubbleIcon().getWidth() - appBadgeBitmap.getWidth());
            translationX = -(mBubble.getBubbleIcon().getWidth() - appBadgeBitmap.icon.getWidth());
        } else {
            translationX = 0;
        }
+5 −4
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.InstanceId;
import com.android.internal.protolog.ProtoLog;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.wm.shell.bubbles.appinfo.BubbleAppInfoProvider;
import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView;
@@ -156,9 +157,9 @@ public class Bubble implements BubbleViewProvider {
    // The developer provided image for the bubble
    private Bitmap mBubbleBitmap;
    // The app badge for the bubble
    private Bitmap mBadgeBitmap;
    private BitmapInfo mBadgeBitmap;
    // App badge without any markings for important conversations
    private Bitmap mRawBadgeBitmap;
    private BitmapInfo mRawBadgeBitmap;
    private int mDotColor;
    private Path mDotPath;
    private int mFlags;
@@ -543,12 +544,12 @@ public class Bubble implements BubbleViewProvider {
    }

    @Override
    public Bitmap getAppBadge() {
    public BitmapInfo getAppBadge() {
        return mBadgeBitmap;
    }

    @Override
    public Bitmap getRawAppBadge() {
    public BitmapInfo getRawAppBadge() {
        return mRawBadgeBitmap;
    }

+4 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.protolog.ProtoLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.launcher3.icons.BitmapInfo;
import com.android.wm.shell.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.bubbles.BubblesNavBarMotionEventHandler.MotionEventListener;
@@ -3554,7 +3555,9 @@ public class BubbleStackView extends FrameLayout
            if (bubble != null && bubble.isChat()) {
                // Setup options for chat bubbles
                mManageDontBubbleView.setVisibility(VISIBLE);
                mManageSettingsIcon.setImageBitmap(bubble.getRawAppBadge());
                BitmapInfo info = bubble.getRawAppBadge();
                mManageSettingsIcon.setImageDrawable(
                        info == null ? null : info.newIcon(getContext()));
                mManageSettingsText.setText(getResources().getString(
                        R.string.bubbles_app_settings, bubble.getAppName()));
                mManageSettingsView.setVisibility(VISIBLE);
+8 −7
Original line number Diff line number Diff line
@@ -250,7 +250,8 @@ public class BubbleViewInfoTask {
        // Always populated
        ShortcutInfo shortcutInfo;
        String appName;
        Bitmap rawBadgeBitmap;
        BitmapInfo rawBadgeBitmap;
        BitmapInfo badgeBitmap;

        // Only populated when showing in taskbar
        @Nullable BubbleBarExpandedView bubbleBarExpandedView;
@@ -261,7 +262,6 @@ public class BubbleViewInfoTask {
        int dotColor;
        Bubble.FlyoutMessage flyoutMessage;
        Bitmap bubbleBitmap;
        Bitmap badgeBitmap;

        @Nullable
        public static BubbleViewInfo populateForBubbleBar(Context c,
@@ -351,7 +351,6 @@ public class BubbleViewInfoTask {
            return false;
        }

        Drawable badgedIcon = appInfo.getBadgedIcon();
        Drawable appIcon = appInfo.getAppIcon();
        if (appInfo.getAppName() != null) {
            info.appName = appInfo.getAppName();
@@ -372,13 +371,15 @@ public class BubbleViewInfoTask {
            bubbleDrawable = appIcon;
        }

        BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(badgedIcon,
        BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(
                appIcon,
                appInfo.getUser(),
                b.isImportantConversation());
        info.badgeBitmap = badgeBitmapInfo.icon;
        info.badgeBitmap = badgeBitmapInfo;
        // Raw badge bitmap never includes the important conversation ring
        info.rawBadgeBitmap = b.isImportantConversation()
                ? iconFactory.getBadgeBitmap(badgedIcon, false).icon
                : badgeBitmapInfo.icon;
                ? iconFactory.getBadgeBitmap(appIcon, appInfo.getUser(), false)
                : badgeBitmapInfo;

        info.bubbleBitmap = iconFactory.getBubbleBitmap(bubbleDrawable);

Loading