Search in sources :

Example 6 with RotationButton

use of com.android.systemui.shared.rotation.RotationButton in project android_packages_apps_404Launcher by P-404.

the class NavigationBarRotationContextTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    Context mTargetContext = InstrumentationRegistry.getTargetContext();
    final View view = new View(mTargetContext);
    RotationButton rotationButton = mock(RotationButton.class);
    mRotationButtonController = new RotationButtonController(mTargetContext, 0, 0, 0, 0, 0, 0, () -> 0);
    mRotationButtonController.setRotationButton(rotationButton, null);
    // Due to a mockito issue, only spy the object after setting the initial state
    mRotationButtonController = spy(mRotationButtonController);
    final AnimatedVectorDrawable kbd = mock(AnimatedVectorDrawable.class);
    doReturn(view).when(rotationButton).getCurrentView();
    doReturn(true).when(rotationButton).acceptRotationProposal();
}
Also used : Context(android.content.Context) RotationButton(com.android.systemui.shared.rotation.RotationButton) View(android.view.View) RotationButtonController(com.android.systemui.shared.rotation.RotationButtonController) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) Before(org.junit.Before)

Example 7 with RotationButton

use of com.android.systemui.shared.rotation.RotationButton in project android_packages_apps_Launcher3 by ProtonAOSP.

the class NavigationBarRotationContextTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    Context mTargetContext = InstrumentationRegistry.getTargetContext();
    final View view = new View(mTargetContext);
    RotationButton rotationButton = mock(RotationButton.class);
    mRotationButtonController = new RotationButtonController(mTargetContext, 0, 0, 0, 0, 0, 0, () -> 0);
    mRotationButtonController.setRotationButton(rotationButton, null);
    // Due to a mockito issue, only spy the object after setting the initial state
    mRotationButtonController = spy(mRotationButtonController);
    final AnimatedVectorDrawable kbd = mock(AnimatedVectorDrawable.class);
    doReturn(view).when(rotationButton).getCurrentView();
    doReturn(true).when(rotationButton).acceptRotationProposal();
}
Also used : Context(android.content.Context) RotationButton(com.android.systemui.shared.rotation.RotationButton) View(android.view.View) RotationButtonController(com.android.systemui.shared.rotation.RotationButtonController) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) Before(org.junit.Before)

Example 8 with RotationButton

use of com.android.systemui.shared.rotation.RotationButton in project android_packages_apps_Launcher3 by ProtonAOSP.

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

AnimatedVectorDrawable (android.graphics.drawable.AnimatedVectorDrawable)8 View (android.view.View)8 RotationButton (com.android.systemui.shared.rotation.RotationButton)8 RotationButtonController (com.android.systemui.shared.rotation.RotationButtonController)8 ArgbEvaluator (android.animation.ArgbEvaluator)4 ObjectAnimator (android.animation.ObjectAnimator)4 DrawableRes (android.annotation.DrawableRes)4 IdRes (android.annotation.IdRes)4 LayoutRes (android.annotation.LayoutRes)4 Config (android.content.pm.ActivityInfo.Config)4 ColorStateList (android.content.res.ColorStateList)4 Configuration (android.content.res.Configuration)4 Rect (android.graphics.Rect)4 Region (android.graphics.Region)4 Op (android.graphics.Region.Op)4 Property (android.util.Property)4 Gravity (android.view.Gravity)4 MotionEvent (android.view.MotionEvent)4 OnClickListener (android.view.View.OnClickListener)4 OnHoverListener (android.view.View.OnHoverListener)4