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

Commit 44bcba3d authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Merge branch 'ub-launcher3-master' into launcher3merge2018-11-13

Test: Tested on unbundled branch
Change-Id: Icf6beaf668feeb9d86d7fe3a7bcefdd16a15e9ac
parents ee817568 4194f242
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \
    androidx.recyclerview_recyclerview \
    androidx.dynamicanimation_dynamicanimation \
    androidx.preference_preference \
    iconloader
    iconloader_base

LOCAL_STATIC_JAVA_LIBRARIES := LauncherPluginLib

+17 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
// limitations under the License.

android_library {
    name: "iconloader",
    name: "iconloader_base",
    sdk_version: "28",
    min_sdk_version: "21",
    static_libs: [
@@ -26,3 +26,19 @@ android_library {
        "src/**/*.java",
    ],
}

android_library {
    name: "iconloader",
    sdk_version: "system_current",
    min_sdk_version: "21",
    static_libs: [
        "androidx.core_core",
    ],
    resource_dirs: [
        "res",
    ],
    srcs: [
        "src/**/*.java",
        "src_full_lib/**/*.java",
    ],
}
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ android {

    sourceSets {
        main {
            java.srcDirs = ['src']
            java.srcDirs = ['src', 'src_full_lib']
            manifest.srcFile 'AndroidManifest.xml'
            res.srcDirs = ['res']
        }
+27 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2018, 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.
*/
-->
<resources>

    <!-- Various configurations to control the simple cache implementation -->

    <dimen name="default_icon_bitmap_size">56dp</dimen>
    <bool name="simple_cache_enable_im_memory">false</bool>
    <string name="cache_db_name" translatable="false">app_icons.db</string>

</resources>
 No newline at end of file
+52 −9
Original line number Diff line number Diff line
package com.android.launcher3.icons;

import static android.graphics.Paint.DITHER_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_FLAG;

import static com.android.launcher3.icons.ShadowGenerator.BLUR_FACTOR;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -18,28 +23,26 @@ import android.os.Build;
import android.os.Process;
import android.os.UserHandle;

import static android.graphics.Paint.DITHER_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
import static com.android.launcher3.icons.ShadowGenerator.BLUR_FACTOR;

/**
 * This class will be moved to androidx library. There shouldn't be any dependency outside
 * this package.
 */
public class BaseIconFactory {
public class BaseIconFactory implements AutoCloseable {

    private static final String TAG = "BaseIconFactory";
    private static final int DEFAULT_WRAPPER_BACKGROUND = Color.WHITE;
    public static final boolean ATLEAST_OREO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
    static final boolean ATLEAST_OREO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
    static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;

    private final Rect mOldBounds = new Rect();
    private final Context mContext;
    protected final Context mContext;
    private final Canvas mCanvas;
    private final PackageManager mPm;
    private final ColorExtractor mColorExtractor;
    private boolean mDisableColorExtractor;

    private int mFillResIconDpi;
    private int mIconBitmapSize;
    protected final int mFillResIconDpi;
    protected final int mIconBitmapSize;

    private IconNormalizer mNormalizer;
    private ShadowGenerator mShadowGenerator;
@@ -115,6 +118,29 @@ public class BaseIconFactory {
        return createBadgedIconBitmap(icon, user, shrinkNonAdaptiveIcons, isInstantApp, null);
    }

    public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
            int iconAppTargetSdk) {
        return createBadgedIconBitmap(icon, user, iconAppTargetSdk, false);
    }

    public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
            int iconAppTargetSdk, boolean isInstantApp) {
        return createBadgedIconBitmap(icon, user, iconAppTargetSdk, isInstantApp, null);
    }

    public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
            int iconAppTargetSdk, boolean isInstantApp, float[] scale) {
        boolean shrinkNonAdaptiveIcons = ATLEAST_P ||
                (ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O);
        return createBadgedIconBitmap(icon, user, shrinkNonAdaptiveIcons, isInstantApp, scale);
    }

    public Bitmap createScaledBitmapWithoutShadow(Drawable icon, int iconAppTargetSdk) {
        boolean shrinkNonAdaptiveIcons = ATLEAST_P ||
                (ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O);
        return  createScaledBitmapWithoutShadow(icon, shrinkNonAdaptiveIcons);
    }

    /**
     * Creates bitmap using the source drawable and various parameters.
     * The bitmap is visually normalized with other icons and has enough spacing to add shadow.
@@ -277,6 +303,23 @@ public class BaseIconFactory {
        return bitmap;
    }

    @Override
    public void close() {
        clear();
    }

    public BitmapInfo makeDefaultIcon(UserHandle user) {
        return createBadgedIconBitmap(getFullResDefaultActivityIcon(mFillResIconDpi),
                user, Build.VERSION.SDK_INT);
    }

    public static Drawable getFullResDefaultActivityIcon(int iconDpi) {
        return Resources.getSystem().getDrawableForDensity(
                Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
                        ? android.R.drawable.sym_def_app_icon : android.R.mipmap.sym_def_app_icon,
                iconDpi);
    }

    /**
     * An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size.
     * This allows the badging to be done based on the action bitmap size rather than
Loading