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

Commit 3ba002b6 authored by mpodolian's avatar mpodolian
Browse files

Switch Bubble Bar side on navigation mode change to 3 buttons.

When user updates to the 3 buttons navigation mode, launcher should
switch the bubble ber to the left side (or to the right if RTL).

Fixes: 346381754
Test: WMShellRobolectricTests
Test: Manual. Have bubble bar on the default side with some bubbles in
gesture mode. Switch to 3 buttons navigation mode. Bubble bar is
moved to the opposite side.
Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/hH2pQqDOTzQuci4k1N3q99
Flag: com.android.wm.shell.enable_bubble_bar

Change-Id: I6b8dd9fbcf872958a2a305c21241b0c865bbef04
parent c3217eaa
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -274,7 +274,8 @@ public class BubbleController implements ConfigurationChangeListener,
    private final DragAndDropController mDragAndDropController;
    /** Used to send bubble events to launcher. */
    private Bubbles.BubbleStateListener mBubbleStateListener;

    /** Used to track previous navigation mode to detect switch to buttons navigation. */
    private boolean mIsPrevNavModeGestures;
    /** Used to send updates to the views from {@link #mBubbleDataListener}. */
    private BubbleViewCallback mBubbleViewCallback;

@@ -356,6 +357,7 @@ public class BubbleController implements ConfigurationChangeListener,
            }
        };
        mExpandedViewManager = BubbleExpandedViewManager.fromBubbleController(this);
        mIsPrevNavModeGestures = ContextUtils.isGestureNavigationMode(mContext);
    }

    private void registerOneHandedState(OneHandedController oneHanded) {
@@ -589,6 +591,13 @@ public class BubbleController implements ConfigurationChangeListener,
     */
    private void sendInitialListenerUpdate() {
        if (mBubbleStateListener != null) {
            boolean isCurrentNavModeGestures = ContextUtils.isGestureNavigationMode(mContext);
            if (mIsPrevNavModeGestures && !isCurrentNavModeGestures) {
                BubbleBarLocation navButtonsLocation = ContextUtils.isRtl(mContext)
                        ? BubbleBarLocation.RIGHT : BubbleBarLocation.LEFT;
                mBubblePositioner.setBubbleBarLocation(navButtonsLocation);
            }
            mIsPrevNavModeGestures = isCurrentNavModeGestures;
            BubbleBarUpdate update = mBubbleData.getInitialStateForBubbleBar();
            mBubbleStateListener.onBubbleStateChange(update);
        }
+3 −10
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ import android.view.ViewOutlineProvider;
import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.WindowManagerPolicyConstants;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.FrameLayout;
@@ -91,10 +90,10 @@ import com.android.wm.shell.bubbles.animation.PhysicsAnimationLayout;
import com.android.wm.shell.bubbles.animation.StackAnimationController;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.shared.bubbles.DismissView;
import com.android.wm.shell.shared.bubbles.RelativeTouchListener;
import com.android.wm.shell.shared.animation.Interpolators;
import com.android.wm.shell.shared.animation.PhysicsAnimator;
import com.android.wm.shell.shared.bubbles.DismissView;
import com.android.wm.shell.shared.bubbles.RelativeTouchListener;
import com.android.wm.shell.shared.magnetictarget.MagnetizedObject;

import java.io.PrintWriter;
@@ -2276,7 +2275,7 @@ public class BubbleStackView extends FrameLayout
    void startMonitoringSwipeUpGesture() {
        stopMonitoringSwipeUpGestureInternal();

        if (isGestureNavEnabled()) {
        if (ContextUtils.isGestureNavigationMode(mContext)) {
            mBubblesNavBarGestureTracker = new BubblesNavBarGestureTracker(mContext, mPositioner);
            mBubblesNavBarGestureTracker.start(mSwipeUpListener);
            setOnTouchListener(mContainerSwipeListener);
@@ -2311,12 +2310,6 @@ public class BubbleStackView extends FrameLayout
        }
    }

    private boolean isGestureNavEnabled() {
        return mContext.getResources().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode)
                == WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
    }

    /**
     * Stop monitoring for swipe up gesture
     */
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.bubbles

import android.content.Context
import android.view.View
import android.view.WindowManagerPolicyConstants
import com.android.internal.R

/** Simplifies accessing context fields. */
object ContextUtils {

    /** Gets navigation mode. */
    @JvmStatic
    val Context.navigationMode: Int
        get() = resources.getInteger(R.integer.config_navBarInteractionMode)

    /** Returns whether the navigation mode is gestures. */
    @JvmStatic
    val Context.isGestureNavigationMode: Boolean
        get() = navigationMode == WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL

    /** Returns whether layout direction is rtl. */
    @JvmStatic
    val Context.isRtl: Boolean
        get() = resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL
}