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

Commit 78a66d6c authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Add badge colors for dark theme" into rvc-dev

parents 83dd0ade 2b4306a8
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -1574,7 +1574,7 @@ public class ApplicationPackageManager extends PackageManager {
        }
        Drawable badge = new LauncherIcons(mContext).getBadgeDrawable(
                getUserManager().getUserIconBadgeResId(user.getIdentifier()),
                getUserBadgeColor(user));
                getUserBadgeColor(user, false));
        return getBadgedDrawable(icon, badge, null, true);
    }

@@ -1588,8 +1588,16 @@ public class ApplicationPackageManager extends PackageManager {
        return getBadgedDrawable(drawable, badgeDrawable, badgeLocation, true);
    }

    /** Returns the color of the user's actual badge (not the badge's shadow). */
    private int getUserBadgeColor(UserHandle user) {
    /**
     * Returns the color of the user's actual badge (not the badge's shadow).
     * @param checkTheme whether to check the theme to determine the badge color. This should be
     *                   true if the background is determined by the theme. Otherwise, if
     *                   checkTheme is false, returns the color assuming a light background.
     */
    private int getUserBadgeColor(UserHandle user, boolean checkTheme) {
        if (checkTheme && mContext.getResources().getConfiguration().isNightModeActive()) {
            return getUserManager().getUserBadgeDarkColor(user.getIdentifier());
        }
        return getUserManager().getUserBadgeColor(user.getIdentifier());
    }

@@ -1603,11 +1611,14 @@ public class ApplicationPackageManager extends PackageManager {
        }
        Drawable badgeForeground = getDrawableForDensity(
                getUserManager().getUserBadgeResId(user.getIdentifier()), density);
        badgeForeground.setTint(getUserBadgeColor(user));
        badgeForeground.setTint(getUserBadgeColor(user, false));
        Drawable badge = new LayerDrawable(new Drawable[] {badgeColor, badgeForeground });
        return badge;
    }

    /**
     * Returns the badge color based on whether device has dark theme enabled or not.
     */
    @Override
    public Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density) {
        if (!hasUserBadge(user.getIdentifier())) {
@@ -1616,7 +1627,7 @@ public class ApplicationPackageManager extends PackageManager {
        Drawable badge = getDrawableForDensity(
                getUserManager().getUserBadgeNoBackgroundResId(user.getIdentifier()), density);
        if (badge != null) {
            badge.setTint(getUserBadgeColor(user));
            badge.setTint(getUserBadgeColor(user, true));
        }
        return badge;
    }
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ interface IUserManager {
    int getUserBadgeNoBackgroundResId(int userId);
    int getUserBadgeLabelResId(int userId);
    int getUserBadgeColorResId(int userId);
    int getUserBadgeDarkColorResId(int userId);
    boolean hasBadge(int userId);
    boolean isUserUnlocked(int userId);
    boolean isUserRunning(int userId);
+23 −1
Original line number Diff line number Diff line
@@ -3663,7 +3663,8 @@ public class UserManager {
    }

    /**
     * Returns the badge color for the given user (generally to color a profile's icon's badge).
     * Returns the light theme badge color for the given user (generally to color a profile's
     * icon's badge).
     *
     * <p>To check whether a badge color is expected for the user, first call {@link #hasBadge}.
     *
@@ -3682,6 +3683,27 @@ public class UserManager {
        }
    }

    /**
     * Returns the dark theme badge color for the given user (generally to color a profile's icon's
     * badge).
     *
     * <p>To check whether a badge color is expected for the user, first call {@link #hasBadge}.
     *
     * @return the color (not the resource ID) to be used for the user's badge
     * @throws Resources.NotFoundException if no valid badge color exists for this user
     *
     * @see #getBadgedIconForUser more information about badging in general
     * @hide
     */
    public @ColorInt int getUserBadgeDarkColor(@UserIdInt int userId) {
        try {
            final int resourceId = mService.getUserBadgeDarkColorResId(userId);
            return Resources.getSystem().getColor(resourceId, null);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the Resource ID of the user's icon badge.
     *
+4 −0
Original line number Diff line number Diff line
@@ -183,6 +183,10 @@
    <color name="profile_badge_2">#ffff6d00</color><!-- Orange -->
    <color name="profile_badge_3">#ff22f033</color><!-- Green -->

    <color name="profile_badge_1_dark">#ff8ab4f8</color><!-- Blue 300-->
    <color name="profile_badge_2_dark">#fffdd663</color><!-- Orange 300 -->
    <color name="profile_badge_3_dark">#ff81c995</color><!-- Green 300 -->

    <!-- Default instant app badge color -->
    <color name="instant_app_badge">#ff757575</color><!-- Grey -->

+3 −0
Original line number Diff line number Diff line
@@ -1448,6 +1448,9 @@
  <java-symbol type="color" name="profile_badge_1" />
  <java-symbol type="color" name="profile_badge_2" />
  <java-symbol type="color" name="profile_badge_3" />
  <java-symbol type="color" name="profile_badge_1_dark" />
  <java-symbol type="color" name="profile_badge_2_dark" />
  <java-symbol type="color" name="profile_badge_3_dark" />
  <java-symbol type="color" name="instant_app_badge" />

  <java-symbol type="layout" name="action_bar_home" />
Loading