Search in sources :

Example 91 with ItemInfo

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());
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 92 with ItemInfo

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);
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 93 with ItemInfo

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);
}
Also used : SessionParams(android.content.pm.PackageInstaller.SessionParams) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) PackageInstaller(android.content.pm.PackageInstaller) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 94 with ItemInfo

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;
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 95 with ItemInfo

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);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo)

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