Loading iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java +1 −1 Original line number Diff line number Diff line Loading @@ -414,7 +414,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { sFlagHoverEnabled = isFlagHoverEnabled; } protected static class FastBitmapConstantState extends ConstantState { public static class FastBitmapConstantState extends ConstantState { protected final Bitmap mBitmap; protected final int mIconColor; Loading iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.javadeleted 100644 → 0 +0 −130 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.icons; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BlendMode; import android.graphics.BlendModeColorFilter; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Rect; /** * Class to handle monochrome themed app icons */ @SuppressWarnings("NewApi") public class ThemedIconDrawable extends FastBitmapDrawable { public static final String TAG = "ThemedIconDrawable"; final BitmapInfo bitmapInfo; final int colorFg, colorBg; // The foreground/monochrome icon for the app private final Bitmap mMonoIcon; private final Paint mMonoPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private final Bitmap mBgBitmap; private final Paint mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private final ColorFilter mBgFilter, mMonoFilter; protected ThemedIconDrawable(ThemedConstantState constantState) { super(constantState.mBitmap, constantState.colorFg); bitmapInfo = constantState.bitmapInfo; colorBg = constantState.colorBg; colorFg = constantState.colorFg; mMonoIcon = bitmapInfo.mMono; mMonoFilter = new BlendModeColorFilter(colorFg, BlendMode.SRC_IN); mMonoPaint.setColorFilter(mMonoFilter); mBgBitmap = bitmapInfo.mWhiteShadowLayer; mBgFilter = new BlendModeColorFilter(colorBg, BlendMode.SRC_IN); mBgPaint.setColorFilter(mBgFilter); } @Override protected void drawInternal(Canvas canvas, Rect bounds) { canvas.drawBitmap(mBgBitmap, null, bounds, mBgPaint); canvas.drawBitmap(mMonoIcon, null, bounds, mMonoPaint); } @Override protected void updateFilter() { super.updateFilter(); int alpha = mIsDisabled ? (int) (mDisabledAlpha * FULLY_OPAQUE) : FULLY_OPAQUE; mBgPaint.setAlpha(alpha); mBgPaint.setColorFilter(mIsDisabled ? new BlendModeColorFilter( getDisabledColor(colorBg), BlendMode.SRC_IN) : mBgFilter); mMonoPaint.setAlpha(alpha); mMonoPaint.setColorFilter(mIsDisabled ? new BlendModeColorFilter( getDisabledColor(colorFg), BlendMode.SRC_IN) : mMonoFilter); } @Override public boolean isThemed() { return true; } @Override public FastBitmapConstantState newConstantState() { return new ThemedConstantState(bitmapInfo, colorBg, colorFg); } static class ThemedConstantState extends FastBitmapConstantState { final BitmapInfo bitmapInfo; final int colorFg, colorBg; public ThemedConstantState(BitmapInfo bitmapInfo, int colorBg, int colorFg) { super(bitmapInfo.icon, bitmapInfo.color); this.bitmapInfo = bitmapInfo; this.colorBg = colorBg; this.colorFg = colorFg; } @Override public FastBitmapDrawable createDrawable() { return new ThemedIconDrawable(this); } } public static FastBitmapDrawable newDrawable(BitmapInfo info, Context context) { int[] colors = getColors(context); return new ThemedConstantState(info, colors[0], colors[1]).newDrawable(); } /** * Get an int array representing background and foreground colors for themed icons */ public static int[] getColors(Context context) { Resources res = context.getResources(); int[] colors = new int[2]; colors[0] = res.getColor(R.color.themed_icon_background_color); colors[1] = res.getColor(R.color.themed_icon_color); return colors; } @Override public int getIconColor() { return colorFg; } } iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.kt 0 → 100644 +93 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.icons import android.content.Context import android.graphics.BlendMode.SRC_IN import android.graphics.BlendModeColorFilter import android.graphics.Canvas import android.graphics.Paint import android.graphics.Rect /** Class to handle monochrome themed app icons */ class ThemedIconDrawable(constantState: ThemedConstantState) : FastBitmapDrawable(constantState.mBitmap, constantState.colorFg) { val bitmapInfo = constantState.bitmapInfo private val colorFg = constantState.colorFg private val colorBg = constantState.colorBg // The foreground/monochrome icon for the app private val monoIcon = bitmapInfo.mMono!! private val monoFilter = BlendModeColorFilter(colorFg, SRC_IN) private val monoPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG).apply { colorFilter = monoFilter } private val bgBitmap = bitmapInfo.mWhiteShadowLayer private val bgFilter = BlendModeColorFilter(colorBg, SRC_IN) private val mBgPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG).apply { colorFilter = bgFilter } override fun drawInternal(canvas: Canvas, bounds: Rect) { canvas.drawBitmap(bgBitmap, null, bounds, mBgPaint) canvas.drawBitmap(monoIcon, null, bounds, monoPaint) } override fun updateFilter() { super.updateFilter() val alpha = if (mIsDisabled) (mDisabledAlpha * FULLY_OPAQUE).toInt() else FULLY_OPAQUE mBgPaint.alpha = alpha mBgPaint.setColorFilter( if (mIsDisabled) BlendModeColorFilter(getDisabledColor(colorBg), SRC_IN) else bgFilter ) monoPaint.alpha = alpha monoPaint.setColorFilter( if (mIsDisabled) BlendModeColorFilter(getDisabledColor(colorFg), SRC_IN) else monoFilter ) } override fun isThemed() = true override fun newConstantState() = ThemedConstantState(bitmapInfo, colorBg, colorFg) override fun getIconColor() = colorFg class ThemedConstantState(val bitmapInfo: BitmapInfo, val colorBg: Int, val colorFg: Int) : FastBitmapConstantState(bitmapInfo.icon, bitmapInfo.color) { public override fun createDrawable() = ThemedIconDrawable(this) } companion object { const val TAG: String = "ThemedIconDrawable" @JvmStatic fun newDrawable(info: BitmapInfo, context: Context): FastBitmapDrawable { val colors = getColors(context) return ThemedConstantState(info, colors[0], colors[1]).newDrawable() } /** Get an int array representing background and foreground colors for themed icons */ @JvmStatic fun getColors(context: Context): IntArray { val res = context.resources return intArrayOf( res.getColor(R.color.themed_icon_background_color), res.getColor(R.color.themed_icon_color), ) } } } viewcapturelib/src/com/android/app/viewcapture/ViewCaptureAwareWindowManager.kt +0 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.app.viewcapture import android.media.permission.SafeCloseable import android.util.Log import android.view.View import android.view.ViewGroup import android.view.WindowManager Loading Loading @@ -63,8 +62,6 @@ class ViewCaptureAwareWindowManager( if (viewCaptureCloseableMap.containsKey(view)) { viewCaptureCloseableMap[view]?.close() viewCaptureCloseableMap.remove(view) } else { Log.wtf(TAG, "removeView called with view not present in closeable map!") } } } Loading Loading
iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java +1 −1 Original line number Diff line number Diff line Loading @@ -414,7 +414,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { sFlagHoverEnabled = isFlagHoverEnabled; } protected static class FastBitmapConstantState extends ConstantState { public static class FastBitmapConstantState extends ConstantState { protected final Bitmap mBitmap; protected final int mIconColor; Loading
iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.javadeleted 100644 → 0 +0 −130 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.icons; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BlendMode; import android.graphics.BlendModeColorFilter; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Rect; /** * Class to handle monochrome themed app icons */ @SuppressWarnings("NewApi") public class ThemedIconDrawable extends FastBitmapDrawable { public static final String TAG = "ThemedIconDrawable"; final BitmapInfo bitmapInfo; final int colorFg, colorBg; // The foreground/monochrome icon for the app private final Bitmap mMonoIcon; private final Paint mMonoPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private final Bitmap mBgBitmap; private final Paint mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private final ColorFilter mBgFilter, mMonoFilter; protected ThemedIconDrawable(ThemedConstantState constantState) { super(constantState.mBitmap, constantState.colorFg); bitmapInfo = constantState.bitmapInfo; colorBg = constantState.colorBg; colorFg = constantState.colorFg; mMonoIcon = bitmapInfo.mMono; mMonoFilter = new BlendModeColorFilter(colorFg, BlendMode.SRC_IN); mMonoPaint.setColorFilter(mMonoFilter); mBgBitmap = bitmapInfo.mWhiteShadowLayer; mBgFilter = new BlendModeColorFilter(colorBg, BlendMode.SRC_IN); mBgPaint.setColorFilter(mBgFilter); } @Override protected void drawInternal(Canvas canvas, Rect bounds) { canvas.drawBitmap(mBgBitmap, null, bounds, mBgPaint); canvas.drawBitmap(mMonoIcon, null, bounds, mMonoPaint); } @Override protected void updateFilter() { super.updateFilter(); int alpha = mIsDisabled ? (int) (mDisabledAlpha * FULLY_OPAQUE) : FULLY_OPAQUE; mBgPaint.setAlpha(alpha); mBgPaint.setColorFilter(mIsDisabled ? new BlendModeColorFilter( getDisabledColor(colorBg), BlendMode.SRC_IN) : mBgFilter); mMonoPaint.setAlpha(alpha); mMonoPaint.setColorFilter(mIsDisabled ? new BlendModeColorFilter( getDisabledColor(colorFg), BlendMode.SRC_IN) : mMonoFilter); } @Override public boolean isThemed() { return true; } @Override public FastBitmapConstantState newConstantState() { return new ThemedConstantState(bitmapInfo, colorBg, colorFg); } static class ThemedConstantState extends FastBitmapConstantState { final BitmapInfo bitmapInfo; final int colorFg, colorBg; public ThemedConstantState(BitmapInfo bitmapInfo, int colorBg, int colorFg) { super(bitmapInfo.icon, bitmapInfo.color); this.bitmapInfo = bitmapInfo; this.colorBg = colorBg; this.colorFg = colorFg; } @Override public FastBitmapDrawable createDrawable() { return new ThemedIconDrawable(this); } } public static FastBitmapDrawable newDrawable(BitmapInfo info, Context context) { int[] colors = getColors(context); return new ThemedConstantState(info, colors[0], colors[1]).newDrawable(); } /** * Get an int array representing background and foreground colors for themed icons */ public static int[] getColors(Context context) { Resources res = context.getResources(); int[] colors = new int[2]; colors[0] = res.getColor(R.color.themed_icon_background_color); colors[1] = res.getColor(R.color.themed_icon_color); return colors; } @Override public int getIconColor() { return colorFg; } }
iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.kt 0 → 100644 +93 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.icons import android.content.Context import android.graphics.BlendMode.SRC_IN import android.graphics.BlendModeColorFilter import android.graphics.Canvas import android.graphics.Paint import android.graphics.Rect /** Class to handle monochrome themed app icons */ class ThemedIconDrawable(constantState: ThemedConstantState) : FastBitmapDrawable(constantState.mBitmap, constantState.colorFg) { val bitmapInfo = constantState.bitmapInfo private val colorFg = constantState.colorFg private val colorBg = constantState.colorBg // The foreground/monochrome icon for the app private val monoIcon = bitmapInfo.mMono!! private val monoFilter = BlendModeColorFilter(colorFg, SRC_IN) private val monoPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG).apply { colorFilter = monoFilter } private val bgBitmap = bitmapInfo.mWhiteShadowLayer private val bgFilter = BlendModeColorFilter(colorBg, SRC_IN) private val mBgPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG).apply { colorFilter = bgFilter } override fun drawInternal(canvas: Canvas, bounds: Rect) { canvas.drawBitmap(bgBitmap, null, bounds, mBgPaint) canvas.drawBitmap(monoIcon, null, bounds, monoPaint) } override fun updateFilter() { super.updateFilter() val alpha = if (mIsDisabled) (mDisabledAlpha * FULLY_OPAQUE).toInt() else FULLY_OPAQUE mBgPaint.alpha = alpha mBgPaint.setColorFilter( if (mIsDisabled) BlendModeColorFilter(getDisabledColor(colorBg), SRC_IN) else bgFilter ) monoPaint.alpha = alpha monoPaint.setColorFilter( if (mIsDisabled) BlendModeColorFilter(getDisabledColor(colorFg), SRC_IN) else monoFilter ) } override fun isThemed() = true override fun newConstantState() = ThemedConstantState(bitmapInfo, colorBg, colorFg) override fun getIconColor() = colorFg class ThemedConstantState(val bitmapInfo: BitmapInfo, val colorBg: Int, val colorFg: Int) : FastBitmapConstantState(bitmapInfo.icon, bitmapInfo.color) { public override fun createDrawable() = ThemedIconDrawable(this) } companion object { const val TAG: String = "ThemedIconDrawable" @JvmStatic fun newDrawable(info: BitmapInfo, context: Context): FastBitmapDrawable { val colors = getColors(context) return ThemedConstantState(info, colors[0], colors[1]).newDrawable() } /** Get an int array representing background and foreground colors for themed icons */ @JvmStatic fun getColors(context: Context): IntArray { val res = context.resources return intArrayOf( res.getColor(R.color.themed_icon_background_color), res.getColor(R.color.themed_icon_color), ) } } }
viewcapturelib/src/com/android/app/viewcapture/ViewCaptureAwareWindowManager.kt +0 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.app.viewcapture import android.media.permission.SafeCloseable import android.util.Log import android.view.View import android.view.ViewGroup import android.view.WindowManager Loading Loading @@ -63,8 +62,6 @@ class ViewCaptureAwareWindowManager( if (viewCaptureCloseableMap.containsKey(view)) { viewCaptureCloseableMap[view]?.close() viewCaptureCloseableMap.remove(view) } else { Log.wtf(TAG, "removeView called with view not present in closeable map!") } } } Loading