From fb95451369d5fa9fb208e91d15c0e5c4b51811d2 Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Sun, 6 Nov 2022 17:27:03 +0800 Subject: [PATCH] Reserve the icon space to avoid preference padding change If the injection icon is to be retrieved from a provider, the preset transparent drawable is a 1x1 icon, which may cause the preference padding change before and after the injection icon reloading. Bug: 253471066 Test: robotest, visual Change-Id: Ie88f69bb047a64a6a0ee30c060d8cbb8fe27b3d7 --- res/layout/homepage_preference.xml | 4 ++-- .../settings/dashboard/DashboardFeatureProviderImpl.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/res/layout/homepage_preference.xml b/res/layout/homepage_preference.xml index ed1a2f1f5ee..18ecdcffde6 100644 --- a/res/layout/homepage_preference.xml +++ b/res/layout/homepage_preference.xml @@ -39,8 +39,8 @@ diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java index 80c9ec652dd..f6dd0b7a329 100644 --- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java +++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java @@ -382,10 +382,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider { // Icon provided by the content provider overrides any static icon. if (tile.getMetaData() != null && tile.getMetaData().containsKey(META_DATA_PREFERENCE_ICON_URI)) { - // Set a transparent color before starting to fetch the real icon, this is necessary - // to avoid preference padding change. - setPreferenceIcon(preference, tile, forceRoundedIcon, mContext.getPackageName(), - Icon.createWithResource(mContext, android.R.color.transparent)); + // Reserve the icon space to avoid preference padding change. + preference.setIconSpaceReserved(true); ThreadUtils.postOnBackgroundThread(() -> { final Intent intent = tile.getIntent();