Merge "Fix advanced icon will incorrect on some device" into rvc-dev am: 40bdc176e1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11862404 Change-Id: Id9280fb10cc19c6ac5acd4b729b6ccc6a6321c34
This commit is contained in:
@@ -30,9 +30,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.drawable.AdaptiveIconDrawable;
|
||||
import android.graphics.drawable.DrawableWrapper;
|
||||
import android.os.RemoteException;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.PathParser;
|
||||
import android.view.Display;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
|
||||
@@ -47,6 +45,9 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
public class AdaptiveOutlineDrawable extends DrawableWrapper {
|
||||
|
||||
private static final float ADVANCED_ICON_CENTER = 50f;
|
||||
private static final float ADVANCED_ICON_RADIUS = 48f;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({TYPE_DEFAULT, TYPE_ADVANCED})
|
||||
public @interface AdaptiveOutlineIconType {
|
||||
@@ -61,7 +62,6 @@ public class AdaptiveOutlineDrawable extends DrawableWrapper {
|
||||
private int mStrokeWidth;
|
||||
private Bitmap mBitmap;
|
||||
private int mType;
|
||||
private float mDensity;
|
||||
|
||||
public AdaptiveOutlineDrawable(Resources resources, Bitmap bitmap) {
|
||||
super(new AdaptiveIconShapeDrawable(resources));
|
||||
@@ -83,7 +83,6 @@ public class AdaptiveOutlineDrawable extends DrawableWrapper {
|
||||
mPath = new Path(PathParser.createPathFromPathData(
|
||||
resources.getString(com.android.internal.R.string.config_icon_mask)));
|
||||
mStrokeWidth = resources.getDimensionPixelSize(R.dimen.adaptive_outline_stroke);
|
||||
mDensity = resources.getDisplayMetrics().density;
|
||||
mOutlinePaint = new Paint();
|
||||
mOutlinePaint.setColor(getColor(resources, type));
|
||||
mOutlinePaint.setStyle(Paint.Style.STROKE);
|
||||
@@ -137,12 +136,7 @@ public class AdaptiveOutlineDrawable extends DrawableWrapper {
|
||||
if (mType == TYPE_DEFAULT) {
|
||||
canvas.drawPath(mPath, mOutlinePaint);
|
||||
} else {
|
||||
final float defaultDensity = getDefaultDisplayDensity(Display.DEFAULT_DISPLAY)
|
||||
/ (float) DisplayMetrics.DENSITY_DEFAULT;
|
||||
final int insetPx =
|
||||
Math.round(mInsetPx / (float) (Math.floor(
|
||||
(mDensity / defaultDensity) * 100) / 100.0));
|
||||
canvas.drawCircle(2 * insetPx, 2 * insetPx, 2 * insetPx - mStrokeWidth,
|
||||
canvas.drawCircle(ADVANCED_ICON_CENTER, ADVANCED_ICON_CENTER, ADVANCED_ICON_RADIUS,
|
||||
mOutlinePaint);
|
||||
}
|
||||
canvas.restoreToCount(count);
|
||||
|
||||
Reference in New Issue
Block a user