Search in sources :

Example 41 with Widget

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

the class BindWidgetTest method verifyWidgetPresent.

private void verifyWidgetPresent(LauncherAppWidgetProviderInfo info) {
    final Widget widget = mLauncher.getWorkspace().tryGetWidget(info.label, DEFAULT_UI_TIMEOUT);
    assertTrue("Widget is not present", widget != null);
}
Also used : Widget(com.android.launcher3.tapl.Widget)

Example 42 with Widget

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

the class BindWidgetTest method verifyPendingWidgetPresent.

private void verifyPendingWidgetPresent() {
    final Widget widget = mLauncher.getWorkspace().tryGetPendingWidget(DEFAULT_UI_TIMEOUT);
    assertTrue("Pending widget is not present", widget != null);
}
Also used : Widget(com.android.launcher3.tapl.Widget)

Example 43 with Widget

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

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

the class WidgetsListAdapterTest method setWidgetsOnSearch_expandedApp_shouldResetExpandedApp.

@Test
public void setWidgetsOnSearch_expandedApp_shouldResetExpandedApp() {
    // GIVEN a list of widgets entries:
    // [Empty item
    // com.google.test0,
    // com.google.test0 content,
    // com.google.test1,
    // com.google.test1 content,
    // com.google.test2,
    // com.google.test2 content]
    // The visible widgets entries:
    // [Empty item,
    // com.google.test0,
    // com.google.test1,
    // com.google.test2].
    ArrayList<WidgetsListBaseEntry> allEntries = generateSampleMap(3);
    mAdapter.setWidgetsOnSearch(allEntries);
    // GIVEN com.google.test.1 header is expanded. The visible entries list becomes:
    // [Empty item, com.google.test0, com.google.test1, com.google.test1 content,
    // com.google.test2]
    mAdapter.onHeaderClicked(/* showWidgets= */
    true, new PackageUserKey(TEST_PACKAGE_PLACEHOLDER + 1, mUserHandle));
    Mockito.reset(mListener);
    // WHEN same widget entries are set again.
    mAdapter.setWidgetsOnSearch(allEntries);
    // THEN expanded app is reset and the visible entries list becomes:
    // [Empty item, com.google.test0, com.google.test1, com.google.test2]
    verify(mListener).onItemRangeChanged(eq(2), eq(1), isNull());
    verify(mListener).onItemRangeRemoved(/* positionStart= */
    3, /* itemCount= */
    1);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) PackageUserKey(com.android.launcher3.util.PackageUserKey) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 45 with Widget

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

the class Launcher method handleActivityResult.

private void handleActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (isWorkspaceLoading()) {
        // process the result once the workspace has loaded.
        mPendingActivityResult = new ActivityResultInfo(requestCode, resultCode, data);
        return;
    }
    mPendingActivityResult = null;
    // Reset the startActivity waiting flag
    final PendingRequestArgs requestArgs = mPendingRequestArgs;
    setWaitingForResult(null);
    if (requestArgs == null) {
        return;
    }
    final int pendingAddWidgetId = requestArgs.getWidgetId();
    Runnable exitSpringLoaded = new Runnable() {

        @Override
        public void run() {
            mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
        }
    };
    if (requestCode == REQUEST_BIND_APPWIDGET) {
        // This is called only if the user did not previously have permissions to bind widgets
        final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
        if (resultCode == RESULT_CANCELED) {
            completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId, requestArgs);
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, exitSpringLoaded);
        } else if (resultCode == RESULT_OK) {
            addAppWidgetImpl(appWidgetId, requestArgs, null, requestArgs.getWidgetHandler(), ON_ACTIVITY_RESULT_ANIMATION_DELAY);
        }
        return;
    }
    boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET);
    // We have special handling for widgets
    if (isWidgetDrop) {
        final int appWidgetId;
        int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
        if (widgetId < 0) {
            appWidgetId = pendingAddWidgetId;
        } else {
            appWidgetId = widgetId;
        }
        final int result;
        if (appWidgetId < 0 || resultCode == RESULT_CANCELED) {
            Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " + "returned from the widget configuration activity.");
            result = RESULT_CANCELED;
            completeTwoStageWidgetDrop(result, appWidgetId, requestArgs);
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, () -> getStateManager().goToState(NORMAL));
        } else {
            if (requestArgs.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
                // When the screen id represents an actual screen (as opposed to a rank)
                // we make sure that the drop page actually exists.
                requestArgs.screenId = ensurePendingDropLayoutExists(requestArgs.screenId);
            }
            final CellLayout dropLayout = mWorkspace.getScreenWithId(requestArgs.screenId);
            dropLayout.setDropPending(true);
            final Runnable onComplete = new Runnable() {

                @Override
                public void run() {
                    completeTwoStageWidgetDrop(resultCode, appWidgetId, requestArgs);
                    dropLayout.setDropPending(false);
                }
            };
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, onComplete);
        }
        return;
    }
    if (requestCode == REQUEST_RECONFIGURE_APPWIDGET || requestCode == REQUEST_BIND_PENDING_APPWIDGET) {
        if (resultCode == RESULT_OK) {
            // Update the widget view.
            completeAdd(requestCode, data, pendingAddWidgetId, requestArgs);
        }
        // Leave the widget in the pending state if the user canceled the configure.
        return;
    }
    if (requestCode == REQUEST_CREATE_SHORTCUT) {
        // Handle custom shortcuts created using ACTION_CREATE_SHORTCUT.
        if (resultCode == RESULT_OK && requestArgs.container != ItemInfo.NO_ID) {
            completeAdd(requestCode, data, -1, requestArgs);
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, exitSpringLoaded);
        } else if (resultCode == RESULT_CANCELED) {
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, exitSpringLoaded);
        }
    }
    mDragLayer.clearAnimatedView();
}
Also used : ActivityResultInfo(com.android.launcher3.util.ActivityResultInfo) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs)

Aggregations

LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)105 Test (org.junit.Test)87 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)71 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)66 Point (android.graphics.Point)62 ArrayList (java.util.ArrayList)60 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)56 View (android.view.View)55 LargeTest (androidx.test.filters.LargeTest)55 ComponentName (android.content.ComponentName)53 AppWidgetHostView (android.appwidget.AppWidgetHostView)52 Bundle (android.os.Bundle)50 WidgetItem (com.android.launcher3.model.WidgetItem)49 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)49 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)47 ItemInfo (com.android.launcher3.model.data.ItemInfo)44 PackageUserKey (com.android.launcher3.util.PackageUserKey)41 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)41 Context (android.content.Context)31 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)31