Here are the examples of the java api com.android.launcher3.ItemInfo taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
104 Examples
19
Source : WidgetsBottomSheet.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public void populateAndShow(ItemInfo itemInfo) {
mOriginalItemInfo = itemInfo;
((TextView) findViewById(R.id.replacedle)).setText(getContext().getString(R.string.widgets_bottom_sheet_replacedle, mOriginalItemInfo.replacedle));
onWidgetsBound();
mLauncher.getDragLayer().addView(this);
mIsOpen = false;
animateOpen();
}
19
Source : BaseWidgetSheet.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
targetParent.containerType = ContainerType.WIDGETS;
targetParent.cardinality = getElementsRowCount();
}
19
Source : PendingRequestArgs.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static PendingRequestArgs forIntent(int requestCode, Intent intent, ItemInfo info) {
PendingRequestArgs args = new PendingRequestArgs(requestCode, TYPE_INTENT, intent);
args.copyFrom(info);
return args;
}
19
Source : PackageUserKey.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static PackageUserKey fromItemInfo(ItemInfo info) {
return new PackageUserKey(info.getTargetComponent().getPackageName(), info.user);
}
19
Source : GridOccupancy.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public void markCells(ItemInfo item, boolean value) {
markCells(item.cellX, item.cellY, item.spanX, item.spanY, value);
}
19
Source : ShortcutKey.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static ShortcutKey fromItemInfo(ItemInfo info) {
return fromIntent(info.getIntent(), info.user);
}
19
Source : DeepShortcutManager.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static boolean supportsShortcuts(ItemInfo info) {
boolean isItemPromise = info instanceof com.android.launcher3.ShortcutInfo && ((com.android.launcher3.ShortcutInfo) info).hasPromiseIconUi();
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && !info.isDisabled() && !isItemPromise;
}
19
Source : ModelWriter.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
private void updateItemInfoProps(ItemInfo item, long container, long screenId, int cellX, int cellY) {
item.container = container;
item.cellX = cellX;
item.cellY = cellY;
// We store hotseat items in canonical form which is this orientation invariant position
// in the hotseat
if (container == Favorites.CONTAINER_HOTSEAT) {
item.screenId = mHasVerticalHotseat ? LauncherAppState.getIDP(mContext).numHotseatIcons - cellY - 1 : cellX;
} else {
item.screenId = screenId;
}
}
19
Source : ModelWriter.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Adds an item to the DB if it was not created previously, or move it to a new
* <container, screen, cellX, cellY>
*/
public void addOrMoveItemInDatabase(ItemInfo item, long container, long screenId, int cellX, int cellY) {
if (item.container == ItemInfo.NO_ID) {
// From all apps
addItemToDatabase(item, container, screenId, cellX, cellY);
} else {
// From somewhere else
moveItemInDatabase(item, container, screenId, cellX, cellY);
}
}
19
Source : LoaderCursor.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Applies the following properties:
* {@link ItemInfo#id}
* {@link ItemInfo#container}
* {@link ItemInfo#screenId}
* {@link ItemInfo#cellX}
* {@link ItemInfo#cellY}
*/
public void applyCommonProperties(ItemInfo info) {
info.id = id;
info.container = container;
info.screenId = getInt(screenIndex);
info.cellX = getInt(cellXIndex);
info.cellY = getInt(cellYIndex);
}
19
Source : FirstScreenBroadcast.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
private static String getPackageName(ItemInfo info) {
String packageName = null;
if (info instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) info;
if (widgetInfo.providerName != null) {
packageName = widgetInfo.providerName.getPackageName();
}
} else if (info.getTargetComponent() != null) {
packageName = info.getTargetComponent().getPackageName();
}
return packageName;
}
19
Source : BgDataModel.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public synchronized void addShortcutOnMain(ItemInfo info) {
}
19
Source : HorizontalPageScrollView.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) {
}
19
Source : LoggerUtils.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static Target newItemTarget(ItemInfo info, InstantAppResolver instantAppResolver) {
Target t = newTarget(Target.Type.ITEM);
switch(info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
t.itemType = (instantAppResolver != null && info instanceof ShortcutInfo && instantAppResolver.isInstantApp(((ShortcutInfo) info))) ? ItemType.WEB_APP : ItemType.APP_ICON;
// Never replacedigned
t.predictedRank = -100;
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
t.itemType = ItemType.SHORTCUT;
break;
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
t.itemType = ItemType.FOLDER_ICON;
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
t.itemType = ItemType.WIDGET;
break;
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
t.itemType = ItemType.DEEPSHORTCUT;
break;
}
return t;
}
19
Source : DumpTargetWrapper.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public DumpTarget writeToDumpTarget(ItemInfo info) {
node.component = info.getTargetComponent() == null ? "" : info.getTargetComponent().flattenToString();
node.packageName = info.getTargetComponent() == null ? "" : info.getTargetComponent().getPackageName();
if (info instanceof LauncherAppWidgetInfo) {
node.component = ((LauncherAppWidgetInfo) info).providerName.flattenToString();
node.packageName = ((LauncherAppWidgetInfo) info).providerName.getPackageName();
}
node.gridX = info.cellX;
node.gridY = info.cellY;
node.spanX = info.spanX;
node.spanY = info.spanY;
node.userType = (info.user.equals(Process.myUserHandle())) ? UserType.DEFAULT : UserType.WORK;
return node;
}
19
Source : DumpTargetWrapper.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public DumpTarget newItemTarget(ItemInfo info) {
DumpTarget dt = new DumpTarget();
dt.type = DumpTarget.Type.ITEM;
switch(info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
dt.itemType = ItemType.APP_ICON;
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
dt.itemType = ItemType.UNKNOWN_ITEMTYPE;
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
dt.itemType = ItemType.WIDGET;
break;
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
dt.itemType = ItemType.SHORTCUT;
break;
}
return dt;
}
19
Source : DrawableFactory.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public FastBitmapDrawable newIcon(Bitmap info, ItemInfo target) {
return new FastBitmapDrawable(info);
}
19
Source : FolderIcon.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
private boolean willAccepreplacedem(ItemInfo item) {
final int itemType = item.itemType;
return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT || itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) && item != mInfo && !mFolder.isOpen());
}
19
Source : FolderIcon.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public boolean acceptDrop(ItemInfo dragInfo) {
return !mFolder.isDestroyed() && willAccepreplacedem(dragInfo);
}
19
Source : PinItemDragListener.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) {
targetParent.containerType = LauncherLogProto.ContainerType.PINITEM;
}
19
Source : WorkspaceAccessibilityHelper.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Find the virtual view id corresponding to the top left corner of any drop region by which
* the preplaceded id is contained. For an icon, this is simply
*/
@Override
protected int intersectsValidDropTarget(int id) {
int mCountX = mView.getCountX();
int mCountY = mView.getCountY();
int x = id % mCountX;
int y = id / mCountX;
LauncherAccessibilityDelegate.DragInfo dragInfo = mDelegate.getDragInfo();
if (dragInfo.dragType == DragType.WIDGET && !mView.acceptsWidget()) {
return INVALID_POSITION;
}
if (dragInfo.dragType == DragType.WIDGET) {
// For a widget, every cell must be vacant. In addition, we will return any valid
// drop target by which the preplaceded id is contained.
boolean fits = false;
// These represent the amount that we can back off if we hit a problem. They
// get consumed as we move up and to the right, trying new regions.
int spanX = dragInfo.info.spanX;
int spanY = dragInfo.info.spanY;
for (int m = 0; m < spanX; m++) {
for (int n = 0; n < spanY; n++) {
fits = true;
int x0 = x - m;
int y0 = y - n;
if (x0 < 0 || y0 < 0)
continue;
for (int i = x0; i < x0 + spanX; i++) {
if (!fits)
break;
for (int j = y0; j < y0 + spanY; j++) {
if (i >= mCountX || j >= mCountY || mView.isOccupied(i, j)) {
fits = false;
break;
}
}
}
if (fits) {
return x0 + mCountX * y0;
}
}
}
return INVALID_POSITION;
} else {
// For an icon, we simply check the view directly below
View child = mView.getChildAt(x, y);
if (child == null || child == dragInfo.item) {
// Empty cell. Good for an icon or folder.
return id;
} else if (dragInfo.dragType != DragType.FOLDER) {
// For icons, we can consider cells that have another icon or a folder.
ItemInfo info = (ItemInfo) child.getTag();
if (info instanceof FolderInfo || info instanceof ShortcutInfo) {
return id;
}
}
return INVALID_POSITION;
}
}
19
Source : WorkspaceAccessibilityHelper.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
protected String getConfirmationForIconDrop(int id) {
int x = id % mView.getCountX();
int y = id / mView.getCountX();
LauncherAccessibilityDelegate.DragInfo dragInfo = mDelegate.getDragInfo();
View child = mView.getChildAt(x, y);
if (child == null || child == dragInfo.item) {
return mContext.getString(R.string.item_moved);
} else {
ItemInfo info = (ItemInfo) child.getTag();
if (info instanceof ShortcutInfo || info instanceof ShortcutInfo) {
return mContext.getString(R.string.folder_created);
} else if (info instanceof FolderInfo) {
return mContext.getString(R.string.added_to_folder);
}
}
return "";
}
19
Source : TaskSystemShortcut.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public View.OnClickListener getOnClickListener(BaseDraggingActivity activity, ItemInfo itemInfo) {
return null;
}
18
Source : WidgetsBottomSheet.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Bottom sheet for the "Widgets" system shortcut in the long-press popup.
*/
public clreplaced WidgetsBottomSheet extends BaseWidgetSheet implements Insettable {
private static final int DEFAULT_CLOSE_DURATION = 200;
private ItemInfo mOriginalItemInfo;
private Rect mInsets;
public WidgetsBottomSheet(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public WidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWillNotDraw(false);
mInsets = new Rect();
mContent = this;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
setTranslationShift(mTranslationShift);
}
public void populateAndShow(ItemInfo itemInfo) {
mOriginalItemInfo = itemInfo;
((TextView) findViewById(R.id.replacedle)).setText(getContext().getString(R.string.widgets_bottom_sheet_replacedle, mOriginalItemInfo.replacedle));
onWidgetsBound();
mLauncher.getDragLayer().addView(this);
mIsOpen = false;
animateOpen();
}
@Override
protected void onWidgetsBound() {
List<Widgereplacedem> widgets = mLauncher.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey(mOriginalItemInfo.getTargetComponent().getPackageName(), mOriginalItemInfo.user));
ViewGroup widgetRow = findViewById(R.id.widgets);
ViewGroup widgetCells = widgetRow.findViewById(R.id.widgets_cell_list);
widgetCells.removeAllViews();
for (int i = 0; i < widgets.size(); i++) {
WidgetCell widget = addItemCell(widgetCells);
widget.applyFromCellItem(widgets.get(i), LauncherAppState.getInstance(mLauncher).getWidgetCache());
widget.ensurePreview();
widget.setVisibility(View.VISIBLE);
if (i < widgets.size() - 1) {
addDivider(widgetCells);
}
}
if (widgets.size() == 1) {
// If there is only one widget, we want to center it instead of left-align.
WidgetsBottomSheet.LayoutParams params = (WidgetsBottomSheet.LayoutParams) widgetRow.getLayoutParams();
params.gravity = Gravity.CENTER_HORIZONTAL;
} else {
// Otherwise, add an empty view to the start as padding (but still scroll edge to edge).
View leftPaddingView = LayoutInflater.from(getContext()).inflate(R.layout.widget_list_divider, widgetRow, false);
leftPaddingView.getLayoutParams().width = Utilities.pxFromDp(16, getResources().getDisplayMetrics());
widgetCells.addView(leftPaddingView, 0);
}
}
private void addDivider(ViewGroup parent) {
LayoutInflater.from(getContext()).inflate(R.layout.widget_list_divider, parent, true);
}
private WidgetCell addItemCell(ViewGroup parent) {
WidgetCell widget = (WidgetCell) LayoutInflater.from(getContext()).inflate(R.layout.widget_cell, parent, false);
widget.setOnClickListener(this);
widget.setOnLongClickListener(this);
widget.setAnimatePreview(false);
parent.addView(widget);
return widget;
}
private void animateOpen() {
if (mIsOpen || mOpenCloseAnimator.isRunning()) {
return;
}
mIsOpen = true;
setupNavBarColor();
mOpenCloseAnimator.setValues(PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
mOpenCloseAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
mOpenCloseAnimator.start();
}
@Override
protected void handleClose(boolean animate) {
handleClose(animate, DEFAULT_CLOSE_DURATION);
}
@Override
protected boolean isOfType(@FloatingViewType int type) {
return (type & TYPE_WIDGETS_BOTTOM_SHEET) != 0;
}
@Override
public void setInsets(Rect insets) {
// Extend behind left, right, and bottom insets.
int leftInset = insets.left - mInsets.left;
int rightInset = insets.right - mInsets.right;
int bottomInset = insets.bottom - mInsets.bottom;
mInsets.set(insets);
setPadding(getPaddingLeft() + leftInset, getPaddingTop(), getPaddingRight() + rightInset, getPaddingBottom() + bottomInset);
}
@Override
protected int getElementsRowCount() {
return 1;
}
@Override
protected Pair<View, String> getAccessibilityTarget() {
return Pair.create(findViewById(R.id.replacedle), getContext().getString(mIsOpen ? R.string.widgets_list : R.string.widgets_list_closed));
}
}
18
Source : WidgetAddFlowHandler.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Starts the widget configuration flow if needed.
*
* @return true if the configuration flow was started, false otherwise.
*/
public boolean startConfigActivity(Launcher launcher, int appWidgetId, ItemInfo info, int requestCode) {
if (!needsConfigure()) {
return false;
}
launcher.setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, this, info));
launcher.getAppWidgetHost().startConfigActivity(launcher, appWidgetId, requestCode);
return true;
}
18
Source : WidgetAddFlowHandler.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public void startBindFlow(Launcher launcher, int appWidgetId, ItemInfo info, int requestCode) {
launcher.setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, this, info));
launcher.getAppWidgetHost().startBindFlow(launcher, appWidgetId, mProviderInfo, requestCode);
}
18
Source : PendingRequestArgs.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static PendingRequestArgs forWidgetInfo(int appWidgetId, WidgetAddFlowHandler widgetHandler, ItemInfo info) {
PendingRequestArgs args = new PendingRequestArgs(appWidgetId, TYPE_APP_WIDGET, widgetHandler);
args.copyFrom(info);
return args;
}
18
Source : PackageUserKey.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* This should only be called to avoid new object creations in a loop.
*
* @return Whether this PackageUserKey was successfully updated - it shouldn't be used if not.
*/
public boolean updateFromItemInfo(ItemInfo info) {
if (DeepShortcutManager.supportsShortcuts(info)) {
update(info.getTargetComponent().getPackageName(), info.user);
return true;
}
return false;
}
18
Source : UninstallOrDeleteUtil.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
private static View getViewUnderDrag(Launcher launcher, ItemInfo info) {
if (info instanceof LauncherAppWidgetInfo && info.container == CONTAINER_DESKTOP && launcher.getWorkspace().getDragInfo() != null) {
return launcher.getWorkspace().getDragInfo().cell;
}
return null;
}
18
Source : UninstallOrDeleteUtil.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* 是否支持卸载
*
* @param launcher Launcher
* @param info 要卸载应用对象
*
* @return
*/
public static boolean supportsUninstall(Launcher launcher, ItemInfo info) {
return supportsAccessibilityDrop(launcher, info, getViewUnderDrag(launcher, info));
}
18
Source : PopupContainerWithArrow.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Updates the notification header if the original icon's badge updated.
*/
public void updateNotificationHeader(Set<PackageUserKey> updatedBadges) {
ItemInfo itemInfo = (ItemInfo) mOriginalIcon.getTag();
PackageUserKey packageUser = PackageUserKey.fromItemInfo(itemInfo);
if (updatedBadges.contains(packageUser)) {
updateNotificationHeader();
}
}
18
Source : ModelWriter.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Removes the specified item from the database
*/
public void deleteItemFromDatabase(ItemInfo item) {
deleteItemsFromDatabase(Arrays.asList(item));
}
18
Source : ModelWriter.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
private void checkItemInfoLocked(long itemId, ItemInfo item, StackTraceElement[] stackTrace) {
ItemInfo modelItem = mBgDataModel.itemsIdMap.get(itemId);
if (modelItem != null && item != modelItem) {
// check all the data is consistent
if (modelItem instanceof ShortcutInfo && item instanceof ShortcutInfo) {
ShortcutInfo modelShortcut = (ShortcutInfo) modelItem;
ShortcutInfo shortcut = (ShortcutInfo) item;
if (modelShortcut.replacedle.toString().equals(shortcut.replacedle.toString()) && modelShortcut.intent.filterEquals(shortcut.intent) && modelShortcut.id == shortcut.id && modelShortcut.itemType == shortcut.itemType && modelShortcut.container == shortcut.container && modelShortcut.screenId == shortcut.screenId && modelShortcut.cellX == shortcut.cellX && modelShortcut.cellY == shortcut.cellY && modelShortcut.spanX == shortcut.spanX && modelShortcut.spanY == shortcut.spanY) {
// For all intents and purposes, this is the same object
return;
}
}
// the modelItem needs to match up perfectly with item if our model is
// to be consistent with the database-- for now, just require
// modelItem == item or the equality check above
String msg = "item: " + ((item != null) ? item.toString() : "null") + "modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") + "Error: ItemInfo preplaceded to checkItemInfo doesn't match original";
RuntimeException e = new RuntimeException(msg);
if (stackTrace != null) {
e.setStackTrace(stackTrace);
}
throw e;
}
}
18
Source : LoaderCursor.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Adds the {@param info} to {@param dataModel} if it does not overlap with any other item,
* otherwise marks it for deletion.
*/
public void checkAndAddItem(ItemInfo info, BgDataModel dataModel) {
if (checkItemPlacement(info, dataModel.workspaceScreens)) {
dataModel.addItem(mContext, info, false);
} else {
markDeleted("Item position overlap");
}
}
18
Source : ShortcutMenuAccessibilityDelegate.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public boolean performAction(View host, ItemInfo item, int action) {
if (action == ADD_TO_WORKSPACE) {
if (!(host.getParent() instanceof DeepShortcutView)) {
return false;
}
final ShortcutInfo info = ((DeepShortcutView) host.getParent()).getFinalInfo();
final int[] coordinates = new int[2];
final long screenId = findSpaceOnWorkspace(item, coordinates);
Runnable onComplete = new Runnable() {
@Override
public void run() {
mLauncher.getModelWriter().addItemToDatabase(info, LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId, coordinates[0], coordinates[1]);
ArrayList<ItemInfo> itemList = new ArrayList<>();
itemList.add(info);
mLauncher.bindItems(itemList, true);
AbstractFloatingView.closeAllOpenViews(mLauncher);
announceConfirmation(R.string.item_added_to_workspace);
}
};
mLauncher.getStateManager().goToState(NORMAL, true, onComplete);
return true;
} else if (action == DISMISS_NOTIFICATION) {
if (!(host instanceof NotificationMainView)) {
return false;
}
((NotificationMainView) host).onChildDismissed();
announceConfirmation(R.string.notification_dismissed);
return true;
}
return false;
}
18
Source : TaskSystemShortcut.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
protected View.OnClickListener getOnClickListenerForTask(BaseDraggingActivity activity, Task task, ItemInfo dummyInfo) {
return mSystemShortcut.getOnClickListener(activity, dummyInfo);
}
18
Source : RecentsActivity.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public BadgeInfo getBadgeInfoForItem(ItemInfo info) {
return null;
}
18
Source : RecentsActivity.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public void invalidateParent(ItemInfo info) {
}
17
Source : ItemLongClickListener.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public static void beginDrag(View v, Launcher launcher, ItemInfo info, DragOptions dragOptions) {
if (info.container >= 0) {
Folder folder = Folder.getOpen(launcher);
if (folder != null) {
if (!folder.gereplacedemsInReadingOrder().contains(v)) {
folder.close(true);
} else {
folder.startDrag(v, dragOptions);
return;
}
}
}
CellLayout.CellInfo longClickCellInfo = new CellLayout.CellInfo(v, info);
launcher.getWorkspace().startDrag(longClickCellInfo, dragOptions);
}
17
Source : PopupDataProvider.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@NonNull
public List<SystemShortcut> getEnabledSystemShortcutsForItem(ItemInfo info) {
List<SystemShortcut> systemShortcuts = new ArrayList<>();
for (SystemShortcut systemShortcut : SYSTEM_SHORTCUTS) {
if (systemShortcut.getOnClickListener(mLauncher, info) != null) {
systemShortcuts.add(systemShortcut);
}
}
return systemShortcuts;
}
17
Source : PopupDataProvider.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@NonNull
public List<NotificationKeyData> getNotificationKeysForItem(ItemInfo info) {
BadgeInfo badgeInfo = getBadgeInfoForItem(info);
return badgeInfo == null ? Collections.EMPTY_LIST : badgeInfo.getNotificationKeys();
}
17
Source : PopupDataProvider.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public BadgeInfo getBadgeInfoForItem(ItemInfo info) {
if (!DeepShortcutManager.supportsShortcuts(info)) {
return null;
}
return mPackageUserToBadgeInfos.get(PackageUserKey.fromItemInfo(info));
}
17
Source : NotificationMainView.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* A {@link android.widget.FrameLayout} that contains a single notification,
* e.g. icon + replacedle + text.
*/
@TargetApi(Build.VERSION_CODES.N)
public clreplaced NotificationMainView extends FrameLayout implements SwipeDetector.Listener {
private static FloatProperty<NotificationMainView> CONTENT_TRANSLATION = new FloatProperty<NotificationMainView>("contentTranslation") {
@Override
public void setValue(NotificationMainView view, float v) {
view.setContentTranslation(v);
}
@Override
public Float get(NotificationMainView view) {
return view.mTextAndBackground.getTranslationX();
}
};
// This is used only to track the notification view, so that it can be properly logged.
public static final ItemInfo NOTIFICATION_ITEM_INFO = new ItemInfo();
private final ObjectAnimator mContentTranslateAnimator;
private NotificationInfo mNotificationInfo;
private ViewGroup mTextAndBackground;
private int mBackgroundColor;
private TextView mreplacedleView;
private TextView mTextView;
private View mIconView;
private SwipeDetector mSwipeDetector;
public NotificationMainView(Context context) {
this(context, null, 0);
}
public NotificationMainView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public NotificationMainView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContentTranslateAnimator = ObjectAnimator.ofFloat(this, CONTENT_TRANSLATION, 0);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mTextAndBackground = findViewById(R.id.text_and_background);
ColorDrawable colorBackground = (ColorDrawable) mTextAndBackground.getBackground();
mBackgroundColor = colorBackground.getColor();
RippleDrawable rippleBackground = new RippleDrawable(ColorStateList.valueOf(Themes.getAttrColor(getContext(), android.R.attr.colorControlHighlight)), colorBackground, null);
mTextAndBackground.setBackground(rippleBackground);
mreplacedleView = mTextAndBackground.findViewById(R.id.replacedle);
mTextView = mTextAndBackground.findViewById(R.id.text);
mIconView = findViewById(R.id.popup_item_icon);
}
public void setSwipeDetector(SwipeDetector swipeDetector) {
mSwipeDetector = swipeDetector;
}
/**
* Sets the content of this view, animating it after a new icon shifts up if necessary.
*/
public void applyNotificationInfo(NotificationInfo mainNotification, boolean animate) {
mNotificationInfo = mainNotification;
CharSequence replacedle = mNotificationInfo.replacedle;
CharSequence text = mNotificationInfo.text;
if (!TextUtils.isEmpty(replacedle) && !TextUtils.isEmpty(text)) {
mreplacedleView.setText(replacedle.toString());
mTextView.setText(text.toString());
} else {
mreplacedleView.setMaxLines(2);
mreplacedleView.setText(TextUtils.isEmpty(replacedle) ? text.toString() : replacedle.toString());
mTextView.setVisibility(GONE);
}
mIconView.setBackground(mNotificationInfo.getIconForBackground(getContext(), mBackgroundColor));
if (mNotificationInfo.intent != null) {
setOnClickListener(mNotificationInfo);
}
setContentTranslation(0);
// Add a dummy ItemInfo so that logging populates the correct container and item types
// instead of DEFAULT_CONTAINERTYPE and DEFAULT_ITEMTYPE, respectively.
setTag(NOTIFICATION_ITEM_INFO);
if (animate) {
ObjectAnimator.ofFloat(mTextAndBackground, ALPHA, 0, 1).setDuration(150).start();
}
}
public void setContentTranslation(float translation) {
mTextAndBackground.setTranslationX(translation);
mIconView.setTranslationX(translation);
}
public void setContentVisibility(int visibility) {
mTextAndBackground.setVisibility(visibility);
mIconView.setVisibility(visibility);
}
public NotificationInfo getNotificationInfo() {
return mNotificationInfo;
}
public boolean canChildBeDismissed() {
return mNotificationInfo != null && mNotificationInfo.dismissable;
}
public void onChildDismissed() {
Launcher launcher = Launcher.getLauncher(getContext());
launcher.getPopupDataProvider().cancelNotification(mNotificationInfo.notificationKey);
launcher.getUserEventDispatcher().logActionOnItem(LauncherLogProto.Action.Touch.SWIPE, // replacedume all swipes are right for logging.
LauncherLogProto.Action.Direction.RIGHT, LauncherLogProto.ItemType.NOTIFICATION);
}
// SwipeDetector.Listener's
@Override
public void onDragStart(boolean start) {
}
@Override
public boolean onDrag(float displacement, float velocity) {
setContentTranslation(canChildBeDismissed() ? displacement : OverScroll.dampedScroll(displacement, getWidth()));
mContentTranslateAnimator.cancel();
return true;
}
@Override
public void onDragEnd(float velocity, boolean fling) {
final boolean willExit;
final float endTranslation;
final float startTranslation = mTextAndBackground.getTranslationX();
if (!canChildBeDismissed()) {
willExit = false;
endTranslation = 0;
} else if (fling) {
willExit = true;
endTranslation = velocity < 0 ? -getWidth() : getWidth();
} else if (Math.abs(startTranslation) > getWidth() / 2) {
willExit = true;
endTranslation = (startTranslation < 0 ? -getWidth() : getWidth());
} else {
willExit = false;
endTranslation = 0;
}
long duration = SwipeDetector.calculateDuration(velocity, (endTranslation - startTranslation) / getWidth());
mContentTranslateAnimator.removeAllListeners();
mContentTranslateAnimator.setDuration(duration).setInterpolator(scrollInterpolatorForVelocity(velocity));
mContentTranslateAnimator.setFloatValues(startTranslation, endTranslation);
mContentTranslateAnimator.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mSwipeDetector.finishedScrolling();
if (willExit) {
onChildDismissed();
}
}
});
mContentTranslateAnimator.start();
}
}
17
Source : ModelWriter.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Update an item to the database in a specified container.
*/
public void updateItemInDatabase(ItemInfo item) {
ContentWriter writer = new ContentWriter(mContext);
item.onAddToDatabase(writer);
mWorkerExecutor.execute(new UpdateItemRunnable(item, writer));
}
17
Source : LoaderResults.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
private void bindWorkspaceItems(final ArrayList<ItemInfo> workspaceItems, final ArrayList<LauncherAppWidgetInfo> appWidgets, final Executor executor) {
// Bind the workspace items
int N = workspaceItems.size();
for (int i = 0; i < N; i += ITEMS_CHUNK) {
final int start = i;
final int chunkSize = (i + ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N - i);
final Runnable r = new Runnable() {
@Override
public void run() {
Callbacks callbacks = mCallbacks.get();
if (callbacks != null) {
callbacks.bindItems(workspaceItems.subList(start, start + chunkSize), false);
}
}
};
executor.execute(r);
}
// Bind the widgets, one at a time
N = appWidgets.size();
for (int i = 0; i < N; i++) {
final ItemInfo widget = appWidgets.get(i);
final Runnable r = new Runnable() {
public void run() {
Callbacks callbacks = mCallbacks.get();
if (callbacks != null) {
callbacks.bindItems(Collections.singletonList(widget), false);
}
}
};
executor.execute(r);
}
}
17
Source : CacheDataUpdatedTask.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
IconCache iconCache = app.getIconCache();
final ArrayList<ShortcutInfo> updatedApps = new ArrayList<>();
ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
synchronized (dataModel) {
for (ItemInfo info : dataModel.itemsIdMap) {
if (info instanceof ShortcutInfo && mUser.equals(info.user)) {
ShortcutInfo si = (ShortcutInfo) info;
ComponentName cn = si.getTargetComponent();
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && isValidShortcut(si) && cn != null && mPackages.contains(cn.getPackageName())) {
iconCache.getreplacedleAndIcon(si, si.usingLowResIcon);
updatedShortcuts.add(si);
}
}
}
apps.updateIconsAndLabels(mPackages, mUser, updatedApps);
}
bindUpdatedShortcuts(updatedShortcuts, mUser);
if (!updatedApps.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
callbacks.bindAppsAddedOrUpdated(updatedApps);
}
});
}
}
17
Source : BgDataModel.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public synchronized void removeItem(Context context, ItemInfo... items) {
removeItem(context, Arrays.asList(items));
}
17
Source : UserEventDispatcher.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
// APP_ICON SHORTCUT WIDGET
// --------------------------------------------------------------
// packageNameHash required optional required
// componentNameHash required required
// intentHash required
// --------------------------------------------------------------
/**
* Fills in the container data on the given event if the given view is not null.
*
* @return whether container data was added.
*/
protected boolean fillInLogContainerData(LauncherEvent event, @Nullable View v) {
// Fill in grid(x,y), pageIndex of the child and container type of the parent
LogContainerProvider provider = getLaunchProviderRecursive(v);
if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) {
return false;
}
ItemInfo itemInfo = (ItemInfo) v.getTag();
provider.fillInLogContainerData(v, itemInfo, event.srcTarget[0], event.srcTarget[1]);
return true;
}
17
Source : UserEventDispatcher.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
public void logDeepShortcutsOpen(View icon) {
LogContainerProvider provider = getLaunchProviderRecursive(icon);
if (icon == null || !(icon.getTag() instanceof ItemInfo)) {
return;
}
ItemInfo info = (ItemInfo) icon.getTag();
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.LONGPRESS), newItemTarget(info, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]);
dispatchUserEvent(event, null);
resetElapsedContainerMillis("deep shortcut open");
}
17
Source : DragView.java
with Apache License 2.0
from Launcher3-dev
with Apache License 2.0
from Launcher3-dev
/**
* Initialize {@code #mIconDrawable} if the item can be represented using
* an {@link AdaptiveIconDrawable} or {@link FolderAdaptiveIcon}.
*/
@TargetApi(Build.VERSION_CODES.O)
public void sereplacedemInfo(final ItemInfo info) {
if (!(FeatureFlags.LAUNCHER3_SPRING_ICONS && Utilities.ATLEAST_OREO)) {
return;
}
if (info.itemType != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && info.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT && info.itemType != LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
return;
}
// Load the adaptive icon on a background thread and add the view in ui thread.
final Looper workerLooper = LauncherModel.getWorkerLooper();
new Handler(workerLooper).postAtFrontOfQueue(new Runnable() {
@Override
public void run() {
LauncherAppState appState = LauncherAppState.getInstance(mLauncher);
Object[] outObj = new Object[1];
final Drawable dr = getFullDrawable(info, appState, outObj);
if (dr instanceof AdaptiveIconDrawable) {
int w = mBitmap.getWidth();
int h = mBitmap.getHeight();
int blurMargin = (int) mLauncher.getResources().getDimension(R.dimen.blur_size_medium_outline) / 2;
Rect bounds = new Rect(0, 0, w, h);
bounds.inset(blurMargin, blurMargin);
// Badge is applied after icon normalization so the bounds for badge should not
// be scaled down due to icon normalization.
Rect badgeBounds = new Rect(bounds);
mBadge = getBadge(info, appState, outObj[0]);
mBadge.setBounds(badgeBounds);
LauncherIcons li = LauncherIcons.obtain(mLauncher);
Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(dr, null, null, null));
li.recycle();
AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) dr;
// Shrink very tiny bit so that the clip path is smaller than the original bitmap
// that has anti aliased edges and shadows.
Rect shrunkBounds = new Rect(bounds);
Utilities.scaleRectAboutCenter(shrunkBounds, 0.98f);
adaptiveIcon.setBounds(shrunkBounds);
final Path mask = adaptiveIcon.getIconMask();
mTranslateX = new SpringFloatValue(DragView.this, w * AdaptiveIconDrawable.getExtraInsetFraction());
mTranslateY = new SpringFloatValue(DragView.this, h * AdaptiveIconDrawable.getExtraInsetFraction());
bounds.inset((int) (-bounds.width() * AdaptiveIconDrawable.getExtraInsetFraction()), (int) (-bounds.height() * AdaptiveIconDrawable.getExtraInsetFraction()));
mBgSpringDrawable = adaptiveIcon.getBackground();
if (mBgSpringDrawable == null) {
mBgSpringDrawable = new ColorDrawable(Color.TRANSPARENT);
}
mBgSpringDrawable.setBounds(bounds);
mFgSpringDrawable = adaptiveIcon.getForeground();
if (mFgSpringDrawable == null) {
mFgSpringDrawable = new ColorDrawable(Color.TRANSPARENT);
}
mFgSpringDrawable.setBounds(bounds);
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
// replacedign the variable on the UI thread to avoid race conditions.
mScaledMaskPath = mask;
// Do not draw the background in case of folder as its translucent
mDrawBitmap = !(dr instanceof FolderAdaptiveIcon);
if (info.isDisabled()) {
FastBitmapDrawable d = new FastBitmapDrawable((Bitmap) null);
d.setIsDisabled(true);
mBaseFilter = (ColorMatrixColorFilter) d.getColorFilter();
}
updateColorFilter();
}
});
}
}
});
}
See More Examples