ShortcutInfo renamed to WorkspaceItemInfo

Will get rid of ShortcutInfoCompat in a follow up cl

Change-Id: I7d7d9c938635f59b216290ba28bea9d0e0721a7d
This commit is contained in:
Sunny Goyal 2019-03-27 16:03:06 -07:00
parent 1f457ae87f
commit 9589916418
53 changed files with 317 additions and 329 deletions

View File

@ -38,7 +38,7 @@ import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.InstantAppResolver;
@ -86,7 +86,7 @@ public class TaskSystemShortcut<T extends SystemShortcut> extends SystemShortcut
public View.OnClickListener getOnClickListener(BaseDraggingActivity activity, TaskView view) {
Task task = view.getTask();
ShortcutInfo dummyInfo = new ShortcutInfo();
WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo();
dummyInfo.intent = new Intent();
ComponentName component = task.getTopComponent();
dummyInfo.intent.setComponent(component);

View File

@ -1,6 +1,6 @@
# Model data used by CacheDataUpdatedTaskTest
classMap s com.android.launcher3.ShortcutInfo
classMap s com.android.launcher3.WorkspaceItemInfo
# Items for the BgDataModel

View File

@ -1,6 +1,6 @@
# Model data used by PackageInstallStateChangeTaskTest
classMap s com.android.launcher3.ShortcutInfo
classMap s com.android.launcher3.WorkspaceItemInfo
classMap w com.android.launcher3.LauncherAppWidgetInfo
# Items for the BgDataModel

View File

@ -7,19 +7,14 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.verify;
import android.content.ComponentName;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
import android.util.Pair;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherProvider;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.util.ContentWriter;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.IntArray;
@ -103,7 +98,7 @@ public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
@Test
public void testAddItem_existing_item_ignored() throws Exception {
ShortcutInfo info = new ShortcutInfo();
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.intent = new Intent().setComponent(mComponent1);
// Setup a screen with a hole
@ -115,10 +110,10 @@ public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
@Test
public void testAddItem_some_items_added() throws Exception {
ShortcutInfo info = new ShortcutInfo();
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.intent = new Intent().setComponent(mComponent1);
ShortcutInfo info2 = new ShortcutInfo();
WorkspaceItemInfo info2 = new WorkspaceItemInfo();
info2.intent = new Intent().setComponent(mComponent2);
// Setup a screen with a hole
@ -155,7 +150,7 @@ public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
continue;
}
ShortcutInfo info = new ShortcutInfo();
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.intent = new Intent().setComponent(mComponent1);
info.id = startId++;
info.screenId = screenId;

View File

@ -8,7 +8,7 @@ import static org.junit.Assert.assertNull;
import com.android.launcher3.AppInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import org.junit.Before;
import org.junit.Ignore;
@ -89,10 +89,10 @@ public class CacheDataUpdatedTaskTest extends BaseModelUpdateTaskTestCase {
for (ItemInfo info : bgDataModel.itemsIdMap) {
if (updates.contains(info.id)) {
assertEquals(NEW_LABEL_PREFIX + info.id, info.title);
assertNotNull(((ShortcutInfo) info).iconBitmap);
assertNotNull(((WorkspaceItemInfo) info).iconBitmap);
} else {
assertNotSame(NEW_LABEL_PREFIX + info.id, info.title);
assertNull(((ShortcutInfo) info).iconBitmap);
assertNull(((WorkspaceItemInfo) info).iconBitmap);
}
}
}

View File

@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
@ -58,9 +58,9 @@ public class PackageInstallStateChangedTaskTest extends BaseModelUpdateTaskTestC
private void verifyProgressUpdate(int progress, Integer... idsUpdated) {
HashSet<Integer> updates = new HashSet<>(Arrays.asList(idsUpdated));
for (ItemInfo info : bgDataModel.itemsIdMap) {
if (info instanceof ShortcutInfo) {
if (info instanceof WorkspaceItemInfo) {
assertEquals(updates.contains(info.id) ? progress: 0,
((ShortcutInfo) info).getInstallProgress());
((WorkspaceItemInfo) info).getInstallProgress());
} else {
assertEquals(updates.contains(info.id) ? progress: -1,
((LauncherAppWidgetInfo) info).installProgress);

View File

@ -81,8 +81,8 @@ public class AppInfo extends ItemInfoWithIcon {
return super.dumpProperties() + " componentName=" + componentName;
}
public ShortcutInfo makeShortcut() {
return new ShortcutInfo(this);
public WorkspaceItemInfo makeWorkspaceItem() {
return new WorkspaceItemInfo(this);
}
public ComponentKey toComponentKey() {

View File

@ -391,7 +391,7 @@ public class AutoInstallsLayout {
return -1;
}
mValues.put(Favorites.RESTORED, ShortcutInfo.FLAG_AUTOINSTALL_ICON);
mValues.put(Favorites.RESTORED, WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON);
final Intent intent = new Intent(Intent.ACTION_MAIN, null)
.addCategory(Intent.CATEGORY_LAUNCHER)
.setComponent(new ComponentName(packageName, className))

View File

@ -16,8 +16,6 @@
package com.android.launcher3;
import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_SEARCH;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Intent;
@ -169,10 +167,10 @@ public abstract class BaseDraggingActivity extends BaseActivity
intent.setSourceBounds(getViewBounds(v));
}
try {
boolean isShortcut = (item instanceof ShortcutInfo)
boolean isShortcut = (item instanceof WorkspaceItemInfo)
&& (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
|| item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
&& !((ShortcutInfo) item).isPromise();
&& !((WorkspaceItemInfo) item).isPromise();
if (isShortcut) {
// Shortcuts need some special checks due to legacy reasons.
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
@ -209,7 +207,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
.penaltyLog().build());
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
String id = ((ShortcutInfo) info).getDeepShortcutId();
String id = ((WorkspaceItemInfo) info).getDeepShortcutId();
String packageName = intent.getPackage();
DeepShortcutManager.getInstance(this).startShortcut(
packageName, id, intent.getSourceBounds(), optsBundle, info.user);

View File

@ -215,11 +215,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
mDotScaleAnim.start();
}
public void applyFromShortcutInfo(ShortcutInfo info) {
applyFromShortcutInfo(info, false);
public void applyFromWorkspaceItem(WorkspaceItemInfo info) {
applyFromWorkspaceItem(info, false);
}
public void applyFromShortcutInfo(ShortcutInfo info, boolean promiseStateChanged) {
public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) {
applyIconAndLabel(info);
setTag(info);
if (promiseStateChanged || (info.hasPromiseIconUi())) {
@ -232,7 +232,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
public void applyFromApplicationInfo(AppInfo info) {
applyIconAndLabel(info);
// We don't need to check the info since it's not a ShortcutInfo
// We don't need to check the info since it's not a WorkspaceItemInfo
super.setTag(info);
// Verify high res immediately
@ -247,7 +247,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
public void applyFromPackageItemInfo(PackageItemInfo info) {
applyIconAndLabel(info);
// We don't need to check the info since it's not a ShortcutInfo
// We don't need to check the info since it's not a WorkspaceItemInfo
super.setTag(info);
// Verify high res immediately
@ -491,11 +491,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
}
public void applyPromiseState(boolean promiseStateChanged) {
if (getTag() instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) getTag();
if (getTag() instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
final boolean isPromise = info.hasPromiseIconUi();
final int progressLevel = isPromise ?
((info.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
((info.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
info.getInstallProgress() : 0)) : 100;
PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
@ -619,8 +619,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
if (info instanceof AppInfo) {
applyFromApplicationInfo((AppInfo) info);
} else if (info instanceof ShortcutInfo) {
applyFromShortcutInfo((ShortcutInfo) info);
} else if (info instanceof WorkspaceItemInfo) {
applyFromWorkspaceItem((WorkspaceItemInfo) info);
mActivity.invalidateParent(info);
} else if (info instanceof PackageItemInfo) {
applyFromPackageItemInfo((PackageItemInfo) info);

View File

@ -16,8 +16,6 @@
package com.android.launcher3;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
@ -64,7 +62,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
*/
@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
if (info instanceof ShortcutInfo) {
if (info instanceof WorkspaceItemInfo) {
// Support the action unless the item is in a context menu.
return info.screenId >= 0;
}

View File

@ -50,7 +50,7 @@ public class FolderInfo extends ItemInfo {
/**
* The apps and shortcuts
*/
public ArrayList<ShortcutInfo> contents = new ArrayList<ShortcutInfo>();
public ArrayList<WorkspaceItemInfo> contents = new ArrayList<WorkspaceItemInfo>();
ArrayList<FolderListener> listeners = new ArrayList<FolderListener>();
@ -64,14 +64,14 @@ public class FolderInfo extends ItemInfo {
*
* @param item
*/
public void add(ShortcutInfo item, boolean animate) {
public void add(WorkspaceItemInfo item, boolean animate) {
add(item, contents.size(), animate);
}
/**
* Add an app or shortcut for a specified rank.
*/
public void add(ShortcutInfo item, int rank, boolean animate) {
public void add(WorkspaceItemInfo item, int rank, boolean animate) {
rank = Utilities.boundToRange(rank, 0, contents.size());
contents.add(rank, item);
for (int i = 0; i < listeners.size(); i++) {
@ -85,7 +85,7 @@ public class FolderInfo extends ItemInfo {
*
* @param item
*/
public void remove(ShortcutInfo item, boolean animate) {
public void remove(WorkspaceItemInfo item, boolean animate) {
contents.remove(item);
for (int i = 0; i < listeners.size(); i++) {
listeners.get(i).onRemove(item);
@ -129,8 +129,8 @@ public class FolderInfo extends ItemInfo {
}
public interface FolderListener {
public void onAdd(ShortcutInfo item, int rank);
public void onRemove(ShortcutInfo item);
public void onAdd(WorkspaceItemInfo item, int rank);
public void onRemove(WorkspaceItemInfo item);
public void onTitleChanged(CharSequence title);
public void onItemsChanged(boolean animate);
public void prepareAutoUpdate();

View File

@ -244,13 +244,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return convertToLauncherActivityIfPossible(info);
}
public static ShortcutInfo fromShortcutIntent(Context context, Intent data) {
public static WorkspaceItemInfo fromShortcutIntent(Context context, Intent data) {
PendingInstallShortcutInfo info = createPendingInfo(context, data);
return info == null ? null : (ShortcutInfo) info.getItemInfo().first;
return info == null ? null : (WorkspaceItemInfo) info.getItemInfo().first;
}
public static ShortcutInfo fromActivityInfo(LauncherActivityInfo info, Context context) {
return (ShortcutInfo) (new PendingInstallShortcutInfo(info, context).getItemInfo().first);
public static WorkspaceItemInfo fromActivityInfo(LauncherActivityInfo info, Context context) {
return (WorkspaceItemInfo) (new PendingInstallShortcutInfo(info, context).getItemInfo().first);
}
public static void queueShortcut(ShortcutInfoCompat info, Context context) {
@ -483,11 +483,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
// Set default values until proper values is loaded.
appInfo.title = "";
appInfo.applyFrom(app.getIconCache().getDefaultIcon(user));
final ShortcutInfo si = appInfo.makeShortcut();
final WorkspaceItemInfo si = appInfo.makeWorkspaceItem();
if (Looper.myLooper() == LauncherModel.getWorkerLooper()) {
app.getIconCache().getTitleAndIcon(si, activityInfo, false /* useLowResIcon */);
} else {
app.getModel().updateAndBindShortcutInfo(() -> {
app.getModel().updateAndBindWorkspaceItem(() -> {
app.getIconCache().getTitleAndIcon(
si, activityInfo, false /* useLowResIcon */);
return si;
@ -495,7 +495,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
}
return Pair.create((ItemInfo) si, (Object) activityInfo);
} else if (shortcutInfo != null) {
ShortcutInfo si = new ShortcutInfo(shortcutInfo, mContext);
WorkspaceItemInfo si = new WorkspaceItemInfo(shortcutInfo, mContext);
LauncherIcons li = LauncherIcons.obtain(mContext);
si.applyFrom(li.createShortcutIcon(shortcutInfo));
li.recycle();
@ -513,7 +513,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
widgetInfo.spanY = Math.min(info.spanY, idp.numRows);
return Pair.create((ItemInfo) widgetInfo, (Object) providerInfo);
} else {
ShortcutInfo si = createShortcutInfo(data, LauncherAppState.getInstance(mContext));
WorkspaceItemInfo si = createWorkspaceItemInfo(data, LauncherAppState.getInstance(mContext));
return Pair.create((ItemInfo) si, null);
}
}
@ -625,18 +625,18 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return new PendingInstallShortcutInfo(info, original.mContext);
}
private static ShortcutInfo createShortcutInfo(Intent data, LauncherAppState app) {
private static WorkspaceItemInfo createWorkspaceItemInfo(Intent data, LauncherAppState app) {
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
if (intent == null) {
// If the intent is null, we can't construct a valid ShortcutInfo, so we return null
Log.e(TAG, "Can't construct ShorcutInfo with null intent");
// If the intent is null, return null as we can't construct a valid WorkspaceItemInfo
Log.e(TAG, "Can't construct WorkspaceItemInfo with null intent");
return null;
}
final ShortcutInfo info = new ShortcutInfo();
final WorkspaceItemInfo info = new WorkspaceItemInfo();
// Only support intents for current user for now. Intents sent from other
// users wouldn't get here without intent forwarding anyway.

View File

@ -57,7 +57,6 @@ import android.os.Handler;
import android.os.Parcelable;
import android.os.Process;
import android.os.StrictMode;
import android.os.UserHandle;
import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.Log;
@ -981,7 +980,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
*
* @param info The data structure describing the shortcut.
*/
View createShortcut(ShortcutInfo info) {
View createShortcut(WorkspaceItemInfo info) {
return createShortcut((ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentPage()), info);
}
@ -993,10 +992,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
*
* @return A View inflated from layoutResId.
*/
public View createShortcut(ViewGroup parent, ShortcutInfo info) {
public View createShortcut(ViewGroup parent, WorkspaceItemInfo info) {
BubbleTextView favorite = (BubbleTextView) LayoutInflater.from(parent.getContext())
.inflate(R.layout.app_icon, parent, false);
favorite.applyFromShortcutInfo(info);
favorite.applyFromWorkspaceItem(info);
favorite.setOnClickListener(ItemClickHandler.INSTANCE);
favorite.setOnFocusChangeListener(mFocusHandler);
return favorite;
@ -1017,9 +1016,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
int[] cellXY = mTmpAddItemCellCoordinates;
CellLayout layout = getCellLayout(container, screenId);
ShortcutInfo info = null;
WorkspaceItemInfo info = null;
if (Utilities.ATLEAST_OREO) {
info = LauncherAppsCompatVO.createShortcutInfoFromPinItemRequest(
info = LauncherAppsCompatVO.createWorkspaceItemFromPinItemRequest(
this, LauncherAppsCompatVO.getPinItemRequest(data), 0);
}
@ -1541,11 +1540,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
* @param deleteFromDb whether or not to delete this item from the db.
*/
public boolean removeItem(View v, final ItemInfo itemInfo, boolean deleteFromDb) {
if (itemInfo instanceof ShortcutInfo) {
if (itemInfo instanceof WorkspaceItemInfo) {
// Remove the shortcut from the folder before removing it from launcher
View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
if (folderIcon instanceof FolderIcon) {
((FolderInfo) folderIcon.getTag()).remove((ShortcutInfo) itemInfo, true);
((FolderInfo) folderIcon.getTag()).remove((WorkspaceItemInfo) itemInfo, true);
} else {
mWorkspace.removeWorkspaceItem(v);
}
@ -1870,7 +1869,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: {
ShortcutInfo info = (ShortcutInfo) item;
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
view = createShortcut(info);
break;
}
@ -2228,7 +2227,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
* @param updated list of shortcuts which have changed.
*/
@Override
public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated, final UserHandle user) {
public void bindWorkspaceItemsChanged(ArrayList<WorkspaceItemInfo> updated) {
if (!updated.isEmpty()) {
mWorkspace.updateShortcuts(updated);
}

View File

@ -149,7 +149,7 @@ public class LauncherModel extends BroadcastReceiver
public void bindAppsAdded(IntArray newScreens,
ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated);
public void bindPromiseAppProgressUpdated(PromiseAppInfo app);
public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated, UserHandle user);
public void bindWorkspaceItemsChanged(ArrayList<WorkspaceItemInfo> updated);
public void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher);
@ -530,8 +530,8 @@ public class LauncherModel extends BroadcastReceiver
}
public void updateAndBindShortcutInfo(final ShortcutInfo si, final ShortcutInfoCompat info) {
updateAndBindShortcutInfo(() -> {
public void updateAndBindWorkspaceItem(WorkspaceItemInfo si, ShortcutInfoCompat info) {
updateAndBindWorkspaceItem(() -> {
si.updateFromDeepShortcutInfo(info, mApp.getContext());
LauncherIcons li = LauncherIcons.obtain(mApp.getContext());
si.applyFrom(li.createShortcutIcon(info));
@ -543,15 +543,15 @@ public class LauncherModel extends BroadcastReceiver
/**
* Utility method to update a shortcut on the background thread.
*/
public void updateAndBindShortcutInfo(final Supplier<ShortcutInfo> shortcutProvider) {
public void updateAndBindWorkspaceItem(final Supplier<WorkspaceItemInfo> itemProvider) {
enqueueModelUpdateTask(new BaseModelUpdateTask() {
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
ShortcutInfo info = shortcutProvider.get();
WorkspaceItemInfo info = itemProvider.get();
getModelWriter().updateItemInDatabase(info);
ArrayList<ShortcutInfo> update = new ArrayList<>();
ArrayList<WorkspaceItemInfo> update = new ArrayList<>();
update.add(info);
bindUpdatedShortcuts(update, info.user);
bindUpdatedWorkspaceItems(update);
}
});
}

View File

@ -38,13 +38,13 @@ public class PromiseAppInfo extends AppInfo {
}
@Override
public ShortcutInfo makeShortcut() {
ShortcutInfo shortcut = new ShortcutInfo(this);
public WorkspaceItemInfo makeWorkspaceItem() {
WorkspaceItemInfo shortcut = new WorkspaceItemInfo(this);
shortcut.setInstallProgress(level);
// We need to update the component name when the apk is installed
shortcut.status |= ShortcutInfo.FLAG_AUTOINSTALL_ICON;
shortcut.status |= WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON;
// Since the user is manually placing it on homescreen, it should not be auto-removed later
shortcut.status |= ShortcutInfo.FLAG_RESTORE_STARTED;
shortcut.status |= WorkspaceItemInfo.FLAG_RESTORE_STARTED;
return shortcut;
}

View File

@ -1609,7 +1609,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
return false;
}
boolean aboveShortcut = (dropOverView.getTag() instanceof ShortcutInfo);
boolean aboveShortcut = (dropOverView.getTag() instanceof WorkspaceItemInfo);
boolean willBecomeShortcut =
(info.itemType == ITEM_TYPE_APPLICATION ||
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT ||
@ -1658,12 +1658,12 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mCreateUserFolderOnDrop = false;
final int screenId = getIdForScreen(target);
boolean aboveShortcut = (v.getTag() instanceof ShortcutInfo);
boolean willBecomeShortcut = (newView.getTag() instanceof ShortcutInfo);
boolean aboveShortcut = (v.getTag() instanceof WorkspaceItemInfo);
boolean willBecomeShortcut = (newView.getTag() instanceof WorkspaceItemInfo);
if (aboveShortcut && willBecomeShortcut) {
ShortcutInfo sourceInfo = (ShortcutInfo) newView.getTag();
ShortcutInfo destInfo = (ShortcutInfo) v.getTag();
WorkspaceItemInfo sourceInfo = (WorkspaceItemInfo) newView.getTag();
WorkspaceItemInfo destInfo = (WorkspaceItemInfo) v.getTag();
// if the drag started here, we need to remove it from the workspace
if (!external) {
getParentCellLayoutForView(mDragInfo.cell).removeView(mDragInfo.cell);
@ -2418,8 +2418,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
*/
private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) {
if (d.dragInfo instanceof PendingAddShortcutInfo) {
ShortcutInfo si = ((PendingAddShortcutInfo) d.dragInfo)
.activityInfo.createShortcutInfo();
WorkspaceItemInfo si = ((PendingAddShortcutInfo) d.dragInfo)
.activityInfo.createWorkspaceItemInfo();
if (si != null) {
d.dragInfo = si;
}
@ -2524,10 +2524,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
if (info.container == NO_ID && info instanceof AppInfo) {
// Came from all apps -- make a copy
info = ((AppInfo) info).makeShortcut();
info = ((AppInfo) info).makeWorkspaceItem();
d.dragInfo = info;
}
view = mLauncher.createShortcut(cellLayout, (ShortcutInfo) info);
view = mLauncher.createShortcut(cellLayout, (WorkspaceItemInfo) info);
break;
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher, cellLayout,
@ -2916,7 +2916,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
final Workspace.ItemOperator packageAndUserInFolder = (info, view) -> {
if (info instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) info;
for (ShortcutInfo shortcutInfo : folderInfo.contents) {
for (WorkspaceItemInfo shortcutInfo : folderInfo.contents) {
if (packageAndUser.evaluate(shortcutInfo, view)) {
return true;
}
@ -3045,7 +3045,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
if (parent != null) {
FolderInfo folderInfo = (FolderInfo) parent.getTag();
folderInfo.prepareAutoUpdate();
folderInfo.remove((ShortcutInfo) itemToRemove, false);
folderInfo.remove((WorkspaceItemInfo) itemToRemove, false);
}
}
}
@ -3112,13 +3112,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
return false;
}
void updateShortcuts(ArrayList<ShortcutInfo> shortcuts) {
void updateShortcuts(ArrayList<WorkspaceItemInfo> shortcuts) {
int total = shortcuts.size();
final HashSet<ShortcutInfo> updates = new HashSet<>(total);
final HashSet<WorkspaceItemInfo> updates = new HashSet<>(total);
final IntSet folderIds = new IntSet();
for (int i = 0; i < total; i++) {
ShortcutInfo s = shortcuts.get(i);
WorkspaceItemInfo s = shortcuts.get(i);
updates.add(s);
folderIds.add(s.container);
}
@ -3126,14 +3126,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mapOverItems(MAP_RECURSE, new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View v) {
if (info instanceof ShortcutInfo && v instanceof BubbleTextView &&
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView &&
updates.contains(info)) {
ShortcutInfo si = (ShortcutInfo) info;
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
BubbleTextView shortcut = (BubbleTextView) v;
Drawable oldIcon = shortcut.getIcon();
boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable)
&& ((PreloadIconDrawable) oldIcon).hasNotCompleted();
shortcut.applyFromShortcutInfo(si, si.isPromise() != oldPromiseState);
shortcut.applyFromWorkspaceItem(si, si.isPromise() != oldPromiseState);
}
// process all the shortcuts
return false;
@ -3159,7 +3159,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mapOverItems(MAP_RECURSE, new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View v) {
if (info instanceof ShortcutInfo && v instanceof BubbleTextView) {
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView) {
if (!packageUserKey.updateFromItemInfo(info)
|| updatedDots.test(packageUserKey)) {
((BubbleTextView) v).applyDotState(info, true /* animate */);
@ -3178,7 +3178,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
if (info instanceof FolderInfo && folderIds.contains(info.id)
&& v instanceof FolderIcon) {
FolderDotInfo folderDotInfo = new FolderDotInfo();
for (ShortcutInfo si : ((FolderInfo) info).contents) {
for (WorkspaceItemInfo si : ((FolderInfo) info).contents) {
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
}
((FolderIcon) v).setDotInfo(folderDotInfo);
@ -3201,7 +3201,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mapOverItems(MAP_RECURSE, new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View v) {
if (info instanceof ShortcutInfo && v instanceof BubbleTextView
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView
&& updates.contains(info)) {
((BubbleTextView) v).applyPromiseState(false /* promiseStateChanged */);
} else if (v instanceof PendingAppWidgetHostView

View File

@ -29,7 +29,7 @@ import com.android.launcher3.util.ContentWriter;
/**
* Represents a launchable icon on the workspaces and in folders.
*/
public class ShortcutInfo extends ItemInfoWithIcon {
public class WorkspaceItemInfo extends ItemInfoWithIcon {
public static final int DEFAULT = 0;
@ -86,11 +86,11 @@ public class ShortcutInfo extends ItemInfoWithIcon {
*/
private int mInstallProgress;
public ShortcutInfo() {
public WorkspaceItemInfo() {
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
}
public ShortcutInfo(ShortcutInfo info) {
public WorkspaceItemInfo(WorkspaceItemInfo info) {
super(info);
title = info.title;
intent = new Intent(info.intent);
@ -99,17 +99,17 @@ public class ShortcutInfo extends ItemInfoWithIcon {
mInstallProgress = info.mInstallProgress;
}
/** TODO: Remove this. It's only called by ApplicationInfo.makeShortcut. */
public ShortcutInfo(AppInfo info) {
/** TODO: Remove this. It's only called by ApplicationInfo.makeWorkspaceItem. */
public WorkspaceItemInfo(AppInfo info) {
super(info);
title = Utilities.trim(info.title);
intent = new Intent(info.intent);
}
/**
* Creates a {@link ShortcutInfo} from a {@link ShortcutInfoCompat}.
* Creates a {@link WorkspaceItemInfo} from a {@link ShortcutInfoCompat}.
*/
public ShortcutInfo(ShortcutInfoCompat shortcutInfo, Context context) {
public WorkspaceItemInfo(ShortcutInfoCompat shortcutInfo, Context context) {
user = shortcutInfo.getUserHandle();
itemType = Favorites.ITEM_TYPE_DEEP_SHORTCUT;
updateFromDeepShortcutInfo(shortcutInfo, context);
@ -176,7 +176,7 @@ public class ShortcutInfo extends ItemInfoWithIcon {
disabledMessage = shortcutInfo.getDisabledMessage();
}
/** Returns the ShortcutInfo id associated with the deep shortcut. */
/** Returns the WorkspaceItemInfo id associated with the deep shortcut. */
public String getDeepShortcutId() {
return itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT ?
getIntent().getStringExtra(ShortcutInfoCompat.EXTRA_SHORTCUT_ID) : null;

View File

@ -30,7 +30,7 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Workspace;
import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragOptions;
@ -145,7 +145,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
}
private boolean itemSupportsAccessibleDrag(ItemInfo item) {
if (item instanceof ShortcutInfo) {
if (item instanceof WorkspaceItemInfo) {
// Support the action unless the item is in a context menu.
return item.screenId >= 0;
}
@ -173,7 +173,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
@Override
public void run() {
if (item instanceof AppInfo) {
ShortcutInfo info = ((AppInfo) item).makeShortcut();
WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
mLauncher.getModelWriter().addItemToDatabase(info,
Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
@ -195,7 +195,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
} else if (action == MOVE_TO_WORKSPACE) {
Folder folder = Folder.getOpen(mLauncher);
folder.close(true);
ShortcutInfo info = (ShortcutInfo) item;
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
folder.getInfo().remove(info, false);
final int[] coordinates = new int[2];

View File

@ -27,7 +27,7 @@ import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.notification.NotificationMainView;
import com.android.launcher3.shortcuts.DeepShortcutView;
@ -64,7 +64,7 @@ public class ShortcutMenuAccessibilityDelegate extends LauncherAccessibilityDele
if (!(host.getParent() instanceof DeepShortcutView)) {
return false;
}
final ShortcutInfo info = ((DeepShortcutView) host.getParent()).getFinalInfo();
final WorkspaceItemInfo info = ((DeepShortcutView) host.getParent()).getFinalInfo();
final int[] coordinates = new int[2];
final int screenId = findSpaceOnWorkspace(item, coordinates);
Runnable onComplete = new Runnable() {

View File

@ -27,7 +27,7 @@ import com.android.launcher3.FolderInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DragType;
import com.android.launcher3.dragndrop.DragLayer;
@ -106,7 +106,7 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
// For icons, we can consider cells that have another icon or a folder.
ItemInfo info = (ItemInfo) child.getTag();
if (info instanceof AppInfo || info instanceof FolderInfo ||
info instanceof ShortcutInfo) {
info instanceof WorkspaceItemInfo) {
return id;
}
}
@ -125,7 +125,7 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
return mContext.getString(R.string.item_moved);
} else {
ItemInfo info = (ItemInfo) child.getTag();
if (info instanceof AppInfo || info instanceof ShortcutInfo) {
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
return mContext.getString(R.string.folder_created);
} else if (info instanceof FolderInfo) {
@ -170,14 +170,14 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
public static String getDescriptionForDropOver(View overChild, Context context) {
ItemInfo info = (ItemInfo) overChild.getTag();
if (info instanceof ShortcutInfo) {
if (info instanceof WorkspaceItemInfo) {
return context.getString(R.string.create_folder_with, info.title);
} else if (info instanceof FolderInfo) {
if (TextUtils.isEmpty(info.title)) {
// Find the first item in the folder.
FolderInfo folder = (FolderInfo) info;
ShortcutInfo firstItem = null;
for (ShortcutInfo shortcut : folder.contents) {
WorkspaceItemInfo firstItem = null;
for (WorkspaceItemInfo shortcut : folder.contents) {
if (firstItem == null || firstItem.rank > shortcut.rank) {
firstItem = shortcut;
}

View File

@ -31,7 +31,7 @@ import android.os.UserHandle;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.compat.ShortcutConfigActivityInfo.ShortcutConfigActivityInfoVO;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@ -103,12 +103,12 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
* thread to UI thread.
* If (d) happens before we add this shortcut to our model, we will end up unpinning
* the shortcut in the system.
* Here its the caller's responsibility to add the newly created ShortcutInfo immediately
* Here its the caller's responsibility to add the newly created WorkspaceItemInfo immediately
* to the model (which may involves a single post-to-worker-thread). That will guarantee
* that (d) happens after model is updated.
*/
@Nullable
public static ShortcutInfo createShortcutInfoFromPinItemRequest(
public static WorkspaceItemInfo createWorkspaceItemFromPinItemRequest(
Context context, final PinItemRequest request, final long acceptDelay) {
if (request != null &&
request.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT &&
@ -136,13 +136,13 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
}
ShortcutInfoCompat compat = new ShortcutInfoCompat(request.getShortcutInfo());
ShortcutInfo info = new ShortcutInfo(compat, context);
WorkspaceItemInfo info = new WorkspaceItemInfo(compat, context);
// Apply the unbadged icon and fetch the actual icon asynchronously.
LauncherIcons li = LauncherIcons.obtain(context);
info.applyFrom(li.createShortcutIcon(compat, false /* badged */));
li.recycle();
LauncherAppState.getInstance(context).getModel()
.updateAndBindShortcutInfo(info, compat);
.updateAndBindWorkspaceItem(info, compat);
return info;
} else {
return null;

View File

@ -32,11 +32,11 @@ import android.os.UserHandle;
import android.util.Log;
import android.widget.Toast;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.ComponentWithLabel;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
/**
* Wrapper class for representing a shortcut configure activity.
@ -70,10 +70,10 @@ public abstract class ShortcutConfigActivityInfo implements ComponentWithLabel {
public abstract Drawable getFullResIcon(IconCache cache);
/**
* Return a shortcut info, if it can be created directly on drop, without requiring any
* Return a WorkspaceItemInfo, if it can be created directly on drop, without requiring any
* {@link #startConfigActivity(Activity, int)}.
*/
public ShortcutInfo createShortcutInfo() {
public WorkspaceItemInfo createWorkspaceItemInfo() {
return null;
}

View File

@ -39,7 +39,7 @@ import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Thunk;
@ -288,7 +288,7 @@ public class DragController implements DragDriver.EventListener, TouchController
// Cancel the current drag if we are removing an app that we are dragging
if (mDragObject != null) {
ItemInfo dragInfo = mDragObject.dragInfo;
if (dragInfo instanceof ShortcutInfo) {
if (dragInfo instanceof WorkspaceItemInfo) {
ComponentName cn = dragInfo.getTargetComponent();
if (cn != null && matcher.matches(dragInfo, cn)) {
cancelDrag();

View File

@ -29,6 +29,7 @@ import android.os.Build;
import android.os.Process;
import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherAppState;
@ -81,13 +82,13 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
}
@Override
public com.android.launcher3.ShortcutInfo createShortcutInfo() {
public WorkspaceItemInfo createWorkspaceItemInfo() {
// Total duration for the drop animation to complete.
long duration = mContext.getResources().getInteger(R.integer.config_dropAnimMaxDuration) +
LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY +
LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
// Delay the actual accept() call until the drop animation is complete.
return LauncherAppsCompatVO.createShortcutInfoFromPinItemRequest(
return LauncherAppsCompatVO.createWorkspaceItemFromPinItemRequest(
mContext, mRequest, duration);
}

View File

@ -61,7 +61,7 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.OnAlarmListener;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Workspace.ItemOperator;
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
import com.android.launcher3.config.FeatureFlags;
@ -236,8 +236,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
public boolean startDrag(View v, DragOptions options) {
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
ShortcutInfo item = (ShortcutInfo) tag;
if (tag instanceof WorkspaceItemInfo) {
WorkspaceItemInfo item = (WorkspaceItemInfo) tag;
mEmptyCellRank = item.rank;
mCurrentDragView = v;
@ -269,13 +269,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
mContent.removeItem(mCurrentDragView);
if (dragObject.dragInfo instanceof ShortcutInfo) {
if (dragObject.dragInfo instanceof WorkspaceItemInfo) {
mItemsInvalidated = true;
// We do not want to get events for the item being removed, as they will get handled
// when the drop completes
try (SuppressInfoChanges s = new SuppressInfoChanges()) {
mInfo.remove((ShortcutInfo) dragObject.dragInfo, true);
mInfo.remove((WorkspaceItemInfo) dragObject.dragInfo, true);
}
}
mDragInProgress = true;
@ -379,7 +379,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
void bind(FolderInfo info) {
mInfo = info;
ArrayList<ShortcutInfo> children = info.contents;
ArrayList<WorkspaceItemInfo> children = info.contents;
Collections.sort(children, ITEM_POS_COMPARATOR);
mContent.bindItems(children);
@ -800,7 +800,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
} else {
// The drag failed, we need to return the item to the folder
ShortcutInfo info = (ShortcutInfo) d.dragInfo;
WorkspaceItemInfo info = (WorkspaceItemInfo) d.dragInfo;
View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info)
? mCurrentDragView : mContent.createNewView(info);
ArrayList<View> views = getItemsInReadingOrder();
@ -1023,7 +1023,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
// folder
CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container,
mInfo.screenId);
ShortcutInfo finalItem = mInfo.contents.remove(0);
WorkspaceItemInfo finalItem = mInfo.contents.remove(0);
newIcon = mLauncher.createShortcut(cellLayout, finalItem);
mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem,
mInfo.container, mInfo.screenId, mInfo.cellX, mInfo.cellY);
@ -1111,9 +1111,9 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
PendingAddShortcutInfo pasi = d.dragInfo instanceof PendingAddShortcutInfo
? (PendingAddShortcutInfo) d.dragInfo : null;
ShortcutInfo pasiSi = pasi != null ? pasi.activityInfo.createShortcutInfo() : null;
WorkspaceItemInfo pasiSi = pasi != null ? pasi.activityInfo.createWorkspaceItemInfo() : null;
if (pasi != null && pasiSi == null) {
// There is no ShortcutInfo, so we have to go through a configuration activity.
// There is no WorkspaceItemInfo, so we have to go through a configuration activity.
pasi.container = mInfo.id;
pasi.rank = mEmptyCellRank;
@ -1122,15 +1122,15 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
d.deferDragViewCleanupPostAnimation = false;
mRearrangeOnClose = true;
} else {
final ShortcutInfo si;
final WorkspaceItemInfo si;
if (pasiSi != null) {
si = pasiSi;
} else if (d.dragInfo instanceof AppInfo) {
// Came from all apps -- make a copy.
si = ((AppInfo) d.dragInfo).makeShortcut();
si = ((AppInfo) d.dragInfo).makeWorkspaceItem();
} else {
// ShortcutInfo
si = (ShortcutInfo) d.dragInfo;
// WorkspaceItemInfo
si = (WorkspaceItemInfo) d.dragInfo;
}
View currentDragView;
@ -1138,7 +1138,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
currentDragView = mContent.createAndAddViewForRank(si, mEmptyCellRank);
// Actually move the item in the database if it was an external drag. Call this
// before creating the view, so that ShortcutInfo is updated appropriately.
// before creating the view, so that WorkspaceItemInfo is updated appropriately.
mLauncher.getModelWriter().addOrMoveItemInDatabase(
si, mInfo.id, 0, si.cellX, si.cellY);
@ -1194,17 +1194,17 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
// This is used so the item doesn't immediately appear in the folder when added. In one case
// we need to create the illusion that the item isn't added back to the folder yet, to
// to correspond to the animation of the icon back into the folder. This is
public void hideItem(ShortcutInfo info) {
public void hideItem(WorkspaceItemInfo info) {
View v = getViewForInfo(info);
v.setVisibility(INVISIBLE);
}
public void showItem(ShortcutInfo info) {
public void showItem(WorkspaceItemInfo info) {
View v = getViewForInfo(info);
v.setVisibility(VISIBLE);
}
@Override
public void onAdd(ShortcutInfo item, int rank) {
public void onAdd(WorkspaceItemInfo item, int rank) {
View view = mContent.createAndAddViewForRank(item, rank);
mLauncher.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX,
item.cellY);
@ -1215,7 +1215,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
mItemsInvalidated = true;
}
public void onRemove(ShortcutInfo item) {
public void onRemove(WorkspaceItemInfo item) {
mItemsInvalidated = true;
View v = getViewForInfo(item);
mContent.removeItem(v);
@ -1233,7 +1233,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
}
private View getViewForInfo(final ShortcutInfo item) {
private View getViewForInfo(final WorkspaceItemInfo item) {
return mContent.iterateOverItems(new ItemOperator() {
@Override

View File

@ -50,7 +50,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.OnAlarmListener;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.SimpleOnStylusPressListener;
import com.android.launcher3.StylusEventHelper;
import com.android.launcher3.Utilities;
@ -226,15 +226,15 @@ public class FolderIcon extends FrameLayout implements FolderListener {
return !mFolder.isDestroyed() && willAcceptItem(dragInfo);
}
public void addItem(ShortcutInfo item) {
public void addItem(WorkspaceItemInfo item) {
addItem(item, true);
}
public void addItem(ShortcutInfo item, boolean animate) {
public void addItem(WorkspaceItemInfo item, boolean animate) {
mInfo.add(item, animate);
}
public void removeItem(ShortcutInfo item, boolean animate) {
public void removeItem(WorkspaceItemInfo item, boolean animate) {
mInfo.remove(item, animate);
}
@ -247,7 +247,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
mOpenAlarm.setOnAlarmListener(mOnOpenListener);
if (SPRING_LOADING_ENABLED &&
((dragInfo instanceof AppInfo)
|| (dragInfo instanceof ShortcutInfo)
|| (dragInfo instanceof WorkspaceItemInfo)
|| (dragInfo instanceof PendingAddShortcutInfo))) {
mOpenAlarm.setAlarm(ON_OPEN_DELAY);
}
@ -264,8 +264,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
return mPreviewItemManager.prepareCreateAnimation(destView);
}
public void performCreateAnimation(final ShortcutInfo destInfo, final View destView,
final ShortcutInfo srcInfo, final DragView srcView, Rect dstRect,
public void performCreateAnimation(final WorkspaceItemInfo destInfo, final View destView,
final WorkspaceItemInfo srcInfo, final DragView srcView, Rect dstRect,
float scaleRelativeToDragLayer) {
prepareCreateAnimation(destView);
addItem(destInfo);
@ -290,7 +290,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
mOpenAlarm.cancelAlarm();
}
private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect,
private void onDrop(final WorkspaceItemInfo item, DragView animateView, Rect finalRect,
float scaleRelativeToDragLayer, int index,
boolean itemReturnedOnFailedDrop) {
item.cellX = -1;
@ -382,15 +382,15 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) {
ShortcutInfo item;
WorkspaceItemInfo item;
if (d.dragInfo instanceof AppInfo) {
// Came from all apps -- make a copy
item = ((AppInfo) d.dragInfo).makeShortcut();
item = ((AppInfo) d.dragInfo).makeWorkspaceItem();
} else if (d.dragSource instanceof BaseItemDragListener){
// Came from a different window -- make a copy
item = new ShortcutInfo((ShortcutInfo) d.dragInfo);
item = new WorkspaceItemInfo((WorkspaceItemInfo) d.dragInfo);
} else {
item = (ShortcutInfo) d.dragInfo;
item = (WorkspaceItemInfo) d.dragInfo;
}
mFolder.notifyDrop();
onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(),
@ -581,7 +581,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
@Override
public void onAdd(ShortcutInfo item, int rank) {
public void onAdd(WorkspaceItemInfo item, int rank) {
boolean wasDotted = mDotInfo.hasDot();
mDotInfo.addDotInfo(mLauncher.getDotInfoForItem(item));
boolean isDotted = mDotInfo.hasDot();
@ -591,7 +591,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
@Override
public void onRemove(ShortcutInfo item) {
public void onRemove(WorkspaceItemInfo item) {
boolean wasDotted = mDotInfo.hasDot();
mDotInfo.subtractDotInfo(mLauncher.getDotInfoForItem(item));
boolean isDotted = mDotInfo.hasDot();

View File

@ -38,7 +38,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace.ItemOperator;
import com.android.launcher3.anim.Interpolators;
@ -178,9 +178,9 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
/**
* Binds items to the layout.
*/
public void bindItems(ArrayList<ShortcutInfo> items) {
public void bindItems(ArrayList<WorkspaceItemInfo> items) {
ArrayList<View> icons = new ArrayList<>();
for (ShortcutInfo item : items) {
for (WorkspaceItemInfo item : items) {
icons.add(createNewView(item));
}
arrangeChildren(icons, icons.size(), false);
@ -203,7 +203,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
return rank;
}
public View createAndAddViewForRank(ShortcutInfo item, int rank) {
public View createAndAddViewForRank(WorkspaceItemInfo item, int rank) {
View icon = createNewView(item);
allocateSpaceForRank(rank);
addViewForRank(icon, item, rank);
@ -214,7 +214,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
* Adds the {@param view} to the layout based on {@param rank} and updated the position
* related attributes. It assumes that {@param item} is already attached to the view.
*/
public void addViewForRank(View view, ShortcutInfo item, int rank) {
public void addViewForRank(View view, WorkspaceItemInfo item, int rank) {
int pagePos = rank % mMaxItemsPerPage;
int pageNo = rank / mMaxItemsPerPage;
@ -229,10 +229,10 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
}
@SuppressLint("InflateParams")
public View createNewView(ShortcutInfo item) {
public View createNewView(WorkspaceItemInfo item) {
final BubbleTextView textView = (BubbleTextView) mInflater.inflate(
R.layout.folder_application, null, false);
textView.applyFromShortcutInfo(item);
textView.applyFromWorkspaceItem(item);
textView.setHapticFeedbackEnabled(false);
textView.setOnClickListener(ItemClickHandler.INSTANCE);
textView.setOnLongClickListener(mFolder);
@ -631,7 +631,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
if (v != null) {
if (pageToAnimate != p) {
page.removeView(v);
addViewForRank(v, (ShortcutInfo) v.getTag(), moveStart);
addViewForRank(v, (WorkspaceItemInfo) v.getTag(), moveStart);
} else {
// Do a fake animation before removing it.
final int newRank = moveStart;
@ -644,7 +644,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
mPendingAnimations.remove(v);
v.setTranslationX(oldTranslateX);
((CellLayout) v.getParent().getParent()).removeView(v);
addViewForRank(v, (ShortcutInfo) v.getTag(), newRank);
addViewForRank(v, (WorkspaceItemInfo) v.getTag(), newRank);
}
};
v.animate()

View File

@ -31,7 +31,7 @@ import android.view.View;
import android.widget.TextView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import java.util.ArrayList;
@ -301,7 +301,7 @@ public class PreviewItemManager {
* @param dropped The item that was dropped onto the FolderIcon.
*/
public void onDrop(List<BubbleTextView> oldParams, List<BubbleTextView> newParams,
ShortcutInfo dropped) {
WorkspaceItemInfo dropped) {
int numItems = newParams.size();
final ArrayList<PreviewItemDrawingParams> params = mFirstPageParams;
buildParamsForPage(0, params, false);

View File

@ -21,7 +21,6 @@ import static android.view.View.VISIBLE;
import android.annotation.TargetApi;
import android.app.Fragment;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
@ -30,7 +29,6 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Handler;
@ -52,7 +50,7 @@ import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.WorkspaceLayoutManager;
import com.android.launcher3.allapps.SearchUiManager;
@ -85,7 +83,7 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
private final DeviceProfile mDp;
private final Rect mInsets;
private final ShortcutInfo mShortcutInfo;
private final WorkspaceItemInfo mWorkspaceItemInfo;
public LauncherPreviewRenderer(Context context, InvariantDeviceProfile idp) {
mUiHandler = new Handler(Looper.getMainLooper());
@ -106,10 +104,10 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
Process.myUserHandle(),
Build.VERSION.SDK_INT);
mShortcutInfo = new ShortcutInfo();
mShortcutInfo.applyFrom(iconInfo);
mShortcutInfo.intent = new Intent();
mShortcutInfo.contentDescription = mShortcutInfo.title =
mWorkspaceItemInfo = new WorkspaceItemInfo();
mWorkspaceItemInfo.applyFrom(iconInfo);
mWorkspaceItemInfo.intent = new Intent();
mWorkspaceItemInfo.contentDescription = mWorkspaceItemInfo.title =
context.getString(R.string.label_application);
}
@ -217,10 +215,10 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
return mWorkspace;
}
private void inflateAndAddIcon(ShortcutInfo info) {
private void inflateAndAddIcon(WorkspaceItemInfo info) {
BubbleTextView icon = (BubbleTextView) mHomeElementInflater.inflate(
R.layout.app_icon, mWorkspace, false);
icon.applyFromShortcutInfo(info);
icon.applyFromWorkspaceItem(info);
addInScreenFromBind(icon, info);
}
@ -245,7 +243,7 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
private void renderScreenShot(Canvas canvas) {
// Add hotseat icons
for (int i = 0; i < mIdp.numHotseatIcons; i++) {
ShortcutInfo info = new ShortcutInfo(mShortcutInfo);
WorkspaceItemInfo info = new WorkspaceItemInfo(mWorkspaceItemInfo);
info.container = Favorites.CONTAINER_HOTSEAT;
info.screenId = i;
inflateAndAddIcon(info);
@ -253,7 +251,7 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
// Add workspace icons
for (int i = 0; i < mIdp.numColumns; i++) {
ShortcutInfo info = new ShortcutInfo(mShortcutInfo);
WorkspaceItemInfo info = new WorkspaceItemInfo(mWorkspaceItemInfo);
info.container = Favorites.CONTAINER_DESKTOP;
info.screenId = 0;
info.cellX = i;

View File

@ -36,7 +36,7 @@ import com.android.launcher3.ItemInfoWithIcon;
import com.android.launcher3.LauncherFiles;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
@ -130,7 +130,7 @@ public class IconCache extends BaseIconCache {
IconLoadRequest request = new IconLoadRequest(mWorkerHandler, this::onIconRequestEnd) {
@Override
public void run() {
if (info instanceof AppInfo || info instanceof ShortcutInfo) {
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
getTitleAndIcon(info, false);
} else if (info instanceof PackageItemInfo) {
getTitleAndIconForApp((PackageItemInfo) info, false);
@ -199,7 +199,7 @@ public class IconCache extends BaseIconCache {
}
/**
* Fill in {@param shortcutInfo} with the icon and label for {@param info}
* Fill in {@param mWorkspaceItemInfo} with the icon and label for {@param info}
*/
private synchronized void getTitleAndIcon(
@NonNull ItemInfoWithIcon infoInOut,

View File

@ -30,7 +30,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.IntArray;
@ -77,7 +77,7 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
if (item instanceof AppInfo) {
item = ((AppInfo) item).makeShortcut();
item = ((AppInfo) item).makeWorkspaceItem();
}
}
if (item != null) {
@ -92,11 +92,11 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
int screenId = coords[0];
ItemInfo itemInfo;
if (item instanceof ShortcutInfo || item instanceof FolderInfo ||
if (item instanceof WorkspaceItemInfo || item instanceof FolderInfo ||
item instanceof LauncherAppWidgetInfo) {
itemInfo = item;
} else if (item instanceof AppInfo) {
itemInfo = ((AppInfo) item).makeShortcut();
itemInfo = ((AppInfo) item).makeWorkspaceItem();
} else {
throw new RuntimeException("Unexpected info type");
}
@ -106,7 +106,7 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId,
coords[1], coords[2]);
// Save the ShortcutInfo for binding in the workspace
// Save the WorkspaceItemInfo for binding in the workspace
addedItemsFinal.add(itemInfo);
}
}
@ -165,8 +165,8 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
boolean isLauncherAppTarget = Utilities.isLauncherAppTarget(intent);
synchronized (dataModel) {
for (ItemInfo item : dataModel.itemsIdMap) {
if (item instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) item;
if (item instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
if (item.getIntent() != null && info.user.equals(user)) {
Intent copyIntent = new Intent(item.getIntent());
copyIntent.setSourceBounds(intent.getSourceBounds());
@ -178,7 +178,7 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
// checking for existing promise icon with same package name
if (isLauncherAppTarget
&& info.isPromise()
&& info.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)
&& info.hasStatusFlag(WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON)
&& info.getTargetComponent() != null
&& compPkgName != null
&& compPkgName.equals(info.getTargetComponent().getPackageName())) {

View File

@ -15,7 +15,6 @@
*/
package com.android.launcher3.model;
import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.AllAppsList;
@ -24,7 +23,7 @@ import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherModel.ModelUpdateTask;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.widget.WidgetListRowEntry;
@ -94,13 +93,12 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
}
public void bindUpdatedShortcuts(
final ArrayList<ShortcutInfo> updatedShortcuts, final UserHandle user) {
public void bindUpdatedWorkspaceItems(final ArrayList<WorkspaceItemInfo> updatedShortcuts) {
if (!updatedShortcuts.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
callbacks.bindShortcutsChanged(updatedShortcuts, user);
callbacks.bindWorkspaceItemsChanged(updatedShortcuts);
}
});
}

View File

@ -26,7 +26,7 @@ import com.android.launcher3.InstallShortcutReceiver;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.DumpTargetWrapper;
@ -185,7 +185,7 @@ public class BgDataModel {
FolderInfo fInfo = folders.valueAt(i);
dtw = new DumpTargetWrapper(ContainerType.FOLDER, folders.size());
dtw.writeToDumpTarget(fInfo);
for(ShortcutInfo sInfo: fInfo.contents) {
for(WorkspaceItemInfo sInfo: fInfo.contents) {
DumpTargetWrapper child = new DumpTargetWrapper(sInfo);
child.writeToDumpTarget(sInfo);
dtw.add(child);
@ -335,7 +335,7 @@ public class BgDataModel {
Log.e(TAG, msg);
}
} else {
findOrMakeFolder(item.container).add((ShortcutInfo) item, false);
findOrMakeFolder(item.container).add((WorkspaceItemInfo) item, false);
}
}

View File

@ -20,13 +20,13 @@ import android.os.UserHandle;
import com.android.launcher3.AllAppsList;
import com.android.launcher3.AppInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import java.util.ArrayList;
import java.util.HashSet;
@ -55,11 +55,11 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask {
final ArrayList<AppInfo> updatedApps = new ArrayList<>();
ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
ArrayList<WorkspaceItemInfo> updatedShortcuts = new ArrayList<>();
synchronized (dataModel) {
for (ItemInfo info : dataModel.itemsIdMap) {
if (info instanceof ShortcutInfo && mUser.equals(info.user)) {
ShortcutInfo si = (ShortcutInfo) info;
if (info instanceof WorkspaceItemInfo && mUser.equals(info.user)) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
ComponentName cn = si.getTargetComponent();
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
&& isValidShortcut(si) && cn != null
@ -71,7 +71,7 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask {
}
apps.updateIconsAndLabels(mPackages, mUser, updatedApps);
}
bindUpdatedShortcuts(updatedShortcuts, mUser);
bindUpdatedWorkspaceItems(updatedShortcuts);
if (!updatedApps.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@ -83,7 +83,7 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask {
}
}
public boolean isValidShortcut(ShortcutInfo si) {
public boolean isValidShortcut(WorkspaceItemInfo si) {
switch (mOp) {
case OP_CACHE_UPDATE:
return true;

View File

@ -33,12 +33,12 @@ import android.util.Log;
import android.util.LongSparseArray;
import com.android.launcher3.AppInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.compat.LauncherAppsCompat;
@ -145,8 +145,8 @@ public class LoaderCursor extends CursorWrapper {
}
}
public ShortcutInfo loadSimpleShortcut() {
final ShortcutInfo info = new ShortcutInfo();
public WorkspaceItemInfo loadSimpleWorkspaceItem() {
final WorkspaceItemInfo info = new WorkspaceItemInfo();
// Non-app shortcuts are only supported for current user.
info.user = user;
info.itemType = itemType;
@ -164,7 +164,7 @@ public class LoaderCursor extends CursorWrapper {
/**
* Loads the icon from the cursor and updates the {@param info} if the icon is an app resource.
*/
protected boolean loadIcon(ShortcutInfo info) {
protected boolean loadIcon(WorkspaceItemInfo info) {
try (LauncherIcons li = LauncherIcons.obtain(mContext)) {
return loadIcon(info, li);
}
@ -173,7 +173,7 @@ public class LoaderCursor extends CursorWrapper {
/**
* Loads the icon from the cursor and updates the {@param info} if the icon is an app resource.
*/
protected boolean loadIcon(ShortcutInfo info, LauncherIcons li) {
protected boolean loadIcon(WorkspaceItemInfo info, LauncherIcons li) {
if (itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
String packageName = getString(iconPackageIndex);
String resourceName = getString(iconResourceIndex);
@ -209,11 +209,11 @@ public class LoaderCursor extends CursorWrapper {
}
/**
* Make an ShortcutInfo object for a restored application or shortcut item that points
* Make an WorkspaceItemInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
*/
public ShortcutInfo getRestoredItemInfo(Intent intent) {
final ShortcutInfo info = new ShortcutInfo();
public WorkspaceItemInfo getRestoredItemInfo(Intent intent) {
final WorkspaceItemInfo info = new WorkspaceItemInfo();
info.user = user;
info.intent = intent;
@ -222,12 +222,12 @@ public class LoaderCursor extends CursorWrapper {
mIconCache.getTitleAndIcon(info, false /* useLowResIcon */);
}
if (hasRestoreFlag(ShortcutInfo.FLAG_RESTORED_ICON)) {
if (hasRestoreFlag(WorkspaceItemInfo.FLAG_RESTORED_ICON)) {
String title = getTitle();
if (!TextUtils.isEmpty(title)) {
info.title = Utilities.trim(title);
}
} else if (hasRestoreFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) {
} else if (hasRestoreFlag(WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON)) {
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
@ -242,9 +242,9 @@ public class LoaderCursor extends CursorWrapper {
}
/**
* Make an ShortcutInfo object for a shortcut that is an application.
* Make an WorkspaceItemInfo object for a shortcut that is an application.
*/
public ShortcutInfo getAppShortcutInfo(
public WorkspaceItemInfo getAppShortcutInfo(
Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
Log.d(TAG, "Null user found in getShortcutInfo");
@ -267,7 +267,7 @@ public class LoaderCursor extends CursorWrapper {
return null;
}
final ShortcutInfo info = new ShortcutInfo();
final WorkspaceItemInfo info = new WorkspaceItemInfo();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
info.user = user;
info.intent = newIntent;

View File

@ -19,7 +19,6 @@ package com.android.launcher3.model;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
import static com.android.launcher3.model.LoaderResults.filterCurrentWorkspaceItems;
import android.appwidget.AppWidgetProviderInfo;
@ -49,7 +48,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
@ -335,7 +334,7 @@ public class LoaderTask implements Runnable {
unlockedUsers.put(serialNo, userUnlocked);
}
ShortcutInfo info;
WorkspaceItemInfo info;
LauncherAppWidgetInfo appWidgetInfo;
Intent intent;
String targetPkg;
@ -360,7 +359,7 @@ public class LoaderTask implements Runnable {
}
int disabledState = quietMode.get(c.serialNumber) ?
ShortcutInfo.FLAG_DISABLED_QUIET_USER : 0;
WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER : 0;
ComponentName cn = intent.getComponent();
targetPkg = cn == null ? intent.getPackage() : cn.getPackageName();
@ -420,11 +419,11 @@ public class LoaderTask implements Runnable {
// installed later.
FileLog.d(TAG, "package not yet restored: " + targetPkg);
if (c.hasRestoreFlag(ShortcutInfo.FLAG_RESTORE_STARTED)) {
if (c.hasRestoreFlag(WorkspaceItemInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installingPkgs.containsKey(targetPkg)) {
// App restore has started. Update the flag
c.restoreFlag |= ShortcutInfo.FLAG_RESTORE_STARTED;
c.restoreFlag |= WorkspaceItemInfo.FLAG_RESTORE_STARTED;
c.updater().put(LauncherSettings.Favorites.RESTORED,
c.restoreFlag).commit();
} else {
@ -433,7 +432,7 @@ public class LoaderTask implements Runnable {
}
} else if (pmHelper.isAppOnSdcard(targetPkg, c.user)) {
// Package is present but not available.
disabledState |= ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE;
disabledState |= WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE;
// Add the icon on the workspace anyway.
allowMissingTarget = true;
} else if (!isSdCardReady) {
@ -450,7 +449,7 @@ public class LoaderTask implements Runnable {
}
}
if ((c.restoreFlag & ShortcutInfo.FLAG_SUPPORTS_WEB_UI) != 0) {
if ((c.restoreFlag & WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) != 0) {
validTarget = false;
}
@ -481,8 +480,8 @@ public class LoaderTask implements Runnable {
c.markDeleted("Pinned shortcut not found");
continue;
}
info = new ShortcutInfo(pinnedShortcut, context);
final ShortcutInfo finalInfo = info;
info = new WorkspaceItemInfo(pinnedShortcut, context);
final WorkspaceItemInfo finalInfo = info;
LauncherIcons li = LauncherIcons.obtain(context);
// If the pinned deep shortcut is no longer published,
@ -499,11 +498,11 @@ public class LoaderTask implements Runnable {
intent = info.intent;
} else {
// Create a shortcut info in disabled mode for now.
info = c.loadSimpleShortcut();
info = c.loadSimpleWorkspaceItem();
info.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
}
} else { // item type == ITEM_TYPE_SHORTCUT
info = c.loadSimpleShortcut();
info = c.loadSimpleWorkspaceItem();
// Shortcuts are only available on the primary profile
if (!TextUtils.isEmpty(targetPkg)
@ -539,7 +538,7 @@ public class LoaderTask implements Runnable {
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
SessionInfo si = installingPkgs.get(targetPkg);
if (si == null) {
info.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
info.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
} else {
info.setInstallProgress((int) (si.getProgress() * 100));
}
@ -547,7 +546,7 @@ public class LoaderTask implements Runnable {
c.checkAndAddItem(info, mBgDataModel);
} else {
throw new RuntimeException("Unexpected null ShortcutInfo");
throw new RuntimeException("Unexpected null WorkspaceItemInfo");
}
break;
@ -755,7 +754,7 @@ public class LoaderTask implements Runnable {
// Ranks are the source of truth for folder items, so cellX and cellY can be ignored
// for now. Database will be updated once user manually modifies folder.
for (int rank = 0; rank < size; ++rank) {
ShortcutInfo info = folder.contents.get(rank);
WorkspaceItemInfo info = folder.contents.get(rank);
info.rank = rank;
if (info.usingLowResIcon()
@ -782,8 +781,8 @@ public class LoaderTask implements Runnable {
HashSet<String> packagesToIgnore = new HashSet<>();
synchronized (mBgDataModel) {
for (ItemInfo info : mBgDataModel.itemsIdMap) {
if (info instanceof ShortcutInfo) {
ShortcutInfo si = (ShortcutInfo) info;
if (info instanceof WorkspaceItemInfo) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
if (si.isPromise() && si.getTargetComponent() != null) {
packagesToIgnore.add(si.getTargetComponent().getPackageName());
}

View File

@ -36,7 +36,7 @@ import com.android.launcher3.LauncherProvider;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings.Settings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.ContentWriter;
@ -114,7 +114,7 @@ public class ModelWriter {
if (modelItem != null && item != modelItem) {
// check all the data is consistent
if (!Utilities.IS_DEBUG_DEVICE && !FeatureFlags.IS_DOGFOOD_BUILD &&
modelItem instanceof ShortcutInfo && item instanceof ShortcutInfo) {
modelItem instanceof WorkspaceItemInfo && item instanceof WorkspaceItemInfo) {
if (modelItem.title.toString().equals(item.title.toString()) &&
modelItem.getIntent().filterEquals(item.getIntent()) &&
modelItem.id == item.id &&

View File

@ -28,7 +28,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.PromiseAppInfo;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
import com.android.launcher3.util.InstantAppResolver;
@ -106,15 +106,15 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask {
synchronized (dataModel) {
final HashSet<ItemInfo> updates = new HashSet<>();
for (ItemInfo info : dataModel.itemsIdMap) {
if (info instanceof ShortcutInfo) {
ShortcutInfo si = (ShortcutInfo) info;
if (info instanceof WorkspaceItemInfo) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
ComponentName cn = si.getTargetComponent();
if (si.hasPromiseIconUi() && (cn != null)
&& mInstallInfo.packageName.equals(cn.getPackageName())) {
si.setInstallProgress(mInstallInfo.progress);
if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED) {
// Mark this info as broken.
si.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
si.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
}
updates.add(si);
}

View File

@ -24,6 +24,7 @@ import android.util.Log;
import com.android.launcher3.AllAppsList;
import com.android.launcher3.AppInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.InstallShortcutReceiver;
import com.android.launcher3.ItemInfo;
@ -33,7 +34,6 @@ import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.SessionCommitReceiver;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
@ -108,7 +108,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
SessionCommitReceiver.queueAppIconAddition(context, packages[i], mUser);
}
}
flagOp = FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
break;
}
case OP_UPDATE:
@ -119,7 +119,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
app.getWidgetCache().removePackage(packages[i], mUser);
}
// Since package was just updated, the target must be available now.
flagOp = FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
break;
case OP_REMOVE: {
for (int i = 0; i < N; i++) {
@ -133,20 +133,20 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
appsList.removePackage(packages[i], mUser);
app.getWidgetCache().removePackage(packages[i], mUser);
}
flagOp = FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
flagOp = FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
break;
case OP_SUSPEND:
case OP_UNSUSPEND:
flagOp = mOp == OP_SUSPEND ?
FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_SUSPENDED) :
FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_SUSPENDED);
FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED) :
FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED);
if (DEBUG) Log.d(TAG, "mAllAppsList.(un)suspend " + N);
appsList.updateDisabledFlags(matcher, flagOp);
break;
case OP_USER_AVAILABILITY_CHANGE:
flagOp = UserManagerCompat.getInstance(context).isQuietModeEnabled(mUser)
? FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_QUIET_USER)
: FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_QUIET_USER);
? FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER)
: FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER);
// We want to update all packages for this user.
matcher = ItemInfoMatcher.ofUser(mUser);
appsList.updateDisabledFlags(matcher, flagOp);
@ -175,15 +175,15 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
// Update shortcut infos
if (mOp == OP_ADD || flagOp != FlagOp.NO_OP) {
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
final ArrayList<WorkspaceItemInfo> updatedWorkspaceItems = new ArrayList<>();
final ArrayList<LauncherAppWidgetInfo> widgets = new ArrayList<>();
// For system apps, package manager send OP_UPDATE when an app is enabled.
final boolean isNewApkAvailable = mOp == OP_ADD || mOp == OP_UPDATE;
synchronized (dataModel) {
for (ItemInfo info : dataModel.itemsIdMap) {
if (info instanceof ShortcutInfo && mUser.equals(info.user)) {
ShortcutInfo si = (ShortcutInfo) info;
if (info instanceof WorkspaceItemInfo && mUser.equals(info.user)) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
boolean infoUpdated = false;
boolean shortcutUpdated = false;
@ -203,7 +203,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
if (cn != null && matcher.matches(si, cn)) {
String packageName = cn.getPackageName();
if (si.hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)) {
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI)) {
removedShortcuts.put(si.id, false);
if (mOp == OP_REMOVE) {
continue;
@ -227,9 +227,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
isTargetValid = LauncherAppsCompat.getInstance(context)
.isActivityEnabledForProfile(cn, mUser);
}
if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON)
&& !isTargetValid) {
if (updateShortcutIntent(context, si, packageName)) {
if (updateWorkspaceItemIntent(context, si, packageName)) {
infoUpdated = true;
} else if (si.hasPromiseIconUi()) {
removedShortcuts.put(si.id, true);
@ -241,11 +241,11 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
+ si.intent);
continue;
} else {
si.status = ShortcutInfo.DEFAULT;
si.status = WorkspaceItemInfo.DEFAULT;
infoUpdated = true;
}
} else if (isNewApkAvailable && removedComponents.contains(cn)) {
if (updateShortcutIntent(context, si, packageName)) {
if (updateWorkspaceItemIntent(context, si, packageName)) {
infoUpdated = true;
}
}
@ -264,7 +264,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
}
if (infoUpdated || shortcutUpdated) {
updatedShortcuts.add(si);
updatedWorkspaceItems.add(si);
}
if (infoUpdated) {
getModelWriter().updateItemInDatabase(si);
@ -290,7 +290,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
}
}
bindUpdatedShortcuts(updatedShortcuts, mUser);
bindUpdatedWorkspaceItems(updatedWorkspaceItems);
if (!removedShortcuts.isEmpty()) {
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofItemIds(removedShortcuts, false));
}
@ -356,12 +356,13 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
* Updates {@param si}'s intent to point to a new ComponentName.
* @return Whether the shortcut intent was changed.
*/
private boolean updateShortcutIntent(Context context, ShortcutInfo si, String packageName) {
private boolean updateWorkspaceItemIntent(Context context,
WorkspaceItemInfo si, String packageName) {
// Try to find the best match activity.
Intent intent = new PackageManagerHelper(context).getAppLaunchIntent(packageName, mUser);
if (intent != null) {
si.intent = intent;
si.status = ShortcutInfo.DEFAULT;
si.status = WorkspaceItemInfo.DEFAULT;
return true;
}
return false;

View File

@ -22,7 +22,7 @@ import com.android.launcher3.AllAppsList;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@ -58,14 +58,14 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
DeepShortcutManager deepShortcutManager = DeepShortcutManager.getInstance(context);
deepShortcutManager.onShortcutsChanged(mShortcuts);
// Find ShortcutInfo's that have changed on the workspace.
// Find WorkspaceItemInfo's that have changed on the workspace.
HashSet<ShortcutKey> removedKeys = new HashSet<>();
MultiHashMap<ShortcutKey, ShortcutInfo> keyToShortcutInfo = new MultiHashMap<>();
MultiHashMap<ShortcutKey, WorkspaceItemInfo> keyToShortcutInfo = new MultiHashMap<>();
HashSet<String> allIds = new HashSet<>();
for (ItemInfo itemInfo : dataModel.itemsIdMap) {
if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
ShortcutInfo si = (ShortcutInfo) itemInfo;
WorkspaceItemInfo si = (WorkspaceItemInfo) itemInfo;
if (si.getIntent().getPackage().equals(mPackageName) && si.user.equals(mUser)) {
keyToShortcutInfo.addToList(ShortcutKey.fromItemInfo(si), si);
allIds.add(si.getDeepShortcutId());
@ -73,14 +73,14 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
}
}
final ArrayList<ShortcutInfo> updatedShortcutInfos = new ArrayList<>();
final ArrayList<WorkspaceItemInfo> updatedWorkspaceItemInfos = new ArrayList<>();
if (!keyToShortcutInfo.isEmpty()) {
// Update the workspace to reflect the changes to updated shortcuts residing on it.
List<ShortcutInfoCompat> shortcuts = deepShortcutManager.queryForFullDetails(
mPackageName, new ArrayList<>(allIds), mUser);
for (ShortcutInfoCompat fullDetails : shortcuts) {
ShortcutKey key = ShortcutKey.fromInfo(fullDetails);
List<ShortcutInfo> shortcutInfos = keyToShortcutInfo.remove(key);
List<WorkspaceItemInfo> workspaceItemInfos = keyToShortcutInfo.remove(key);
if (!fullDetails.isPinned()) {
// The shortcut was previously pinned but is no longer, so remove it from
// the workspace and our pinned shortcut counts.
@ -90,15 +90,15 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
removedKeys.add(key);
continue;
}
for (final ShortcutInfo shortcutInfo : shortcutInfos) {
shortcutInfo.updateFromDeepShortcutInfo(fullDetails, context);
for (final WorkspaceItemInfo workspaceItemInfo : workspaceItemInfos) {
workspaceItemInfo.updateFromDeepShortcutInfo(fullDetails, context);
// If the shortcut is pinned but no longer has an icon in the system,
// keep the current icon instead of reverting to the default icon.
LauncherIcons li = LauncherIcons.obtain(context);
shortcutInfo.applyFrom(li.createShortcutIcon(fullDetails, true,
() -> shortcutInfo));
workspaceItemInfo.applyFrom(li.createShortcutIcon(fullDetails, true,
() -> workspaceItemInfo));
li.recycle();
updatedShortcutInfos.add(shortcutInfo);
updatedWorkspaceItemInfos.add(workspaceItemInfo);
}
}
}
@ -108,7 +108,7 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
// means they were cleared, so we remove and unpin them now.
removedKeys.addAll(keyToShortcutInfo.keySet());
bindUpdatedShortcuts(updatedShortcutInfos, mUser);
bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
if (!keyToShortcutInfo.isEmpty()) {
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
}

View File

@ -24,7 +24,7 @@ import com.android.launcher3.AllAppsList;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.shortcuts.DeepShortcutManager;
@ -73,13 +73,13 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
}
// Update the workspace to reflect the changes to updated shortcuts residing on it.
ArrayList<ShortcutInfo> updatedShortcutInfos = new ArrayList<>();
ArrayList<WorkspaceItemInfo> updatedWorkspaceItemInfos = new ArrayList<>();
HashSet<ShortcutKey> removedKeys = new HashSet<>();
for (ItemInfo itemInfo : dataModel.itemsIdMap) {
if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
&& mUser.equals(itemInfo.user)) {
ShortcutInfo si = (ShortcutInfo) itemInfo;
WorkspaceItemInfo si = (WorkspaceItemInfo) itemInfo;
if (isUserUnlocked) {
ShortcutKey key = ShortcutKey.fromItemInfo(si);
ShortcutInfoCompat shortcut = pinnedShortcuts.get(key);
@ -99,10 +99,10 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
} else {
si.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
}
updatedShortcutInfos.add(si);
updatedWorkspaceItemInfos.add(si);
}
}
bindUpdatedShortcuts(updatedShortcutInfos, mUser);
bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
if (!removedKeys.isEmpty()) {
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
}

View File

@ -23,7 +23,7 @@ import android.service.notification.StatusBarNotification;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.notification.NotificationInfo;
import com.android.launcher3.notification.NotificationKeyData;
@ -147,7 +147,7 @@ public class PopupPopulator {
shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
for (int i = 0; i < shortcuts.size() && i < shortcutViews.size(); i++) {
final ShortcutInfoCompat shortcut = shortcuts.get(i);
final ShortcutInfo si = new ShortcutInfo(shortcut, launcher);
final WorkspaceItemInfo si = new WorkspaceItemInfo(shortcut, launcher);
// Use unbadged icon for the menu.
LauncherIcons li = LauncherIcons.obtain(launcher);
si.applyFrom(li.createShortcutIcon(shortcut, false /* badged */));

View File

@ -20,7 +20,7 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.PackageManagerHelper;
@ -176,8 +176,8 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
@Override
public View.OnClickListener getOnClickListener(
BaseDraggingActivity activity, ItemInfo itemInfo) {
boolean supportsWebUI = (itemInfo instanceof ShortcutInfo) &&
((ShortcutInfo) itemInfo).hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI);
boolean supportsWebUI = (itemInfo instanceof WorkspaceItemInfo) &&
((WorkspaceItemInfo) itemInfo).hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI);
boolean isInstantApp = false;
if (itemInfo instanceof com.android.launcher3.AppInfo) {
com.android.launcher3.AppInfo appInfo = (com.android.launcher3.AppInfo) itemInfo;

View File

@ -31,7 +31,7 @@ import android.util.SparseLongArray;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherProvider.DatabaseHelper;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
@ -110,8 +110,8 @@ public class RestoreDbTask {
// Mark all items as restored.
boolean keepAllIcons = Utilities.isPropertyEnabled(LogConfig.KEEP_ALL_ICONS);
ContentValues values = new ContentValues();
values.put(Favorites.RESTORED, ShortcutInfo.FLAG_RESTORED_ICON
| (keepAllIcons ? ShortcutInfo.FLAG_RESTORE_STARTED : 0));
values.put(Favorites.RESTORED, WorkspaceItemInfo.FLAG_RESTORED_ICON
| (keepAllIcons ? WorkspaceItemInfo.FLAG_RESTORE_STARTED : 0));
db.update(Favorites.TABLE_NAME, values, null, null);
// Mark widgets with appropriate restore flag.

View File

@ -18,7 +18,6 @@ package com.android.launcher3.shortcuts;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
@ -27,10 +26,9 @@ import android.widget.FrameLayout;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.touch.ItemClickHandler;
/**
* A {@link android.widget.FrameLayout} that contains a {@link DeepShortcutView}.
@ -44,7 +42,7 @@ public class DeepShortcutView extends FrameLayout {
private View mIconView;
private View mDivider;
private ShortcutInfo mInfo;
private WorkspaceItemInfo mInfo;
private ShortcutInfoCompat mDetail;
public DeepShortcutView(Context context) {
@ -95,11 +93,11 @@ public class DeepShortcutView extends FrameLayout {
}
/** package private **/
public void applyShortcutInfo(ShortcutInfo info, ShortcutInfoCompat detail,
public void applyShortcutInfo(WorkspaceItemInfo info, ShortcutInfoCompat detail,
PopupContainerWithArrow container) {
mInfo = info;
mDetail = detail;
mBubbleText.applyFromShortcutInfo(info);
mBubbleText.applyFromWorkspaceItem(info);
mIconView.setBackground(mBubbleText.getIcon());
// Use the long label as long as it exists and fits.
@ -119,12 +117,12 @@ public class DeepShortcutView extends FrameLayout {
/**
* Returns the shortcut info that is suitable to be added on the homescreen
*/
public ShortcutInfo getFinalInfo() {
final ShortcutInfo badged = new ShortcutInfo(mInfo);
public WorkspaceItemInfo getFinalInfo() {
final WorkspaceItemInfo badged = new WorkspaceItemInfo(mInfo);
// Queue an update task on the worker thread. This ensures that the badged
// shortcut eventually gets its icon updated.
Launcher.getLauncher(getContext()).getModel()
.updateAndBindShortcutInfo(badged, mDetail);
.updateAndBindWorkspaceItem(badged, mDetail);
return badged;
}

View File

@ -23,11 +23,12 @@ import android.content.pm.ShortcutInfo;
import android.os.UserHandle;
import com.android.launcher3.R;
import com.android.launcher3.WorkspaceItemInfo;
/**
* Wrapper class for {@link android.content.pm.ShortcutInfo}, representing deep shortcuts into apps.
*
* Not to be confused with {@link com.android.launcher3.ShortcutInfo}.
* Not to be confused with {@link WorkspaceItemInfo}.
*/
public class ShortcutInfoCompat {
private static final String INTENT_CATEGORY = "com.android.launcher3.DEEP_SHORTCUT";

View File

@ -43,7 +43,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.PromiseAppInfo;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
@ -86,8 +86,8 @@ public class ItemClickHandler {
}
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
onClickAppShortcut(v, (ShortcutInfo) tag, launcher, sourceContainer);
if (tag instanceof WorkspaceItemInfo) {
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher, sourceContainer);
} else if (tag instanceof FolderInfo) {
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
@ -176,12 +176,13 @@ public class ItemClickHandler {
/**
* Event handler for an app shortcut click.
*
* @param v The view that was clicked. Must be a tagged with a {@link ShortcutInfo}.
* @param v The view that was clicked. Must be a tagged with a {@link WorkspaceItemInfo}.
*/
public static void onClickAppShortcut(View v, ShortcutInfo shortcut, Launcher launcher,
public static void onClickAppShortcut(View v, WorkspaceItemInfo shortcut, Launcher launcher,
@Nullable String sourceContainer) {
if (shortcut.isDisabled()) {
final int disabledFlags = shortcut.runtimeStatusFlags & ShortcutInfo.FLAG_DISABLED_MASK;
final int disabledFlags = shortcut.runtimeStatusFlags
& WorkspaceItemInfo.FLAG_DISABLED_MASK;
if ((disabledFlags &
~FLAG_DISABLED_SUSPENDED &
~FLAG_DISABLED_QUIET_USER) == 0) {
@ -212,7 +213,7 @@ public class ItemClickHandler {
shortcut.intent.getComponent().getPackageName() : shortcut.intent.getPackage();
if (!TextUtils.isEmpty(packageName)) {
onClickPendingAppItem(v, launcher, packageName,
shortcut.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE));
shortcut.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE));
return;
}
}
@ -233,9 +234,9 @@ public class ItemClickHandler {
if (intent == null) {
throw new IllegalArgumentException("Input must have a valid intent");
}
if (item instanceof ShortcutInfo) {
ShortcutInfo si = (ShortcutInfo) item;
if (si.hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)
if (item instanceof WorkspaceItemInfo) {
WorkspaceItemInfo si = (WorkspaceItemInfo) item;
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI)
&& Intent.ACTION_VIEW.equals(intent.getAction())) {
// make a copy of the intent that has the package set to null
// we do this because the platform sometimes disables instant

View File

@ -23,7 +23,7 @@ import com.android.launcher3.FolderInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.shortcuts.ShortcutKey;
import java.util.HashSet;
@ -41,15 +41,15 @@ public interface ItemInfoMatcher {
default HashSet<ItemInfo> filterItemInfos(Iterable<ItemInfo> infos) {
HashSet<ItemInfo> filtered = new HashSet<>();
for (ItemInfo i : infos) {
if (i instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) i;
if (i instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = (WorkspaceItemInfo) i;
ComponentName cn = info.getTargetComponent();
if (cn != null && matches(info, cn)) {
filtered.add(info);
}
} else if (i instanceof FolderInfo) {
FolderInfo info = (FolderInfo) i;
for (ShortcutInfo s : info.contents) {
for (WorkspaceItemInfo s : info.contents) {
ComponentName cn = s.getTargetComponent();
if (cn != null && matches(s, cn)) {
filtered.add(s);

View File

@ -41,7 +41,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.PromiseAppInfo;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.compat.LauncherAppsCompat;
import java.net.URISyntaxException;
@ -183,7 +183,7 @@ public class PackageManagerHelper {
ComponentName componentName = null;
if (info instanceof AppInfo) {
componentName = ((AppInfo) info).componentName;
} else if (info instanceof ShortcutInfo) {
} else if (info instanceof WorkspaceItemInfo) {
componentName = info.getTargetComponent();
} else if (info instanceof PendingAddItemInfo) {
componentName = ((PendingAddItemInfo) info).componentName;

View File

@ -29,6 +29,7 @@ import android.util.Log;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.WorkspaceItemInfo;
import java.util.ArrayList;
import java.util.Collections;
@ -63,8 +64,8 @@ public class DeepShortcutManager {
}
public static boolean supportsShortcuts(ItemInfo info) {
boolean isItemPromise = info instanceof com.android.launcher3.ShortcutInfo
&& ((com.android.launcher3.ShortcutInfo) info).hasPromiseIconUi();
boolean isItemPromise = info instanceof WorkspaceItemInfo
&& ((WorkspaceItemInfo) info).hasPromiseIconUi();
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
&& !info.isDisabled() && !isItemPromise;
}

View File

@ -10,11 +10,11 @@ import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.icons.BitmapInfo;
@ -112,7 +112,7 @@ public class LoaderCursorTest {
ComponentName cn = mLauncherApps.getActivityList(null, mLoaderCursor.user)
.get(0).getComponentName();
ShortcutInfo info = mLoaderCursor.getAppShortcutInfo(
WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo(
new Intent().setComponent(cn), false /* allowMissingTarget */, true);
assertNotNull(info);
assertTrue(Utilities.isLauncherAppTarget(info.intent));
@ -124,7 +124,7 @@ public class LoaderCursorTest {
assertTrue(mLoaderCursor.moveToNext());
ComponentName cn = new ComponentName(mContext.getPackageName(), "dummy-do");
ShortcutInfo info = mLoaderCursor.getAppShortcutInfo(
WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo(
new Intent().setComponent(cn), true /* allowMissingTarget */, true);
assertNotNull(info);
assertTrue(Utilities.isLauncherAppTarget(info.intent));
@ -138,7 +138,7 @@ public class LoaderCursorTest {
Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
when(mMockIconCache.getDefaultIcon(eq(mLoaderCursor.user)))
.thenReturn(BitmapInfo.fromBitmap(icon));
ShortcutInfo info = mLoaderCursor.loadSimpleShortcut();
WorkspaceItemInfo info = mLoaderCursor.loadSimpleWorkspaceItem();
assertEquals(icon, info.iconBitmap);
assertEquals("my-shortcut", info.title);
assertEquals(ITEM_TYPE_SHORTCUT, info.itemType);

View File

@ -34,7 +34,7 @@ import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace.ItemOperator;
import com.android.launcher3.shortcuts.ShortcutKey;
@ -134,7 +134,7 @@ public class RequestPinItemTest extends AbstractLauncherUiTest {
runTest("pinShortcut", false, new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View view) {
return info instanceof ShortcutInfo &&
return info instanceof WorkspaceItemInfo &&
info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT &&
ShortcutKey.fromItemInfo(info).getId().equals(mShortcutId);
}