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

Commit 3458141a authored by Brandon Dayauon's avatar Brandon Dayauon Committed by Android (Google) Code Review
Browse files

Merge "Add Utility method in userCache to get badgeDrawables" into main

parents 3dafeb2d 72542b60
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -28,9 +28,13 @@ import android.os.UserManager;

import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;

import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.UserBadgeDrawable;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.SimpleBroadcastReceiver;
@@ -166,4 +170,14 @@ public class UserCache implements SafeCloseable {
    public List<UserHandle> getUserProfiles() {
        return List.copyOf(mUserToSerialMap.keySet());
    }

    /**
     * Get a non-themed {@link UserBadgeDrawable} based on the provided {@link UserHandle}.
     */
    @Nullable
    public static UserBadgeDrawable getBadgeDrawable(Context context, UserHandle userHandle) {
        return (UserBadgeDrawable) BitmapInfo.LOW_RES_INFO.withFlags(UserCache.getInstance(context)
                        .getUserInfo(userHandle).applyBitmapInfoFlags(FlagOp.NO_OP))
                .getBadgeDrawable(context, false /* isThemed */);
    }
}