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

Commit 84269d34 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Add UI updates for incremental app installs.

1. Changed Preload Icon UI to be grayscale while the app is not startable.
2. Added progress bar for when app is installed but still ownloading.
3. Updated Preload Icon progress and click handling to use new incremental api.

Progress bar color updates will follow in a separate CL.

Demo: https://drive.google.com/file/d/1H1EvtTorLeJwC1eiq10tm-TT81YZ6osk/view?usp=sharing

Bug: 171008815

Test: manual

Change-Id: I5874a5146d79a8c91d7d90ff0b9c1c427a3c95dd
parent 5fa687dd
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).getInstallProgress());
                        ((WorkspaceItemInfo) info).getProgressLevel());
            } else {
                assertEquals(updates.contains(info.id) ? progress: -1,
                        ((LauncherAppWidgetInfo) info).installProgress);
+33 −17
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ 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;
@@ -71,7 +72,6 @@ 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,10 +287,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    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 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        // 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 @@ 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,21 +595,35 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        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;
            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 && promiseStateChanged) {
        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 @@ 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;
+2 −3
Original line number Diff line number Diff line
@@ -137,7 +137,6 @@ 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;
@@ -2517,8 +2516,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
    }

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

    @Override
+10 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ 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;
@@ -195,6 +196,15 @@ 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) {
+4 −3
Original line number Diff line number Diff line
@@ -107,12 +107,13 @@ 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_R = BuildCompat.isAtLeastR();
    public static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;

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

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

    public static final boolean ATLEAST_S = BuildCompat.isAtLeastS();

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