diff options
author | Xin Li <delphij@google.com> | 2022-03-08 00:18:25 +0000 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2022-03-08 00:18:25 +0000 |
commit | 9c88414993c98c4fead3162a6b00ebe8657ef652 (patch) | |
tree | 1035a20d466e8a3a4a3b9bda27c331438da5f1b2 | |
parent | 9f9280f2e63f234dbe51dcb520d2073be5ef1476 (diff) | |
parent | 820707d6c938f3899a11d48578ecbc0ceb6787f9 (diff) | |
download | systemui-9c88414993c98c4fead3162a6b00ebe8657ef652.tar.gz |
Merge Android 12L
Bug: 222710654
Merged-In: I146a7e642778aa3c5c5c8f0b7f03535de5d9a814
Change-Id: Ifa4f1fb59786da5910892ac8f04ff837bfc79f3a
9 files changed, 119 insertions, 38 deletions
diff --git a/iconloaderlib/build.gradle b/iconloaderlib/build.gradle index 8410275..10ec889 100644 --- a/iconloaderlib/build.gradle +++ b/iconloaderlib/build.gradle @@ -7,8 +7,6 @@ android { defaultConfig { minSdkVersion 26 targetSdkVersion 28 - versionCode 1 - versionName "1.0" } sourceSets { diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java index 9ce9975..f5ce814 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java @@ -63,7 +63,7 @@ public class BaseIconFactory implements AutoCloseable { private final Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private static final float PLACEHOLDER_TEXT_SIZE = 20f; - private static int PLACEHOLDER_BACKGROUND_COLOR = Color.rgb(240, 240, 240); + private static int PLACEHOLDER_BACKGROUND_COLOR = Color.rgb(245, 245, 245); protected BaseIconFactory(Context context, int fillResIconDpi, int iconBitmapSize, boolean shapeDetection) { @@ -144,7 +144,7 @@ public class BaseIconFactory implements AutoCloseable { AdaptiveIconDrawable drawable = new AdaptiveIconDrawable( new ColorDrawable(PLACEHOLDER_BACKGROUND_COLOR), new BitmapDrawable(mContext.getResources(), placeholderBitmap)); - Bitmap icon = createIconBitmap(drawable, 1f); + Bitmap icon = createIconBitmap(drawable, IconNormalizer.ICON_VISIBLE_AREA_FACTOR); return BitmapInfo.of(icon, extractColor(icon)); } diff --git a/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java b/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java index a7894c9..d2cbe72 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java +++ b/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java @@ -25,10 +25,8 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; -import android.graphics.PorterDuff; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; @@ -373,10 +371,13 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap // prepare and draw the foreground mInfo.animInfo.applyTime(mTime, mForeground); + int saveCount = canvas.save(); canvas.scale(mInfo.scale, mInfo.scale, bounds.exactCenterX() + mInfo.offset, bounds.exactCenterY() + mInfo.offset); canvas.clipPath(mFullDrawable.getIconMask()); + mForeground.setBounds(bounds); mForeground.draw(canvas); + canvas.restoreToCount(saveCount); reschedule(); } diff --git a/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java b/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java index 4aa2846..2a5f029 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java +++ b/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java @@ -287,7 +287,7 @@ public class FastBitmapDrawable extends Drawable { mat[14] = brightnessI; mat[18] = disabledAlpha; tempFilterMatrix.preConcat(tempBrightnessMatrix); - return new ColorMatrixColorFilter(tempBrightnessMatrix); + return new ColorMatrixColorFilter(tempFilterMatrix); } protected static class FastBitmapConstantState extends ConstantState { diff --git a/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java b/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java index e24f353..96dee3b 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java +++ b/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java @@ -35,14 +35,14 @@ public class ShadowGenerator { public static final boolean ENABLE_SHADOWS = true; - public static final float BLUR_FACTOR = 1.5f/48; + public static final float BLUR_FACTOR = 1.68f/48; // Percent of actual icon size public static final float KEY_SHADOW_DISTANCE = 1f/48; - private static final int KEY_SHADOW_ALPHA = 10; + private static final int KEY_SHADOW_ALPHA = 7; // Percent of actual icon size private static final float HALF_DISTANCE = 0.5f; - private static final int AMBIENT_SHADOW_ALPHA = 7; + private static final int AMBIENT_SHADOW_ALPHA = 25; private final int mIconSize; diff --git a/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java b/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java index d685737..7c4624d 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java +++ b/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java @@ -38,6 +38,7 @@ import android.os.Handler; import android.os.LocaleList; import android.os.Looper; import android.os.Process; +import android.os.Trace; import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; @@ -264,7 +265,14 @@ public abstract class BaseIconCache { // (e.g. fallback icon, default icon). So we drop here since there's no point in caching // an empty entry. if (entry.bitmap.isNullOrLowRes()) return; - entry.title = cachingLogic.getLabel(object); + + CharSequence entryTitle = cachingLogic.getLabel(object); + if (entryTitle == null) { + Log.d(TAG, "No label returned from caching logic instance: " + cachingLogic); + return; + } + entry.title = entryTitle; + entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user); if (cachingLogic.addToMemCache()) mCache.put(key, entry); @@ -306,6 +314,20 @@ public abstract class BaseIconCache { @NonNull ComponentName componentName, @NonNull UserHandle user, @NonNull Supplier<T> infoProvider, @NonNull CachingLogic<T> cachingLogic, boolean usePackageIcon, boolean useLowResIcon) { + return cacheLocked( + componentName, + user, + infoProvider, + cachingLogic, + null, + usePackageIcon, + useLowResIcon); + } + + protected <T> CacheEntry cacheLocked( + @NonNull ComponentName componentName, @NonNull UserHandle user, + @NonNull Supplier<T> infoProvider, @NonNull CachingLogic<T> cachingLogic, + @Nullable Cursor cursor, boolean usePackageIcon, boolean useLowResIcon) { assertWorkerThread(); ComponentKey cacheKey = new ComponentKey(componentName, user); CacheEntry entry = mCache.get(cacheKey); @@ -318,8 +340,10 @@ public abstract class BaseIconCache { // Check the DB first. T object = null; boolean providerFetchedOnce = false; - - if (!getEntryFromDB(cacheKey, entry, useLowResIcon)) { + boolean cacheEntryUpdated = cursor == null + ? getEntryFromDB(cacheKey, entry, useLowResIcon) + : updateTitleAndIcon(cacheKey, entry, cursor, useLowResIcon); + if (!cacheEntryUpdated) { object = infoProvider.get(); providerFetchedOnce = true; @@ -459,6 +483,7 @@ public abstract class BaseIconCache { protected boolean getEntryFromDB(ComponentKey cacheKey, CacheEntry entry, boolean lowRes) { Cursor c = null; + Trace.beginSection("loadIconIndividually"); try { c = mIconDb.query( lowRes ? IconDB.COLUMNS_LOW_RES : IconDB.COLUMNS_HIGH_RES, @@ -467,26 +492,7 @@ public abstract class BaseIconCache { cacheKey.componentName.flattenToString(), Long.toString(getSerialNumberForUser(cacheKey.user))}); if (c.moveToNext()) { - // Set the alpha to be 255, so that we never have a wrong color - entry.bitmap = BitmapInfo.of(LOW_RES_ICON, setColorAlphaBound(c.getInt(0), 255)); - entry.title = c.getString(1); - if (entry.title == null) { - entry.title = ""; - entry.contentDescription = ""; - } else { - entry.contentDescription = mPackageManager.getUserBadgedLabel( - entry.title, cacheKey.user); - } - - if (!lowRes) { - try { - entry.bitmap = BitmapInfo.fromByteArray( - c.getBlob(2), entry.bitmap.color, cacheKey.user, this, mContext); - } catch (Exception e) { - return false; - } - } - return entry.bitmap != null; + return updateTitleAndIcon(cacheKey, entry, c, lowRes); } } catch (SQLiteException e) { Log.d(TAG, "Error reading icon cache", e); @@ -494,10 +500,35 @@ public abstract class BaseIconCache { if (c != null) { c.close(); } + Trace.endSection(); } return false; } + private boolean updateTitleAndIcon( + ComponentKey cacheKey, CacheEntry entry, Cursor c, boolean lowRes) { + // Set the alpha to be 255, so that we never have a wrong color + entry.bitmap = BitmapInfo.of(LOW_RES_ICON, setColorAlphaBound(c.getInt(0), 255)); + entry.title = c.getString(1); + if (entry.title == null) { + entry.title = ""; + entry.contentDescription = ""; + } else { + entry.contentDescription = mPackageManager.getUserBadgedLabel( + entry.title, cacheKey.user); + } + + if (!lowRes) { + try { + entry.bitmap = BitmapInfo.fromByteArray( + c.getBlob(2), entry.bitmap.color, cacheKey.user, this, mContext); + } catch (Exception e) { + return false; + } + } + return entry.bitmap != null; + } + /** * Returns a cursor for an arbitrary query to the cache db */ @@ -510,7 +541,7 @@ public abstract class BaseIconCache { * Cache class to store the actual entries on disk */ public static final class IconDB extends SQLiteCacheHelper { - private static final int RELEASE_VERSION = 31; + private static final int RELEASE_VERSION = 32; public static final String TABLE_NAME = "icons"; public static final String COLUMN_ROWID = "rowid"; @@ -525,9 +556,12 @@ public abstract class BaseIconCache { public static final String COLUMN_KEYWORDS = "keywords"; public static final String[] COLUMNS_HIGH_RES = new String[] { - IconDB.COLUMN_ICON_COLOR, IconDB.COLUMN_LABEL, IconDB.COLUMN_ICON }; + IconDB.COLUMN_ICON_COLOR, + IconDB.COLUMN_LABEL, + IconDB.COLUMN_ICON, + COLUMN_COMPONENT}; public static final String[] COLUMNS_LOW_RES = new String[] { - IconDB.COLUMN_ICON_COLOR, IconDB.COLUMN_LABEL }; + IconDB.COLUMN_ICON_COLOR, IconDB.COLUMN_LABEL, COLUMN_COMPONENT}; public IconDB(Context context, String dbFileName, int iconPixelSize) { super(context, dbFileName, (RELEASE_VERSION << 16) + iconPixelSize, TABLE_NAME); diff --git a/searchuilib/build.gradle b/searchuilib/build.gradle index 4f372e3..3bf65fe 100644 --- a/searchuilib/build.gradle +++ b/searchuilib/build.gradle @@ -7,8 +7,6 @@ android { defaultConfig { minSdkVersion 25 targetSdkVersion 28 - versionCode 1 - versionName "1.0" } sourceSets { diff --git a/searchuilib/src/com/android/app/search/LayoutType.java b/searchuilib/src/com/android/app/search/LayoutType.java index cf27e2b..b39cc76 100644 --- a/searchuilib/src/com/android/app/search/LayoutType.java +++ b/searchuilib/src/com/android/app/search/LayoutType.java @@ -44,6 +44,7 @@ public class LayoutType { public static final String ICON_HORIZONTAL_TEXT = "icon_row"; public static final String HORIZONTAL_MEDIUM_TEXT = "icon_row_medium"; public static final String SMALL_ICON_HORIZONTAL_TEXT = "short_icon_row"; + public static final String SMALL_ICON_HORIZONTAL_TEXT_THUMBNAIL = "short_icon_row_thumbnail"; // This layout creates square thumbnail image (currently 3 column) public static final String THUMBNAIL = "thumbnail"; diff --git a/searchuilib/src/com/android/app/search/ResultType.java b/searchuilib/src/com/android/app/search/ResultType.java new file mode 100644 index 0000000..f5fd272 --- /dev/null +++ b/searchuilib/src/com/android/app/search/ResultType.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 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.app.search; + +/** + * Constants to be used with {@link android.app.search.SearchContext} and + * {@link android.app.search.SearchTarget}. + * + * Note, a result type could be a of two types. + * For example, unpublished settings result type could be in slices: + * <code> resultType = SETTING | SLICE </code> + */ +public class ResultType { + + // published corpus by 3rd party app, supported by SystemService + public static final int APPLICATION = 1 << 0; + public static final int SHORTCUT = 1 << 1; + public static final int SLICE = 1 << 6; + public static final int WIDGETS = 1 << 7; + + // Not extracted from any of the SystemService + public static final int PEOPLE = 1 << 2; + public static final int ACTION = 1 << 3; + public static final int SETTING = 1 << 4; + public static final int SCREENSHOT = 1 << 5; + public static final int PLAY = 1 << 8; + public static final int SUGGEST = 1 << 9; + public static final int ASSISTANT = 1 << 10; + public static final int CHROMETAB = 1 << 11; + public static final int NAVVYSITE = 1 << 12; + public static final int TIPS = 1 << 13; + public static final int PEOPLE_TILE = 1 << 14; + public static final int LEGACY_SHORTCUT = 1 << 15; + public static final int MEMORY = 1 << 16; +} |