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();
}
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;
}
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)));
}
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)));
}
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;
}));
}
Aggregations