Merge "Sharesheet - make work profile badges render" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-04-23 19:20:56 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 8 deletions

View File

@@ -1802,7 +1802,8 @@ public class ChooserActivity extends ResolverActivity {
if (info == null) return null; if (info == null) return null;
// Now fetch app icon and raster with no badging even in work profile // 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 // Raster target drawable with appIcon as a badge
SimpleIconFactory sif = SimpleIconFactory.obtain(ChooserActivity.this); SimpleIconFactory sif = SimpleIconFactory.obtain(ChooserActivity.this);

View File

@@ -551,11 +551,11 @@ public class ResolverActivity extends Activity {
mAi.packageName); mAi.packageName);
} }
public Drawable getIcon() { public Drawable getIcon(UserHandle userHandle) {
return new BitmapDrawable(mCtx.getResources(), getIconBitmap()); return new BitmapDrawable(mCtx.getResources(), getIconBitmap(userHandle));
} }
public Bitmap getIconBitmap() { public Bitmap getIconBitmap(UserHandle userHandle) {
Drawable dr = null; Drawable dr = null;
if (mHasSubstitutePermission) { if (mHasSubstitutePermission) {
dr = getIconSubstituteInternal(); dr = getIconSubstituteInternal();
@@ -576,7 +576,7 @@ public class ResolverActivity extends Activity {
} }
SimpleIconFactory sif = SimpleIconFactory.obtain(mCtx); SimpleIconFactory sif = SimpleIconFactory.obtain(mCtx);
Bitmap icon = sif.createUserBadgedIconBitmap(dr, Process.myUserHandle()); Bitmap icon = sif.createUserBadgedIconBitmap(dr, userHandle);
sif.recycle(); sif.recycle();
return icon; return icon;
@@ -699,7 +699,8 @@ public class ResolverActivity extends Activity {
} }
Drawable loadIconForResolveInfo(ResolveInfo ri) { 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 @Override

View File

@@ -43,7 +43,6 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableWrapper; import android.graphics.drawable.DrawableWrapper;
import android.os.Process;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Pools.SynchronizedPool; import android.util.Pools.SynchronizedPool;
@@ -161,6 +160,7 @@ public class SimpleIconFactory {
/** /**
* Creates bitmap using the source drawable and various parameters. * Creates bitmap using the source drawable and various parameters.
* The bitmap is visually normalized with other icons and has enough spacing to add shadow. * 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, * @param icon source of the icon associated with a user that has no badge,
* likely user 0 * likely user 0
@@ -186,7 +186,7 @@ public class SimpleIconFactory {
} }
final Bitmap result; final Bitmap result;
if (user != null && !Process.myUserHandle().equals(user)) { if (user != null /* if modification from iconloaderlib */) {
BitmapDrawable drawable = new FixedSizeBitmapDrawable(bitmap); BitmapDrawable drawable = new FixedSizeBitmapDrawable(bitmap);
Drawable badged = mPm.getUserBadgedIcon(drawable, user); Drawable badged = mPm.getUserBadgedIcon(drawable, user);
if (badged instanceof BitmapDrawable) { if (badged instanceof BitmapDrawable) {