ShortcutInfo renamed to WorkspaceItemInfo
Will get rid of ShortcutInfoCompat in a follow up cl Change-Id: I7d7d9c938635f59b216290ba28bea9d0e0721a7d
This commit is contained in:
parent
1f457ae87f
commit
9589916418
|
@ -38,7 +38,7 @@ import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.LauncherState;
|
import com.android.launcher3.LauncherState;
|
||||||
import com.android.launcher3.R;
|
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.popup.SystemShortcut;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||||
import com.android.launcher3.util.InstantAppResolver;
|
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) {
|
public View.OnClickListener getOnClickListener(BaseDraggingActivity activity, TaskView view) {
|
||||||
Task task = view.getTask();
|
Task task = view.getTask();
|
||||||
|
|
||||||
ShortcutInfo dummyInfo = new ShortcutInfo();
|
WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo();
|
||||||
dummyInfo.intent = new Intent();
|
dummyInfo.intent = new Intent();
|
||||||
ComponentName component = task.getTopComponent();
|
ComponentName component = task.getTopComponent();
|
||||||
dummyInfo.intent.setComponent(component);
|
dummyInfo.intent.setComponent(component);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Model data used by CacheDataUpdatedTaskTest
|
# Model data used by CacheDataUpdatedTaskTest
|
||||||
|
|
||||||
classMap s com.android.launcher3.ShortcutInfo
|
classMap s com.android.launcher3.WorkspaceItemInfo
|
||||||
|
|
||||||
# Items for the BgDataModel
|
# Items for the BgDataModel
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Model data used by PackageInstallStateChangeTaskTest
|
# Model data used by PackageInstallStateChangeTaskTest
|
||||||
|
|
||||||
classMap s com.android.launcher3.ShortcutInfo
|
classMap s com.android.launcher3.WorkspaceItemInfo
|
||||||
classMap w com.android.launcher3.LauncherAppWidgetInfo
|
classMap w com.android.launcher3.LauncherAppWidgetInfo
|
||||||
|
|
||||||
# Items for the BgDataModel
|
# Items for the BgDataModel
|
||||||
|
|
|
@ -7,19 +7,14 @@ import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentProviderOperation;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.net.Uri;
|
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherProvider;
|
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
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.ContentWriter;
|
||||||
import com.android.launcher3.util.GridOccupancy;
|
import com.android.launcher3.util.GridOccupancy;
|
||||||
import com.android.launcher3.util.IntArray;
|
import com.android.launcher3.util.IntArray;
|
||||||
|
@ -103,7 +98,7 @@ public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddItem_existing_item_ignored() throws Exception {
|
public void testAddItem_existing_item_ignored() throws Exception {
|
||||||
ShortcutInfo info = new ShortcutInfo();
|
WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
info.intent = new Intent().setComponent(mComponent1);
|
info.intent = new Intent().setComponent(mComponent1);
|
||||||
|
|
||||||
// Setup a screen with a hole
|
// Setup a screen with a hole
|
||||||
|
@ -115,10 +110,10 @@ public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddItem_some_items_added() throws Exception {
|
public void testAddItem_some_items_added() throws Exception {
|
||||||
ShortcutInfo info = new ShortcutInfo();
|
WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
info.intent = new Intent().setComponent(mComponent1);
|
info.intent = new Intent().setComponent(mComponent1);
|
||||||
|
|
||||||
ShortcutInfo info2 = new ShortcutInfo();
|
WorkspaceItemInfo info2 = new WorkspaceItemInfo();
|
||||||
info2.intent = new Intent().setComponent(mComponent2);
|
info2.intent = new Intent().setComponent(mComponent2);
|
||||||
|
|
||||||
// Setup a screen with a hole
|
// Setup a screen with a hole
|
||||||
|
@ -155,7 +150,7 @@ public class AddWorkspaceItemsTaskTest extends BaseModelUpdateTaskTestCase {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortcutInfo info = new ShortcutInfo();
|
WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
info.intent = new Intent().setComponent(mComponent1);
|
info.intent = new Intent().setComponent(mComponent1);
|
||||||
info.id = startId++;
|
info.id = startId++;
|
||||||
info.screenId = screenId;
|
info.screenId = screenId;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import com.android.launcher3.AppInfo;
|
import com.android.launcher3.AppInfo;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
@ -89,10 +89,10 @@ public class CacheDataUpdatedTaskTest extends BaseModelUpdateTaskTestCase {
|
||||||
for (ItemInfo info : bgDataModel.itemsIdMap) {
|
for (ItemInfo info : bgDataModel.itemsIdMap) {
|
||||||
if (updates.contains(info.id)) {
|
if (updates.contains(info.id)) {
|
||||||
assertEquals(NEW_LABEL_PREFIX + info.id, info.title);
|
assertEquals(NEW_LABEL_PREFIX + info.id, info.title);
|
||||||
assertNotNull(((ShortcutInfo) info).iconBitmap);
|
assertNotNull(((WorkspaceItemInfo) info).iconBitmap);
|
||||||
} else {
|
} else {
|
||||||
assertNotSame(NEW_LABEL_PREFIX + info.id, info.title);
|
assertNotSame(NEW_LABEL_PREFIX + info.id, info.title);
|
||||||
assertNull(((ShortcutInfo) info).iconBitmap);
|
assertNull(((WorkspaceItemInfo) info).iconBitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
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;
|
||||||
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
|
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ public class PackageInstallStateChangedTaskTest extends BaseModelUpdateTaskTestC
|
||||||
private void verifyProgressUpdate(int progress, Integer... idsUpdated) {
|
private void verifyProgressUpdate(int progress, Integer... idsUpdated) {
|
||||||
HashSet<Integer> updates = new HashSet<>(Arrays.asList(idsUpdated));
|
HashSet<Integer> updates = new HashSet<>(Arrays.asList(idsUpdated));
|
||||||
for (ItemInfo info : bgDataModel.itemsIdMap) {
|
for (ItemInfo info : bgDataModel.itemsIdMap) {
|
||||||
if (info instanceof ShortcutInfo) {
|
if (info instanceof WorkspaceItemInfo) {
|
||||||
assertEquals(updates.contains(info.id) ? progress: 0,
|
assertEquals(updates.contains(info.id) ? progress: 0,
|
||||||
((ShortcutInfo) info).getInstallProgress());
|
((WorkspaceItemInfo) info).getInstallProgress());
|
||||||
} else {
|
} else {
|
||||||
assertEquals(updates.contains(info.id) ? progress: -1,
|
assertEquals(updates.contains(info.id) ? progress: -1,
|
||||||
((LauncherAppWidgetInfo) info).installProgress);
|
((LauncherAppWidgetInfo) info).installProgress);
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||||
return super.dumpProperties() + " componentName=" + componentName;
|
return super.dumpProperties() + " componentName=" + componentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutInfo makeShortcut() {
|
public WorkspaceItemInfo makeWorkspaceItem() {
|
||||||
return new ShortcutInfo(this);
|
return new WorkspaceItemInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentKey toComponentKey() {
|
public ComponentKey toComponentKey() {
|
||||||
|
|
|
@ -391,7 +391,7 @@ public class AutoInstallsLayout {
|
||||||
return -1;
|
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)
|
final Intent intent = new Intent(Intent.ACTION_MAIN, null)
|
||||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
.setComponent(new ComponentName(packageName, className))
|
.setComponent(new ComponentName(packageName, className))
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.android.launcher3;
|
package com.android.launcher3;
|
||||||
|
|
||||||
import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_SEARCH;
|
|
||||||
|
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -169,10 +167,10 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||||
intent.setSourceBounds(getViewBounds(v));
|
intent.setSourceBounds(getViewBounds(v));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
boolean isShortcut = (item instanceof ShortcutInfo)
|
boolean isShortcut = (item instanceof WorkspaceItemInfo)
|
||||||
&& (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
|
&& (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
|
||||||
|| item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
|
|| item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
|
||||||
&& !((ShortcutInfo) item).isPromise();
|
&& !((WorkspaceItemInfo) item).isPromise();
|
||||||
if (isShortcut) {
|
if (isShortcut) {
|
||||||
// Shortcuts need some special checks due to legacy reasons.
|
// Shortcuts need some special checks due to legacy reasons.
|
||||||
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
|
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
|
||||||
|
@ -209,7 +207,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||||
.penaltyLog().build());
|
.penaltyLog().build());
|
||||||
|
|
||||||
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||||
String id = ((ShortcutInfo) info).getDeepShortcutId();
|
String id = ((WorkspaceItemInfo) info).getDeepShortcutId();
|
||||||
String packageName = intent.getPackage();
|
String packageName = intent.getPackage();
|
||||||
DeepShortcutManager.getInstance(this).startShortcut(
|
DeepShortcutManager.getInstance(this).startShortcut(
|
||||||
packageName, id, intent.getSourceBounds(), optsBundle, info.user);
|
packageName, id, intent.getSourceBounds(), optsBundle, info.user);
|
||||||
|
|
|
@ -215,11 +215,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
mDotScaleAnim.start();
|
mDotScaleAnim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyFromShortcutInfo(ShortcutInfo info) {
|
public void applyFromWorkspaceItem(WorkspaceItemInfo info) {
|
||||||
applyFromShortcutInfo(info, false);
|
applyFromWorkspaceItem(info, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyFromShortcutInfo(ShortcutInfo info, boolean promiseStateChanged) {
|
public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) {
|
||||||
applyIconAndLabel(info);
|
applyIconAndLabel(info);
|
||||||
setTag(info);
|
setTag(info);
|
||||||
if (promiseStateChanged || (info.hasPromiseIconUi())) {
|
if (promiseStateChanged || (info.hasPromiseIconUi())) {
|
||||||
|
@ -232,7 +232,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
public void applyFromApplicationInfo(AppInfo info) {
|
public void applyFromApplicationInfo(AppInfo info) {
|
||||||
applyIconAndLabel(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);
|
super.setTag(info);
|
||||||
|
|
||||||
// Verify high res immediately
|
// Verify high res immediately
|
||||||
|
@ -247,7 +247,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
|
|
||||||
public void applyFromPackageItemInfo(PackageItemInfo info) {
|
public void applyFromPackageItemInfo(PackageItemInfo info) {
|
||||||
applyIconAndLabel(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);
|
super.setTag(info);
|
||||||
|
|
||||||
// Verify high res immediately
|
// Verify high res immediately
|
||||||
|
@ -491,11 +491,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyPromiseState(boolean promiseStateChanged) {
|
public void applyPromiseState(boolean promiseStateChanged) {
|
||||||
if (getTag() instanceof ShortcutInfo) {
|
if (getTag() instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo info = (ShortcutInfo) getTag();
|
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
|
||||||
final boolean isPromise = info.hasPromiseIconUi();
|
final boolean isPromise = info.hasPromiseIconUi();
|
||||||
final int progressLevel = isPromise ?
|
final int progressLevel = isPromise ?
|
||||||
((info.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
|
((info.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
|
||||||
info.getInstallProgress() : 0)) : 100;
|
info.getInstallProgress() : 0)) : 100;
|
||||||
|
|
||||||
PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
|
PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
|
||||||
|
@ -619,8 +619,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
|
|
||||||
if (info instanceof AppInfo) {
|
if (info instanceof AppInfo) {
|
||||||
applyFromApplicationInfo((AppInfo) info);
|
applyFromApplicationInfo((AppInfo) info);
|
||||||
} else if (info instanceof ShortcutInfo) {
|
} else if (info instanceof WorkspaceItemInfo) {
|
||||||
applyFromShortcutInfo((ShortcutInfo) info);
|
applyFromWorkspaceItem((WorkspaceItemInfo) info);
|
||||||
mActivity.invalidateParent(info);
|
mActivity.invalidateParent(info);
|
||||||
} else if (info instanceof PackageItemInfo) {
|
} else if (info instanceof PackageItemInfo) {
|
||||||
applyFromPackageItemInfo((PackageItemInfo) info);
|
applyFromPackageItemInfo((PackageItemInfo) info);
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.android.launcher3;
|
package com.android.launcher3;
|
||||||
|
|
||||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
@ -64,7 +62,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
|
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.
|
// Support the action unless the item is in a context menu.
|
||||||
return info.screenId >= 0;
|
return info.screenId >= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class FolderInfo extends ItemInfo {
|
||||||
/**
|
/**
|
||||||
* The apps and shortcuts
|
* The apps and shortcuts
|
||||||
*/
|
*/
|
||||||
public ArrayList<ShortcutInfo> contents = new ArrayList<ShortcutInfo>();
|
public ArrayList<WorkspaceItemInfo> contents = new ArrayList<WorkspaceItemInfo>();
|
||||||
|
|
||||||
ArrayList<FolderListener> listeners = new ArrayList<FolderListener>();
|
ArrayList<FolderListener> listeners = new ArrayList<FolderListener>();
|
||||||
|
|
||||||
|
@ -64,14 +64,14 @@ public class FolderInfo extends ItemInfo {
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void add(ShortcutInfo item, boolean animate) {
|
public void add(WorkspaceItemInfo item, boolean animate) {
|
||||||
add(item, contents.size(), animate);
|
add(item, contents.size(), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an app or shortcut for a specified rank.
|
* 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());
|
rank = Utilities.boundToRange(rank, 0, contents.size());
|
||||||
contents.add(rank, item);
|
contents.add(rank, item);
|
||||||
for (int i = 0; i < listeners.size(); i++) {
|
for (int i = 0; i < listeners.size(); i++) {
|
||||||
|
@ -85,7 +85,7 @@ public class FolderInfo extends ItemInfo {
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void remove(ShortcutInfo item, boolean animate) {
|
public void remove(WorkspaceItemInfo item, boolean animate) {
|
||||||
contents.remove(item);
|
contents.remove(item);
|
||||||
for (int i = 0; i < listeners.size(); i++) {
|
for (int i = 0; i < listeners.size(); i++) {
|
||||||
listeners.get(i).onRemove(item);
|
listeners.get(i).onRemove(item);
|
||||||
|
@ -129,8 +129,8 @@ public class FolderInfo extends ItemInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface FolderListener {
|
public interface FolderListener {
|
||||||
public void onAdd(ShortcutInfo item, int rank);
|
public void onAdd(WorkspaceItemInfo item, int rank);
|
||||||
public void onRemove(ShortcutInfo item);
|
public void onRemove(WorkspaceItemInfo item);
|
||||||
public void onTitleChanged(CharSequence title);
|
public void onTitleChanged(CharSequence title);
|
||||||
public void onItemsChanged(boolean animate);
|
public void onItemsChanged(boolean animate);
|
||||||
public void prepareAutoUpdate();
|
public void prepareAutoUpdate();
|
||||||
|
|
|
@ -244,13 +244,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
||||||
return convertToLauncherActivityIfPossible(info);
|
return convertToLauncherActivityIfPossible(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortcutInfo fromShortcutIntent(Context context, Intent data) {
|
public static WorkspaceItemInfo fromShortcutIntent(Context context, Intent data) {
|
||||||
PendingInstallShortcutInfo info = createPendingInfo(context, 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) {
|
public static WorkspaceItemInfo fromActivityInfo(LauncherActivityInfo info, Context context) {
|
||||||
return (ShortcutInfo) (new PendingInstallShortcutInfo(info, context).getItemInfo().first);
|
return (WorkspaceItemInfo) (new PendingInstallShortcutInfo(info, context).getItemInfo().first);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueShortcut(ShortcutInfoCompat info, Context context) {
|
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.
|
// Set default values until proper values is loaded.
|
||||||
appInfo.title = "";
|
appInfo.title = "";
|
||||||
appInfo.applyFrom(app.getIconCache().getDefaultIcon(user));
|
appInfo.applyFrom(app.getIconCache().getDefaultIcon(user));
|
||||||
final ShortcutInfo si = appInfo.makeShortcut();
|
final WorkspaceItemInfo si = appInfo.makeWorkspaceItem();
|
||||||
if (Looper.myLooper() == LauncherModel.getWorkerLooper()) {
|
if (Looper.myLooper() == LauncherModel.getWorkerLooper()) {
|
||||||
app.getIconCache().getTitleAndIcon(si, activityInfo, false /* useLowResIcon */);
|
app.getIconCache().getTitleAndIcon(si, activityInfo, false /* useLowResIcon */);
|
||||||
} else {
|
} else {
|
||||||
app.getModel().updateAndBindShortcutInfo(() -> {
|
app.getModel().updateAndBindWorkspaceItem(() -> {
|
||||||
app.getIconCache().getTitleAndIcon(
|
app.getIconCache().getTitleAndIcon(
|
||||||
si, activityInfo, false /* useLowResIcon */);
|
si, activityInfo, false /* useLowResIcon */);
|
||||||
return si;
|
return si;
|
||||||
|
@ -495,7 +495,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
return Pair.create((ItemInfo) si, (Object) activityInfo);
|
return Pair.create((ItemInfo) si, (Object) activityInfo);
|
||||||
} else if (shortcutInfo != null) {
|
} else if (shortcutInfo != null) {
|
||||||
ShortcutInfo si = new ShortcutInfo(shortcutInfo, mContext);
|
WorkspaceItemInfo si = new WorkspaceItemInfo(shortcutInfo, mContext);
|
||||||
LauncherIcons li = LauncherIcons.obtain(mContext);
|
LauncherIcons li = LauncherIcons.obtain(mContext);
|
||||||
si.applyFrom(li.createShortcutIcon(shortcutInfo));
|
si.applyFrom(li.createShortcutIcon(shortcutInfo));
|
||||||
li.recycle();
|
li.recycle();
|
||||||
|
@ -513,7 +513,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
||||||
widgetInfo.spanY = Math.min(info.spanY, idp.numRows);
|
widgetInfo.spanY = Math.min(info.spanY, idp.numRows);
|
||||||
return Pair.create((ItemInfo) widgetInfo, (Object) providerInfo);
|
return Pair.create((ItemInfo) widgetInfo, (Object) providerInfo);
|
||||||
} else {
|
} else {
|
||||||
ShortcutInfo si = createShortcutInfo(data, LauncherAppState.getInstance(mContext));
|
WorkspaceItemInfo si = createWorkspaceItemInfo(data, LauncherAppState.getInstance(mContext));
|
||||||
return Pair.create((ItemInfo) si, null);
|
return Pair.create((ItemInfo) si, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,18 +625,18 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
||||||
return new PendingInstallShortcutInfo(info, original.mContext);
|
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);
|
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
|
||||||
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
||||||
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
|
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
|
||||||
|
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
// If the intent is null, we can't construct a valid ShortcutInfo, so we return null
|
// If the intent is null, return null as we can't construct a valid WorkspaceItemInfo
|
||||||
Log.e(TAG, "Can't construct ShorcutInfo with null intent");
|
Log.e(TAG, "Can't construct WorkspaceItemInfo with null intent");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ShortcutInfo info = new ShortcutInfo();
|
final WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
|
|
||||||
// Only support intents for current user for now. Intents sent from other
|
// Only support intents for current user for now. Intents sent from other
|
||||||
// users wouldn't get here without intent forwarding anyway.
|
// users wouldn't get here without intent forwarding anyway.
|
||||||
|
|
|
@ -57,7 +57,6 @@ import android.os.Handler;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.method.TextKeyListener;
|
import android.text.method.TextKeyListener;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -981,7 +980,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||||
*
|
*
|
||||||
* @param info The data structure describing the shortcut.
|
* @param info The data structure describing the shortcut.
|
||||||
*/
|
*/
|
||||||
View createShortcut(ShortcutInfo info) {
|
View createShortcut(WorkspaceItemInfo info) {
|
||||||
return createShortcut((ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentPage()), 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.
|
* @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())
|
BubbleTextView favorite = (BubbleTextView) LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.app_icon, parent, false);
|
.inflate(R.layout.app_icon, parent, false);
|
||||||
favorite.applyFromShortcutInfo(info);
|
favorite.applyFromWorkspaceItem(info);
|
||||||
favorite.setOnClickListener(ItemClickHandler.INSTANCE);
|
favorite.setOnClickListener(ItemClickHandler.INSTANCE);
|
||||||
favorite.setOnFocusChangeListener(mFocusHandler);
|
favorite.setOnFocusChangeListener(mFocusHandler);
|
||||||
return favorite;
|
return favorite;
|
||||||
|
@ -1017,9 +1016,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||||
int[] cellXY = mTmpAddItemCellCoordinates;
|
int[] cellXY = mTmpAddItemCellCoordinates;
|
||||||
CellLayout layout = getCellLayout(container, screenId);
|
CellLayout layout = getCellLayout(container, screenId);
|
||||||
|
|
||||||
ShortcutInfo info = null;
|
WorkspaceItemInfo info = null;
|
||||||
if (Utilities.ATLEAST_OREO) {
|
if (Utilities.ATLEAST_OREO) {
|
||||||
info = LauncherAppsCompatVO.createShortcutInfoFromPinItemRequest(
|
info = LauncherAppsCompatVO.createWorkspaceItemFromPinItemRequest(
|
||||||
this, LauncherAppsCompatVO.getPinItemRequest(data), 0);
|
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.
|
* @param deleteFromDb whether or not to delete this item from the db.
|
||||||
*/
|
*/
|
||||||
public boolean removeItem(View v, final ItemInfo itemInfo, boolean deleteFromDb) {
|
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
|
// Remove the shortcut from the folder before removing it from launcher
|
||||||
View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
|
View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
|
||||||
if (folderIcon instanceof FolderIcon) {
|
if (folderIcon instanceof FolderIcon) {
|
||||||
((FolderInfo) folderIcon.getTag()).remove((ShortcutInfo) itemInfo, true);
|
((FolderInfo) folderIcon.getTag()).remove((WorkspaceItemInfo) itemInfo, true);
|
||||||
} else {
|
} else {
|
||||||
mWorkspace.removeWorkspaceItem(v);
|
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_APPLICATION:
|
||||||
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
|
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
|
||||||
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: {
|
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: {
|
||||||
ShortcutInfo info = (ShortcutInfo) item;
|
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
|
||||||
view = createShortcut(info);
|
view = createShortcut(info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2228,7 +2227,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||||
* @param updated list of shortcuts which have changed.
|
* @param updated list of shortcuts which have changed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated, final UserHandle user) {
|
public void bindWorkspaceItemsChanged(ArrayList<WorkspaceItemInfo> updated) {
|
||||||
if (!updated.isEmpty()) {
|
if (!updated.isEmpty()) {
|
||||||
mWorkspace.updateShortcuts(updated);
|
mWorkspace.updateShortcuts(updated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class LauncherModel extends BroadcastReceiver
|
||||||
public void bindAppsAdded(IntArray newScreens,
|
public void bindAppsAdded(IntArray newScreens,
|
||||||
ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated);
|
ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated);
|
||||||
public void bindPromiseAppProgressUpdated(PromiseAppInfo app);
|
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 bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
|
||||||
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
|
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
|
||||||
public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher);
|
public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher);
|
||||||
|
@ -530,8 +530,8 @@ public class LauncherModel extends BroadcastReceiver
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAndBindShortcutInfo(final ShortcutInfo si, final ShortcutInfoCompat info) {
|
public void updateAndBindWorkspaceItem(WorkspaceItemInfo si, ShortcutInfoCompat info) {
|
||||||
updateAndBindShortcutInfo(() -> {
|
updateAndBindWorkspaceItem(() -> {
|
||||||
si.updateFromDeepShortcutInfo(info, mApp.getContext());
|
si.updateFromDeepShortcutInfo(info, mApp.getContext());
|
||||||
LauncherIcons li = LauncherIcons.obtain(mApp.getContext());
|
LauncherIcons li = LauncherIcons.obtain(mApp.getContext());
|
||||||
si.applyFrom(li.createShortcutIcon(info));
|
si.applyFrom(li.createShortcutIcon(info));
|
||||||
|
@ -543,15 +543,15 @@ public class LauncherModel extends BroadcastReceiver
|
||||||
/**
|
/**
|
||||||
* Utility method to update a shortcut on the background thread.
|
* 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() {
|
enqueueModelUpdateTask(new BaseModelUpdateTask() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
|
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
|
||||||
ShortcutInfo info = shortcutProvider.get();
|
WorkspaceItemInfo info = itemProvider.get();
|
||||||
getModelWriter().updateItemInDatabase(info);
|
getModelWriter().updateItemInDatabase(info);
|
||||||
ArrayList<ShortcutInfo> update = new ArrayList<>();
|
ArrayList<WorkspaceItemInfo> update = new ArrayList<>();
|
||||||
update.add(info);
|
update.add(info);
|
||||||
bindUpdatedShortcuts(update, info.user);
|
bindUpdatedWorkspaceItems(update);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,13 @@ public class PromiseAppInfo extends AppInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShortcutInfo makeShortcut() {
|
public WorkspaceItemInfo makeWorkspaceItem() {
|
||||||
ShortcutInfo shortcut = new ShortcutInfo(this);
|
WorkspaceItemInfo shortcut = new WorkspaceItemInfo(this);
|
||||||
shortcut.setInstallProgress(level);
|
shortcut.setInstallProgress(level);
|
||||||
// We need to update the component name when the apk is installed
|
// 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
|
// 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;
|
return shortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1609,7 +1609,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean aboveShortcut = (dropOverView.getTag() instanceof ShortcutInfo);
|
boolean aboveShortcut = (dropOverView.getTag() instanceof WorkspaceItemInfo);
|
||||||
boolean willBecomeShortcut =
|
boolean willBecomeShortcut =
|
||||||
(info.itemType == ITEM_TYPE_APPLICATION ||
|
(info.itemType == ITEM_TYPE_APPLICATION ||
|
||||||
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT ||
|
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT ||
|
||||||
|
@ -1658,12 +1658,12 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
mCreateUserFolderOnDrop = false;
|
mCreateUserFolderOnDrop = false;
|
||||||
final int screenId = getIdForScreen(target);
|
final int screenId = getIdForScreen(target);
|
||||||
|
|
||||||
boolean aboveShortcut = (v.getTag() instanceof ShortcutInfo);
|
boolean aboveShortcut = (v.getTag() instanceof WorkspaceItemInfo);
|
||||||
boolean willBecomeShortcut = (newView.getTag() instanceof ShortcutInfo);
|
boolean willBecomeShortcut = (newView.getTag() instanceof WorkspaceItemInfo);
|
||||||
|
|
||||||
if (aboveShortcut && willBecomeShortcut) {
|
if (aboveShortcut && willBecomeShortcut) {
|
||||||
ShortcutInfo sourceInfo = (ShortcutInfo) newView.getTag();
|
WorkspaceItemInfo sourceInfo = (WorkspaceItemInfo) newView.getTag();
|
||||||
ShortcutInfo destInfo = (ShortcutInfo) v.getTag();
|
WorkspaceItemInfo destInfo = (WorkspaceItemInfo) v.getTag();
|
||||||
// if the drag started here, we need to remove it from the workspace
|
// if the drag started here, we need to remove it from the workspace
|
||||||
if (!external) {
|
if (!external) {
|
||||||
getParentCellLayoutForView(mDragInfo.cell).removeView(mDragInfo.cell);
|
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) {
|
private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) {
|
||||||
if (d.dragInfo instanceof PendingAddShortcutInfo) {
|
if (d.dragInfo instanceof PendingAddShortcutInfo) {
|
||||||
ShortcutInfo si = ((PendingAddShortcutInfo) d.dragInfo)
|
WorkspaceItemInfo si = ((PendingAddShortcutInfo) d.dragInfo)
|
||||||
.activityInfo.createShortcutInfo();
|
.activityInfo.createWorkspaceItemInfo();
|
||||||
if (si != null) {
|
if (si != null) {
|
||||||
d.dragInfo = si;
|
d.dragInfo = si;
|
||||||
}
|
}
|
||||||
|
@ -2524,10 +2524,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
|
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
|
||||||
if (info.container == NO_ID && info instanceof AppInfo) {
|
if (info.container == NO_ID && info instanceof AppInfo) {
|
||||||
// Came from all apps -- make a copy
|
// Came from all apps -- make a copy
|
||||||
info = ((AppInfo) info).makeShortcut();
|
info = ((AppInfo) info).makeWorkspaceItem();
|
||||||
d.dragInfo = info;
|
d.dragInfo = info;
|
||||||
}
|
}
|
||||||
view = mLauncher.createShortcut(cellLayout, (ShortcutInfo) info);
|
view = mLauncher.createShortcut(cellLayout, (WorkspaceItemInfo) info);
|
||||||
break;
|
break;
|
||||||
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
|
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
|
||||||
view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher, cellLayout,
|
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) -> {
|
final Workspace.ItemOperator packageAndUserInFolder = (info, view) -> {
|
||||||
if (info instanceof FolderInfo) {
|
if (info instanceof FolderInfo) {
|
||||||
FolderInfo folderInfo = (FolderInfo) info;
|
FolderInfo folderInfo = (FolderInfo) info;
|
||||||
for (ShortcutInfo shortcutInfo : folderInfo.contents) {
|
for (WorkspaceItemInfo shortcutInfo : folderInfo.contents) {
|
||||||
if (packageAndUser.evaluate(shortcutInfo, view)) {
|
if (packageAndUser.evaluate(shortcutInfo, view)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3045,7 +3045,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
FolderInfo folderInfo = (FolderInfo) parent.getTag();
|
FolderInfo folderInfo = (FolderInfo) parent.getTag();
|
||||||
folderInfo.prepareAutoUpdate();
|
folderInfo.prepareAutoUpdate();
|
||||||
folderInfo.remove((ShortcutInfo) itemToRemove, false);
|
folderInfo.remove((WorkspaceItemInfo) itemToRemove, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3112,13 +3112,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateShortcuts(ArrayList<ShortcutInfo> shortcuts) {
|
void updateShortcuts(ArrayList<WorkspaceItemInfo> shortcuts) {
|
||||||
int total = shortcuts.size();
|
int total = shortcuts.size();
|
||||||
final HashSet<ShortcutInfo> updates = new HashSet<>(total);
|
final HashSet<WorkspaceItemInfo> updates = new HashSet<>(total);
|
||||||
final IntSet folderIds = new IntSet();
|
final IntSet folderIds = new IntSet();
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
for (int i = 0; i < total; i++) {
|
||||||
ShortcutInfo s = shortcuts.get(i);
|
WorkspaceItemInfo s = shortcuts.get(i);
|
||||||
updates.add(s);
|
updates.add(s);
|
||||||
folderIds.add(s.container);
|
folderIds.add(s.container);
|
||||||
}
|
}
|
||||||
|
@ -3126,14 +3126,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluate(ItemInfo info, View v) {
|
public boolean evaluate(ItemInfo info, View v) {
|
||||||
if (info instanceof ShortcutInfo && v instanceof BubbleTextView &&
|
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView &&
|
||||||
updates.contains(info)) {
|
updates.contains(info)) {
|
||||||
ShortcutInfo si = (ShortcutInfo) info;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
|
||||||
BubbleTextView shortcut = (BubbleTextView) v;
|
BubbleTextView shortcut = (BubbleTextView) v;
|
||||||
Drawable oldIcon = shortcut.getIcon();
|
Drawable oldIcon = shortcut.getIcon();
|
||||||
boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable)
|
boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable)
|
||||||
&& ((PreloadIconDrawable) oldIcon).hasNotCompleted();
|
&& ((PreloadIconDrawable) oldIcon).hasNotCompleted();
|
||||||
shortcut.applyFromShortcutInfo(si, si.isPromise() != oldPromiseState);
|
shortcut.applyFromWorkspaceItem(si, si.isPromise() != oldPromiseState);
|
||||||
}
|
}
|
||||||
// process all the shortcuts
|
// process all the shortcuts
|
||||||
return false;
|
return false;
|
||||||
|
@ -3159,7 +3159,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluate(ItemInfo info, View v) {
|
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)
|
if (!packageUserKey.updateFromItemInfo(info)
|
||||||
|| updatedDots.test(packageUserKey)) {
|
|| updatedDots.test(packageUserKey)) {
|
||||||
((BubbleTextView) v).applyDotState(info, true /* animate */);
|
((BubbleTextView) v).applyDotState(info, true /* animate */);
|
||||||
|
@ -3178,7 +3178,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
if (info instanceof FolderInfo && folderIds.contains(info.id)
|
if (info instanceof FolderInfo && folderIds.contains(info.id)
|
||||||
&& v instanceof FolderIcon) {
|
&& v instanceof FolderIcon) {
|
||||||
FolderDotInfo folderDotInfo = new FolderDotInfo();
|
FolderDotInfo folderDotInfo = new FolderDotInfo();
|
||||||
for (ShortcutInfo si : ((FolderInfo) info).contents) {
|
for (WorkspaceItemInfo si : ((FolderInfo) info).contents) {
|
||||||
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
|
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
|
||||||
}
|
}
|
||||||
((FolderIcon) v).setDotInfo(folderDotInfo);
|
((FolderIcon) v).setDotInfo(folderDotInfo);
|
||||||
|
@ -3201,7 +3201,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluate(ItemInfo info, View v) {
|
public boolean evaluate(ItemInfo info, View v) {
|
||||||
if (info instanceof ShortcutInfo && v instanceof BubbleTextView
|
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView
|
||||||
&& updates.contains(info)) {
|
&& updates.contains(info)) {
|
||||||
((BubbleTextView) v).applyPromiseState(false /* promiseStateChanged */);
|
((BubbleTextView) v).applyPromiseState(false /* promiseStateChanged */);
|
||||||
} else if (v instanceof PendingAppWidgetHostView
|
} else if (v instanceof PendingAppWidgetHostView
|
||||||
|
|
|
@ -29,7 +29,7 @@ import com.android.launcher3.util.ContentWriter;
|
||||||
/**
|
/**
|
||||||
* Represents a launchable icon on the workspaces and in folders.
|
* 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;
|
public static final int DEFAULT = 0;
|
||||||
|
|
||||||
|
@ -86,11 +86,11 @@ public class ShortcutInfo extends ItemInfoWithIcon {
|
||||||
*/
|
*/
|
||||||
private int mInstallProgress;
|
private int mInstallProgress;
|
||||||
|
|
||||||
public ShortcutInfo() {
|
public WorkspaceItemInfo() {
|
||||||
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutInfo(ShortcutInfo info) {
|
public WorkspaceItemInfo(WorkspaceItemInfo info) {
|
||||||
super(info);
|
super(info);
|
||||||
title = info.title;
|
title = info.title;
|
||||||
intent = new Intent(info.intent);
|
intent = new Intent(info.intent);
|
||||||
|
@ -99,17 +99,17 @@ public class ShortcutInfo extends ItemInfoWithIcon {
|
||||||
mInstallProgress = info.mInstallProgress;
|
mInstallProgress = info.mInstallProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO: Remove this. It's only called by ApplicationInfo.makeShortcut. */
|
/** TODO: Remove this. It's only called by ApplicationInfo.makeWorkspaceItem. */
|
||||||
public ShortcutInfo(AppInfo info) {
|
public WorkspaceItemInfo(AppInfo info) {
|
||||||
super(info);
|
super(info);
|
||||||
title = Utilities.trim(info.title);
|
title = Utilities.trim(info.title);
|
||||||
intent = new Intent(info.intent);
|
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();
|
user = shortcutInfo.getUserHandle();
|
||||||
itemType = Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
itemType = Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||||
updateFromDeepShortcutInfo(shortcutInfo, context);
|
updateFromDeepShortcutInfo(shortcutInfo, context);
|
||||||
|
@ -176,7 +176,7 @@ public class ShortcutInfo extends ItemInfoWithIcon {
|
||||||
disabledMessage = shortcutInfo.getDisabledMessage();
|
disabledMessage = shortcutInfo.getDisabledMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the ShortcutInfo id associated with the deep shortcut. */
|
/** Returns the WorkspaceItemInfo id associated with the deep shortcut. */
|
||||||
public String getDeepShortcutId() {
|
public String getDeepShortcutId() {
|
||||||
return itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT ?
|
return itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT ?
|
||||||
getIntent().getStringExtra(ShortcutInfoCompat.EXTRA_SHORTCUT_ID) : null;
|
getIntent().getStringExtra(ShortcutInfoCompat.EXTRA_SHORTCUT_ID) : null;
|
|
@ -30,7 +30,7 @@ import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
import com.android.launcher3.LauncherSettings.Favorites;
|
||||||
import com.android.launcher3.PendingAddItemInfo;
|
import com.android.launcher3.PendingAddItemInfo;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Workspace;
|
import com.android.launcher3.Workspace;
|
||||||
import com.android.launcher3.dragndrop.DragController.DragListener;
|
import com.android.launcher3.dragndrop.DragController.DragListener;
|
||||||
import com.android.launcher3.dragndrop.DragOptions;
|
import com.android.launcher3.dragndrop.DragOptions;
|
||||||
|
@ -145,7 +145,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean itemSupportsAccessibleDrag(ItemInfo item) {
|
private boolean itemSupportsAccessibleDrag(ItemInfo item) {
|
||||||
if (item instanceof ShortcutInfo) {
|
if (item instanceof WorkspaceItemInfo) {
|
||||||
// Support the action unless the item is in a context menu.
|
// Support the action unless the item is in a context menu.
|
||||||
return item.screenId >= 0;
|
return item.screenId >= 0;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (item instanceof AppInfo) {
|
if (item instanceof AppInfo) {
|
||||||
ShortcutInfo info = ((AppInfo) item).makeShortcut();
|
WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
|
||||||
mLauncher.getModelWriter().addItemToDatabase(info,
|
mLauncher.getModelWriter().addItemToDatabase(info,
|
||||||
Favorites.CONTAINER_DESKTOP,
|
Favorites.CONTAINER_DESKTOP,
|
||||||
screenId, coordinates[0], coordinates[1]);
|
screenId, coordinates[0], coordinates[1]);
|
||||||
|
@ -195,7 +195,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||||
} else if (action == MOVE_TO_WORKSPACE) {
|
} else if (action == MOVE_TO_WORKSPACE) {
|
||||||
Folder folder = Folder.getOpen(mLauncher);
|
Folder folder = Folder.getOpen(mLauncher);
|
||||||
folder.close(true);
|
folder.close(true);
|
||||||
ShortcutInfo info = (ShortcutInfo) item;
|
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
|
||||||
folder.getInfo().remove(info, false);
|
folder.getInfo().remove(info, false);
|
||||||
|
|
||||||
final int[] coordinates = new int[2];
|
final int[] coordinates = new int[2];
|
||||||
|
|
|
@ -27,7 +27,7 @@ import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.R;
|
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.notification.NotificationMainView;
|
||||||
import com.android.launcher3.shortcuts.DeepShortcutView;
|
import com.android.launcher3.shortcuts.DeepShortcutView;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class ShortcutMenuAccessibilityDelegate extends LauncherAccessibilityDele
|
||||||
if (!(host.getParent() instanceof DeepShortcutView)) {
|
if (!(host.getParent() instanceof DeepShortcutView)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ShortcutInfo info = ((DeepShortcutView) host.getParent()).getFinalInfo();
|
final WorkspaceItemInfo info = ((DeepShortcutView) host.getParent()).getFinalInfo();
|
||||||
final int[] coordinates = new int[2];
|
final int[] coordinates = new int[2];
|
||||||
final int screenId = findSpaceOnWorkspace(item, coordinates);
|
final int screenId = findSpaceOnWorkspace(item, coordinates);
|
||||||
Runnable onComplete = new Runnable() {
|
Runnable onComplete = new Runnable() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import com.android.launcher3.FolderInfo;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.R;
|
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.accessibility.LauncherAccessibilityDelegate.DragType;
|
||||||
import com.android.launcher3.dragndrop.DragLayer;
|
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.
|
// For icons, we can consider cells that have another icon or a folder.
|
||||||
ItemInfo info = (ItemInfo) child.getTag();
|
ItemInfo info = (ItemInfo) child.getTag();
|
||||||
if (info instanceof AppInfo || info instanceof FolderInfo ||
|
if (info instanceof AppInfo || info instanceof FolderInfo ||
|
||||||
info instanceof ShortcutInfo) {
|
info instanceof WorkspaceItemInfo) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
|
||||||
return mContext.getString(R.string.item_moved);
|
return mContext.getString(R.string.item_moved);
|
||||||
} else {
|
} else {
|
||||||
ItemInfo info = (ItemInfo) child.getTag();
|
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);
|
return mContext.getString(R.string.folder_created);
|
||||||
|
|
||||||
} else if (info instanceof FolderInfo) {
|
} else if (info instanceof FolderInfo) {
|
||||||
|
@ -170,14 +170,14 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
|
||||||
|
|
||||||
public static String getDescriptionForDropOver(View overChild, Context context) {
|
public static String getDescriptionForDropOver(View overChild, Context context) {
|
||||||
ItemInfo info = (ItemInfo) overChild.getTag();
|
ItemInfo info = (ItemInfo) overChild.getTag();
|
||||||
if (info instanceof ShortcutInfo) {
|
if (info instanceof WorkspaceItemInfo) {
|
||||||
return context.getString(R.string.create_folder_with, info.title);
|
return context.getString(R.string.create_folder_with, info.title);
|
||||||
} else if (info instanceof FolderInfo) {
|
} else if (info instanceof FolderInfo) {
|
||||||
if (TextUtils.isEmpty(info.title)) {
|
if (TextUtils.isEmpty(info.title)) {
|
||||||
// Find the first item in the folder.
|
// Find the first item in the folder.
|
||||||
FolderInfo folder = (FolderInfo) info;
|
FolderInfo folder = (FolderInfo) info;
|
||||||
ShortcutInfo firstItem = null;
|
WorkspaceItemInfo firstItem = null;
|
||||||
for (ShortcutInfo shortcut : folder.contents) {
|
for (WorkspaceItemInfo shortcut : folder.contents) {
|
||||||
if (firstItem == null || firstItem.rank > shortcut.rank) {
|
if (firstItem == null || firstItem.rank > shortcut.rank) {
|
||||||
firstItem = shortcut;
|
firstItem = shortcut;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import android.os.UserHandle;
|
||||||
|
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.LauncherModel;
|
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.compat.ShortcutConfigActivityInfo.ShortcutConfigActivityInfoVO;
|
||||||
import com.android.launcher3.icons.LauncherIcons;
|
import com.android.launcher3.icons.LauncherIcons;
|
||||||
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
||||||
|
@ -103,12 +103,12 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
|
||||||
* thread to UI thread.
|
* thread to UI thread.
|
||||||
* If (d) happens before we add this shortcut to our model, we will end up unpinning
|
* If (d) happens before we add this shortcut to our model, we will end up unpinning
|
||||||
* the shortcut in the system.
|
* 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
|
* to the model (which may involves a single post-to-worker-thread). That will guarantee
|
||||||
* that (d) happens after model is updated.
|
* that (d) happens after model is updated.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ShortcutInfo createShortcutInfoFromPinItemRequest(
|
public static WorkspaceItemInfo createWorkspaceItemFromPinItemRequest(
|
||||||
Context context, final PinItemRequest request, final long acceptDelay) {
|
Context context, final PinItemRequest request, final long acceptDelay) {
|
||||||
if (request != null &&
|
if (request != null &&
|
||||||
request.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT &&
|
request.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT &&
|
||||||
|
@ -136,13 +136,13 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortcutInfoCompat compat = new ShortcutInfoCompat(request.getShortcutInfo());
|
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.
|
// Apply the unbadged icon and fetch the actual icon asynchronously.
|
||||||
LauncherIcons li = LauncherIcons.obtain(context);
|
LauncherIcons li = LauncherIcons.obtain(context);
|
||||||
info.applyFrom(li.createShortcutIcon(compat, false /* badged */));
|
info.applyFrom(li.createShortcutIcon(compat, false /* badged */));
|
||||||
li.recycle();
|
li.recycle();
|
||||||
LauncherAppState.getInstance(context).getModel()
|
LauncherAppState.getInstance(context).getModel()
|
||||||
.updateAndBindShortcutInfo(info, compat);
|
.updateAndBindWorkspaceItem(info, compat);
|
||||||
return info;
|
return info;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -32,11 +32,11 @@ import android.os.UserHandle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.icons.ComponentWithLabel;
|
import com.android.launcher3.icons.ComponentWithLabel;
|
||||||
import com.android.launcher3.icons.IconCache;
|
import com.android.launcher3.icons.IconCache;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for representing a shortcut configure activity.
|
* Wrapper class for representing a shortcut configure activity.
|
||||||
|
@ -70,10 +70,10 @@ public abstract class ShortcutConfigActivityInfo implements ComponentWithLabel {
|
||||||
public abstract Drawable getFullResIcon(IconCache cache);
|
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)}.
|
* {@link #startConfigActivity(Activity, int)}.
|
||||||
*/
|
*/
|
||||||
public ShortcutInfo createShortcutInfo() {
|
public WorkspaceItemInfo createWorkspaceItemInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.android.launcher3.DropTarget;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.R;
|
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.accessibility.DragViewStateAnnouncer;
|
||||||
import com.android.launcher3.util.ItemInfoMatcher;
|
import com.android.launcher3.util.ItemInfoMatcher;
|
||||||
import com.android.launcher3.util.Thunk;
|
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
|
// Cancel the current drag if we are removing an app that we are dragging
|
||||||
if (mDragObject != null) {
|
if (mDragObject != null) {
|
||||||
ItemInfo dragInfo = mDragObject.dragInfo;
|
ItemInfo dragInfo = mDragObject.dragInfo;
|
||||||
if (dragInfo instanceof ShortcutInfo) {
|
if (dragInfo instanceof WorkspaceItemInfo) {
|
||||||
ComponentName cn = dragInfo.getTargetComponent();
|
ComponentName cn = dragInfo.getTargetComponent();
|
||||||
if (cn != null && matcher.matches(dragInfo, cn)) {
|
if (cn != null && matcher.matches(dragInfo, cn)) {
|
||||||
cancelDrag();
|
cancelDrag();
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.os.Build;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
|
||||||
import com.android.launcher3.FastBitmapDrawable;
|
import com.android.launcher3.FastBitmapDrawable;
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.icons.IconCache;
|
import com.android.launcher3.icons.IconCache;
|
||||||
import com.android.launcher3.LauncherAnimUtils;
|
import com.android.launcher3.LauncherAnimUtils;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
|
@ -81,13 +82,13 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.android.launcher3.ShortcutInfo createShortcutInfo() {
|
public WorkspaceItemInfo createWorkspaceItemInfo() {
|
||||||
// Total duration for the drop animation to complete.
|
// Total duration for the drop animation to complete.
|
||||||
long duration = mContext.getResources().getInteger(R.integer.config_dropAnimMaxDuration) +
|
long duration = mContext.getResources().getInteger(R.integer.config_dropAnimMaxDuration) +
|
||||||
LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY +
|
LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY +
|
||||||
LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
|
LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
|
||||||
// Delay the actual accept() call until the drop animation is complete.
|
// Delay the actual accept() call until the drop animation is complete.
|
||||||
return LauncherAppsCompatVO.createShortcutInfoFromPinItemRequest(
|
return LauncherAppsCompatVO.createWorkspaceItemFromPinItemRequest(
|
||||||
mContext, mRequest, duration);
|
mContext, mRequest, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.OnAlarmListener;
|
import com.android.launcher3.OnAlarmListener;
|
||||||
import com.android.launcher3.PagedView;
|
import com.android.launcher3.PagedView;
|
||||||
import com.android.launcher3.R;
|
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.Workspace.ItemOperator;
|
||||||
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
|
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
|
||||||
import com.android.launcher3.config.FeatureFlags;
|
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) {
|
public boolean startDrag(View v, DragOptions options) {
|
||||||
Object tag = v.getTag();
|
Object tag = v.getTag();
|
||||||
if (tag instanceof ShortcutInfo) {
|
if (tag instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo item = (ShortcutInfo) tag;
|
WorkspaceItemInfo item = (WorkspaceItemInfo) tag;
|
||||||
|
|
||||||
mEmptyCellRank = item.rank;
|
mEmptyCellRank = item.rank;
|
||||||
mCurrentDragView = v;
|
mCurrentDragView = v;
|
||||||
|
@ -269,13 +269,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
}
|
}
|
||||||
|
|
||||||
mContent.removeItem(mCurrentDragView);
|
mContent.removeItem(mCurrentDragView);
|
||||||
if (dragObject.dragInfo instanceof ShortcutInfo) {
|
if (dragObject.dragInfo instanceof WorkspaceItemInfo) {
|
||||||
mItemsInvalidated = true;
|
mItemsInvalidated = true;
|
||||||
|
|
||||||
// We do not want to get events for the item being removed, as they will get handled
|
// We do not want to get events for the item being removed, as they will get handled
|
||||||
// when the drop completes
|
// when the drop completes
|
||||||
try (SuppressInfoChanges s = new SuppressInfoChanges()) {
|
try (SuppressInfoChanges s = new SuppressInfoChanges()) {
|
||||||
mInfo.remove((ShortcutInfo) dragObject.dragInfo, true);
|
mInfo.remove((WorkspaceItemInfo) dragObject.dragInfo, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDragInProgress = true;
|
mDragInProgress = true;
|
||||||
|
@ -379,7 +379,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
|
|
||||||
void bind(FolderInfo info) {
|
void bind(FolderInfo info) {
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
ArrayList<ShortcutInfo> children = info.contents;
|
ArrayList<WorkspaceItemInfo> children = info.contents;
|
||||||
Collections.sort(children, ITEM_POS_COMPARATOR);
|
Collections.sort(children, ITEM_POS_COMPARATOR);
|
||||||
mContent.bindItems(children);
|
mContent.bindItems(children);
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The drag failed, we need to return the item to the folder
|
// 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)
|
View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info)
|
||||||
? mCurrentDragView : mContent.createNewView(info);
|
? mCurrentDragView : mContent.createNewView(info);
|
||||||
ArrayList<View> views = getItemsInReadingOrder();
|
ArrayList<View> views = getItemsInReadingOrder();
|
||||||
|
@ -1023,7 +1023,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
// folder
|
// folder
|
||||||
CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container,
|
CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container,
|
||||||
mInfo.screenId);
|
mInfo.screenId);
|
||||||
ShortcutInfo finalItem = mInfo.contents.remove(0);
|
WorkspaceItemInfo finalItem = mInfo.contents.remove(0);
|
||||||
newIcon = mLauncher.createShortcut(cellLayout, finalItem);
|
newIcon = mLauncher.createShortcut(cellLayout, finalItem);
|
||||||
mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem,
|
mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem,
|
||||||
mInfo.container, mInfo.screenId, mInfo.cellX, mInfo.cellY);
|
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 pasi = d.dragInfo instanceof PendingAddShortcutInfo
|
||||||
? (PendingAddShortcutInfo) d.dragInfo : null;
|
? (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) {
|
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.container = mInfo.id;
|
||||||
pasi.rank = mEmptyCellRank;
|
pasi.rank = mEmptyCellRank;
|
||||||
|
|
||||||
|
@ -1122,15 +1122,15 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
d.deferDragViewCleanupPostAnimation = false;
|
d.deferDragViewCleanupPostAnimation = false;
|
||||||
mRearrangeOnClose = true;
|
mRearrangeOnClose = true;
|
||||||
} else {
|
} else {
|
||||||
final ShortcutInfo si;
|
final WorkspaceItemInfo si;
|
||||||
if (pasiSi != null) {
|
if (pasiSi != null) {
|
||||||
si = pasiSi;
|
si = pasiSi;
|
||||||
} else if (d.dragInfo instanceof AppInfo) {
|
} else if (d.dragInfo instanceof AppInfo) {
|
||||||
// Came from all apps -- make a copy.
|
// Came from all apps -- make a copy.
|
||||||
si = ((AppInfo) d.dragInfo).makeShortcut();
|
si = ((AppInfo) d.dragInfo).makeWorkspaceItem();
|
||||||
} else {
|
} else {
|
||||||
// ShortcutInfo
|
// WorkspaceItemInfo
|
||||||
si = (ShortcutInfo) d.dragInfo;
|
si = (WorkspaceItemInfo) d.dragInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
View currentDragView;
|
View currentDragView;
|
||||||
|
@ -1138,7 +1138,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
currentDragView = mContent.createAndAddViewForRank(si, mEmptyCellRank);
|
currentDragView = mContent.createAndAddViewForRank(si, mEmptyCellRank);
|
||||||
|
|
||||||
// Actually move the item in the database if it was an external drag. Call this
|
// 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(
|
mLauncher.getModelWriter().addOrMoveItemInDatabase(
|
||||||
si, mInfo.id, 0, si.cellX, si.cellY);
|
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
|
// 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
|
// 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
|
// 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);
|
View v = getViewForInfo(info);
|
||||||
v.setVisibility(INVISIBLE);
|
v.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
public void showItem(ShortcutInfo info) {
|
public void showItem(WorkspaceItemInfo info) {
|
||||||
View v = getViewForInfo(info);
|
View v = getViewForInfo(info);
|
||||||
v.setVisibility(VISIBLE);
|
v.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAdd(ShortcutInfo item, int rank) {
|
public void onAdd(WorkspaceItemInfo item, int rank) {
|
||||||
View view = mContent.createAndAddViewForRank(item, rank);
|
View view = mContent.createAndAddViewForRank(item, rank);
|
||||||
mLauncher.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX,
|
mLauncher.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX,
|
||||||
item.cellY);
|
item.cellY);
|
||||||
|
@ -1215,7 +1215,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
mItemsInvalidated = true;
|
mItemsInvalidated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRemove(ShortcutInfo item) {
|
public void onRemove(WorkspaceItemInfo item) {
|
||||||
mItemsInvalidated = true;
|
mItemsInvalidated = true;
|
||||||
View v = getViewForInfo(item);
|
View v = getViewForInfo(item);
|
||||||
mContent.removeItem(v);
|
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() {
|
return mContent.iterateOverItems(new ItemOperator() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,7 @@ import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.OnAlarmListener;
|
import com.android.launcher3.OnAlarmListener;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.SimpleOnStylusPressListener;
|
import com.android.launcher3.SimpleOnStylusPressListener;
|
||||||
import com.android.launcher3.StylusEventHelper;
|
import com.android.launcher3.StylusEventHelper;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
|
@ -226,15 +226,15 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
return !mFolder.isDestroyed() && willAcceptItem(dragInfo);
|
return !mFolder.isDestroyed() && willAcceptItem(dragInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(ShortcutInfo item) {
|
public void addItem(WorkspaceItemInfo item) {
|
||||||
addItem(item, true);
|
addItem(item, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(ShortcutInfo item, boolean animate) {
|
public void addItem(WorkspaceItemInfo item, boolean animate) {
|
||||||
mInfo.add(item, animate);
|
mInfo.add(item, animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeItem(ShortcutInfo item, boolean animate) {
|
public void removeItem(WorkspaceItemInfo item, boolean animate) {
|
||||||
mInfo.remove(item, animate);
|
mInfo.remove(item, animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
mOpenAlarm.setOnAlarmListener(mOnOpenListener);
|
mOpenAlarm.setOnAlarmListener(mOnOpenListener);
|
||||||
if (SPRING_LOADING_ENABLED &&
|
if (SPRING_LOADING_ENABLED &&
|
||||||
((dragInfo instanceof AppInfo)
|
((dragInfo instanceof AppInfo)
|
||||||
|| (dragInfo instanceof ShortcutInfo)
|
|| (dragInfo instanceof WorkspaceItemInfo)
|
||||||
|| (dragInfo instanceof PendingAddShortcutInfo))) {
|
|| (dragInfo instanceof PendingAddShortcutInfo))) {
|
||||||
mOpenAlarm.setAlarm(ON_OPEN_DELAY);
|
mOpenAlarm.setAlarm(ON_OPEN_DELAY);
|
||||||
}
|
}
|
||||||
|
@ -264,8 +264,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
return mPreviewItemManager.prepareCreateAnimation(destView);
|
return mPreviewItemManager.prepareCreateAnimation(destView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performCreateAnimation(final ShortcutInfo destInfo, final View destView,
|
public void performCreateAnimation(final WorkspaceItemInfo destInfo, final View destView,
|
||||||
final ShortcutInfo srcInfo, final DragView srcView, Rect dstRect,
|
final WorkspaceItemInfo srcInfo, final DragView srcView, Rect dstRect,
|
||||||
float scaleRelativeToDragLayer) {
|
float scaleRelativeToDragLayer) {
|
||||||
prepareCreateAnimation(destView);
|
prepareCreateAnimation(destView);
|
||||||
addItem(destInfo);
|
addItem(destInfo);
|
||||||
|
@ -290,7 +290,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
mOpenAlarm.cancelAlarm();
|
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,
|
float scaleRelativeToDragLayer, int index,
|
||||||
boolean itemReturnedOnFailedDrop) {
|
boolean itemReturnedOnFailedDrop) {
|
||||||
item.cellX = -1;
|
item.cellX = -1;
|
||||||
|
@ -382,15 +382,15 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) {
|
public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) {
|
||||||
ShortcutInfo item;
|
WorkspaceItemInfo item;
|
||||||
if (d.dragInfo instanceof AppInfo) {
|
if (d.dragInfo instanceof AppInfo) {
|
||||||
// Came from all apps -- make a copy
|
// Came from all apps -- make a copy
|
||||||
item = ((AppInfo) d.dragInfo).makeShortcut();
|
item = ((AppInfo) d.dragInfo).makeWorkspaceItem();
|
||||||
} else if (d.dragSource instanceof BaseItemDragListener){
|
} else if (d.dragSource instanceof BaseItemDragListener){
|
||||||
// Came from a different window -- make a copy
|
// Came from a different window -- make a copy
|
||||||
item = new ShortcutInfo((ShortcutInfo) d.dragInfo);
|
item = new WorkspaceItemInfo((WorkspaceItemInfo) d.dragInfo);
|
||||||
} else {
|
} else {
|
||||||
item = (ShortcutInfo) d.dragInfo;
|
item = (WorkspaceItemInfo) d.dragInfo;
|
||||||
}
|
}
|
||||||
mFolder.notifyDrop();
|
mFolder.notifyDrop();
|
||||||
onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(),
|
onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(),
|
||||||
|
@ -581,7 +581,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAdd(ShortcutInfo item, int rank) {
|
public void onAdd(WorkspaceItemInfo item, int rank) {
|
||||||
boolean wasDotted = mDotInfo.hasDot();
|
boolean wasDotted = mDotInfo.hasDot();
|
||||||
mDotInfo.addDotInfo(mLauncher.getDotInfoForItem(item));
|
mDotInfo.addDotInfo(mLauncher.getDotInfoForItem(item));
|
||||||
boolean isDotted = mDotInfo.hasDot();
|
boolean isDotted = mDotInfo.hasDot();
|
||||||
|
@ -591,7 +591,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove(ShortcutInfo item) {
|
public void onRemove(WorkspaceItemInfo item) {
|
||||||
boolean wasDotted = mDotInfo.hasDot();
|
boolean wasDotted = mDotInfo.hasDot();
|
||||||
mDotInfo.subtractDotInfo(mLauncher.getDotInfoForItem(item));
|
mDotInfo.subtractDotInfo(mLauncher.getDotInfoForItem(item));
|
||||||
boolean isDotted = mDotInfo.hasDot();
|
boolean isDotted = mDotInfo.hasDot();
|
||||||
|
|
|
@ -38,7 +38,7 @@ import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.PagedView;
|
import com.android.launcher3.PagedView;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutAndWidgetContainer;
|
import com.android.launcher3.ShortcutAndWidgetContainer;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.Workspace.ItemOperator;
|
import com.android.launcher3.Workspace.ItemOperator;
|
||||||
import com.android.launcher3.anim.Interpolators;
|
import com.android.launcher3.anim.Interpolators;
|
||||||
|
@ -178,9 +178,9 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
||||||
/**
|
/**
|
||||||
* Binds items to the layout.
|
* Binds items to the layout.
|
||||||
*/
|
*/
|
||||||
public void bindItems(ArrayList<ShortcutInfo> items) {
|
public void bindItems(ArrayList<WorkspaceItemInfo> items) {
|
||||||
ArrayList<View> icons = new ArrayList<>();
|
ArrayList<View> icons = new ArrayList<>();
|
||||||
for (ShortcutInfo item : items) {
|
for (WorkspaceItemInfo item : items) {
|
||||||
icons.add(createNewView(item));
|
icons.add(createNewView(item));
|
||||||
}
|
}
|
||||||
arrangeChildren(icons, icons.size(), false);
|
arrangeChildren(icons, icons.size(), false);
|
||||||
|
@ -203,7 +203,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
||||||
return rank;
|
return rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View createAndAddViewForRank(ShortcutInfo item, int rank) {
|
public View createAndAddViewForRank(WorkspaceItemInfo item, int rank) {
|
||||||
View icon = createNewView(item);
|
View icon = createNewView(item);
|
||||||
allocateSpaceForRank(rank);
|
allocateSpaceForRank(rank);
|
||||||
addViewForRank(icon, item, 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
|
* 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.
|
* 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 pagePos = rank % mMaxItemsPerPage;
|
||||||
int pageNo = rank / mMaxItemsPerPage;
|
int pageNo = rank / mMaxItemsPerPage;
|
||||||
|
|
||||||
|
@ -229,10 +229,10 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
public View createNewView(ShortcutInfo item) {
|
public View createNewView(WorkspaceItemInfo item) {
|
||||||
final BubbleTextView textView = (BubbleTextView) mInflater.inflate(
|
final BubbleTextView textView = (BubbleTextView) mInflater.inflate(
|
||||||
R.layout.folder_application, null, false);
|
R.layout.folder_application, null, false);
|
||||||
textView.applyFromShortcutInfo(item);
|
textView.applyFromWorkspaceItem(item);
|
||||||
textView.setHapticFeedbackEnabled(false);
|
textView.setHapticFeedbackEnabled(false);
|
||||||
textView.setOnClickListener(ItemClickHandler.INSTANCE);
|
textView.setOnClickListener(ItemClickHandler.INSTANCE);
|
||||||
textView.setOnLongClickListener(mFolder);
|
textView.setOnLongClickListener(mFolder);
|
||||||
|
@ -631,7 +631,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
if (pageToAnimate != p) {
|
if (pageToAnimate != p) {
|
||||||
page.removeView(v);
|
page.removeView(v);
|
||||||
addViewForRank(v, (ShortcutInfo) v.getTag(), moveStart);
|
addViewForRank(v, (WorkspaceItemInfo) v.getTag(), moveStart);
|
||||||
} else {
|
} else {
|
||||||
// Do a fake animation before removing it.
|
// Do a fake animation before removing it.
|
||||||
final int newRank = moveStart;
|
final int newRank = moveStart;
|
||||||
|
@ -644,7 +644,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> {
|
||||||
mPendingAnimations.remove(v);
|
mPendingAnimations.remove(v);
|
||||||
v.setTranslationX(oldTranslateX);
|
v.setTranslationX(oldTranslateX);
|
||||||
((CellLayout) v.getParent().getParent()).removeView(v);
|
((CellLayout) v.getParent().getParent()).removeView(v);
|
||||||
addViewForRank(v, (ShortcutInfo) v.getTag(), newRank);
|
addViewForRank(v, (WorkspaceItemInfo) v.getTag(), newRank);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
v.animate()
|
v.animate()
|
||||||
|
|
|
@ -31,7 +31,7 @@ import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.launcher3.BubbleTextView;
|
import com.android.launcher3.BubbleTextView;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -301,7 +301,7 @@ public class PreviewItemManager {
|
||||||
* @param dropped The item that was dropped onto the FolderIcon.
|
* @param dropped The item that was dropped onto the FolderIcon.
|
||||||
*/
|
*/
|
||||||
public void onDrop(List<BubbleTextView> oldParams, List<BubbleTextView> newParams,
|
public void onDrop(List<BubbleTextView> oldParams, List<BubbleTextView> newParams,
|
||||||
ShortcutInfo dropped) {
|
WorkspaceItemInfo dropped) {
|
||||||
int numItems = newParams.size();
|
int numItems = newParams.size();
|
||||||
final ArrayList<PreviewItemDrawingParams> params = mFirstPageParams;
|
final ArrayList<PreviewItemDrawingParams> params = mFirstPageParams;
|
||||||
buildParamsForPage(0, params, false);
|
buildParamsForPage(0, params, false);
|
||||||
|
|
|
@ -21,7 +21,6 @@ import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.WallpaperManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
@ -30,7 +29,6 @@ import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.AdaptiveIconDrawable;
|
import android.graphics.drawable.AdaptiveIconDrawable;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -52,7 +50,7 @@ import com.android.launcher3.InsettableFrameLayout;
|
||||||
import com.android.launcher3.InvariantDeviceProfile;
|
import com.android.launcher3.InvariantDeviceProfile;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
import com.android.launcher3.LauncherSettings.Favorites;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.WorkspaceLayoutManager;
|
import com.android.launcher3.WorkspaceLayoutManager;
|
||||||
import com.android.launcher3.allapps.SearchUiManager;
|
import com.android.launcher3.allapps.SearchUiManager;
|
||||||
|
@ -85,7 +83,7 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
|
||||||
private final DeviceProfile mDp;
|
private final DeviceProfile mDp;
|
||||||
private final Rect mInsets;
|
private final Rect mInsets;
|
||||||
|
|
||||||
private final ShortcutInfo mShortcutInfo;
|
private final WorkspaceItemInfo mWorkspaceItemInfo;
|
||||||
|
|
||||||
public LauncherPreviewRenderer(Context context, InvariantDeviceProfile idp) {
|
public LauncherPreviewRenderer(Context context, InvariantDeviceProfile idp) {
|
||||||
mUiHandler = new Handler(Looper.getMainLooper());
|
mUiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
@ -106,10 +104,10 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
|
||||||
Process.myUserHandle(),
|
Process.myUserHandle(),
|
||||||
Build.VERSION.SDK_INT);
|
Build.VERSION.SDK_INT);
|
||||||
|
|
||||||
mShortcutInfo = new ShortcutInfo();
|
mWorkspaceItemInfo = new WorkspaceItemInfo();
|
||||||
mShortcutInfo.applyFrom(iconInfo);
|
mWorkspaceItemInfo.applyFrom(iconInfo);
|
||||||
mShortcutInfo.intent = new Intent();
|
mWorkspaceItemInfo.intent = new Intent();
|
||||||
mShortcutInfo.contentDescription = mShortcutInfo.title =
|
mWorkspaceItemInfo.contentDescription = mWorkspaceItemInfo.title =
|
||||||
context.getString(R.string.label_application);
|
context.getString(R.string.label_application);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,10 +215,10 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
|
||||||
return mWorkspace;
|
return mWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inflateAndAddIcon(ShortcutInfo info) {
|
private void inflateAndAddIcon(WorkspaceItemInfo info) {
|
||||||
BubbleTextView icon = (BubbleTextView) mHomeElementInflater.inflate(
|
BubbleTextView icon = (BubbleTextView) mHomeElementInflater.inflate(
|
||||||
R.layout.app_icon, mWorkspace, false);
|
R.layout.app_icon, mWorkspace, false);
|
||||||
icon.applyFromShortcutInfo(info);
|
icon.applyFromWorkspaceItem(info);
|
||||||
addInScreenFromBind(icon, info);
|
addInScreenFromBind(icon, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +243,7 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
|
||||||
private void renderScreenShot(Canvas canvas) {
|
private void renderScreenShot(Canvas canvas) {
|
||||||
// Add hotseat icons
|
// Add hotseat icons
|
||||||
for (int i = 0; i < mIdp.numHotseatIcons; i++) {
|
for (int i = 0; i < mIdp.numHotseatIcons; i++) {
|
||||||
ShortcutInfo info = new ShortcutInfo(mShortcutInfo);
|
WorkspaceItemInfo info = new WorkspaceItemInfo(mWorkspaceItemInfo);
|
||||||
info.container = Favorites.CONTAINER_HOTSEAT;
|
info.container = Favorites.CONTAINER_HOTSEAT;
|
||||||
info.screenId = i;
|
info.screenId = i;
|
||||||
inflateAndAddIcon(info);
|
inflateAndAddIcon(info);
|
||||||
|
@ -253,7 +251,7 @@ public class LauncherPreviewRenderer implements Callable<Bitmap> {
|
||||||
|
|
||||||
// Add workspace icons
|
// Add workspace icons
|
||||||
for (int i = 0; i < mIdp.numColumns; i++) {
|
for (int i = 0; i < mIdp.numColumns; i++) {
|
||||||
ShortcutInfo info = new ShortcutInfo(mShortcutInfo);
|
WorkspaceItemInfo info = new WorkspaceItemInfo(mWorkspaceItemInfo);
|
||||||
info.container = Favorites.CONTAINER_DESKTOP;
|
info.container = Favorites.CONTAINER_DESKTOP;
|
||||||
info.screenId = 0;
|
info.screenId = 0;
|
||||||
info.cellX = i;
|
info.cellX = i;
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.android.launcher3.ItemInfoWithIcon;
|
||||||
import com.android.launcher3.LauncherFiles;
|
import com.android.launcher3.LauncherFiles;
|
||||||
import com.android.launcher3.LauncherModel;
|
import com.android.launcher3.LauncherModel;
|
||||||
import com.android.launcher3.MainThreadExecutor;
|
import com.android.launcher3.MainThreadExecutor;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
import com.android.launcher3.compat.UserManagerCompat;
|
import com.android.launcher3.compat.UserManagerCompat;
|
||||||
|
@ -130,7 +130,7 @@ public class IconCache extends BaseIconCache {
|
||||||
IconLoadRequest request = new IconLoadRequest(mWorkerHandler, this::onIconRequestEnd) {
|
IconLoadRequest request = new IconLoadRequest(mWorkerHandler, this::onIconRequestEnd) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (info instanceof AppInfo || info instanceof ShortcutInfo) {
|
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
|
||||||
getTitleAndIcon(info, false);
|
getTitleAndIcon(info, false);
|
||||||
} else if (info instanceof PackageItemInfo) {
|
} else if (info instanceof PackageItemInfo) {
|
||||||
getTitleAndIconForApp((PackageItemInfo) info, false);
|
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(
|
private synchronized void getTitleAndIcon(
|
||||||
@NonNull ItemInfoWithIcon infoInOut,
|
@NonNull ItemInfoWithIcon infoInOut,
|
||||||
|
|
|
@ -30,7 +30,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherModel.CallbackTask;
|
import com.android.launcher3.LauncherModel.CallbackTask;
|
||||||
import com.android.launcher3.LauncherModel.Callbacks;
|
import com.android.launcher3.LauncherModel.Callbacks;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.util.GridOccupancy;
|
import com.android.launcher3.util.GridOccupancy;
|
||||||
import com.android.launcher3.util.IntArray;
|
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.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
|
||||||
if (item instanceof AppInfo) {
|
if (item instanceof AppInfo) {
|
||||||
item = ((AppInfo) item).makeShortcut();
|
item = ((AppInfo) item).makeWorkspaceItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
@ -92,11 +92,11 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||||
int screenId = coords[0];
|
int screenId = coords[0];
|
||||||
|
|
||||||
ItemInfo itemInfo;
|
ItemInfo itemInfo;
|
||||||
if (item instanceof ShortcutInfo || item instanceof FolderInfo ||
|
if (item instanceof WorkspaceItemInfo || item instanceof FolderInfo ||
|
||||||
item instanceof LauncherAppWidgetInfo) {
|
item instanceof LauncherAppWidgetInfo) {
|
||||||
itemInfo = item;
|
itemInfo = item;
|
||||||
} else if (item instanceof AppInfo) {
|
} else if (item instanceof AppInfo) {
|
||||||
itemInfo = ((AppInfo) item).makeShortcut();
|
itemInfo = ((AppInfo) item).makeWorkspaceItem();
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unexpected info type");
|
throw new RuntimeException("Unexpected info type");
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||||
LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId,
|
LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId,
|
||||||
coords[1], coords[2]);
|
coords[1], coords[2]);
|
||||||
|
|
||||||
// Save the ShortcutInfo for binding in the workspace
|
// Save the WorkspaceItemInfo for binding in the workspace
|
||||||
addedItemsFinal.add(itemInfo);
|
addedItemsFinal.add(itemInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,8 +165,8 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||||
boolean isLauncherAppTarget = Utilities.isLauncherAppTarget(intent);
|
boolean isLauncherAppTarget = Utilities.isLauncherAppTarget(intent);
|
||||||
synchronized (dataModel) {
|
synchronized (dataModel) {
|
||||||
for (ItemInfo item : dataModel.itemsIdMap) {
|
for (ItemInfo item : dataModel.itemsIdMap) {
|
||||||
if (item instanceof ShortcutInfo) {
|
if (item instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo info = (ShortcutInfo) item;
|
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
|
||||||
if (item.getIntent() != null && info.user.equals(user)) {
|
if (item.getIntent() != null && info.user.equals(user)) {
|
||||||
Intent copyIntent = new Intent(item.getIntent());
|
Intent copyIntent = new Intent(item.getIntent());
|
||||||
copyIntent.setSourceBounds(intent.getSourceBounds());
|
copyIntent.setSourceBounds(intent.getSourceBounds());
|
||||||
|
@ -178,7 +178,7 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||||
// checking for existing promise icon with same package name
|
// checking for existing promise icon with same package name
|
||||||
if (isLauncherAppTarget
|
if (isLauncherAppTarget
|
||||||
&& info.isPromise()
|
&& info.isPromise()
|
||||||
&& info.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)
|
&& info.hasStatusFlag(WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON)
|
||||||
&& info.getTargetComponent() != null
|
&& info.getTargetComponent() != null
|
||||||
&& compPkgName != null
|
&& compPkgName != null
|
||||||
&& compPkgName.equals(info.getTargetComponent().getPackageName())) {
|
&& compPkgName.equals(info.getTargetComponent().getPackageName())) {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.android.launcher3.model;
|
package com.android.launcher3.model;
|
||||||
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.launcher3.AllAppsList;
|
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.ModelUpdateTask;
|
||||||
import com.android.launcher3.LauncherModel.CallbackTask;
|
import com.android.launcher3.LauncherModel.CallbackTask;
|
||||||
import com.android.launcher3.LauncherModel.Callbacks;
|
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.ComponentKey;
|
||||||
import com.android.launcher3.util.ItemInfoMatcher;
|
import com.android.launcher3.util.ItemInfoMatcher;
|
||||||
import com.android.launcher3.widget.WidgetListRowEntry;
|
import com.android.launcher3.widget.WidgetListRowEntry;
|
||||||
|
@ -94,13 +93,12 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void bindUpdatedShortcuts(
|
public void bindUpdatedWorkspaceItems(final ArrayList<WorkspaceItemInfo> updatedShortcuts) {
|
||||||
final ArrayList<ShortcutInfo> updatedShortcuts, final UserHandle user) {
|
|
||||||
if (!updatedShortcuts.isEmpty()) {
|
if (!updatedShortcuts.isEmpty()) {
|
||||||
scheduleCallbackTask(new CallbackTask() {
|
scheduleCallbackTask(new CallbackTask() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Callbacks callbacks) {
|
public void execute(Callbacks callbacks) {
|
||||||
callbacks.bindShortcutsChanged(updatedShortcuts, user);
|
callbacks.bindWorkspaceItemsChanged(updatedShortcuts);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.android.launcher3.InstallShortcutReceiver;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Workspace;
|
import com.android.launcher3.Workspace;
|
||||||
import com.android.launcher3.config.FeatureFlags;
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
import com.android.launcher3.logging.DumpTargetWrapper;
|
import com.android.launcher3.logging.DumpTargetWrapper;
|
||||||
|
@ -185,7 +185,7 @@ public class BgDataModel {
|
||||||
FolderInfo fInfo = folders.valueAt(i);
|
FolderInfo fInfo = folders.valueAt(i);
|
||||||
dtw = new DumpTargetWrapper(ContainerType.FOLDER, folders.size());
|
dtw = new DumpTargetWrapper(ContainerType.FOLDER, folders.size());
|
||||||
dtw.writeToDumpTarget(fInfo);
|
dtw.writeToDumpTarget(fInfo);
|
||||||
for(ShortcutInfo sInfo: fInfo.contents) {
|
for(WorkspaceItemInfo sInfo: fInfo.contents) {
|
||||||
DumpTargetWrapper child = new DumpTargetWrapper(sInfo);
|
DumpTargetWrapper child = new DumpTargetWrapper(sInfo);
|
||||||
child.writeToDumpTarget(sInfo);
|
child.writeToDumpTarget(sInfo);
|
||||||
dtw.add(child);
|
dtw.add(child);
|
||||||
|
@ -335,7 +335,7 @@ public class BgDataModel {
|
||||||
Log.e(TAG, msg);
|
Log.e(TAG, msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
findOrMakeFolder(item.container).add((ShortcutInfo) item, false);
|
findOrMakeFolder(item.container).add((WorkspaceItemInfo) item, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,13 @@ import android.os.UserHandle;
|
||||||
|
|
||||||
import com.android.launcher3.AllAppsList;
|
import com.android.launcher3.AllAppsList;
|
||||||
import com.android.launcher3.AppInfo;
|
import com.android.launcher3.AppInfo;
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.icons.IconCache;
|
import com.android.launcher3.icons.IconCache;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.LauncherModel.CallbackTask;
|
import com.android.launcher3.LauncherModel.CallbackTask;
|
||||||
import com.android.launcher3.LauncherModel.Callbacks;
|
import com.android.launcher3.LauncherModel.Callbacks;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -55,11 +55,11 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask {
|
||||||
|
|
||||||
final ArrayList<AppInfo> updatedApps = new ArrayList<>();
|
final ArrayList<AppInfo> updatedApps = new ArrayList<>();
|
||||||
|
|
||||||
ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
|
ArrayList<WorkspaceItemInfo> updatedShortcuts = new ArrayList<>();
|
||||||
synchronized (dataModel) {
|
synchronized (dataModel) {
|
||||||
for (ItemInfo info : dataModel.itemsIdMap) {
|
for (ItemInfo info : dataModel.itemsIdMap) {
|
||||||
if (info instanceof ShortcutInfo && mUser.equals(info.user)) {
|
if (info instanceof WorkspaceItemInfo && mUser.equals(info.user)) {
|
||||||
ShortcutInfo si = (ShortcutInfo) info;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
|
||||||
ComponentName cn = si.getTargetComponent();
|
ComponentName cn = si.getTargetComponent();
|
||||||
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
|
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
|
||||||
&& isValidShortcut(si) && cn != null
|
&& isValidShortcut(si) && cn != null
|
||||||
|
@ -71,7 +71,7 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask {
|
||||||
}
|
}
|
||||||
apps.updateIconsAndLabels(mPackages, mUser, updatedApps);
|
apps.updateIconsAndLabels(mPackages, mUser, updatedApps);
|
||||||
}
|
}
|
||||||
bindUpdatedShortcuts(updatedShortcuts, mUser);
|
bindUpdatedWorkspaceItems(updatedShortcuts);
|
||||||
|
|
||||||
if (!updatedApps.isEmpty()) {
|
if (!updatedApps.isEmpty()) {
|
||||||
scheduleCallbackTask(new CallbackTask() {
|
scheduleCallbackTask(new CallbackTask() {
|
||||||
|
@ -83,7 +83,7 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidShortcut(ShortcutInfo si) {
|
public boolean isValidShortcut(WorkspaceItemInfo si) {
|
||||||
switch (mOp) {
|
switch (mOp) {
|
||||||
case OP_CACHE_UPDATE:
|
case OP_CACHE_UPDATE:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -33,12 +33,12 @@ import android.util.Log;
|
||||||
import android.util.LongSparseArray;
|
import android.util.LongSparseArray;
|
||||||
|
|
||||||
import com.android.launcher3.AppInfo;
|
import com.android.launcher3.AppInfo;
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.icons.IconCache;
|
import com.android.launcher3.icons.IconCache;
|
||||||
import com.android.launcher3.InvariantDeviceProfile;
|
import com.android.launcher3.InvariantDeviceProfile;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.Workspace;
|
import com.android.launcher3.Workspace;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
|
@ -145,8 +145,8 @@ public class LoaderCursor extends CursorWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutInfo loadSimpleShortcut() {
|
public WorkspaceItemInfo loadSimpleWorkspaceItem() {
|
||||||
final ShortcutInfo info = new ShortcutInfo();
|
final WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
// Non-app shortcuts are only supported for current user.
|
// Non-app shortcuts are only supported for current user.
|
||||||
info.user = user;
|
info.user = user;
|
||||||
info.itemType = itemType;
|
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.
|
* 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)) {
|
try (LauncherIcons li = LauncherIcons.obtain(mContext)) {
|
||||||
return loadIcon(info, li);
|
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.
|
* 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) {
|
if (itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
|
||||||
String packageName = getString(iconPackageIndex);
|
String packageName = getString(iconPackageIndex);
|
||||||
String resourceName = getString(iconResourceIndex);
|
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.
|
* to a package that is not yet installed on the system.
|
||||||
*/
|
*/
|
||||||
public ShortcutInfo getRestoredItemInfo(Intent intent) {
|
public WorkspaceItemInfo getRestoredItemInfo(Intent intent) {
|
||||||
final ShortcutInfo info = new ShortcutInfo();
|
final WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
info.user = user;
|
info.user = user;
|
||||||
info.intent = intent;
|
info.intent = intent;
|
||||||
|
|
||||||
|
@ -222,12 +222,12 @@ public class LoaderCursor extends CursorWrapper {
|
||||||
mIconCache.getTitleAndIcon(info, false /* useLowResIcon */);
|
mIconCache.getTitleAndIcon(info, false /* useLowResIcon */);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRestoreFlag(ShortcutInfo.FLAG_RESTORED_ICON)) {
|
if (hasRestoreFlag(WorkspaceItemInfo.FLAG_RESTORED_ICON)) {
|
||||||
String title = getTitle();
|
String title = getTitle();
|
||||||
if (!TextUtils.isEmpty(title)) {
|
if (!TextUtils.isEmpty(title)) {
|
||||||
info.title = Utilities.trim(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)) {
|
if (TextUtils.isEmpty(info.title)) {
|
||||||
info.title = getTitle();
|
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) {
|
Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
Log.d(TAG, "Null user found in getShortcutInfo");
|
Log.d(TAG, "Null user found in getShortcutInfo");
|
||||||
|
@ -267,7 +267,7 @@ public class LoaderCursor extends CursorWrapper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ShortcutInfo info = new ShortcutInfo();
|
final WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||||
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||||
info.user = user;
|
info.user = user;
|
||||||
info.intent = newIntent;
|
info.intent = newIntent;
|
||||||
|
|
|
@ -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_LOCKED_USER;
|
||||||
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE;
|
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE;
|
||||||
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED;
|
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 static com.android.launcher3.model.LoaderResults.filterCurrentWorkspaceItems;
|
||||||
|
|
||||||
import android.appwidget.AppWidgetProviderInfo;
|
import android.appwidget.AppWidgetProviderInfo;
|
||||||
|
@ -49,7 +48,7 @@ import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherModel;
|
import com.android.launcher3.LauncherModel;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
|
@ -335,7 +334,7 @@ public class LoaderTask implements Runnable {
|
||||||
unlockedUsers.put(serialNo, userUnlocked);
|
unlockedUsers.put(serialNo, userUnlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortcutInfo info;
|
WorkspaceItemInfo info;
|
||||||
LauncherAppWidgetInfo appWidgetInfo;
|
LauncherAppWidgetInfo appWidgetInfo;
|
||||||
Intent intent;
|
Intent intent;
|
||||||
String targetPkg;
|
String targetPkg;
|
||||||
|
@ -360,7 +359,7 @@ public class LoaderTask implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
int disabledState = quietMode.get(c.serialNumber) ?
|
int disabledState = quietMode.get(c.serialNumber) ?
|
||||||
ShortcutInfo.FLAG_DISABLED_QUIET_USER : 0;
|
WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER : 0;
|
||||||
ComponentName cn = intent.getComponent();
|
ComponentName cn = intent.getComponent();
|
||||||
targetPkg = cn == null ? intent.getPackage() : cn.getPackageName();
|
targetPkg = cn == null ? intent.getPackage() : cn.getPackageName();
|
||||||
|
|
||||||
|
@ -420,11 +419,11 @@ public class LoaderTask implements Runnable {
|
||||||
// installed later.
|
// installed later.
|
||||||
FileLog.d(TAG, "package not yet restored: " + targetPkg);
|
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.
|
// Restore has started once.
|
||||||
} else if (installingPkgs.containsKey(targetPkg)) {
|
} else if (installingPkgs.containsKey(targetPkg)) {
|
||||||
// App restore has started. Update the flag
|
// 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.updater().put(LauncherSettings.Favorites.RESTORED,
|
||||||
c.restoreFlag).commit();
|
c.restoreFlag).commit();
|
||||||
} else {
|
} else {
|
||||||
|
@ -433,7 +432,7 @@ public class LoaderTask implements Runnable {
|
||||||
}
|
}
|
||||||
} else if (pmHelper.isAppOnSdcard(targetPkg, c.user)) {
|
} else if (pmHelper.isAppOnSdcard(targetPkg, c.user)) {
|
||||||
// Package is present but not available.
|
// 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.
|
// Add the icon on the workspace anyway.
|
||||||
allowMissingTarget = true;
|
allowMissingTarget = true;
|
||||||
} else if (!isSdCardReady) {
|
} 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;
|
validTarget = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,8 +480,8 @@ public class LoaderTask implements Runnable {
|
||||||
c.markDeleted("Pinned shortcut not found");
|
c.markDeleted("Pinned shortcut not found");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
info = new ShortcutInfo(pinnedShortcut, context);
|
info = new WorkspaceItemInfo(pinnedShortcut, context);
|
||||||
final ShortcutInfo finalInfo = info;
|
final WorkspaceItemInfo finalInfo = info;
|
||||||
|
|
||||||
LauncherIcons li = LauncherIcons.obtain(context);
|
LauncherIcons li = LauncherIcons.obtain(context);
|
||||||
// If the pinned deep shortcut is no longer published,
|
// If the pinned deep shortcut is no longer published,
|
||||||
|
@ -499,11 +498,11 @@ public class LoaderTask implements Runnable {
|
||||||
intent = info.intent;
|
intent = info.intent;
|
||||||
} else {
|
} else {
|
||||||
// Create a shortcut info in disabled mode for now.
|
// Create a shortcut info in disabled mode for now.
|
||||||
info = c.loadSimpleShortcut();
|
info = c.loadSimpleWorkspaceItem();
|
||||||
info.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
|
info.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
|
||||||
}
|
}
|
||||||
} else { // item type == ITEM_TYPE_SHORTCUT
|
} else { // item type == ITEM_TYPE_SHORTCUT
|
||||||
info = c.loadSimpleShortcut();
|
info = c.loadSimpleWorkspaceItem();
|
||||||
|
|
||||||
// Shortcuts are only available on the primary profile
|
// Shortcuts are only available on the primary profile
|
||||||
if (!TextUtils.isEmpty(targetPkg)
|
if (!TextUtils.isEmpty(targetPkg)
|
||||||
|
@ -539,7 +538,7 @@ public class LoaderTask implements Runnable {
|
||||||
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
|
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
|
||||||
SessionInfo si = installingPkgs.get(targetPkg);
|
SessionInfo si = installingPkgs.get(targetPkg);
|
||||||
if (si == null) {
|
if (si == null) {
|
||||||
info.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
|
info.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
|
||||||
} else {
|
} else {
|
||||||
info.setInstallProgress((int) (si.getProgress() * 100));
|
info.setInstallProgress((int) (si.getProgress() * 100));
|
||||||
}
|
}
|
||||||
|
@ -547,7 +546,7 @@ public class LoaderTask implements Runnable {
|
||||||
|
|
||||||
c.checkAndAddItem(info, mBgDataModel);
|
c.checkAndAddItem(info, mBgDataModel);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unexpected null ShortcutInfo");
|
throw new RuntimeException("Unexpected null WorkspaceItemInfo");
|
||||||
}
|
}
|
||||||
break;
|
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
|
// 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 now. Database will be updated once user manually modifies folder.
|
||||||
for (int rank = 0; rank < size; ++rank) {
|
for (int rank = 0; rank < size; ++rank) {
|
||||||
ShortcutInfo info = folder.contents.get(rank);
|
WorkspaceItemInfo info = folder.contents.get(rank);
|
||||||
info.rank = rank;
|
info.rank = rank;
|
||||||
|
|
||||||
if (info.usingLowResIcon()
|
if (info.usingLowResIcon()
|
||||||
|
@ -782,8 +781,8 @@ public class LoaderTask implements Runnable {
|
||||||
HashSet<String> packagesToIgnore = new HashSet<>();
|
HashSet<String> packagesToIgnore = new HashSet<>();
|
||||||
synchronized (mBgDataModel) {
|
synchronized (mBgDataModel) {
|
||||||
for (ItemInfo info : mBgDataModel.itemsIdMap) {
|
for (ItemInfo info : mBgDataModel.itemsIdMap) {
|
||||||
if (info instanceof ShortcutInfo) {
|
if (info instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo si = (ShortcutInfo) info;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
|
||||||
if (si.isPromise() && si.getTargetComponent() != null) {
|
if (si.isPromise() && si.getTargetComponent() != null) {
|
||||||
packagesToIgnore.add(si.getTargetComponent().getPackageName());
|
packagesToIgnore.add(si.getTargetComponent().getPackageName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.android.launcher3.LauncherProvider;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
import com.android.launcher3.LauncherSettings.Favorites;
|
||||||
import com.android.launcher3.LauncherSettings.Settings;
|
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.Utilities;
|
||||||
import com.android.launcher3.config.FeatureFlags;
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
import com.android.launcher3.util.ContentWriter;
|
import com.android.launcher3.util.ContentWriter;
|
||||||
|
@ -114,7 +114,7 @@ public class ModelWriter {
|
||||||
if (modelItem != null && item != modelItem) {
|
if (modelItem != null && item != modelItem) {
|
||||||
// check all the data is consistent
|
// check all the data is consistent
|
||||||
if (!Utilities.IS_DEBUG_DEVICE && !FeatureFlags.IS_DOGFOOD_BUILD &&
|
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()) &&
|
if (modelItem.title.toString().equals(item.title.toString()) &&
|
||||||
modelItem.getIntent().filterEquals(item.getIntent()) &&
|
modelItem.getIntent().filterEquals(item.getIntent()) &&
|
||||||
modelItem.id == item.id &&
|
modelItem.id == item.id &&
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherModel.CallbackTask;
|
import com.android.launcher3.LauncherModel.CallbackTask;
|
||||||
import com.android.launcher3.LauncherModel.Callbacks;
|
import com.android.launcher3.LauncherModel.Callbacks;
|
||||||
import com.android.launcher3.PromiseAppInfo;
|
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;
|
||||||
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
|
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
|
||||||
import com.android.launcher3.util.InstantAppResolver;
|
import com.android.launcher3.util.InstantAppResolver;
|
||||||
|
@ -106,15 +106,15 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask {
|
||||||
synchronized (dataModel) {
|
synchronized (dataModel) {
|
||||||
final HashSet<ItemInfo> updates = new HashSet<>();
|
final HashSet<ItemInfo> updates = new HashSet<>();
|
||||||
for (ItemInfo info : dataModel.itemsIdMap) {
|
for (ItemInfo info : dataModel.itemsIdMap) {
|
||||||
if (info instanceof ShortcutInfo) {
|
if (info instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo si = (ShortcutInfo) info;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
|
||||||
ComponentName cn = si.getTargetComponent();
|
ComponentName cn = si.getTargetComponent();
|
||||||
if (si.hasPromiseIconUi() && (cn != null)
|
if (si.hasPromiseIconUi() && (cn != null)
|
||||||
&& mInstallInfo.packageName.equals(cn.getPackageName())) {
|
&& mInstallInfo.packageName.equals(cn.getPackageName())) {
|
||||||
si.setInstallProgress(mInstallInfo.progress);
|
si.setInstallProgress(mInstallInfo.progress);
|
||||||
if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED) {
|
if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED) {
|
||||||
// Mark this info as broken.
|
// Mark this info as broken.
|
||||||
si.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
|
si.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
|
||||||
}
|
}
|
||||||
updates.add(si);
|
updates.add(si);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.android.launcher3.AllAppsList;
|
import com.android.launcher3.AllAppsList;
|
||||||
import com.android.launcher3.AppInfo;
|
import com.android.launcher3.AppInfo;
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.icons.IconCache;
|
import com.android.launcher3.icons.IconCache;
|
||||||
import com.android.launcher3.InstallShortcutReceiver;
|
import com.android.launcher3.InstallShortcutReceiver;
|
||||||
import com.android.launcher3.ItemInfo;
|
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.LauncherModel.Callbacks;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
import com.android.launcher3.LauncherSettings.Favorites;
|
||||||
import com.android.launcher3.SessionCommitReceiver;
|
import com.android.launcher3.SessionCommitReceiver;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
import com.android.launcher3.compat.UserManagerCompat;
|
import com.android.launcher3.compat.UserManagerCompat;
|
||||||
|
@ -108,7 +108,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
SessionCommitReceiver.queueAppIconAddition(context, packages[i], mUser);
|
SessionCommitReceiver.queueAppIconAddition(context, packages[i], mUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flagOp = FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_UPDATE:
|
case OP_UPDATE:
|
||||||
|
@ -119,7 +119,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
app.getWidgetCache().removePackage(packages[i], mUser);
|
app.getWidgetCache().removePackage(packages[i], mUser);
|
||||||
}
|
}
|
||||||
// Since package was just updated, the target must be available now.
|
// 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;
|
break;
|
||||||
case OP_REMOVE: {
|
case OP_REMOVE: {
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
|
@ -133,20 +133,20 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
appsList.removePackage(packages[i], mUser);
|
appsList.removePackage(packages[i], mUser);
|
||||||
app.getWidgetCache().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;
|
break;
|
||||||
case OP_SUSPEND:
|
case OP_SUSPEND:
|
||||||
case OP_UNSUSPEND:
|
case OP_UNSUSPEND:
|
||||||
flagOp = mOp == OP_SUSPEND ?
|
flagOp = mOp == OP_SUSPEND ?
|
||||||
FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_SUSPENDED) :
|
FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED) :
|
||||||
FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_SUSPENDED);
|
FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED);
|
||||||
if (DEBUG) Log.d(TAG, "mAllAppsList.(un)suspend " + N);
|
if (DEBUG) Log.d(TAG, "mAllAppsList.(un)suspend " + N);
|
||||||
appsList.updateDisabledFlags(matcher, flagOp);
|
appsList.updateDisabledFlags(matcher, flagOp);
|
||||||
break;
|
break;
|
||||||
case OP_USER_AVAILABILITY_CHANGE:
|
case OP_USER_AVAILABILITY_CHANGE:
|
||||||
flagOp = UserManagerCompat.getInstance(context).isQuietModeEnabled(mUser)
|
flagOp = UserManagerCompat.getInstance(context).isQuietModeEnabled(mUser)
|
||||||
? FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_QUIET_USER)
|
? FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER)
|
||||||
: FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_QUIET_USER);
|
: FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER);
|
||||||
// We want to update all packages for this user.
|
// We want to update all packages for this user.
|
||||||
matcher = ItemInfoMatcher.ofUser(mUser);
|
matcher = ItemInfoMatcher.ofUser(mUser);
|
||||||
appsList.updateDisabledFlags(matcher, flagOp);
|
appsList.updateDisabledFlags(matcher, flagOp);
|
||||||
|
@ -175,15 +175,15 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
|
|
||||||
// Update shortcut infos
|
// Update shortcut infos
|
||||||
if (mOp == OP_ADD || flagOp != FlagOp.NO_OP) {
|
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<>();
|
final ArrayList<LauncherAppWidgetInfo> widgets = new ArrayList<>();
|
||||||
|
|
||||||
// For system apps, package manager send OP_UPDATE when an app is enabled.
|
// For system apps, package manager send OP_UPDATE when an app is enabled.
|
||||||
final boolean isNewApkAvailable = mOp == OP_ADD || mOp == OP_UPDATE;
|
final boolean isNewApkAvailable = mOp == OP_ADD || mOp == OP_UPDATE;
|
||||||
synchronized (dataModel) {
|
synchronized (dataModel) {
|
||||||
for (ItemInfo info : dataModel.itemsIdMap) {
|
for (ItemInfo info : dataModel.itemsIdMap) {
|
||||||
if (info instanceof ShortcutInfo && mUser.equals(info.user)) {
|
if (info instanceof WorkspaceItemInfo && mUser.equals(info.user)) {
|
||||||
ShortcutInfo si = (ShortcutInfo) info;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
|
||||||
boolean infoUpdated = false;
|
boolean infoUpdated = false;
|
||||||
boolean shortcutUpdated = false;
|
boolean shortcutUpdated = false;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
if (cn != null && matcher.matches(si, cn)) {
|
if (cn != null && matcher.matches(si, cn)) {
|
||||||
String packageName = cn.getPackageName();
|
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);
|
removedShortcuts.put(si.id, false);
|
||||||
if (mOp == OP_REMOVE) {
|
if (mOp == OP_REMOVE) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -227,9 +227,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
isTargetValid = LauncherAppsCompat.getInstance(context)
|
isTargetValid = LauncherAppsCompat.getInstance(context)
|
||||||
.isActivityEnabledForProfile(cn, mUser);
|
.isActivityEnabledForProfile(cn, mUser);
|
||||||
}
|
}
|
||||||
if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)
|
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON)
|
||||||
&& !isTargetValid) {
|
&& !isTargetValid) {
|
||||||
if (updateShortcutIntent(context, si, packageName)) {
|
if (updateWorkspaceItemIntent(context, si, packageName)) {
|
||||||
infoUpdated = true;
|
infoUpdated = true;
|
||||||
} else if (si.hasPromiseIconUi()) {
|
} else if (si.hasPromiseIconUi()) {
|
||||||
removedShortcuts.put(si.id, true);
|
removedShortcuts.put(si.id, true);
|
||||||
|
@ -241,11 +241,11 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
+ si.intent);
|
+ si.intent);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
si.status = ShortcutInfo.DEFAULT;
|
si.status = WorkspaceItemInfo.DEFAULT;
|
||||||
infoUpdated = true;
|
infoUpdated = true;
|
||||||
}
|
}
|
||||||
} else if (isNewApkAvailable && removedComponents.contains(cn)) {
|
} else if (isNewApkAvailable && removedComponents.contains(cn)) {
|
||||||
if (updateShortcutIntent(context, si, packageName)) {
|
if (updateWorkspaceItemIntent(context, si, packageName)) {
|
||||||
infoUpdated = true;
|
infoUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (infoUpdated || shortcutUpdated) {
|
if (infoUpdated || shortcutUpdated) {
|
||||||
updatedShortcuts.add(si);
|
updatedWorkspaceItems.add(si);
|
||||||
}
|
}
|
||||||
if (infoUpdated) {
|
if (infoUpdated) {
|
||||||
getModelWriter().updateItemInDatabase(si);
|
getModelWriter().updateItemInDatabase(si);
|
||||||
|
@ -290,7 +290,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bindUpdatedShortcuts(updatedShortcuts, mUser);
|
bindUpdatedWorkspaceItems(updatedWorkspaceItems);
|
||||||
if (!removedShortcuts.isEmpty()) {
|
if (!removedShortcuts.isEmpty()) {
|
||||||
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofItemIds(removedShortcuts, false));
|
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.
|
* Updates {@param si}'s intent to point to a new ComponentName.
|
||||||
* @return Whether the shortcut intent was changed.
|
* @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.
|
// Try to find the best match activity.
|
||||||
Intent intent = new PackageManagerHelper(context).getAppLaunchIntent(packageName, mUser);
|
Intent intent = new PackageManagerHelper(context).getAppLaunchIntent(packageName, mUser);
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
si.intent = intent;
|
si.intent = intent;
|
||||||
si.status = ShortcutInfo.DEFAULT;
|
si.status = WorkspaceItemInfo.DEFAULT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import com.android.launcher3.AllAppsList;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.LauncherSettings;
|
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.icons.LauncherIcons;
|
||||||
import com.android.launcher3.shortcuts.DeepShortcutManager;
|
import com.android.launcher3.shortcuts.DeepShortcutManager;
|
||||||
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
||||||
|
@ -58,14 +58,14 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
|
||||||
DeepShortcutManager deepShortcutManager = DeepShortcutManager.getInstance(context);
|
DeepShortcutManager deepShortcutManager = DeepShortcutManager.getInstance(context);
|
||||||
deepShortcutManager.onShortcutsChanged(mShortcuts);
|
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<>();
|
HashSet<ShortcutKey> removedKeys = new HashSet<>();
|
||||||
MultiHashMap<ShortcutKey, ShortcutInfo> keyToShortcutInfo = new MultiHashMap<>();
|
MultiHashMap<ShortcutKey, WorkspaceItemInfo> keyToShortcutInfo = new MultiHashMap<>();
|
||||||
HashSet<String> allIds = new HashSet<>();
|
HashSet<String> allIds = new HashSet<>();
|
||||||
|
|
||||||
for (ItemInfo itemInfo : dataModel.itemsIdMap) {
|
for (ItemInfo itemInfo : dataModel.itemsIdMap) {
|
||||||
if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
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)) {
|
if (si.getIntent().getPackage().equals(mPackageName) && si.user.equals(mUser)) {
|
||||||
keyToShortcutInfo.addToList(ShortcutKey.fromItemInfo(si), si);
|
keyToShortcutInfo.addToList(ShortcutKey.fromItemInfo(si), si);
|
||||||
allIds.add(si.getDeepShortcutId());
|
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()) {
|
if (!keyToShortcutInfo.isEmpty()) {
|
||||||
// Update the workspace to reflect the changes to updated shortcuts residing on it.
|
// Update the workspace to reflect the changes to updated shortcuts residing on it.
|
||||||
List<ShortcutInfoCompat> shortcuts = deepShortcutManager.queryForFullDetails(
|
List<ShortcutInfoCompat> shortcuts = deepShortcutManager.queryForFullDetails(
|
||||||
mPackageName, new ArrayList<>(allIds), mUser);
|
mPackageName, new ArrayList<>(allIds), mUser);
|
||||||
for (ShortcutInfoCompat fullDetails : shortcuts) {
|
for (ShortcutInfoCompat fullDetails : shortcuts) {
|
||||||
ShortcutKey key = ShortcutKey.fromInfo(fullDetails);
|
ShortcutKey key = ShortcutKey.fromInfo(fullDetails);
|
||||||
List<ShortcutInfo> shortcutInfos = keyToShortcutInfo.remove(key);
|
List<WorkspaceItemInfo> workspaceItemInfos = keyToShortcutInfo.remove(key);
|
||||||
if (!fullDetails.isPinned()) {
|
if (!fullDetails.isPinned()) {
|
||||||
// The shortcut was previously pinned but is no longer, so remove it from
|
// The shortcut was previously pinned but is no longer, so remove it from
|
||||||
// the workspace and our pinned shortcut counts.
|
// the workspace and our pinned shortcut counts.
|
||||||
|
@ -90,15 +90,15 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
|
||||||
removedKeys.add(key);
|
removedKeys.add(key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (final ShortcutInfo shortcutInfo : shortcutInfos) {
|
for (final WorkspaceItemInfo workspaceItemInfo : workspaceItemInfos) {
|
||||||
shortcutInfo.updateFromDeepShortcutInfo(fullDetails, context);
|
workspaceItemInfo.updateFromDeepShortcutInfo(fullDetails, context);
|
||||||
// If the shortcut is pinned but no longer has an icon in the system,
|
// 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.
|
// keep the current icon instead of reverting to the default icon.
|
||||||
LauncherIcons li = LauncherIcons.obtain(context);
|
LauncherIcons li = LauncherIcons.obtain(context);
|
||||||
shortcutInfo.applyFrom(li.createShortcutIcon(fullDetails, true,
|
workspaceItemInfo.applyFrom(li.createShortcutIcon(fullDetails, true,
|
||||||
() -> shortcutInfo));
|
() -> workspaceItemInfo));
|
||||||
li.recycle();
|
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.
|
// means they were cleared, so we remove and unpin them now.
|
||||||
removedKeys.addAll(keyToShortcutInfo.keySet());
|
removedKeys.addAll(keyToShortcutInfo.keySet());
|
||||||
|
|
||||||
bindUpdatedShortcuts(updatedShortcutInfos, mUser);
|
bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
|
||||||
if (!keyToShortcutInfo.isEmpty()) {
|
if (!keyToShortcutInfo.isEmpty()) {
|
||||||
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
|
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import com.android.launcher3.AllAppsList;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.LauncherSettings;
|
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.compat.UserManagerCompat;
|
||||||
import com.android.launcher3.icons.LauncherIcons;
|
import com.android.launcher3.icons.LauncherIcons;
|
||||||
import com.android.launcher3.shortcuts.DeepShortcutManager;
|
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.
|
// 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<>();
|
HashSet<ShortcutKey> removedKeys = new HashSet<>();
|
||||||
|
|
||||||
for (ItemInfo itemInfo : dataModel.itemsIdMap) {
|
for (ItemInfo itemInfo : dataModel.itemsIdMap) {
|
||||||
if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
|
if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
|
||||||
&& mUser.equals(itemInfo.user)) {
|
&& mUser.equals(itemInfo.user)) {
|
||||||
ShortcutInfo si = (ShortcutInfo) itemInfo;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) itemInfo;
|
||||||
if (isUserUnlocked) {
|
if (isUserUnlocked) {
|
||||||
ShortcutKey key = ShortcutKey.fromItemInfo(si);
|
ShortcutKey key = ShortcutKey.fromItemInfo(si);
|
||||||
ShortcutInfoCompat shortcut = pinnedShortcuts.get(key);
|
ShortcutInfoCompat shortcut = pinnedShortcuts.get(key);
|
||||||
|
@ -99,10 +99,10 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
|
||||||
} else {
|
} else {
|
||||||
si.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
|
si.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
|
||||||
}
|
}
|
||||||
updatedShortcutInfos.add(si);
|
updatedWorkspaceItemInfos.add(si);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bindUpdatedShortcuts(updatedShortcutInfos, mUser);
|
bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
|
||||||
if (!removedKeys.isEmpty()) {
|
if (!removedKeys.isEmpty()) {
|
||||||
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
|
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import android.service.notification.StatusBarNotification;
|
||||||
|
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.Launcher;
|
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.icons.LauncherIcons;
|
||||||
import com.android.launcher3.notification.NotificationInfo;
|
import com.android.launcher3.notification.NotificationInfo;
|
||||||
import com.android.launcher3.notification.NotificationKeyData;
|
import com.android.launcher3.notification.NotificationKeyData;
|
||||||
|
@ -147,7 +147,7 @@ public class PopupPopulator {
|
||||||
shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
|
shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
|
||||||
for (int i = 0; i < shortcuts.size() && i < shortcutViews.size(); i++) {
|
for (int i = 0; i < shortcuts.size() && i < shortcutViews.size(); i++) {
|
||||||
final ShortcutInfoCompat shortcut = shortcuts.get(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.
|
// Use unbadged icon for the menu.
|
||||||
LauncherIcons li = LauncherIcons.obtain(launcher);
|
LauncherIcons li = LauncherIcons.obtain(launcher);
|
||||||
si.applyFrom(li.createShortcutIcon(shortcut, false /* badged */));
|
si.applyFrom(li.createShortcutIcon(shortcut, false /* badged */));
|
||||||
|
|
|
@ -20,7 +20,7 @@ import com.android.launcher3.BaseDraggingActivity;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.R;
|
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.model.WidgetItem;
|
||||||
import com.android.launcher3.util.InstantAppResolver;
|
import com.android.launcher3.util.InstantAppResolver;
|
||||||
import com.android.launcher3.util.PackageManagerHelper;
|
import com.android.launcher3.util.PackageManagerHelper;
|
||||||
|
@ -176,8 +176,8 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
|
||||||
@Override
|
@Override
|
||||||
public View.OnClickListener getOnClickListener(
|
public View.OnClickListener getOnClickListener(
|
||||||
BaseDraggingActivity activity, ItemInfo itemInfo) {
|
BaseDraggingActivity activity, ItemInfo itemInfo) {
|
||||||
boolean supportsWebUI = (itemInfo instanceof ShortcutInfo) &&
|
boolean supportsWebUI = (itemInfo instanceof WorkspaceItemInfo) &&
|
||||||
((ShortcutInfo) itemInfo).hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI);
|
((WorkspaceItemInfo) itemInfo).hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI);
|
||||||
boolean isInstantApp = false;
|
boolean isInstantApp = false;
|
||||||
if (itemInfo instanceof com.android.launcher3.AppInfo) {
|
if (itemInfo instanceof com.android.launcher3.AppInfo) {
|
||||||
com.android.launcher3.AppInfo appInfo = (com.android.launcher3.AppInfo) itemInfo;
|
com.android.launcher3.AppInfo appInfo = (com.android.launcher3.AppInfo) itemInfo;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import android.util.SparseLongArray;
|
||||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherProvider.DatabaseHelper;
|
import com.android.launcher3.LauncherProvider.DatabaseHelper;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
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.Utilities;
|
||||||
import com.android.launcher3.logging.FileLog;
|
import com.android.launcher3.logging.FileLog;
|
||||||
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
|
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
|
||||||
|
@ -110,8 +110,8 @@ public class RestoreDbTask {
|
||||||
// Mark all items as restored.
|
// Mark all items as restored.
|
||||||
boolean keepAllIcons = Utilities.isPropertyEnabled(LogConfig.KEEP_ALL_ICONS);
|
boolean keepAllIcons = Utilities.isPropertyEnabled(LogConfig.KEEP_ALL_ICONS);
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(Favorites.RESTORED, ShortcutInfo.FLAG_RESTORED_ICON
|
values.put(Favorites.RESTORED, WorkspaceItemInfo.FLAG_RESTORED_ICON
|
||||||
| (keepAllIcons ? ShortcutInfo.FLAG_RESTORE_STARTED : 0));
|
| (keepAllIcons ? WorkspaceItemInfo.FLAG_RESTORE_STARTED : 0));
|
||||||
db.update(Favorites.TABLE_NAME, values, null, null);
|
db.update(Favorites.TABLE_NAME, values, null, null);
|
||||||
|
|
||||||
// Mark widgets with appropriate restore flag.
|
// Mark widgets with appropriate restore flag.
|
||||||
|
|
|
@ -18,7 +18,6 @@ package com.android.launcher3.shortcuts;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -27,10 +26,9 @@ import android.widget.FrameLayout;
|
||||||
import com.android.launcher3.BubbleTextView;
|
import com.android.launcher3.BubbleTextView;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.popup.PopupContainerWithArrow;
|
import com.android.launcher3.popup.PopupContainerWithArrow;
|
||||||
import com.android.launcher3.touch.ItemClickHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link android.widget.FrameLayout} that contains a {@link DeepShortcutView}.
|
* A {@link android.widget.FrameLayout} that contains a {@link DeepShortcutView}.
|
||||||
|
@ -44,7 +42,7 @@ public class DeepShortcutView extends FrameLayout {
|
||||||
private View mIconView;
|
private View mIconView;
|
||||||
private View mDivider;
|
private View mDivider;
|
||||||
|
|
||||||
private ShortcutInfo mInfo;
|
private WorkspaceItemInfo mInfo;
|
||||||
private ShortcutInfoCompat mDetail;
|
private ShortcutInfoCompat mDetail;
|
||||||
|
|
||||||
public DeepShortcutView(Context context) {
|
public DeepShortcutView(Context context) {
|
||||||
|
@ -95,11 +93,11 @@ public class DeepShortcutView extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** package private **/
|
/** package private **/
|
||||||
public void applyShortcutInfo(ShortcutInfo info, ShortcutInfoCompat detail,
|
public void applyShortcutInfo(WorkspaceItemInfo info, ShortcutInfoCompat detail,
|
||||||
PopupContainerWithArrow container) {
|
PopupContainerWithArrow container) {
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
mDetail = detail;
|
mDetail = detail;
|
||||||
mBubbleText.applyFromShortcutInfo(info);
|
mBubbleText.applyFromWorkspaceItem(info);
|
||||||
mIconView.setBackground(mBubbleText.getIcon());
|
mIconView.setBackground(mBubbleText.getIcon());
|
||||||
|
|
||||||
// Use the long label as long as it exists and fits.
|
// 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
|
* Returns the shortcut info that is suitable to be added on the homescreen
|
||||||
*/
|
*/
|
||||||
public ShortcutInfo getFinalInfo() {
|
public WorkspaceItemInfo getFinalInfo() {
|
||||||
final ShortcutInfo badged = new ShortcutInfo(mInfo);
|
final WorkspaceItemInfo badged = new WorkspaceItemInfo(mInfo);
|
||||||
// Queue an update task on the worker thread. This ensures that the badged
|
// Queue an update task on the worker thread. This ensures that the badged
|
||||||
// shortcut eventually gets its icon updated.
|
// shortcut eventually gets its icon updated.
|
||||||
Launcher.getLauncher(getContext()).getModel()
|
Launcher.getLauncher(getContext()).getModel()
|
||||||
.updateAndBindShortcutInfo(badged, mDetail);
|
.updateAndBindWorkspaceItem(badged, mDetail);
|
||||||
return badged;
|
return badged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,12 @@ import android.content.pm.ShortcutInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for {@link android.content.pm.ShortcutInfo}, representing deep shortcuts into apps.
|
* 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 {
|
public class ShortcutInfoCompat {
|
||||||
private static final String INTENT_CATEGORY = "com.android.launcher3.DEEP_SHORTCUT";
|
private static final String INTENT_CATEGORY = "com.android.launcher3.DEEP_SHORTCUT";
|
||||||
|
|
|
@ -43,7 +43,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||||
import com.android.launcher3.PromiseAppInfo;
|
import com.android.launcher3.PromiseAppInfo;
|
||||||
import com.android.launcher3.R;
|
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.compat.AppWidgetManagerCompat;
|
||||||
import com.android.launcher3.folder.Folder;
|
import com.android.launcher3.folder.Folder;
|
||||||
import com.android.launcher3.folder.FolderIcon;
|
import com.android.launcher3.folder.FolderIcon;
|
||||||
|
@ -86,8 +86,8 @@ public class ItemClickHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object tag = v.getTag();
|
Object tag = v.getTag();
|
||||||
if (tag instanceof ShortcutInfo) {
|
if (tag instanceof WorkspaceItemInfo) {
|
||||||
onClickAppShortcut(v, (ShortcutInfo) tag, launcher, sourceContainer);
|
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher, sourceContainer);
|
||||||
} else if (tag instanceof FolderInfo) {
|
} else if (tag instanceof FolderInfo) {
|
||||||
if (v instanceof FolderIcon) {
|
if (v instanceof FolderIcon) {
|
||||||
onClickFolderIcon(v);
|
onClickFolderIcon(v);
|
||||||
|
@ -176,12 +176,13 @@ public class ItemClickHandler {
|
||||||
/**
|
/**
|
||||||
* Event handler for an app shortcut click.
|
* 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) {
|
@Nullable String sourceContainer) {
|
||||||
if (shortcut.isDisabled()) {
|
if (shortcut.isDisabled()) {
|
||||||
final int disabledFlags = shortcut.runtimeStatusFlags & ShortcutInfo.FLAG_DISABLED_MASK;
|
final int disabledFlags = shortcut.runtimeStatusFlags
|
||||||
|
& WorkspaceItemInfo.FLAG_DISABLED_MASK;
|
||||||
if ((disabledFlags &
|
if ((disabledFlags &
|
||||||
~FLAG_DISABLED_SUSPENDED &
|
~FLAG_DISABLED_SUSPENDED &
|
||||||
~FLAG_DISABLED_QUIET_USER) == 0) {
|
~FLAG_DISABLED_QUIET_USER) == 0) {
|
||||||
|
@ -212,7 +213,7 @@ public class ItemClickHandler {
|
||||||
shortcut.intent.getComponent().getPackageName() : shortcut.intent.getPackage();
|
shortcut.intent.getComponent().getPackageName() : shortcut.intent.getPackage();
|
||||||
if (!TextUtils.isEmpty(packageName)) {
|
if (!TextUtils.isEmpty(packageName)) {
|
||||||
onClickPendingAppItem(v, launcher, packageName,
|
onClickPendingAppItem(v, launcher, packageName,
|
||||||
shortcut.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE));
|
shortcut.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,9 +234,9 @@ public class ItemClickHandler {
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
throw new IllegalArgumentException("Input must have a valid intent");
|
throw new IllegalArgumentException("Input must have a valid intent");
|
||||||
}
|
}
|
||||||
if (item instanceof ShortcutInfo) {
|
if (item instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo si = (ShortcutInfo) item;
|
WorkspaceItemInfo si = (WorkspaceItemInfo) item;
|
||||||
if (si.hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)
|
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI)
|
||||||
&& Intent.ACTION_VIEW.equals(intent.getAction())) {
|
&& Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||||
// make a copy of the intent that has the package set to null
|
// make a copy of the intent that has the package set to null
|
||||||
// we do this because the platform sometimes disables instant
|
// we do this because the platform sometimes disables instant
|
||||||
|
|
|
@ -23,7 +23,7 @@ import com.android.launcher3.FolderInfo;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
import com.android.launcher3.LauncherSettings.Favorites;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -41,15 +41,15 @@ public interface ItemInfoMatcher {
|
||||||
default HashSet<ItemInfo> filterItemInfos(Iterable<ItemInfo> infos) {
|
default HashSet<ItemInfo> filterItemInfos(Iterable<ItemInfo> infos) {
|
||||||
HashSet<ItemInfo> filtered = new HashSet<>();
|
HashSet<ItemInfo> filtered = new HashSet<>();
|
||||||
for (ItemInfo i : infos) {
|
for (ItemInfo i : infos) {
|
||||||
if (i instanceof ShortcutInfo) {
|
if (i instanceof WorkspaceItemInfo) {
|
||||||
ShortcutInfo info = (ShortcutInfo) i;
|
WorkspaceItemInfo info = (WorkspaceItemInfo) i;
|
||||||
ComponentName cn = info.getTargetComponent();
|
ComponentName cn = info.getTargetComponent();
|
||||||
if (cn != null && matches(info, cn)) {
|
if (cn != null && matches(info, cn)) {
|
||||||
filtered.add(info);
|
filtered.add(info);
|
||||||
}
|
}
|
||||||
} else if (i instanceof FolderInfo) {
|
} else if (i instanceof FolderInfo) {
|
||||||
FolderInfo info = (FolderInfo) i;
|
FolderInfo info = (FolderInfo) i;
|
||||||
for (ShortcutInfo s : info.contents) {
|
for (WorkspaceItemInfo s : info.contents) {
|
||||||
ComponentName cn = s.getTargetComponent();
|
ComponentName cn = s.getTargetComponent();
|
||||||
if (cn != null && matches(s, cn)) {
|
if (cn != null && matches(s, cn)) {
|
||||||
filtered.add(s);
|
filtered.add(s);
|
||||||
|
|
|
@ -41,7 +41,7 @@ import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.PendingAddItemInfo;
|
import com.android.launcher3.PendingAddItemInfo;
|
||||||
import com.android.launcher3.PromiseAppInfo;
|
import com.android.launcher3.PromiseAppInfo;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
@ -183,7 +183,7 @@ public class PackageManagerHelper {
|
||||||
ComponentName componentName = null;
|
ComponentName componentName = null;
|
||||||
if (info instanceof AppInfo) {
|
if (info instanceof AppInfo) {
|
||||||
componentName = ((AppInfo) info).componentName;
|
componentName = ((AppInfo) info).componentName;
|
||||||
} else if (info instanceof ShortcutInfo) {
|
} else if (info instanceof WorkspaceItemInfo) {
|
||||||
componentName = info.getTargetComponent();
|
componentName = info.getTargetComponent();
|
||||||
} else if (info instanceof PendingAddItemInfo) {
|
} else if (info instanceof PendingAddItemInfo) {
|
||||||
componentName = ((PendingAddItemInfo) info).componentName;
|
componentName = ((PendingAddItemInfo) info).componentName;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherSettings;
|
import com.android.launcher3.LauncherSettings;
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -63,8 +64,8 @@ public class DeepShortcutManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean supportsShortcuts(ItemInfo info) {
|
public static boolean supportsShortcuts(ItemInfo info) {
|
||||||
boolean isItemPromise = info instanceof com.android.launcher3.ShortcutInfo
|
boolean isItemPromise = info instanceof WorkspaceItemInfo
|
||||||
&& ((com.android.launcher3.ShortcutInfo) info).hasPromiseIconUi();
|
&& ((WorkspaceItemInfo) info).hasPromiseIconUi();
|
||||||
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
|
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
|
||||||
&& !info.isDisabled() && !isItemPromise;
|
&& !info.isDisabled() && !isItemPromise;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@ import androidx.test.InstrumentationRegistry;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.icons.IconCache;
|
import com.android.launcher3.icons.IconCache;
|
||||||
import com.android.launcher3.InvariantDeviceProfile;
|
import com.android.launcher3.InvariantDeviceProfile;
|
||||||
import com.android.launcher3.ItemInfo;
|
import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
import com.android.launcher3.icons.BitmapInfo;
|
import com.android.launcher3.icons.BitmapInfo;
|
||||||
|
@ -112,7 +112,7 @@ public class LoaderCursorTest {
|
||||||
|
|
||||||
ComponentName cn = mLauncherApps.getActivityList(null, mLoaderCursor.user)
|
ComponentName cn = mLauncherApps.getActivityList(null, mLoaderCursor.user)
|
||||||
.get(0).getComponentName();
|
.get(0).getComponentName();
|
||||||
ShortcutInfo info = mLoaderCursor.getAppShortcutInfo(
|
WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo(
|
||||||
new Intent().setComponent(cn), false /* allowMissingTarget */, true);
|
new Intent().setComponent(cn), false /* allowMissingTarget */, true);
|
||||||
assertNotNull(info);
|
assertNotNull(info);
|
||||||
assertTrue(Utilities.isLauncherAppTarget(info.intent));
|
assertTrue(Utilities.isLauncherAppTarget(info.intent));
|
||||||
|
@ -124,7 +124,7 @@ public class LoaderCursorTest {
|
||||||
assertTrue(mLoaderCursor.moveToNext());
|
assertTrue(mLoaderCursor.moveToNext());
|
||||||
|
|
||||||
ComponentName cn = new ComponentName(mContext.getPackageName(), "dummy-do");
|
ComponentName cn = new ComponentName(mContext.getPackageName(), "dummy-do");
|
||||||
ShortcutInfo info = mLoaderCursor.getAppShortcutInfo(
|
WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo(
|
||||||
new Intent().setComponent(cn), true /* allowMissingTarget */, true);
|
new Intent().setComponent(cn), true /* allowMissingTarget */, true);
|
||||||
assertNotNull(info);
|
assertNotNull(info);
|
||||||
assertTrue(Utilities.isLauncherAppTarget(info.intent));
|
assertTrue(Utilities.isLauncherAppTarget(info.intent));
|
||||||
|
@ -138,7 +138,7 @@ public class LoaderCursorTest {
|
||||||
Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
|
Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
|
||||||
when(mMockIconCache.getDefaultIcon(eq(mLoaderCursor.user)))
|
when(mMockIconCache.getDefaultIcon(eq(mLoaderCursor.user)))
|
||||||
.thenReturn(BitmapInfo.fromBitmap(icon));
|
.thenReturn(BitmapInfo.fromBitmap(icon));
|
||||||
ShortcutInfo info = mLoaderCursor.loadSimpleShortcut();
|
WorkspaceItemInfo info = mLoaderCursor.loadSimpleWorkspaceItem();
|
||||||
assertEquals(icon, info.iconBitmap);
|
assertEquals(icon, info.iconBitmap);
|
||||||
assertEquals("my-shortcut", info.title);
|
assertEquals("my-shortcut", info.title);
|
||||||
assertEquals(ITEM_TYPE_SHORTCUT, info.itemType);
|
assertEquals(ITEM_TYPE_SHORTCUT, info.itemType);
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.android.launcher3.ItemInfo;
|
||||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.LauncherSettings.Favorites;
|
import com.android.launcher3.LauncherSettings.Favorites;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.Workspace.ItemOperator;
|
import com.android.launcher3.Workspace.ItemOperator;
|
||||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||||
|
@ -134,7 +134,7 @@ public class RequestPinItemTest extends AbstractLauncherUiTest {
|
||||||
runTest("pinShortcut", false, new ItemOperator() {
|
runTest("pinShortcut", false, new ItemOperator() {
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluate(ItemInfo info, View view) {
|
public boolean evaluate(ItemInfo info, View view) {
|
||||||
return info instanceof ShortcutInfo &&
|
return info instanceof WorkspaceItemInfo &&
|
||||||
info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT &&
|
info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT &&
|
||||||
ShortcutKey.fromItemInfo(info).getId().equals(mShortcutId);
|
ShortcutKey.fromItemInfo(info).getId().equals(mShortcutId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue