use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_folder.
@Test
public void testCustomProfileLoaded_with_folder() throws Exception {
writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putFolder(android.R.string.copy).addApp(TEST_PACKAGE, TEST_ACTIVITY).addApp(TEST_PACKAGE, TEST_ACTIVITY).addApp(TEST_PACKAGE, TEST_ACTIVITY).build());
// Verify folder
assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_FOLDER, info.itemType);
assertEquals(3, ((FolderInfo) info).contents.size());
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_icon_on_hotseat.
@Test
public void testCustomProfileLoaded_with_icon_on_hotseat() throws Exception {
writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putApp(TEST_PACKAGE, TEST_ACTIVITY));
// Verify one item in hotseat
assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
assertEquals(LauncherSettings.Favorites.CONTAINER_HOTSEAT, info.container);
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_APPLICATION, info.itemType);
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_widget.
@Test
public void testCustomProfileLoaded_with_widget() throws Exception {
String pendingAppPkg = "com.test.pending";
// Add a placeholder session info so that the widget exists
SessionParams params = new SessionParams(SessionParams.MODE_FULL_INSTALL);
params.setAppPackageName(pendingAppPkg);
params.setAppIcon(BitmapInfo.LOW_RES_ICON);
PackageInstaller installer = mTargetContext.getPackageManager().getPackageInstaller();
installer.createSession(params);
writeLayoutAndLoad(new LauncherLayoutBuilder().atWorkspace(0, 1, 0).putWidget(pendingAppPkg, "PlaceholderWidget", 2, 2));
// Verify widget
assertEquals(1, mModelHelper.getBgDataModel().appWidgets.size());
ItemInfo info = mModelHelper.getBgDataModel().appWidgets.get(0);
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET, info.itemType);
assertEquals(2, info.spanX);
assertEquals(2, info.spanY);
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class LoaderCursorTest method newItemInfo.
private ItemInfo newItemInfo(int cellX, int cellY, int spanX, int spanY, int container, int screenId) {
ItemInfo info = new ItemInfo();
info.cellX = cellX;
info.cellY = cellY;
info.spanX = spanX;
info.spanY = spanY;
info.container = container;
info.screenId = screenId;
return info;
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class AppWidgetResizeFrame method setupForWidget.
private void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout, DragLayer dragLayer) {
mCellLayout = cellLayout;
if (mWidgetView != null) {
mWidgetView.removeOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
}
mWidgetView = widgetView;
mWidgetView.addOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo) widgetView.getAppWidgetInfo();
mDragLayer = dragLayer;
mMinHSpan = info.minSpanX;
mMinVSpan = info.minSpanY;
mMaxHSpan = info.maxSpanX;
mMaxVSpan = info.maxSpanY;
mWidgetPadding = getDefaultPaddingForWidget(getContext(), widgetView.getAppWidgetInfo().provider, null);
mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button);
if (info.isReconfigurable()) {
mReconfigureButton.setVisibility(VISIBLE);
mReconfigureButton.setOnClickListener(view -> {
mLauncher.setWaitingForResult(PendingRequestArgs.forWidgetInfo(mWidgetView.getAppWidgetId(), /* widgetHandler= */
null, (ItemInfo) mWidgetView.getTag()));
mLauncher.getAppWidgetHost().startConfigActivity(mLauncher, mWidgetView.getAppWidgetId(), Launcher.REQUEST_RECONFIGURE_APPWIDGET);
});
if (!hasSeenReconfigurableWidgetEducationTip()) {
post(() -> {
if (showReconfigurableWidgetEducationTip() != null) {
mLauncher.getSharedPrefs().edit().putBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, true).apply();
}
});
}
}
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mWidgetView.getLayoutParams();
ItemInfo widgetInfo = (ItemInfo) mWidgetView.getTag();
lp.cellX = lp.tmpCellX = widgetInfo.cellX;
lp.cellY = lp.tmpCellY = widgetInfo.cellY;
lp.cellHSpan = widgetInfo.spanX;
lp.cellVSpan = widgetInfo.spanY;
lp.isLockedToGrid = true;
// When we create the resize frame, we first mark all cells as unoccupied. The appropriate
// cells (same if not resized, or different) will be marked as occupied when the resize
// frame is dismissed.
mCellLayout.markCellsAsUnoccupiedForView(mWidgetView);
mLauncher.getStatsLogManager().logger().withInstanceId(logInstanceId).withItemInfo(widgetInfo).log(LAUNCHER_WIDGET_RESIZE_STARTED);
setOnKeyListener(this);
}
Aggregations