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

Commit 2d8e882d authored by Samuel Fufa's avatar Samuel Fufa
Browse files

Allow shortcut predictions in hybrid hotseat

Screenshot: https://screenshot.googleplex.com/TckWKGYWwHW

Note: Shortcut predictions will not be cached.

Bug: 159500320
Test: Manual
Change-Id: Id8ec81544bddb8be87a5e748fd9f9e93aaaf8fea
parent 5c33e250
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -30,8 +30,10 @@ import android.app.prediction.AppPredictor;
import android.app.prediction.AppTarget;
import android.app.prediction.AppTargetEvent;
import android.content.ComponentName;
import android.content.pm.ShortcutInfo;
import android.os.Process;
import android.util.Log;
import android.util.SparseArray;
import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewGroup;
@@ -65,6 +67,7 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.uioverrides.PredictedAppIcon;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -379,16 +382,24 @@ public class HotseatPredictionController implements DragController.DragListener,
            mRestoreHelper.restoreBackup();
        }
        StringBuilder predictionLog = new StringBuilder("predictedApps: [\n");
        ArrayList<ComponentKey> componentKeys = new ArrayList<>();
        ArrayList<ComponentKey> componentKeysToBeCached = new ArrayList<>();
        SparseArray<ShortcutRequest> requests = new SparseArray<>();
        for (AppTarget appTarget : appTargets) {
            ComponentKey key;
            if (appTarget.getShortcutInfo() != null) {
                key = ShortcutKey.fromInfo(appTarget.getShortcutInfo());
            ShortcutRequest request = requests.get(appTarget.getUser().getIdentifier());
            if (request == null) {
                request = new ShortcutRequest(mLauncher, appTarget.getUser());
                requests.put(appTarget.getUser().getIdentifier(), request);
            }
            List<ShortcutInfo> shortcutInfos = request.forPackage(appTarget.getPackageName(),
                    appTarget.getClassName()).query(ShortcutRequest.ALL);
            if (!shortcutInfos.isEmpty()) {
                key = ShortcutKey.fromInfo(shortcutInfos.get(0));
            } else {
                key = new ComponentKey(new ComponentName(appTarget.getPackageName(),
                        appTarget.getClassName()), appTarget.getUser());
                componentKeysToBeCached.add(key);
            }
            componentKeys.add(key);
            predictionLog.append(key.toString());
            predictionLog.append(",rank:");
            predictionLog.append(appTarget.getRank());
@@ -401,7 +412,7 @@ public class HotseatPredictionController implements DragController.DragListener,
        }
        updateDependencies();
        fillGapsWithPrediction();
        cachePredictionComponentKeysIfNecessary(componentKeys);
        cachePredictionComponentKeysIfNecessary(componentKeysToBeCached);
    }

    private void cachePredictionComponentKeysIfNecessary(ArrayList<ComponentKey> componentKeys) {
+4 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import androidx.core.graphics.ColorUtils;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.graphics.IconPalette;
@@ -90,8 +91,9 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements
    public void onDraw(Canvas canvas) {
        int count = canvas.save();
        if (!mIsPinned) {
            boolean isBadged = getTag() instanceof WorkspaceItemInfo
                    && !Process.myUserHandle().equals(((ItemInfo) getTag()).user);
            ItemInfo info = (ItemInfo) getTag();
            boolean isBadged = info != null && (!Process.myUserHandle().equals(info.user)
                    || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT);
            drawEffect(canvas, isBadged);
            canvas.translate(getWidth() * RING_EFFECT_RATIO, getHeight() * RING_EFFECT_RATIO);
            canvas.scale(1 - 2 * RING_EFFECT_RATIO, 1 - 2 * RING_EFFECT_RATIO);