Search in sources :

Example 76 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_404Launcher by P-404.

the class FloatingWidgetView method getFloatingWidgetView.

/**
 * Configures and returns a an instance of {@link FloatingWidgetView} matching the appearance of
 * {@param originalView}.
 *
 * @param widgetBackgroundPosition a {@link RectF} that will be updated with the widget's
 *                                 background bounds
 * @param windowSize               the size of the window when launched
 * @param windowCornerRadius       the corner radius of the window
 */
public static FloatingWidgetView getFloatingWidgetView(Launcher launcher, LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent, int fallbackBackgroundColor) {
    final DragLayer dragLayer = launcher.getDragLayer();
    ViewGroup parent = (ViewGroup) dragLayer.getParent();
    FloatingWidgetView floatingView = launcher.getViewCache().getView(R.layout.floating_widget_view, launcher, parent);
    floatingView.recycle();
    floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize, windowCornerRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
    parent.addView(floatingView);
    return floatingView;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) ViewGroup(android.view.ViewGroup)

Example 77 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_404Launcher by P-404.

the class TaplTestsQuickstep method testQuickSwitchFromApp.

@Test
@NavigationModeSwitch
@PortraitLandscape
public void testQuickSwitchFromApp() throws Exception {
    startTestActivity(2);
    startTestActivity(3);
    startTestActivity(4);
    Background background = getAndAssertBackground();
    background.quickSwitchToPreviousApp();
    assertTrue("The first app we should have quick switched to is not running", isTestActivityRunning(3));
    background = getAndAssertBackground();
    background.quickSwitchToPreviousApp();
    if (mLauncher.getNavigationModel() == NavigationModel.THREE_BUTTON) {
        // 3-button mode toggles between 2 apps, rather than going back further.
        assertTrue("Second quick switch should have returned to the first app.", isTestActivityRunning(4));
    } else {
        assertTrue("The second app we should have quick switched to is not running", isTestActivityRunning(2));
    }
    background = getAndAssertBackground();
    background.quickSwitchToPreviousAppSwipeLeft();
    assertTrue("The 2nd app we should have quick switched to is not running", isTestActivityRunning(3));
    background = getAndAssertBackground();
    background.switchToOverview();
}
Also used : Background(com.android.launcher3.tapl.Background) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) NavigationModeSwitch(com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch)

Example 78 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_404Launcher by P-404.

the class TaplTestsQuickstep method testOverview.

@Test
@PortraitLandscape
public void testOverview() throws Exception {
    startTestAppsWithCheck();
    // mLauncher.pressHome() also tests an important case of pressing home while in background.
    Overview overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
    // Test flinging forward and backward.
    executeOnLauncher(launcher -> assertEquals("Current task in Overview is not 0", 0, getCurrentOverviewPage(launcher)));
    overview.flingForward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer currentTaskAfterFlingForward = getFromLauncher(launcher -> getCurrentOverviewPage(launcher));
    executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
    overview.flingBackward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
    // Test opening a task.
    OverviewTask task = mLauncher.pressHome().switchToOverview().getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (1)", task);
    assertNotNull("OverviewTask.open returned null", task.open());
    assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
    executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher)));
    // Test dismissing a task.
    overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
    task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (2)", task);
    task.dismiss();
    executeOnLauncher(launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(launcher)));
    // Test dismissing all tasks.
    mLauncher.pressHome().switchToOverview().dismissAllTasks();
    assertTrue("Launcher internal state is not Home", isInState(() -> LauncherState.NORMAL));
    executeOnLauncher(launcher -> assertEquals("Still have tasks after dismissing all", 0, getTaskCount(launcher)));
}
Also used : OverviewTask(com.android.launcher3.tapl.OverviewTask) Overview(com.android.launcher3.tapl.Overview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 79 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_404Launcher by P-404.

the class TaplTestsQuickstep method testBackground.

@Test
@NavigationModeSwitch
@PortraitLandscape
public void testBackground() throws Exception {
    startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
    final Background background = getAndAssertBackground();
    assertNotNull("Background.switchToOverview() returned null", background.switchToOverview());
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
}
Also used : Background(com.android.launcher3.tapl.Background) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) NavigationModeSwitch(com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch)

Example 80 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_404Launcher by P-404.

the class ClipIconView method setIcon.

/**
 * Sets the icon for this view as part of initial setup
 */
public void setIcon(@Nullable Drawable drawable, int iconOffset, MarginLayoutParams lp, boolean isOpening, boolean isVerticalBarLayout, DeviceProfile dp) {
    mIsAdaptiveIcon = drawable instanceof AdaptiveIconDrawable;
    if (mIsAdaptiveIcon) {
        boolean isFolderIcon = drawable instanceof FolderAdaptiveIcon;
        AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) drawable;
        Drawable background = adaptiveIcon.getBackground();
        if (background == null) {
            background = new ColorDrawable(Color.TRANSPARENT);
        }
        mBackground = background;
        Drawable foreground = adaptiveIcon.getForeground();
        if (foreground == null) {
            foreground = new ColorDrawable(Color.TRANSPARENT);
        }
        mForeground = foreground;
        final int originalHeight = lp.height;
        final int originalWidth = lp.width;
        int blurMargin = mBlurSizeOutline / 2;
        mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight);
        if (!isFolderIcon) {
            mFinalDrawableBounds.inset(iconOffset - blurMargin, iconOffset - blurMargin);
        }
        mForeground.setBounds(mFinalDrawableBounds);
        mBackground.setBounds(mFinalDrawableBounds);
        mStartRevealRect.set(0, 0, originalWidth, originalHeight);
        if (!isFolderIcon) {
            Utilities.scaleRectAboutCenter(mStartRevealRect, IconShape.getNormalizationScale());
        }
        if (isVerticalBarLayout) {
            lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio);
        } else {
            lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio);
        }
        int left = mIsRtl ? dp.widthPx - lp.getMarginStart() - lp.width : lp.leftMargin;
        layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height);
        float scale = Math.max((float) lp.height / originalHeight, (float) lp.width / originalWidth);
        float bgDrawableStartScale;
        if (isOpening) {
            bgDrawableStartScale = 1f;
            mOutline.set(0, 0, originalWidth, originalHeight);
        } else {
            bgDrawableStartScale = scale;
            mOutline.set(0, 0, lp.width, lp.height);
        }
        setBackgroundDrawableBounds(bgDrawableStartScale, isVerticalBarLayout);
        mEndRevealRect.set(0, 0, lp.width, lp.height);
        setOutlineProvider(new ViewOutlineProvider() {

            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRoundRect(mOutline, mTaskCornerRadius);
            }
        });
        setClipToOutline(true);
    } else {
        setBackground(drawable);
        setClipToOutline(false);
    }
    invalidate();
    invalidateOutline();
}
Also used : FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) ColorDrawable(android.graphics.drawable.ColorDrawable) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Outline(android.graphics.Outline) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View)

Aggregations

View (android.view.View)48 Point (android.graphics.Point)39 Rect (android.graphics.Rect)39 ItemInfo (com.android.launcher3.model.data.ItemInfo)29 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)29 ObjectAnimator (android.animation.ObjectAnimator)28 Background (com.android.launcher3.tapl.Background)28 DragView (com.android.launcher3.dragndrop.DragView)26 DragLayer (com.android.launcher3.dragndrop.DragLayer)25 Animator (android.animation.Animator)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)24 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)24 Drawable (android.graphics.drawable.Drawable)23 ArrayList (java.util.ArrayList)23 ViewGroup (android.view.ViewGroup)22 ColorDrawable (android.graphics.drawable.ColorDrawable)21 Handler (android.os.Handler)21 FolderIcon (com.android.launcher3.folder.FolderIcon)21 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)21 Bitmap (android.graphics.Bitmap)20