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

Commit b2e5e718 authored by Mike Digman's avatar Mike Digman
Browse files

Sharesheet - make work profile badges render

Iconloaderlib has launcher specific logic for pulling and
rendering work profile badges. Alter to work properly with
Sharesheet. Currently, work profile badges aren't shown on top
of app targets.

Fixes: 126568207
Test: manual, visual inspection
Change-Id: If247d0077e8d1fd6256ff6aceb155e245a031001
parent 0d5dacc4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1802,7 +1802,8 @@ public class ChooserActivity extends ResolverActivity {
            if (info == null) return null;

            // Now fetch app icon and raster with no badging even in work profile
            Bitmap appIcon = makePresentationGetter(info).getIconBitmap();
            Bitmap appIcon = makePresentationGetter(info).getIconBitmap(
                    UserHandle.getUserHandleForUid(UserHandle.myUserId()));

            // Raster target drawable with appIcon as a badge
            SimpleIconFactory sif = SimpleIconFactory.obtain(ChooserActivity.this);
+6 −5
Original line number Diff line number Diff line
@@ -551,11 +551,11 @@ public class ResolverActivity extends Activity {
                    mAi.packageName);
        }

        public Drawable getIcon() {
            return new BitmapDrawable(mCtx.getResources(), getIconBitmap());
        public Drawable getIcon(UserHandle userHandle) {
            return new BitmapDrawable(mCtx.getResources(), getIconBitmap(userHandle));
        }

        public Bitmap getIconBitmap() {
        public Bitmap getIconBitmap(UserHandle userHandle) {
            Drawable dr = null;
            if (mHasSubstitutePermission) {
                dr = getIconSubstituteInternal();
@@ -576,7 +576,7 @@ public class ResolverActivity extends Activity {
            }

            SimpleIconFactory sif = SimpleIconFactory.obtain(mCtx);
            Bitmap icon = sif.createUserBadgedIconBitmap(dr, Process.myUserHandle());
            Bitmap icon = sif.createUserBadgedIconBitmap(dr, userHandle);
            sif.recycle();

            return icon;
@@ -699,7 +699,8 @@ public class ResolverActivity extends Activity {
    }

    Drawable loadIconForResolveInfo(ResolveInfo ri) {
        return makePresentationGetter(ri).getIcon();
        // Load icons based on the current process. If in work profile icons should be badged.
        return makePresentationGetter(ri).getIcon(Process.myUserHandle());
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableWrapper;
import android.os.Process;
import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Pools.SynchronizedPool;
@@ -161,6 +160,7 @@ public class SimpleIconFactory {
    /**
     * Creates bitmap using the source drawable and various parameters.
     * The bitmap is visually normalized with other icons and has enough spacing to add shadow.
     * Note: this method has been modified from iconloaderlib to remove a profile diff check.
     *
     * @param icon                      source of the icon associated with a user that has no badge,
     *                                  likely user 0
@@ -186,7 +186,7 @@ public class SimpleIconFactory {
        }

        final Bitmap result;
        if (user != null && !Process.myUserHandle().equals(user)) {
        if (user != null /* if modification from iconloaderlib */) {
            BitmapDrawable drawable = new FixedSizeBitmapDrawable(bitmap);
            Drawable badged = mPm.getUserBadgedIcon(drawable, user);
            if (badged instanceof BitmapDrawable) {