Merge "[Hotseat] Fix badging for shortcut predictions in hotseat" into sc-dev
This commit is contained in:
commit
7165a1d6de
2 files changed
+24
-3
No files matched your search
@@ -42,6 +42,7 @@ import android.app.prediction.AppTargetEvent;
|
||||
import android.app.prediction.AppTargetId;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -62,9 +63,11 @@ import com.android.launcher3.logger.LauncherAtom.WorkspaceContainer;
|
||||
import com.android.launcher3.logging.StatsLogManager.EventEnum;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.quickstep.logging.StatsLogCompatManager.StatsLogConsumer;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.ObjIntConsumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -174,6 +177,7 @@ public class AppEventProducer implements StatsLogConsumer {
|
||||
return null;
|
||||
}
|
||||
ComponentName cn = null;
|
||||
ShortcutInfo shortcutInfo = null;
|
||||
String id = null;
|
||||
|
||||
switch (info.getItemCase()) {
|
||||
@@ -188,6 +192,14 @@ public class AppEventProducer implements StatsLogConsumer {
|
||||
LauncherAtom.Shortcut si = info.getShortcut();
|
||||
if (!TextUtils.isEmpty(si.getShortcutId())
|
||||
&& (cn = parseNullable(si.getShortcutName())) != null) {
|
||||
Optional<ShortcutInfo> opt = new ShortcutRequest(mContext,
|
||||
userHandle).forPackage(cn.getPackageName(), si.getShortcutId()).query(
|
||||
ShortcutRequest.ALL).stream().findFirst();
|
||||
if (opt.isPresent()) {
|
||||
shortcutInfo = opt.get();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
id = "shortcut:" + si.getShortcutId();
|
||||
}
|
||||
break;
|
||||
@@ -210,6 +222,9 @@ public class AppEventProducer implements StatsLogConsumer {
|
||||
return createTempFolderTarget();
|
||||
}
|
||||
if (id != null && cn != null) {
|
||||
if (shortcutInfo != null) {
|
||||
return new AppTarget.Builder(new AppTargetId(id), shortcutInfo).build();
|
||||
}
|
||||
return new AppTarget.Builder(new AppTargetId(id), cn.getPackageName(), userHandle)
|
||||
.setClassName(cn.getClassName())
|
||||
.build();
|
||||
@@ -217,6 +232,7 @@ public class AppEventProducer implements StatsLogConsumer {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private AppTarget createTempFolderTarget() {
|
||||
return new AppTarget.Builder(new AppTargetId("folder:" + SystemClock.uptimeMillis()),
|
||||
mContext.getPackageName(), Process.myUserHandle())
|
||||
|
||||
@@ -34,11 +34,11 @@ 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.graphics.IconPalette;
|
||||
import com.android.launcher3.icons.IconNormalizer;
|
||||
import com.android.launcher3.icons.LauncherIcons;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.touch.ItemLongClickListener;
|
||||
@@ -85,8 +85,13 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
|
||||
public void onDraw(Canvas canvas) {
|
||||
int count = canvas.save();
|
||||
if (!mIsPinned) {
|
||||
boolean isBadged = getTag() instanceof WorkspaceItemInfo
|
||||
&& !Process.myUserHandle().equals(((ItemInfo) getTag()).user);
|
||||
boolean isBadged = false;
|
||||
if (getTag() instanceof WorkspaceItemInfo) {
|
||||
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
|
||||
isBadged = !Process.myUserHandle().equals(info.user)
|
||||
|| info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT
|
||||
|| 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);
|
||||
|
||||
Reference in new issue
Block a user