Search in sources :

Example 46 with Background

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

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)

Example 47 with Background

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

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 48 with Background

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

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 49 with Background

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

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 50 with Background

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

the class PopupContainerWithArrow method initializeSystemShortcut.

private void initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info) {
    View view = inflateAndAdd(resId, container, getInsertIndexForSystemShortcut(container, info));
    if (view instanceof DeepShortcutView) {
        // Expanded system shortcut, with both icon and text shown on white background.
        final DeepShortcutView shortcutView = (DeepShortcutView) view;
        info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText());
    } else if (view instanceof ImageView) {
        // Only the system shortcut icon shows on a gray background header.
        info.setIconAndContentDescriptionFor((ImageView) view);
        view.setTooltipText(view.getContentDescription());
    }
    view.setTag(info);
    view.setOnClickListener(info);
}
Also used : ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

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