Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdfed232 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Add UI updates for incremental app installs.""

parents da5e714c 229497d1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public class PackageInstallStateChangedTaskTest {
        for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
            if (info instanceof WorkspaceItemInfo) {
                assertEquals(updates.contains(info.id) ? progress: 0,
                        ((WorkspaceItemInfo) info).getProgressLevel());
                        ((WorkspaceItemInfo) info).getInstallProgress());
            } else {
                assertEquals(updates.contains(info.id) ? progress: -1,
                        ((LauncherAppWidgetInfo) info).installProgress);
+17 −33
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import android.view.View;
import android.view.ViewDebug;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;

import com.android.launcher3.Launcher.OnResumeCallback;
@@ -72,6 +71,7 @@ import com.android.launcher3.model.data.AppInfo;
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,7 +287,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) {
        applyIconAndLabel(info);
        setTag(info);
        applyLoadingState(promiseStateChanged);
        if (promiseStateChanged || (info.hasPromiseIconUi())) {
            applyPromiseState(promiseStateChanged);
        }

        applyDotState(info, false /* animate */);
    }

@@ -300,8 +303,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        // Verify high res immediately
        verifyHighRes();

        if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
            applyProgressLevel(info.getProgressLevel());
        if (info instanceof PromiseAppInfo) {
            PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
            applyProgressLevel(promiseAppInfo.level);
        }
        applyDotState(info, false /* animate */);
    }
@@ -331,10 +335,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        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,35 +595,21 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        mLongPressHelper.cancelLongPress();
    }

    /** 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) {
    public void applyPromiseState(boolean promiseStateChanged) {
        if (getTag() instanceof WorkspaceItemInfo) {
            WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
            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);
            }
        }
    }
            final boolean isPromise = info.hasPromiseIconUi();
            final int progressLevel = isPromise ?
                    ((info.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
                            info.getInstallProgress() : 0)) : 100;

    private void updateProgressBarUi(int progressLevel, boolean maybePerformFinishedAnimation) {
            PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
        if (preloadDrawable != null && maybePerformFinishedAnimation) {
            if (preloadDrawable != null && promiseStateChanged) {
                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();
@@ -643,11 +629,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
                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;
+3 −2
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.pm.PinRequestHelper;
@@ -2515,8 +2516,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
    }

    @Override
    public void bindIncrementalDownloadProgressUpdated(AppInfo app) {
        mAppsView.getAppsStore().updateProgressBar(app);
    public void bindPromiseAppProgressUpdated(PromiseAppInfo app) {
        mAppsView.getAppsStore().updatePromiseAppProgress(app);
    }

    @Override
+0 −10
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import com.android.launcher3.model.LoaderResults;
import com.android.launcher3.model.LoaderTask;
import com.android.launcher3.model.ModelDelegate;
import com.android.launcher3.model.ModelWriter;
import com.android.launcher3.model.PackageIncrementalDownloadUpdatedTask;
import com.android.launcher3.model.PackageInstallStateChangedTask;
import com.android.launcher3.model.PackageUpdatedTask;
import com.android.launcher3.model.ShortcutsChangedTask;
@@ -196,15 +195,6 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
                PackageUpdatedTask.OP_UNSUSPEND, user, packageNames));
    }

    @Override
    public void onPackageLoadingProgressChanged(
                String packageName, UserHandle user, float progress) {
        if (Utilities.ATLEAST_S) {
            enqueueModelUpdateTask(new PackageIncrementalDownloadUpdatedTask(
                    packageName, user, progress));
        }
    }

    @Override
    public void onShortcutsChanged(String packageName, List<ShortcutInfo> shortcuts,
            UserHandle user) {
+3 −4
Original line number Diff line number Diff line
@@ -107,13 +107,12 @@ public final class Utilities {
    public static final String[] EMPTY_STRING_ARRAY = new String[0];
    public static final Person[] EMPTY_PERSON_ARRAY = new Person[0];

    public static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
    public static final boolean ATLEAST_R = BuildCompat.isAtLeastR();

    public static final boolean ATLEAST_Q = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;

    public static final boolean ATLEAST_R = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;

    public static final boolean ATLEAST_S = BuildCompat.isAtLeastS();
    public static final boolean ATLEAST_P =
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;

    /**
     * Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}.
Loading