Revert "Revert "Add UI updates for incremental app installs.""
This reverts commit 229497d1820f49450687bbc558041df97d0bf779.
Reason for revert: Patching bugs
Fixes: 176901235, 176992421, 176884453
Test: manual
Change-Id: I57e13a15e72284564a10761966732ee31d15fd08
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 3eb52ad..f44f88b 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -50,6 +50,7 @@
import android.view.ViewDebug;
import android.widget.TextView;
+import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import com.android.launcher3.Launcher.OnResumeCallback;
@@ -71,7 +72,6 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.PackageItemInfo;
-import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.model.data.RemoteActionItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.SafeCloseable;
@@ -287,10 +287,7 @@
public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) {
applyIconAndLabel(info);
setTag(info);
- if (promiseStateChanged || (info.hasPromiseIconUi())) {
- applyPromiseState(promiseStateChanged);
- }
-
+ applyLoadingState(promiseStateChanged);
applyDotState(info, false /* animate */);
}
@@ -303,9 +300,8 @@
// Verify high res immediately
verifyHighRes();
- if (info instanceof PromiseAppInfo) {
- PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
- applyProgressLevel(promiseAppInfo.level);
+ if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
+ applyProgressLevel(info.getProgressLevel());
}
applyDotState(info, false /* animate */);
}
@@ -335,6 +331,10 @@
mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f);
setIcon(iconDrawable);
+ applyLabel(info);
+ }
+
+ private void applyLabel(ItemInfoWithIcon info) {
setText(info.title);
if (info.contentDescription != null) {
setContentDescription(info.isDisabled()
@@ -595,21 +595,35 @@
mLongPressHelper.cancelLongPress();
}
- public void applyPromiseState(boolean promiseStateChanged) {
+ /** Applies the loading progress value to the progress bar.
+ *
+ * If this app is installing, the progress bar will be updated with the installation progress.
+ * If this app is installed and downloading incrementally, the progress bar will be updated
+ * with the total download progress.
+ */
+ public void applyLoadingState(boolean promiseStateChanged) {
if (getTag() instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
- final boolean isPromise = info.hasPromiseIconUi();
- final int progressLevel = isPromise ?
- ((info.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
- info.getInstallProgress() : 0)) : 100;
-
- PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
- if (preloadDrawable != null && promiseStateChanged) {
- preloadDrawable.maybePerformFinishedAnimation();
+ int progressLevel = info.getProgressLevel();
+ if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE)
+ != 0) {
+ updateProgressBarUi(progressLevel, progressLevel == 100);
+ } else if (info.hasPromiseIconUi() || (info.runtimeStatusFlags
+ & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
+ updateProgressBarUi(progressLevel, promiseStateChanged);
}
}
}
+ private void updateProgressBarUi(int progressLevel, boolean maybePerformFinishedAnimation) {
+ PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
+ if (preloadDrawable != null && maybePerformFinishedAnimation) {
+ preloadDrawable.maybePerformFinishedAnimation();
+ }
+ }
+
+ /** Applies the given progress level to the this icon's progress bar. */
+ @Nullable
public PreloadIconDrawable applyProgressLevel(int progressLevel) {
if (getTag() instanceof ItemInfoWithIcon) {
ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
@@ -629,9 +643,11 @@
if (mIcon instanceof PreloadIconDrawable) {
preloadDrawable = (PreloadIconDrawable) mIcon;
preloadDrawable.setLevel(progressLevel);
+ preloadDrawable.setIsDisabled(!info.isAppStartable());
} else {
preloadDrawable = newPendingIcon(getContext(), info);
preloadDrawable.setLevel(progressLevel);
+ preloadDrawable.setIsDisabled(!info.isAppStartable());
setIcon(preloadDrawable);
}
return preloadDrawable;