Folder Previews Show Grey Pending Icon

When downloading an app previously the pending icon would show the full color icon when it was in a folder preview. To fix, we consolidated the logic for pending icons in PreloadIconDrawable and moved the logic of the pending state to the ItemInfoWithIcon model to represent the state of a pending application inside the model instead of in views.

Bug: b/324629535
Test: ItemInfoWithIconTest.kt
Flag: None
Change-Id: I4ffab44ddead046adcc84911039c87ea7c304e63
This commit is contained in:
Andrew Cole
2024-02-16 14:34:45 -08:00
parent 6a0c468563
commit d462190ef2
5 changed files with 125 additions and 42 deletions
@@ -139,7 +139,8 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
*/
private int mProgressLevel = 100;
protected ItemInfoWithIcon() { }
protected ItemInfoWithIcon() {
}
protected ItemInfoWithIcon(ItemInfoWithIcon info) {
super(info);
@@ -155,7 +156,20 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
}
/**
* Returns true if the app corresponding to the item is archived. */
* @return {@code true} if the app is pending download (0 progress) or if the app is archived
* and its install session is active
*/
public boolean isPendingDownload() {
if (isArchived()) {
return this.getProgressLevel() == 0
&& (this.runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) != 0;
}
return getProgressLevel() == 0;
}
/**
* Returns true if the app corresponding to the item is archived.
*/
public boolean isArchived() {
if (!Utilities.enableSupportForArchiving()) {
return false;
@@ -179,7 +193,7 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
public boolean isAppStartable() {
return ((runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) == 0)
&& (((runtimeStatusFlags & FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0)
|| mProgressLevel == 100 || isArchived());
|| mProgressLevel == 100 || isArchived());
}
/**
@@ -242,7 +256,7 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
return targetPackage != null
? ApiWrapper.getAppMarketActivityIntent(
context, targetPackage, Process.myUserHandle())
context, targetPackage, Process.myUserHandle())
: null;
}