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

Commit 179249d8 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Dominant color is part of icon cache

> Calculating extracted color during icon generation and storing it in model and DB
> Removing unused logic avoid various types of badge rendering
> Icons are badged with extracted colors, while folder is badged with theme color

Bug: 35428783
Change-Id: I93e30c52fbded7515c3ae1778422e84672eafb56
parent 8c3c9d26
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@

    <!-- Popup container -->
    <color name="notification_icon_default_color">#757575</color> <!-- Gray 600 -->
    <color name="badge_color">#1DE9B6</color> <!-- Teal A400 -->
    <color name="folder_badge_color">#1DE9B6</color> <!-- Teal A400 -->

    <color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
    <color name="legacy_icon_background">#FFFFFF</color>
+0 −4
Original line number Diff line number Diff line
@@ -212,10 +212,6 @@
    <!-- (touch_size - icon_size) / 2 -->
    <dimen name="system_shortcut_header_icon_padding">12dp</dimen>

<!-- Icon badges (with notification counts) -->
    <dimen name="badge_small_padding">0dp</dimen>
    <dimen name="badge_large_padding">3dp</dimen>

<!-- Notifications -->
    <dimen name="bg_round_rect_radius">12dp</dimen>
    <dimen name="notification_padding_start">16dp</dimen>
+2 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Process;
import android.text.TextUtils;
@@ -438,7 +439,7 @@ public class AutoInstallsLayout {
            // Auto installs should always support the current platform version.
            mValues.put(LauncherSettings.Favorites.ICON, Utilities.flattenBitmap(
                    LauncherIcons.createBadgedIconBitmap(
                            icon, Process.myUserHandle(), mContext, Build.VERSION.SDK_INT)));
                            icon, Process.myUserHandle(), mContext, VERSION.SDK_INT).icon));
            mValues.put(Favorites.ICON_PACKAGE, mIconRes.getResourcePackageName(iconId));
            mValues.put(Favorites.ICON_RESOURCE, mIconRes.getResourceName(iconId));

+11 −17
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,

    private BadgeInfo mBadgeInfo;
    private BadgeRenderer mBadgeRenderer;
    private IconPalette mBadgePalette;
    private int mBadgeColor;
    private float mBadgeScale;
    private boolean mForceHideBadge;
    private Point mTempSpaceForBadgeOffset = new Point();
@@ -183,7 +183,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
     */
    public void reset() {
        mBadgeInfo = null;
        mBadgePalette = null;
        mBadgeColor = Color.TRANSPARENT;
        mBadgeScale = 0f;
        mForceHideBadge = false;
    }
@@ -193,7 +193,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    }

    public void applyFromShortcutInfo(ShortcutInfo info, boolean promiseStateChanged) {
        applyIconAndLabel(info.iconBitmap, info);
        applyIconAndLabel(info);
        setTag(info);
        if (promiseStateChanged || (info.hasPromiseIconUi())) {
            applyPromiseState(promiseStateChanged);
@@ -203,7 +203,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    }

    public void applyFromApplicationInfo(AppInfo info) {
        applyIconAndLabel(info.iconBitmap, info);
        applyIconAndLabel(info);

        // We don't need to check the info since it's not a ShortcutInfo
        super.setTag(info);
@@ -219,7 +219,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    }

    public void applyFromPackageItemInfo(PackageItemInfo info) {
        applyIconAndLabel(info.iconBitmap, info);
        applyIconAndLabel(info);
        // We don't need to check the info since it's not a ShortcutInfo
        super.setTag(info);

@@ -227,8 +227,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        verifyHighRes();
    }

    private void applyIconAndLabel(Bitmap icon, ItemInfo info) {
        FastBitmapDrawable iconDrawable = DrawableFactory.get(getContext()).newIcon(icon, info);
    private void applyIconAndLabel(ItemInfoWithIcon info) {
        FastBitmapDrawable iconDrawable = DrawableFactory.get(getContext()).newIcon(info);
        mBadgeColor = IconPalette.getMutedColor(info.iconColor, 0.54f);

        iconDrawable.setIsDisabled(info.isDisabled());
        setIcon(iconDrawable);
        setText(info.title);
@@ -401,7 +403,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
            final int scrollX = getScrollX();
            final int scrollY = getScrollY();
            canvas.translate(scrollX, scrollY);
            mBadgeRenderer.draw(canvas, mBadgePalette, mBadgeInfo, mTempIconBounds, mBadgeScale,
            mBadgeRenderer.draw(canvas, mBadgeColor, mTempIconBounds, mBadgeScale,
                    mTempSpaceForBadgeOffset);
            canvas.translate(-scrollX, -scrollY);
        }
@@ -532,7 +534,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
                    preloadDrawable.setLevel(progressLevel);
                } else {
                    preloadDrawable = DrawableFactory.get(getContext())
                            .newPendingIcon(info.iconBitmap, getContext());
                            .newPendingIcon(info, getContext());
                    preloadDrawable.setLevel(progressLevel);
                    setIcon(preloadDrawable);
                }
@@ -550,10 +552,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
            float newBadgeScale = isBadged ? 1f : 0;
            mBadgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer;
            if (wasBadged || isBadged) {
                mBadgePalette = IconPalette.getBadgePalette(getResources());
                if (mBadgePalette == null) {
                    mBadgePalette = ((FastBitmapDrawable) mIcon).getIconPalette();
                }
                // Animate when a badge is first added or when it is removed.
                if (animate && (wasBadged ^ isBadged) && isShown()) {
                    ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, newBadgeScale).start();
@@ -565,10 +563,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        }
    }

    public IconPalette getBadgePalette() {
        return mBadgePalette;
    }

    /**
     * Sets the icon for this view based on the layout direction.
     */
+1 −1
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ public class DeviceProfile {
        computeAllAppsButtonSize(context);

        // This is done last, after iconSizePx is calculated above.
        mBadgeRenderer = new BadgeRenderer(context, iconSizePx);
        mBadgeRenderer = new BadgeRenderer(iconSizePx);
    }

    DeviceProfile getMultiWindowProfile(Context context, Point mwSize) {
Loading