Merge "Correct Sharesheet icon and badge sizing" into rvc-dev am: 12ea0e4d4a
Change-Id: Id569ef0cd2f0fb5efbba1a6ebc7c4b9d12ff6c2b
This commit is contained in:
@@ -778,6 +778,11 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
mDirectShareShortcutInfoCache = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int appliedThemeResId() {
|
||||
return R.style.Theme_DeviceDefault_Chooser;
|
||||
}
|
||||
|
||||
private AppPredictor setupAppPredictorForUser(UserHandle userHandle,
|
||||
AppPredictor.Callback appPredictorCallback) {
|
||||
AppPredictor appPredictor = getAppPredictorForDirectShareIfEnabled(userHandle);
|
||||
|
||||
@@ -324,7 +324,7 @@ public class ResolverActivity extends Activity implements
|
||||
protected void onCreate(Bundle savedInstanceState, Intent intent,
|
||||
CharSequence title, int defaultTitleRes, Intent[] initialIntents,
|
||||
List<ResolveInfo> rList, boolean supportsAlwaysUseOption) {
|
||||
setTheme(R.style.Theme_DeviceDefault_Resolver);
|
||||
setTheme(appliedThemeResId());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Determine whether we should show that intent is forwarded
|
||||
@@ -507,6 +507,10 @@ public class ResolverActivity extends Activity implements
|
||||
/* shouldShowNoCrossProfileIntentsEmptyState= */ getUser().equals(intentUser));
|
||||
}
|
||||
|
||||
protected int appliedThemeResId() {
|
||||
return R.style.Theme_DeviceDefault_Resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user id of the user that the starting intent originated from.
|
||||
* <p>This is not necessarily equal to {@link #getUserId()} or {@link UserHandle#myUserId()},
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.content.Context.ACTIVITY_SERVICE;
|
||||
import static android.graphics.Paint.DITHER_FLAG;
|
||||
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
|
||||
|
||||
import android.annotation.AttrRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
@@ -46,6 +47,7 @@ import android.graphics.drawable.DrawableWrapper;
|
||||
import android.os.UserHandle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pools.SynchronizedPool;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
@@ -92,10 +94,8 @@ public class SimpleIconFactory {
|
||||
final ActivityManager am = (ActivityManager) ctx.getSystemService(ACTIVITY_SERVICE);
|
||||
final int iconDpi = (am == null) ? 0 : am.getLauncherLargeIconDensity();
|
||||
|
||||
final Resources r = ctx.getResources();
|
||||
final int iconSize = r.getDimensionPixelSize(R.dimen.resolver_icon_size);
|
||||
final int badgeSize = r.getDimensionPixelSize(R.dimen.resolver_badge_size);
|
||||
|
||||
final int iconSize = getIconSizeFromContext(ctx);
|
||||
final int badgeSize = getBadgeSizeFromContext(ctx);
|
||||
instance = new SimpleIconFactory(ctx, iconDpi, iconSize, badgeSize);
|
||||
instance.setWrapperBackgroundColor(Color.WHITE);
|
||||
}
|
||||
@@ -103,6 +103,27 @@ public class SimpleIconFactory {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static int getAttrDimFromContext(Context ctx, @AttrRes int attrId, String errorMsg) {
|
||||
final Resources res = ctx.getResources();
|
||||
TypedValue outVal = new TypedValue();
|
||||
if (!ctx.getTheme().resolveAttribute(attrId, outVal, true)) {
|
||||
throw new IllegalStateException(errorMsg);
|
||||
}
|
||||
return res.getDimensionPixelSize(outVal.resourceId);
|
||||
}
|
||||
|
||||
private static int getIconSizeFromContext(Context ctx) {
|
||||
return getAttrDimFromContext(ctx,
|
||||
com.android.internal.R.attr.iconfactoryIconSize,
|
||||
"Expected theme to define iconfactoryIconSize.");
|
||||
}
|
||||
|
||||
private static int getBadgeSizeFromContext(Context ctx) {
|
||||
return getAttrDimFromContext(ctx,
|
||||
com.android.internal.R.attr.iconfactoryBadgeSize,
|
||||
"Expected theme to define iconfactoryBadgeSize.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycles the SimpleIconFactory so others may use it.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user