Fix bug where app pair icons were appearing empty

Using similar logic as other BubbleTextViews, checks for PlaceholderIconDrawables and redraws the icons if needed.

Fixes: 316041983
Test: Manual and presubmit tested
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TEAMFOOD
Change-Id: I017f1d5597fd28d37ca9a8a5758f33468e46f384
This commit is contained in:
Jeremy Sim
2023-12-26 01:04:05 -08:00
committed by Vinit Nayak
parent a85fa48883
commit d36d4f3f94

View File

@@ -25,6 +25,7 @@ import android.util.Log
import android.view.Gravity
import android.widget.FrameLayout
import com.android.launcher3.DeviceProfile
import com.android.launcher3.icons.PlaceHolderIconDrawable
import com.android.launcher3.model.data.WorkspaceItemInfo
/**
@@ -94,8 +95,16 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
return
}
appIcon1 = parentIcon.info.contents[0].newIcon(context)
appIcon2 = parentIcon.info.contents[1].newIcon(context)
// Generate new icons
val newIcon1 = parentIcon.info.contents[0].newIcon(context)
val newIcon2 = parentIcon.info.contents[1].newIcon(context)
// If app icons did not draw fully last time, animate to full icon
(appIcon1 as? PlaceHolderIconDrawable)?.animateIconUpdate(newIcon1)
(appIcon2 as? PlaceHolderIconDrawable)?.animateIconUpdate(newIcon2)
appIcon1 = newIcon1
appIcon2 = newIcon2
appIcon1?.setBounds(0, 0, memberIconSize.toInt(), memberIconSize.toInt())
appIcon2?.setBounds(0, 0, memberIconSize.toInt(), memberIconSize.toInt())
}
@@ -126,6 +135,16 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
// Draw background
appPairBackground.draw(canvas)
// Make sure icons are loaded
if (
appIcon1 == null ||
appIcon2 == null ||
appIcon1 is PlaceHolderIconDrawable ||
appIcon2 is PlaceHolderIconDrawable
) {
applyIcons(parentIcon.info.contents)
}
// Draw first icon
canvas.save()
// The app icons are placed differently depending on device orientation.