Loading iconloaderlib/Android.bp +4 −0 Original line number Diff line number Diff line Loading @@ -22,12 +22,14 @@ android_library { min_sdk_version: "26", static_libs: [ "androidx.core_core", "androidx.core_core-ktx", ], resource_dirs: [ "res", ], srcs: [ "src/**/*.java", "src/**/*.kt", ], } Loading @@ -37,6 +39,7 @@ android_library { min_sdk_version: "26", static_libs: [ "androidx.core_core", "androidx.core_core-ktx", ], resource_dirs: [ "res", Loading @@ -44,5 +47,6 @@ android_library { srcs: [ "src/**/*.java", "src_full_lib/**/*.java", "src/**/*.kt", ], } iconloaderlib/build.gradle +6 −27 Original line number Diff line number Diff line apply plugin: 'com.android.library' android { compileSdkVersion COMPILE_SDK buildToolsVersion BUILD_TOOLS_VERSION defaultConfig { minSdkVersion 26 targetSdkVersion 28 plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' } android { namespace "com.android.launcher3.icons" sourceSets { main { java.srcDirs = ['src', 'src_full_lib'] java.srcDirs = ['src'] manifest.srcFile 'AndroidManifest.xml' res.srcDirs = ['res'] } } lintOptions { abortOnError false } tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation "androidx.core:core:${ANDROID_X_VERSION}" } iconloaderlib/src/com/android/launcher3/icons/AdaptiveIconGenerator.kt 0 → 100644 +26 −0 Original line number Diff line number Diff line package com.android.launcher3.icons import android.graphics.Bitmap import android.graphics.drawable.Drawable import androidx.core.graphics.drawable.toBitmap object AdaptiveIconGenerator { private const val ICON_SCALE = 1.46f @JvmStatic fun toBitmap(drawable: Drawable) = drawable.toBitmap() @JvmStatic fun getScale(bitmap: Bitmap, scale: Float): Float { val topRightPx = bitmap.getPixel(0, 0) val topLeftPx = bitmap.getPixel(0, bitmap.height - 1) val bottomRightPx = bitmap.getPixel(bitmap.width - 1, 0) val bottomLeftPx = bitmap.getPixel(bitmap.width - 1, bitmap.height - 1) return if (!(topRightPx != 0 && topLeftPx != 0 && bottomRightPx != 0 && bottomLeftPx != 0)) { scale } else { ICON_SCALE } } } iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +13 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Process; import android.os.UserHandle; import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import com.android.launcher3.icons.BitmapInfo.Extender; Loading Loading @@ -305,11 +306,20 @@ public class BaseIconFactory implements AutoCloseable { if (!(icon instanceof AdaptiveIconDrawable) && !outShape[0]) { FixedScaleDrawable fsd = ((FixedScaleDrawable) dr.getForeground()); fsd.setDrawable(icon); int color; if (icon.getIntrinsicHeight() > 0 && icon.getIntrinsicWidth() > 0) { Bitmap bitmap = AdaptiveIconGenerator.toBitmap(icon); fsd.setScale(AdaptiveIconGenerator.getScale(bitmap, scale)); color = ColorUtils.setAlphaComponent(new ColorExtractor().findDominantColorByHue(bitmap), 200); } else { fsd.setScale(scale); color = mWrapperBackgroundColor; } icon = dr; scale = getNormalizer().getScale(icon, outIconBounds, null, null); ((ColorDrawable) dr.getBackground()).setColor(mWrapperBackgroundColor); ((ColorDrawable) dr.getBackground()).setColor(color); } } else { scale = getNormalizer().getScale(icon, outIconBounds, null, null); Loading iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap private static final String TAG = "ClockDrawableWrapper"; private static final boolean DISABLE_SECONDS = true; private static final boolean DISABLE_SECONDS = false; // Time after which the clock icon should check for an update. The actual invalidate // will only happen in case of any change. Loading Loading
iconloaderlib/Android.bp +4 −0 Original line number Diff line number Diff line Loading @@ -22,12 +22,14 @@ android_library { min_sdk_version: "26", static_libs: [ "androidx.core_core", "androidx.core_core-ktx", ], resource_dirs: [ "res", ], srcs: [ "src/**/*.java", "src/**/*.kt", ], } Loading @@ -37,6 +39,7 @@ android_library { min_sdk_version: "26", static_libs: [ "androidx.core_core", "androidx.core_core-ktx", ], resource_dirs: [ "res", Loading @@ -44,5 +47,6 @@ android_library { srcs: [ "src/**/*.java", "src_full_lib/**/*.java", "src/**/*.kt", ], }
iconloaderlib/build.gradle +6 −27 Original line number Diff line number Diff line apply plugin: 'com.android.library' android { compileSdkVersion COMPILE_SDK buildToolsVersion BUILD_TOOLS_VERSION defaultConfig { minSdkVersion 26 targetSdkVersion 28 plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' } android { namespace "com.android.launcher3.icons" sourceSets { main { java.srcDirs = ['src', 'src_full_lib'] java.srcDirs = ['src'] manifest.srcFile 'AndroidManifest.xml' res.srcDirs = ['res'] } } lintOptions { abortOnError false } tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation "androidx.core:core:${ANDROID_X_VERSION}" }
iconloaderlib/src/com/android/launcher3/icons/AdaptiveIconGenerator.kt 0 → 100644 +26 −0 Original line number Diff line number Diff line package com.android.launcher3.icons import android.graphics.Bitmap import android.graphics.drawable.Drawable import androidx.core.graphics.drawable.toBitmap object AdaptiveIconGenerator { private const val ICON_SCALE = 1.46f @JvmStatic fun toBitmap(drawable: Drawable) = drawable.toBitmap() @JvmStatic fun getScale(bitmap: Bitmap, scale: Float): Float { val topRightPx = bitmap.getPixel(0, 0) val topLeftPx = bitmap.getPixel(0, bitmap.height - 1) val bottomRightPx = bitmap.getPixel(bitmap.width - 1, 0) val bottomLeftPx = bitmap.getPixel(bitmap.width - 1, bitmap.height - 1) return if (!(topRightPx != 0 && topLeftPx != 0 && bottomRightPx != 0 && bottomLeftPx != 0)) { scale } else { ICON_SCALE } } }
iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +13 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Process; import android.os.UserHandle; import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import com.android.launcher3.icons.BitmapInfo.Extender; Loading Loading @@ -305,11 +306,20 @@ public class BaseIconFactory implements AutoCloseable { if (!(icon instanceof AdaptiveIconDrawable) && !outShape[0]) { FixedScaleDrawable fsd = ((FixedScaleDrawable) dr.getForeground()); fsd.setDrawable(icon); int color; if (icon.getIntrinsicHeight() > 0 && icon.getIntrinsicWidth() > 0) { Bitmap bitmap = AdaptiveIconGenerator.toBitmap(icon); fsd.setScale(AdaptiveIconGenerator.getScale(bitmap, scale)); color = ColorUtils.setAlphaComponent(new ColorExtractor().findDominantColorByHue(bitmap), 200); } else { fsd.setScale(scale); color = mWrapperBackgroundColor; } icon = dr; scale = getNormalizer().getScale(icon, outIconBounds, null, null); ((ColorDrawable) dr.getBackground()).setColor(mWrapperBackgroundColor); ((ColorDrawable) dr.getBackground()).setColor(color); } } else { scale = getNormalizer().getScale(icon, outIconBounds, null, null); Loading
iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap private static final String TAG = "ClockDrawableWrapper"; private static final boolean DISABLE_SECONDS = true; private static final boolean DISABLE_SECONDS = false; // Time after which the clock icon should check for an update. The actual invalidate // will only happen in case of any change. Loading