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

Commit 51c6fdf7 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Merging from ub-launcher3-master @ build 6188107

Test: manual, presubmit on the source branch
http://x20/teams/android-launcher/merge/ub-launcher3-master_6188107.html

Change-Id: I84c1ea301508ba5f0f3d337a423cea8e61832c0d
parents 907cbb9f 61d639d7
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -78,9 +78,8 @@ include $(CLEAR_VARS)
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := optional

LOCAL_STATIC_ANDROID_LIBRARIES := \
    Launcher3CommonDepsLib \
    SecondaryDisplayLauncherLib
LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib

LOCAL_SRC_FILES := \
    $(call all-java-files-under, src) \
    $(call all-java-files-under, src_shortcuts_overrides) \
@@ -154,9 +153,7 @@ else
endif
LOCAL_MODULE := Launcher3QuickStepLib
LOCAL_PRIVILEGED_MODULE := true
LOCAL_STATIC_ANDROID_LIBRARIES := \
    Launcher3CommonDepsLib \
    SecondaryDisplayLauncherLib
LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib

LOCAL_SRC_FILES := \
    $(call all-java-files-under, src) \
+15 −0
Original line number Diff line number Diff line
@@ -184,5 +184,20 @@
            android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
            android:exported="true"
            android:enabled="false" />

        <!--
        Launcher activity for secondary display
        -->
        <activity
            android:name="com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher"
            android:theme="@style/AppTheme"
            android:launchMode="singleTop"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.SECONDARY_HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>
+20 −0
Original line number Diff line number Diff line
@@ -17,9 +17,13 @@ package com.android.launcher3.icons;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.os.Build.VERSION_CODES;

/**
 * Interface representing a bitmap draw operation.
@@ -29,6 +33,7 @@ public interface BitmapRenderer {
    boolean USE_HARDWARE_BITMAP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;

    static Bitmap createSoftwareBitmap(int width, int height, BitmapRenderer renderer) {
        GraphicsUtils.noteNewBitmapCreated();
        Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        renderer.draw(new Canvas(result));
        return result;
@@ -40,11 +45,26 @@ public interface BitmapRenderer {
            return createSoftwareBitmap(width, height, renderer);
        }

        GraphicsUtils.noteNewBitmapCreated();
        Picture picture = new Picture();
        renderer.draw(picture.beginRecording(width, height));
        picture.endRecording();
        return Bitmap.createBitmap(picture);
    }

    /**
     * Returns a bitmap from subset of the source bitmap. The new bitmap may be the
     * same object as source, or a copy may have been made.
     */
    static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height) {
        if (Build.VERSION.SDK_INT >= VERSION_CODES.O && source.getConfig() == Config.HARDWARE) {
            return createHardwareBitmap(width, height, c -> c.drawBitmap(source,
                    new Rect(x, y, x + width, y + height), new RectF(0, 0, width, height), null));
        } else {
            GraphicsUtils.noteNewBitmapCreated();
            return Bitmap.createBitmap(source, x, y, width, height);
        }
    }

    void draw(Canvas out);
}
+11 −2
Original line number Diff line number Diff line
@@ -21,15 +21,17 @@ import android.graphics.Region;
import android.graphics.RegionIterator;
import android.util.Log;

import androidx.annotation.ColorInt;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import androidx.annotation.ColorInt;

public class GraphicsUtils {

    private static final String TAG = "GraphicsUtils";

    public static Runnable sOnNewBitmapRunnable = () -> { };

    /**
     * Set the alpha component of {@code color} to be {@code alpha}. Unlike the support lib version,
     * it bounds the alpha in valid range instead of throwing an exception to allow for safer
@@ -73,4 +75,11 @@ public class GraphicsUtils {
        }
        return area;
    }

    /**
     * Utility method to track new bitmap creation
     */
    public static void noteNewBitmapCreated() {
        sOnNewBitmapRunnable.run();
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.launcher3.icons;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BlurMaskFilter;
import android.graphics.BlurMaskFilter.Blur;
import android.graphics.Canvas;
@@ -135,9 +134,7 @@ public class ShadowGenerator {
            bounds.offsetTo(center - width / 2f, center - height / 2f);

            int size = center * 2;
            Bitmap result = Bitmap.createBitmap(size, size, Config.ARGB_8888);
            drawShadow(new Canvas(result));
            return result;
            return BitmapRenderer.createHardwareBitmap(size, size, this::drawShadow);
        }

        public void drawShadow(Canvas c) {
Loading