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
This commit is contained in:
Jason Chiu
2022-11-06 17:27:03 +08:00
parent af96b1ea7a
commit fb95451369
2 changed files with 4 additions and 6 deletions

View File

@@ -39,8 +39,8 @@
<androidx.preference.internal.PreferenceImageView <androidx.preference.internal.PreferenceImageView
android:id="@android:id/icon" android:id="@android:id/icon"
android:layout_width="wrap_content" android:layout_width="24dp"
android:layout_height="wrap_content" android:layout_height="24dp"
app:maxWidth="48dp" app:maxWidth="48dp"
app:maxHeight="48dp"/> app:maxHeight="48dp"/>

View File

@@ -382,10 +382,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
// Icon provided by the content provider overrides any static icon. // Icon provided by the content provider overrides any static icon.
if (tile.getMetaData() != null if (tile.getMetaData() != null
&& tile.getMetaData().containsKey(META_DATA_PREFERENCE_ICON_URI)) { && tile.getMetaData().containsKey(META_DATA_PREFERENCE_ICON_URI)) {
// Set a transparent color before starting to fetch the real icon, this is necessary // Reserve the icon space to avoid preference padding change.
// to avoid preference padding change. preference.setIconSpaceReserved(true);
setPreferenceIcon(preference, tile, forceRoundedIcon, mContext.getPackageName(),
Icon.createWithResource(mContext, android.R.color.transparent));
ThreadUtils.postOnBackgroundThread(() -> { ThreadUtils.postOnBackgroundThread(() -> {
final Intent intent = tile.getIntent(); final Intent intent = tile.getIntent();