Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77f114b6 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge branch 'epic6-s-icon-redesign' into 'v1-s'

BlissLauncher3 related changes

See merge request !2
parents fabee838 def0947c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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",
    ],
}

@@ -37,6 +39,7 @@ android_library {
    min_sdk_version: "26",
    static_libs: [
        "androidx.core_core",
        "androidx.core_core-ktx",
    ],
    resource_dirs: [
        "res",
@@ -44,5 +47,6 @@ android_library {
    srcs: [
        "src/**/*.java",
        "src_full_lib/**/*.java",
        "src/**/*.kt",
    ],
}
+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}"
}
+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
        }
    }
}
+13 −3
Original line number Diff line number Diff line
@@ -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;

@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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