Search in sources :

Example 86 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class WorkspaceAccessibilityHelper method getConfirmationForIconDrop.

@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 AppInfo || info instanceof WorkspaceItemInfo) {
            return mContext.getString(R.string.folder_created);
        } else if (info instanceof FolderInfo) {
            return mContext.getString(R.string.added_to_folder);
        }
    }
    return "";
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) View(android.view.View) FolderInfo(com.android.launcher3.model.data.FolderInfo) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 87 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class Launcher method removeItem.

/**
 * Unbinds the view for the specified item, and removes the item and all its children.
 *
 * @param v the view being removed.
 * @param itemInfo the {@link ItemInfo} for this view.
 * @param deleteFromDb whether or not to delete this item from the db.
 */
public boolean removeItem(View v, final ItemInfo itemInfo, boolean deleteFromDb) {
    if (itemInfo instanceof WorkspaceItemInfo) {
        // Remove the shortcut from the folder before removing it from launcher
        View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
        if (folderIcon instanceof FolderIcon) {
            ((FolderInfo) folderIcon.getTag()).remove((WorkspaceItemInfo) itemInfo, true);
        } else {
            mWorkspace.removeWorkspaceItem(v);
        }
        if (deleteFromDb) {
            getModelWriter().deleteItemFromDatabase(itemInfo);
        }
    } else if (itemInfo instanceof FolderInfo) {
        final FolderInfo folderInfo = (FolderInfo) itemInfo;
        if (v instanceof FolderIcon) {
            ((FolderIcon) v).removeListeners();
        }
        mWorkspace.removeWorkspaceItem(v);
        if (deleteFromDb) {
            getModelWriter().deleteFolderAndContentsFromDatabase(folderInfo);
        }
    } else if (itemInfo instanceof LauncherAppWidgetInfo) {
        final LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) itemInfo;
        mWorkspace.removeWorkspaceItem(v);
        if (deleteFromDb) {
            getModelWriter().deleteWidgetInfo(widgetInfo, getAppWidgetHost());
        }
    } else {
        return false;
    }
    return true;
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) ImageView(android.widget.ImageView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 88 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class SecondaryDropTarget method supportsAccessibilityDrop.

@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
    if (view instanceof AppWidgetHostView) {
        if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
            setupUi(RECONFIGURE);
            return true;
        }
        return false;
    } else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
        setupUi(DISMISS_PREDICTION);
        return true;
    }
    setupUi(UNINSTALL);
    Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
    if (uninstallDisabled == null) {
        UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
        Bundle restrictions = userManager.getUserRestrictions(info.user);
        uninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false);
        mUninstallDisabledCache.put(info.user, uninstallDisabled);
    }
    // Cancel any pending alarm and set cache expiry after some time
    mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
    mCacheExpireAlarm.setOnAlarmListener(this);
    if (uninstallDisabled) {
        return false;
    }
    if (info instanceof ItemInfoWithIcon) {
        ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
        if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
            return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
        }
    }
    return getUninstallTarget(info) != null;
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) UserManager(android.os.UserManager) Bundle(android.os.Bundle) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 89 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class Workspace method createWidgetDrawable.

private Drawable createWidgetDrawable(ItemInfo widgetInfo, View layout) {
    int[] unScaledSize = estimateItemSize(widgetInfo);
    int visibility = layout.getVisibility();
    layout.setVisibility(VISIBLE);
    int width = MeasureSpec.makeMeasureSpec(unScaledSize[0], MeasureSpec.EXACTLY);
    int height = MeasureSpec.makeMeasureSpec(unScaledSize[1], MeasureSpec.EXACTLY);
    layout.measure(width, height);
    layout.layout(0, 0, unScaledSize[0], unScaledSize[1]);
    Bitmap b = BitmapRenderer.createHardwareBitmap(unScaledSize[0], unScaledSize[1], layout::draw);
    layout.setVisibility(visibility);
    return new FastBitmapDrawable(b);
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Bitmap(android.graphics.Bitmap) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 90 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class CacheDataUpdatedTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.initializeData("cache_data_updated_task_data");
    // Add placeholder entries in the cache to simulate update
    Context context = mModelHelper.sandboxContext;
    IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
    CachingLogic<ItemInfo> placeholderLogic = new CachingLogic<ItemInfo>() {

        @Override
        public ComponentName getComponent(ItemInfo info) {
            return info.getTargetComponent();
        }

        @Override
        public UserHandle getUser(ItemInfo info) {
            return info.user;
        }

        @Override
        public CharSequence getLabel(ItemInfo info) {
            return NEW_LABEL_PREFIX + info.id;
        }

        @NonNull
        @Override
        public BitmapInfo loadIcon(Context context, ItemInfo info) {
            return BitmapInfo.of(Bitmap.createBitmap(1, 1, Config.ARGB_8888), Color.RED);
        }
    };
    UserManager um = context.getSystemService(UserManager.class);
    for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
        iconCache.addIconToDBAndMemCache(info, placeholderLogic, new PackageInfo(), um.getSerialNumberForUser(info.user), true);
    }
}
Also used : Context(android.content.Context) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserManager(android.os.UserManager) PackageInfo(android.content.pm.PackageInfo) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) IconCache(com.android.launcher3.icons.IconCache) CachingLogic(com.android.launcher3.icons.cache.CachingLogic) Before(org.junit.Before)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72