Search in sources :

Example 11 with ContentWriter

use of com.android.launcher3.util.ContentWriter in project Neo-Launcher by NeoApplications.

the class BindWidgetTest method setupContents.

/**
 * Adds {@param item} on the homescreen on the 0th screen at 0,0, and verifies that the
 * widget class is displayed on the homescreen.
 */
private void setupContents(LauncherAppWidgetInfo item) {
    int screenId = FIRST_SCREEN_ID;
    // Update the screen id counter for the provider.
    LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
    if (screenId > FIRST_SCREEN_ID) {
        screenId = FIRST_SCREEN_ID;
    }
    // Insert the item
    ContentWriter writer = new ContentWriter(mTargetContext);
    item.id = LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_NEW_ITEM_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
    item.screenId = screenId;
    item.onAddToDatabase(writer);
    writer.put(LauncherSettings.Favorites._ID, item.id);
    mResolver.insert(LauncherSettings.Favorites.CONTENT_URI, writer.getValues(mTargetContext));
    resetLoaderState();
    // Launch the home activity
    mDevice.pressHome();
}
Also used : ContentWriter(com.android.launcher3.util.ContentWriter)

Example 12 with ContentWriter

use of com.android.launcher3.util.ContentWriter in project android_packages_apps_Launcher3 by ArrowOS.

the class AddWorkspaceItemsTaskTest method writeWorkspaceWithHoles.

private int writeWorkspaceWithHoles(BgDataModel bgDataModel, int startId, int screenId, Rect... holes) {
    GridOccupancy occupancy = new GridOccupancy(mIdp.numColumns, mIdp.numRows);
    occupancy.markCells(0, 0, mIdp.numColumns, mIdp.numRows, true);
    for (Rect r : holes) {
        occupancy.markCells(r, false);
    }
    mExistingScreens.add(screenId);
    mScreenOccupancy.append(screenId, occupancy);
    for (int x = 0; x < mIdp.numColumns; x++) {
        for (int y = 0; y < mIdp.numRows; y++) {
            if (!occupancy.cells[x][y]) {
                continue;
            }
            WorkspaceItemInfo info = new WorkspaceItemInfo();
            info.intent = new Intent().setComponent(mComponent1);
            info.id = startId++;
            info.screenId = screenId;
            info.cellX = x;
            info.cellY = y;
            info.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
            bgDataModel.addItem(mTargetContext, info, false);
            ContentWriter writer = new ContentWriter(mTargetContext);
            info.writeToValues(writer);
            writer.put(Favorites._ID, info.id);
            mTargetContext.getContentResolver().insert(Favorites.CONTENT_URI, writer.getValues(mTargetContext));
        }
    }
    return startId;
}
Also used : Rect(android.graphics.Rect) ContentWriter(com.android.launcher3.util.ContentWriter) Intent(android.content.Intent) GridOccupancy(com.android.launcher3.util.GridOccupancy) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 13 with ContentWriter

use of com.android.launcher3.util.ContentWriter in project android_packages_apps_Launcher3 by ArrowOS.

the class ModelWriter method modifyItemInDatabase.

/**
 * Move and/or resize item in the DB to a new <container, screen, cellX, cellY, spanX, spanY>
 */
public void modifyItemInDatabase(final ItemInfo item, int container, int screenId, int cellX, int cellY, int spanX, int spanY) {
    updateItemInfoProps(item, container, screenId, cellX, cellY);
    item.spanX = spanX;
    item.spanY = spanY;
    notifyItemModified(item);
    MODEL_EXECUTOR.execute(new UpdateItemRunnable(item, () -> new ContentWriter(mContext).put(Favorites.CONTAINER, item.container).put(Favorites.CELLX, item.cellX).put(Favorites.CELLY, item.cellY).put(Favorites.RANK, item.rank).put(Favorites.SPANX, item.spanX).put(Favorites.SPANY, item.spanY).put(Favorites.SCREEN, item.screenId)));
}
Also used : ContentWriter(com.android.launcher3.util.ContentWriter)

Example 14 with ContentWriter

use of com.android.launcher3.util.ContentWriter in project android_packages_apps_Launcher3 by ArrowOS.

the class ModelWriter method moveItemInDatabase.

/**
 * Move an item in the DB to a new <container, screen, cellX, cellY>
 */
public void moveItemInDatabase(final ItemInfo item, int container, int screenId, int cellX, int cellY) {
    updateItemInfoProps(item, container, screenId, cellX, cellY);
    notifyItemModified(item);
    enqueueDeleteRunnable(new UpdateItemRunnable(item, () -> new ContentWriter(mContext).put(Favorites.CONTAINER, item.container).put(Favorites.CELLX, item.cellX).put(Favorites.CELLY, item.cellY).put(Favorites.RANK, item.rank).put(Favorites.SCREEN, item.screenId)));
}
Also used : ContentWriter(com.android.launcher3.util.ContentWriter)

Example 15 with ContentWriter

use of com.android.launcher3.util.ContentWriter in project android_packages_apps_Launcher3 by ArrowOS.

the class ModelWriter method updateItemInDatabase.

/**
 * Update an item to the database in a specified container.
 */
public void updateItemInDatabase(ItemInfo item) {
    notifyItemModified(item);
    MODEL_EXECUTOR.execute(new UpdateItemRunnable(item, () -> {
        ContentWriter writer = new ContentWriter(mContext);
        item.onAddToDatabase(writer);
        return writer;
    }));
}
Also used : ContentWriter(com.android.launcher3.util.ContentWriter)

Aggregations

ContentWriter (com.android.launcher3.util.ContentWriter)43 ContentResolver (android.content.ContentResolver)16 AppWidgetHost (android.appwidget.AppWidgetHost)7 AppWidgetManager (android.appwidget.AppWidgetManager)7 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)7 Intent (android.content.Intent)7 Cursor (android.database.Cursor)7 Rect (android.graphics.Rect)7 WorkerThread (androidx.annotation.WorkerThread)7 GridOccupancy (com.android.launcher3.util.GridOccupancy)7 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)6 Executor (java.util.concurrent.Executor)6 LauncherAppWidgetHost (com.android.launcher3.widget.LauncherAppWidgetHost)5 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)1 ExecutorService (java.util.concurrent.ExecutorService)1