Search in sources :

Example 51 with Workspace

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

the class LauncherAccessibilityDelegate method findSpaceOnWorkspace.

/**
 * Find empty space on the workspace and returns the screenId.
 */
protected int findSpaceOnWorkspace(ItemInfo info, int[] outCoordinates) {
    Workspace workspace = mLauncher.getWorkspace();
    IntArray workspaceScreens = workspace.getScreenOrder();
    int screenId;
    // First check if there is space on the current screen.
    int screenIndex = workspace.getCurrentPage();
    screenId = workspaceScreens.get(screenIndex);
    CellLayout layout = (CellLayout) workspace.getPageAt(screenIndex);
    boolean found = layout.findCellForSpan(outCoordinates, info.spanX, info.spanY);
    screenIndex = 0;
    while (!found && screenIndex < workspaceScreens.size()) {
        screenId = workspaceScreens.get(screenIndex);
        layout = (CellLayout) workspace.getPageAt(screenIndex);
        found = layout.findCellForSpan(outCoordinates, info.spanX, info.spanY);
        screenIndex++;
    }
    if (found) {
        return screenId;
    }
    workspace.addExtraEmptyScreens();
    IntSet emptyScreenIds = workspace.commitExtraEmptyScreens();
    if (emptyScreenIds.isEmpty()) {
        // Couldn't create extra empty screens for some reason (e.g. Workspace is loading)
        return -1;
    }
    screenId = emptyScreenIds.getArray().get(0);
    layout = workspace.getScreenWithId(screenId);
    found = layout.findCellForSpan(outCoordinates, info.spanX, info.spanY);
    if (!found) {
        Log.wtf(TAG, "Not enough space on an empty screen");
    }
    return screenId;
}
Also used : IntArray(com.android.launcher3.util.IntArray) CellLayout(com.android.launcher3.CellLayout) IntSet(com.android.launcher3.util.IntSet) Point(android.graphics.Point) Workspace(com.android.launcher3.Workspace)

Example 52 with Workspace

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

the class AllAppsGridAdapter method onCreateViewHolder.

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch(viewType) {
        case VIEW_TYPE_ICON:
            int layout = !FeatureFlags.ENABLE_TWOLINE_ALLAPPS.get() ? R.layout.all_apps_icon : R.layout.all_apps_icon_twoline;
            BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(layout, parent, false);
            icon.setLongPressTimeoutFactor(1f);
            icon.setOnFocusChangeListener(mIconFocusListener);
            icon.setOnClickListener(mOnIconClickListener);
            icon.setOnLongClickListener(mOnIconLongClickListener);
            // Ensure the all apps icon height matches the workspace icons in portrait mode.
            icon.getLayoutParams().height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
            if (FeatureFlags.ENABLE_TWOLINE_ALLAPPS.get()) {
                icon.getLayoutParams().height += mExtraHeight;
            }
            return new ViewHolder(icon);
        case VIEW_TYPE_EMPTY_SEARCH:
            return new ViewHolder(mLayoutInflater.inflate(R.layout.all_apps_empty_search, parent, false));
        case VIEW_TYPE_SEARCH_MARKET:
            View searchMarketView = mLayoutInflater.inflate(R.layout.all_apps_search_market, parent, false);
            searchMarketView.setOnClickListener(v -> mLauncher.startActivitySafely(v, mMarketSearchIntent, null));
            return new ViewHolder(searchMarketView);
        case VIEW_TYPE_ALL_APPS_DIVIDER:
            return new ViewHolder(mLayoutInflater.inflate(R.layout.all_apps_divider, parent, false));
        default:
            BaseAdapterProvider adapterProvider = getAdapterProvider(viewType);
            if (adapterProvider != null) {
                return adapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType);
            }
            throw new RuntimeException("Unexpected view type" + viewType);
    }
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView)

Example 53 with Workspace

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

the class AddConfigWidgetTest method runTest.

/**
 * @param acceptConfig accept the config activity
 */
private void runTest(boolean acceptConfig) throws Throwable {
    clearHomescreen();
    mDevice.pressHome();
    final Widgets widgets = mLauncher.getWorkspace().openAllWidgets();
    // Drag widget to homescreen
    WidgetConfigStartupMonitor monitor = new WidgetConfigStartupMonitor();
    WidgetResizeFrame resizeFrame = widgets.getWidget(mWidgetInfo.getLabel(mTargetContext.getPackageManager())).dragConfigWidgetToWorkspace(acceptConfig);
    // Widget id for which the config activity was opened
    mWidgetId = monitor.getWidgetId();
    // Verify that the widget id is valid and bound
    assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId));
    if (acceptConfig) {
        assertNotNull("Widget resize frame not shown after widget added", resizeFrame);
        resizeFrame.dismiss();
        final Widget widget = mLauncher.getWorkspace().tryGetWidget(mWidgetInfo.label, DEFAULT_UI_TIMEOUT);
        assertNotNull("Widget not found on the workspace", widget);
    } else {
        final Widget widget = mLauncher.getWorkspace().tryGetWidget(mWidgetInfo.label, DEFAULT_UI_TIMEOUT);
        assertNull("Widget unexpectedly found on the workspace", widget);
    }
}
Also used : Widgets(com.android.launcher3.tapl.Widgets) WidgetResizeFrame(com.android.launcher3.tapl.WidgetResizeFrame) Widget(com.android.launcher3.tapl.Widget)

Example 54 with Workspace

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

the class TaplTestsLauncher3 method testDragToFolder.

@Ignore("b/205014516")
@Test
@PortraitLandscape
public void testDragToFolder() throws Exception {
    final AppIcon playStoreIcon = createShortcutIfNotExist("Play Store");
    final AppIcon gmailIcon = createShortcutIfNotExist("Gmail");
    FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon);
    Folder folder = folderIcon.open();
    folder.getAppIcon("Play Store");
    folder.getAppIcon("Gmail");
    Workspace workspace = folder.close();
    assertNull("Gmail should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Gmail"));
    assertNull("Play Store should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Play Store"));
    final AppIcon youTubeIcon = createShortcutIfNotExist("YouTube");
    folderIcon = youTubeIcon.dragToIcon(folderIcon);
    folder = folderIcon.open();
    folder.getAppIcon("YouTube");
    folder.close();
}
Also used : FolderIcon(com.android.launcher3.tapl.FolderIcon) AppIcon(com.android.launcher3.tapl.AppIcon) Folder(com.android.launcher3.tapl.Folder) Workspace(com.android.launcher3.tapl.Workspace) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 55 with Workspace

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

the class AddWidgetTest method testDragIcon.

@Test
@PortraitLandscape
public void testDragIcon() throws Throwable {
    clearHomescreen();
    mDevice.pressHome();
    final LauncherAppWidgetProviderInfo widgetInfo = TestViewHelpers.findWidgetProvider(this, false);
    WidgetResizeFrame resizeFrame = mLauncher.getWorkspace().openAllWidgets().getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager())).dragWidgetToWorkspace();
    assertTrue(mActivityMonitor.itemExists((info, view) -> info instanceof LauncherAppWidgetInfo && ((LauncherAppWidgetInfo) info).providerName.getClassName().equals(widgetInfo.provider.getClassName())).call());
    assertNotNull("Widget resize frame not shown after widget add", resizeFrame);
    resizeFrame.dismiss();
    final Widget widget = mLauncher.getWorkspace().tryGetWidget(widgetInfo.label, DEFAULT_UI_TIMEOUT);
    assertNotNull("Widget not found on the workspace", widget);
    widget.launch(getAppPackageName());
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) WidgetResizeFrame(com.android.launcher3.tapl.WidgetResizeFrame) Widget(com.android.launcher3.tapl.Widget) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Test(org.junit.Test) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest)

Aggregations

View (android.view.View)143 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)124 Point (android.graphics.Point)115 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)97 Rect (android.graphics.Rect)93 ArrayList (java.util.ArrayList)91 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 DragView (com.android.launcher3.dragndrop.DragView)77 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)73 AppWidgetHostView (android.appwidget.AppWidgetHostView)72 Workspace (com.android.launcher3.Workspace)63 SuppressLint (android.annotation.SuppressLint)58 DraggableView (com.android.launcher3.dragndrop.DraggableView)58 Test (org.junit.Test)57 FolderInfo (com.android.launcher3.model.data.FolderInfo)55 CellLayout (com.android.launcher3.CellLayout)51 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 IntArray (com.android.launcher3.util.IntArray)45 Intent (android.content.Intent)43 ValueAnimator (android.animation.ValueAnimator)41