Search in sources :

Example 11 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

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));
    getAndAssertBackground();
}
Also used : Background(com.android.launcher3.tapl.Background) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) NavigationModeSwitch(com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch)

Example 12 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

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)

Example 13 with Background

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

the class PopupContainerWithArrow method populateAndShow.

@TargetApi(Build.VERSION_CODES.P)
public void populateAndShow(final BubbleTextView originalIcon, int shortcutCount, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) {
    mNumNotifications = notificationKeys.size();
    mOriginalIcon = originalIcon;
    boolean hasDeepShortcuts = shortcutCount > 0;
    int containerWidth = (int) getResources().getDimension(R.dimen.bg_popup_item_width);
    // horizontally laid out system shortcuts.
    if (hasDeepShortcuts) {
        containerWidth = (int) Math.max(containerWidth, systemShortcuts.size() * getResources().getDimension(R.dimen.system_shortcut_header_icon_touch_size));
    }
    // Add views
    if (mNumNotifications > 0) {
        // Add notification entries
        if (mNotificationContainer == null) {
            mNotificationContainer = findViewById(R.id.notification_container);
            mNotificationContainer.setVisibility(VISIBLE);
            mNotificationContainer.setPopupView(this);
        } else {
            mNotificationContainer.setVisibility(GONE);
        }
        updateNotificationHeader();
    }
    int viewsToFlip = getChildCount();
    mSystemShortcutContainer = this;
    if (mDeepShortcutContainer == null) {
        mDeepShortcutContainer = findViewById(R.id.deep_shortcuts_container);
    }
    if (hasDeepShortcuts) {
        mDeepShortcutContainer.setVisibility(View.VISIBLE);
        for (int i = shortcutCount; i > 0; i--) {
            DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, mDeepShortcutContainer);
            v.getLayoutParams().width = containerWidth;
            mShortcuts.add(v);
        }
        updateHiddenShortcuts();
        if (!systemShortcuts.isEmpty()) {
            for (SystemShortcut shortcut : systemShortcuts) {
                if (shortcut instanceof SystemShortcut.Widgets) {
                    if (mWidgetContainer == null) {
                        mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, this);
                    }
                    initializeSystemShortcut(R.layout.system_shortcut, mWidgetContainer, shortcut);
                }
            }
            mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
            for (SystemShortcut shortcut : systemShortcuts) {
                if (!(shortcut instanceof SystemShortcut.Widgets)) {
                    initializeSystemShortcut(R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
                }
            }
        }
    } else {
        mDeepShortcutContainer.setVisibility(View.GONE);
        if (!systemShortcuts.isEmpty()) {
            for (SystemShortcut shortcut : systemShortcuts) {
                initializeSystemShortcut(R.layout.system_shortcut, this, shortcut);
            }
        }
    }
    reorderAndShow(viewsToFlip);
    ItemInfo originalItemInfo = (ItemInfo) originalIcon.getTag();
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        setAccessibilityPaneTitle(getTitleForAccessibility());
    }
    mOriginalIcon.setForceHideDot(true);
    // All views are added. Animate layout from now on.
    setLayoutTransition(new LayoutTransition());
    // Load the shortcuts on a background thread and update the container as it animates.
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(PopupPopulator.createUpdateRunnable(mActivityContext, originalItemInfo, new Handler(Looper.getMainLooper()), this, mShortcuts, notificationKeys));
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Handler(android.os.Handler) LayoutTransition(android.animation.LayoutTransition) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) TargetApi(android.annotation.TargetApi)

Example 14 with Background

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

the class QuickstepTransitionManager method getBackgroundAnimator.

/**
 * Returns animator that controls depth/blur of the background.
 */
private ObjectAnimator getBackgroundAnimator() {
    // When launching an app from overview that doesn't map to a task, we still want to just
    // blur the wallpaper instead of the launcher surface as well
    boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW;
    DepthController depthController = mLauncher.getDepthController();
    ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mLauncher)).setDuration(APP_LAUNCH_DURATION);
    if (allowBlurringLauncher) {
        final SurfaceControl dimLayer;
        if (BlurUtils.supportsBlursOnWindows()) {
            // Create a temporary effect layer, that lives on top of launcher, so we can apply
            // the blur to it. The EffectLayer will be fullscreen, which will help with caching
            // optimizations on the SurfaceFlinger side:
            // - Results would be able to be cached as a texture
            // - There won't be texture allocation overhead, because EffectLayers don't have
            // buffers
            ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl();
            SurfaceControl parent = viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null;
            dimLayer = new SurfaceControl.Builder().setName("Blur layer").setParent(parent).setOpaque(false).setHidden(false).setEffectLayer().build();
        } else {
            dimLayer = null;
        }
        depthController.setSurface(dimLayer);
        backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                depthController.setIsInLaunchTransition(true);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                depthController.setIsInLaunchTransition(false);
                depthController.setSurface(null);
                if (dimLayer != null) {
                    new SurfaceControl.Transaction().remove(dimLayer).apply();
                }
            }
        });
    }
    return backgroundRadiusAnim;
}
Also used : ViewRootImpl(android.view.ViewRootImpl) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) SurfaceControl(android.view.SurfaceControl) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) DepthController(com.android.launcher3.statehandlers.DepthController)

Example 15 with Background

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

the class NavbarButtonsViewController method init.

/**
 * Initializes the controller
 */
public void init(TaskbarControllers controllers) {
    mControllers = controllers;
    mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;
    mNavButtonTranslationYMultiplier.value = 1;
    boolean isThreeButtonNav = mContext.isThreeButtonNav();
    // IME switcher
    View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH, isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer, mControllers.navButtonController, R.id.ime_switcher);
    mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton, flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) == MASK_IME_SWITCHER_VISIBLE) && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)));
    mPropertyHolders.add(new StatePropertyHolder(mControllers.taskbarViewController.getTaskbarIconAlpha().getProperty(ALPHA_INDEX_KEYGUARD), flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 && (flags & FLAG_SCREEN_PINNING_ACTIVE) == 0, MultiValueAlpha.VALUE, 1, 0));
    mPropertyHolders.add(new StatePropertyHolder(mControllers.taskbarDragLayerController.getKeyguardBgTaskbar(), flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, AnimatedFloat.VALUE, 1, 0));
    // Force nav buttons (specifically back button) to be visible during setup wizard.
    boolean isInSetup = !mContext.isUserSetupComplete();
    boolean alwaysShowButtons = isThreeButtonNav || isInSetup;
    // Make sure to remove nav bar buttons translation when notification shade is expanded or
    // IME is showing (add separate translation for IME).
    int flagsToRemoveTranslation = FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_IME_VISIBLE;
    mPropertyHolders.add(new StatePropertyHolder(mNavButtonTranslationYMultiplier, flags -> (flags & flagsToRemoveTranslation) != 0, AnimatedFloat.VALUE, 0, 1));
    // Center nav buttons in new height for IME.
    float transForIme = (mContext.getDeviceProfile().taskbarSize - mContext.getTaskbarHeightForIme()) / 2f;
    // For gesture nav, nav buttons only show for IME anyway so keep them translated down.
    float defaultButtonTransY = alwaysShowButtons ? 0 : transForIme;
    mPropertyHolders.add(new StatePropertyHolder(mTaskbarNavButtonTranslationYForIme, flags -> (flags & FLAG_IME_VISIBLE) != 0, AnimatedFloat.VALUE, transForIme, defaultButtonTransY));
    if (alwaysShowButtons) {
        initButtons(mNavButtonContainer, mEndContextualContainer, mControllers.navButtonController);
        if (isInSetup) {
            // Since setup wizard only has back button enabled, it looks strange to be
            // end-aligned, so start-align instead.
            FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams();
            navButtonsLayoutParams.setMarginStart(navButtonsLayoutParams.getMarginEnd());
            navButtonsLayoutParams.setMarginEnd(0);
            navButtonsLayoutParams.gravity = Gravity.START;
            mNavButtonContainer.requestLayout();
            // TODO(b/210906568) Dark intensity is currently not propagated during setup, so set
            // it based on dark theme for now.
            int mode = mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
            boolean isDarkTheme = mode == Configuration.UI_MODE_NIGHT_YES;
            mTaskbarNavButtonDarkIntensity.updateValue(isDarkTheme ? 0 : 1);
        }
        // Animate taskbar background when any of these flags are enabled
        int flagsToShowBg = FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE | FLAG_NOTIFICATION_SHADE_EXPANDED;
        mPropertyHolders.add(new StatePropertyHolder(mControllers.taskbarDragLayerController.getNavbarBackgroundAlpha(), flags -> (flags & flagsToShowBg) != 0, AnimatedFloat.VALUE, 1, 0));
        // Rotation button
        RotationButton rotationButton = new RotationButtonImpl(addButton(mEndContextualContainer, R.id.rotate_suggestion, R.layout.taskbar_contextual_button));
        rotationButton.hide();
        mControllers.rotationButtonController.setRotationButton(rotationButton, null);
    } else {
        mFloatingRotationButton = new FloatingRotationButton(mContext, R.string.accessibility_rotate_button, R.layout.rotate_suggestion, R.id.rotate_suggestion, R.dimen.floating_rotation_button_min_margin, R.dimen.rounded_corner_content_padding, R.dimen.floating_rotation_button_taskbar_left_margin, R.dimen.floating_rotation_button_taskbar_bottom_margin, R.dimen.floating_rotation_button_diameter, R.dimen.key_button_ripple_max_width);
        mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton, mRotationButtonListener);
        View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK, mStartContextualContainer, mControllers.navButtonController, R.id.back);
        imeDownButton.setRotation(Utilities.isRtl(mContext.getResources()) ? 90 : -90);
        // Rotate when Ime visible
        mPropertyHolders.add(new StatePropertyHolder(imeDownButton, flags -> (flags & FLAG_IME_VISIBLE) != 0));
    }
    applyState();
    mPropertyHolders.forEach(StatePropertyHolder::endAnimation);
}
Also used : Rect(android.graphics.Rect) BUTTON_A11Y(com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y) Config(android.content.pm.ActivityInfo.Config) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) IntPredicate(java.util.function.IntPredicate) BUTTON_HOME(com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME) Property(android.util.Property) ColorStateList(android.content.res.ColorStateList) BUTTON_BACK(com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK) View(android.view.View) ArgbEvaluator(android.animation.ArgbEvaluator) Op(android.graphics.Region.Op) RotationButtonController(com.android.systemui.shared.rotation.RotationButtonController) LayoutRes(android.annotation.LayoutRes) Utilities(com.android.launcher3.Utilities) RotationButton(com.android.systemui.shared.rotation.RotationButton) AnimatedFloat(com.android.quickstep.AnimatedFloat) SYSUI_STATE_SCREEN_PINNING(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING) ObjectAnimator(android.animation.ObjectAnimator) Region(android.graphics.Region) ViewGroup(android.view.ViewGroup) MultiValueAlpha(com.android.launcher3.util.MultiValueAlpha) SYSUI_STATE_BACK_DISABLED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BACK_DISABLED) IdRes(android.annotation.IdRes) SYSUI_STATE_HOME_DISABLED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED) SYSUI_STATE_OVERVIEW_DISABLED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED) BUTTON_IME_SWITCH(com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH) OnHoverListener(android.view.View.OnHoverListener) LauncherAnimUtils(com.android.launcher3.LauncherAnimUtils) AlphaUpdateListener(com.android.launcher3.anim.AlphaUpdateListener) BUTTON_RECENTS(com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS) SYSUI_STATE_A11Y_BUTTON_CLICKABLE(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) ArrayList(java.util.ArrayList) SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) MotionEvent(android.view.MotionEvent) DrawableRes(android.annotation.DrawableRes) SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) SYSUI_STATE_QUICK_SETTINGS_EXPANDED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED) VIEW_TRANSLATE_X(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X) ALPHA_INDEX_KEYGUARD(com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_KEYGUARD) TaskbarButton(com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton) FloatingRotationButton(com.android.systemui.shared.rotation.FloatingRotationButton) SYSUI_STATE_IME_SWITCHER_SHOWING(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SWITCHER_SHOWING) Gravity(android.view.Gravity) R(com.android.launcher3.R) Configuration(android.content.res.Configuration) SYSUI_STATE_IME_SHOWING(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING) OnClickListener(android.view.View.OnClickListener) RotationButton(com.android.systemui.shared.rotation.RotationButton) FloatingRotationButton(com.android.systemui.shared.rotation.FloatingRotationButton) FloatingRotationButton(com.android.systemui.shared.rotation.FloatingRotationButton) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) 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