Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0842c932 authored by Alison Cichowlas's avatar Alison Cichowlas Committed by Winson Chung
Browse files

Revert "Fix a couple issues with nav bar & rotation button"

This reverts commit 90d8bcf8.

Reason for revert: Causes frequent flakes in presubmit

Bug: 187033888

Change-Id: I5a64f917e78b48f72552d0d8f99caee56f912cd5
parent 90d8bcf8
Loading
Loading
Loading
Loading
+1 −9
Original line number Original line Diff line number Diff line
@@ -101,7 +101,6 @@ import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
import android.view.inputmethod.InputMethodManager;


import androidx.annotation.VisibleForTesting;
import androidx.annotation.VisibleForTesting;


@@ -1176,9 +1175,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        accessibilityButton.setOnLongClickListener(this::onAccessibilityLongClick);
        accessibilityButton.setOnLongClickListener(this::onAccessibilityLongClick);
        updateAccessibilityServicesState(mAccessibilityManager);
        updateAccessibilityServicesState(mAccessibilityManager);


        ButtonDispatcher imeSwitcherButton = mNavigationBarView.getImeSwitchButton();
        imeSwitcherButton.setOnClickListener(this::onImeSwitcherClick);

        updateScreenPinningGestures();
        updateScreenPinningGestures();
    }
    }


@@ -1278,11 +1274,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        mCommandQueue.toggleRecentApps();
        mCommandQueue.toggleRecentApps();
    }
    }


    private void onImeSwitcherClick(View v) {
        mContext.getSystemService(InputMethodManager.class).showInputMethodPickerFromSystem(
                true /* showAuxiliarySubtypes */, mDisplayId);
    };

    private boolean onLongPressBackHome(View v) {
    private boolean onLongPressBackHome(View v) {
        return onLongPressNavigationButtons(v, R.id.back, R.id.home);
        return onLongPressNavigationButtons(v, R.id.back, R.id.home);
    }
    }
@@ -1291,6 +1282,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        return onLongPressNavigationButtons(v, R.id.back, R.id.recent_apps);
        return onLongPressNavigationButtons(v, R.id.back, R.id.recent_apps);
    }
    }



    /**
    /**
     * This handles long-press of both back and recents/home. Back is the common button with
     * This handles long-press of both back and recents/home. Back is the common button with
     * combination of recents if it is visible or home if recents is invisible.
     * combination of recents if it is visible or home if recents is invisible.
+0 −3
Original line number Original line Diff line number Diff line
@@ -217,9 +217,6 @@ public class NavigationBarController implements Callbacks,


    @Override
    @Override
    public void onNavigationModeChanged(int mode) {
    public void onNavigationModeChanged(int mode) {
        if (mNavMode == mode) {
            return;
        }
        final int oldMode = mNavMode;
        final int oldMode = mNavMode;
        mNavMode = mode;
        mNavMode = mode;
        mHandler.post(() -> {
        mHandler.post(() -> {
+1 −0
Original line number Original line Diff line number Diff line
@@ -158,6 +158,7 @@ public class NavigationBarInflaterView extends FrameLayout
    }
    }


    public void onLikelyDefaultLayoutChange() {
    public void onLikelyDefaultLayoutChange() {

        // Reevaluate new layout
        // Reevaluate new layout
        final String newValue = getDefaultLayout();
        final String newValue = getDefaultLayout();
        if (!Objects.equals(mCurrentLayout, newValue)) {
        if (!Objects.equals(mCurrentLayout, newValue)) {
+20 −26
Original line number Original line Diff line number Diff line
@@ -166,7 +166,6 @@ public class NavigationBarView extends FrameLayout implements
    private NavigationBarInflaterView mNavigationInflaterView;
    private NavigationBarInflaterView mNavigationInflaterView;
    private RecentsOnboarding mRecentsOnboarding;
    private RecentsOnboarding mRecentsOnboarding;
    private NotificationPanelViewController mPanelView;
    private NotificationPanelViewController mPanelView;
    private RotationContextButton mRotationContextButton;
    private FloatingRotationButton mFloatingRotationButton;
    private FloatingRotationButton mFloatingRotationButton;
    private RotationButtonController mRotationButtonController;
    private RotationButtonController mRotationButtonController;
    private NavigationBarOverlayController mNavBarOverlayController;
    private NavigationBarOverlayController mNavBarOverlayController;
@@ -234,6 +233,14 @@ public class NavigationBarView extends FrameLayout implements
        }
        }
    }
    }


    private final OnClickListener mImeSwitcherClickListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            mContext.getSystemService(InputMethodManager.class).showInputMethodPickerFromSystem(
                    true /* showAuxiliarySubtypes */, getContext().getDisplayId());
        }
    };

    private final AccessibilityDelegate mQuickStepAccessibilityDelegate =
    private final AccessibilityDelegate mQuickStepAccessibilityDelegate =
            new AccessibilityDelegate() {
            new AccessibilityDelegate() {
                private AccessibilityAction mToggleOverviewAction;
                private AccessibilityAction mToggleOverviewAction;
@@ -304,26 +311,32 @@ public class NavigationBarView extends FrameLayout implements
        mIsVertical = false;
        mIsVertical = false;
        mLongClickableAccessibilityButton = false;
        mLongClickableAccessibilityButton = false;
        mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this);
        mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this);
        boolean isGesturalMode = isGesturalMode(mNavBarMode);


        mSysUiFlagContainer = Dependency.get(SysUiState.class);
        mSysUiFlagContainer = Dependency.get(SysUiState.class);
        // Set up the context group of buttons
        // Set up the context group of buttons
        mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container);
        mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container);
        final ContextualButton imeSwitcherButton = new ContextualButton(R.id.ime_switcher,
        final ContextualButton imeSwitcherButton = new ContextualButton(R.id.ime_switcher,
                mLightContext, R.drawable.ic_ime_switcher_default);
                mLightContext, R.drawable.ic_ime_switcher_default);
        final RotationContextButton rotateSuggestionButton = new RotationContextButton(
                R.id.rotate_suggestion, mLightContext,
                R.drawable.ic_sysbar_rotate_button_ccw_start_0);
        final ContextualButton accessibilityButton =
        final ContextualButton accessibilityButton =
                new ContextualButton(R.id.accessibility_button, mLightContext,
                new ContextualButton(R.id.accessibility_button, mLightContext,
                        R.drawable.ic_sysbar_accessibility_button);
                        R.drawable.ic_sysbar_accessibility_button);
        mContextualButtonGroup.addButton(imeSwitcherButton);
        mContextualButtonGroup.addButton(imeSwitcherButton);
        if (!isGesturalMode) {
            mContextualButtonGroup.addButton(rotateSuggestionButton);
        }
        mContextualButtonGroup.addButton(accessibilityButton);
        mContextualButtonGroup.addButton(accessibilityButton);


        mOverviewProxyService = Dependency.get(OverviewProxyService.class);
        mOverviewProxyService = Dependency.get(OverviewProxyService.class);
        mRotationContextButton = new RotationContextButton(R.id.rotate_suggestion,
                mLightContext, R.drawable.ic_sysbar_rotate_button_ccw_start_0);
        mFloatingRotationButton = new FloatingRotationButton(context);
        mFloatingRotationButton = new FloatingRotationButton(context);
        mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
        mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
        mRotationButtonController = new RotationButtonController(mLightContext,
        mRotationButtonController = new RotationButtonController(mLightContext,
                mLightIconColor, mDarkIconColor);
                mLightIconColor, mDarkIconColor,
        updateRotationButton();
                isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton,
                mRotationButtonListener);


        mNavBarOverlayController = Dependency.get(NavigationBarOverlayController.class);
        mNavBarOverlayController = Dependency.get(NavigationBarOverlayController.class);
        if (mNavBarOverlayController.isNavigationBarOverlayEnabled()) {
        if (mNavBarOverlayController.isNavigationBarOverlayEnabled()) {
@@ -344,6 +357,7 @@ public class NavigationBarView extends FrameLayout implements
        mButtonDispatchers.put(R.id.recent_apps, new ButtonDispatcher(R.id.recent_apps));
        mButtonDispatchers.put(R.id.recent_apps, new ButtonDispatcher(R.id.recent_apps));
        mButtonDispatchers.put(R.id.ime_switcher, imeSwitcherButton);
        mButtonDispatchers.put(R.id.ime_switcher, imeSwitcherButton);
        mButtonDispatchers.put(R.id.accessibility_button, accessibilityButton);
        mButtonDispatchers.put(R.id.accessibility_button, accessibilityButton);
        mButtonDispatchers.put(R.id.rotate_suggestion, rotateSuggestionButton);
        mButtonDispatchers.put(R.id.menu_container, mContextualButtonGroup);
        mButtonDispatchers.put(R.id.menu_container, mContextualButtonGroup);
        mDeadZone = new DeadZone(this);
        mDeadZone = new DeadZone(this);


@@ -541,23 +555,6 @@ public class NavigationBarView extends FrameLayout implements
        }
        }
    }
    }


    /**
     * Updates the rotation button based on the current navigation mode.
     */
    private void updateRotationButton() {
        if (isGesturalMode(mNavBarMode)) {
            mContextualButtonGroup.removeButton(R.id.rotate_suggestion);
            mButtonDispatchers.remove(R.id.rotate_suggestion);
            mRotationButtonController.setRotationButton(mFloatingRotationButton,
                    mRotationButtonListener);
        } else if (mContextualButtonGroup.getContextButton(R.id.rotate_suggestion) == null) {
            mContextualButtonGroup.addButton(mRotationContextButton);
            mButtonDispatchers.put(R.id.rotate_suggestion, mRotationContextButton);
            mRotationButtonController.setRotationButton(mRotationContextButton,
                    mRotationButtonListener);
        }
    }

    public KeyButtonDrawable getBackDrawable() {
    public KeyButtonDrawable getBackDrawable() {
        KeyButtonDrawable drawable = getDrawable(getBackDrawableRes());
        KeyButtonDrawable drawable = getDrawable(getBackDrawableRes());
        orientBackButton(drawable);
        orientBackButton(drawable);
@@ -911,7 +908,6 @@ public class NavigationBarView extends FrameLayout implements
        mBarTransitions.onNavigationModeChanged(mNavBarMode);
        mBarTransitions.onNavigationModeChanged(mNavBarMode);
        mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode);
        mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode);
        mRecentsOnboarding.onNavigationModeChanged(mNavBarMode);
        mRecentsOnboarding.onNavigationModeChanged(mNavBarMode);
        updateRotationButton();


        if (isGesturalMode(mNavBarMode)) {
        if (isGesturalMode(mNavBarMode)) {
            mRegionSamplingHelper.start(mSamplingBounds);
            mRegionSamplingHelper.start(mSamplingBounds);
@@ -936,6 +932,7 @@ public class NavigationBarView extends FrameLayout implements
        mNavigationInflaterView = findViewById(R.id.navigation_inflater);
        mNavigationInflaterView = findViewById(R.id.navigation_inflater);
        mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);
        mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);


        getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
        updateOrientationViews();
        updateOrientationViews();
        reloadNavIcons();
        reloadNavIcons();
    }
    }
@@ -1030,9 +1027,6 @@ public class NavigationBarView extends FrameLayout implements


    private void updateButtonLocation(ButtonDispatcher button, boolean inScreenSpace,
    private void updateButtonLocation(ButtonDispatcher button, boolean inScreenSpace,
            boolean useNearestRegion) {
            boolean useNearestRegion) {
        if (button == null) {
            return;
        }
        View view = button.getCurrentView();
        View view = button.getCurrentView();
        if (view == null || !button.isVisible()) {
        if (view == null || !button.isVisible()) {
            return;
            return;
+7 −8
Original line number Original line Diff line number Diff line
@@ -66,10 +66,10 @@ public class RotationButtonController {
    private static final int NUM_ACCEPTED_ROTATION_SUGGESTIONS_FOR_INTRODUCTION = 3;
    private static final int NUM_ACCEPTED_ROTATION_SUGGESTIONS_FOR_INTRODUCTION = 3;


    private final Context mContext;
    private final Context mContext;
    private final RotationButton mRotationButton;
    private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
    private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
    private final UiEventLogger mUiEventLogger = new UiEventLoggerImpl();
    private final UiEventLogger mUiEventLogger = new UiEventLoggerImpl();
    private final ViewRippler mViewRippler = new ViewRippler();
    private final ViewRippler mViewRippler = new ViewRippler();
    private RotationButton mRotationButton;


    private int mLastRotationSuggestion;
    private int mLastRotationSuggestion;
    private boolean mPendingRotationSuggestion;
    private boolean mPendingRotationSuggestion;
@@ -125,21 +125,20 @@ public class RotationButtonController {
    }
    }


    RotationButtonController(Context context, @ColorInt int lightIconColor,
    RotationButtonController(Context context, @ColorInt int lightIconColor,
            @ColorInt int darkIconColor) {
            @ColorInt int darkIconColor, RotationButton rotationButton,
            Consumer<Boolean> visibilityChangedCallback) {
        mContext = context;
        mContext = context;
        mLightIconColor = lightIconColor;
        mLightIconColor = lightIconColor;
        mDarkIconColor = darkIconColor;
        mDarkIconColor = darkIconColor;
        mRotationButton = rotationButton;
        mRotationButton.setRotationButtonController(this);


        mIsNavigationBarShowing = true;
        mIsNavigationBarShowing = true;
        mRotationLockController = Dependency.get(RotationLockController.class);
        mRotationLockController = Dependency.get(RotationLockController.class);
        mAccessibilityManagerWrapper = Dependency.get(AccessibilityManagerWrapper.class);
        mAccessibilityManagerWrapper = Dependency.get(AccessibilityManagerWrapper.class);
        mTaskStackListener = new TaskStackListenerImpl();
    }


    void setRotationButton(RotationButton rotationButton,
        // Register the task stack listener
            Consumer<Boolean> visibilityChangedCallback) {
        mTaskStackListener = new TaskStackListenerImpl();
        mRotationButton = rotationButton;
        mRotationButton.setRotationButtonController(this);
        mRotationButton.setOnClickListener(this::onRotateSuggestionClick);
        mRotationButton.setOnClickListener(this::onRotateSuggestionClick);
        mRotationButton.setOnHoverListener(this::onRotateSuggestionHover);
        mRotationButton.setOnHoverListener(this::onRotateSuggestionHover);
        mRotationButton.setVisibilityChangedCallback(visibilityChangedCallback);
        mRotationButton.setVisibilityChangedCallback(visibilityChangedCallback);
Loading