Merge "Revert "Allow shortcut predictions in hybrid hotseat"" into ub-launcher3-rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-21 07:24:25 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 20 deletions
@@ -30,10 +30,8 @@ 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;
@@ -67,7 +65,6 @@ 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;
@@ -382,24 +379,16 @@ public class HotseatPredictionController implements DragController.DragListener,
mRestoreHelper.restoreBackup();
}
StringBuilder predictionLog = new StringBuilder("predictedApps: [\n");
ArrayList<ComponentKey> componentKeysToBeCached = new ArrayList<>();
SparseArray<ShortcutRequest> requests = new SparseArray<>();
ArrayList<ComponentKey> componentKeys = new ArrayList<>();
for (AppTarget appTarget : appTargets) {
ComponentKey key;
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));
if (appTarget.getShortcutInfo() != null) {
key = ShortcutKey.fromInfo(appTarget.getShortcutInfo());
} 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());
@@ -412,7 +401,7 @@ public class HotseatPredictionController implements DragController.DragListener,
}
updateDependencies();
fillGapsWithPrediction();
cachePredictionComponentKeysIfNecessary(componentKeysToBeCached);
cachePredictionComponentKeysIfNecessary(componentKeys);
}
private void cachePredictionComponentKeysIfNecessary(ArrayList<ComponentKey> componentKeys) {
@@ -36,7 +36,6 @@ 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;
@@ -91,9 +90,8 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements
public void onDraw(Canvas canvas) {
int count = canvas.save();
if (!mIsPinned) {
ItemInfo info = (ItemInfo) getTag();
boolean isBadged = info != null && (!Process.myUserHandle().equals(info.user)
|| info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT);
boolean isBadged = getTag() instanceof WorkspaceItemInfo
&& !Process.myUserHandle().equals(((ItemInfo) getTag()).user);
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);