Search in sources :

Example 51 with Workspace

use of com.android.launcher3.tapl.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 52 with Workspace

use of com.android.launcher3.tapl.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 53 with Workspace

use of com.android.launcher3.tapl.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 54 with Workspace

use of com.android.launcher3.tapl.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)

Example 55 with Workspace

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

the class AbstractLauncherUiTest method checkLauncherIntegrity.

private void checkLauncherIntegrity(Launcher launcher, ContainerType expectedContainerType) {
    if (launcher != null) {
        final StateManager<LauncherState> stateManager = launcher.getStateManager();
        final LauncherState stableState = stateManager.getCurrentStableState();
        assertTrue("Stable state != state: " + stableState.getClass().getSimpleName() + ", " + stateManager.getState().getClass().getSimpleName(), stableState == stateManager.getState());
        final boolean isResumed = launcher.hasBeenResumed();
        final boolean isStarted = launcher.isStarted();
        checkLauncherState(launcher, expectedContainerType, isResumed, isStarted);
        final int ordinal = stableState.ordinal;
        switch(expectedContainerType) {
            case WORKSPACE:
            case WIDGETS:
                {
                    assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.NORMAL_STATE_ORDINAL);
                    break;
                }
            case ALL_APPS:
                {
                    assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.ALL_APPS_STATE_ORDINAL);
                    break;
                }
            case OVERVIEW:
                {
                    checkLauncherStateInOverview(launcher, expectedContainerType, isStarted, isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.OVERVIEW_STATE_ORDINAL);
                    break;
                }
            case BACKGROUND:
                {
                    assertTrue("Launcher is resumed in state: " + expectedContainerType, !isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.NORMAL_STATE_ORDINAL);
                    break;
                }
            default:
                throw new IllegalArgumentException("Illegal container: " + expectedContainerType);
        }
    } else {
        assertTrue("Container type is not BACKGROUND or FALLBACK_OVERVIEW: " + expectedContainerType, expectedContainerType == ContainerType.BACKGROUND || expectedContainerType == ContainerType.FALLBACK_OVERVIEW);
    }
}
Also used : LauncherState(com.android.launcher3.LauncherState)

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