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

Commit af472956 authored by Tetsutoki Shiozawa's avatar Tetsutoki Shiozawa Committed by Luca Stefani
Browse files

Fix overlap between operator name and heads-up notification

The title of heads-up notification was shown incompletely
becaue it's covered by operator name.
To fix this issue, the operator name should be hidden
when a heads-up notification is shown.

Fixes: b/116533819
Test: atest SystemUITests
Test: manual - enable config_showOperatorNameInStatusBar
               and show a heads-up notification

Merged-In: Id3318cd7cb2c9b6950392fadd11d02ab873d84c5
Change-Id: Id3318cd7cb2c9b6950392fadd11d02ab873d84c5
parent f7fc27e9
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -49,11 +49,6 @@
        android:paddingEnd="@dimen/status_bar_padding_end"
        android:orientation="horizontal"
        >
        <ViewStub
            android:id="@+id/operator_name"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout="@layout/operator_name" />
        <FrameLayout
            android:layout_height="match_parent"
            android:layout_width="0dp"
@@ -70,6 +65,12 @@
                android:layout_width="match_parent"
                android:clipChildren="false"
            >
                <ViewStub
                    android:id="@+id/operator_name"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout="@layout/operator_name" />

                <com.android.systemui.statusbar.policy.Clock
                    android:id="@+id/clock"
                    android:layout_width="wrap_content"
+46 −9
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
    private final NotificationStackScrollLayout mStackScroller;
    private final HeadsUpStatusBarView mHeadsUpStatusBarView;
    private final ClockController mClockController;
    private final View mOperatorNameView;
    private final DarkIconDispatcher mDarkIconDispatcher;
    private final NotificationPanelView mPanelView;
    private final Consumer<ExpandableNotificationRow>
@@ -65,6 +66,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
    private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener =
            (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
                    -> updatePanelTranslation();
    private boolean mAnimationsEnabled = true;
    Point mPoint;

    public HeadsUpAppearanceController(
@@ -75,6 +77,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
                statusbarView.findViewById(R.id.heads_up_status_bar_view),
                statusbarView.findViewById(R.id.notification_stack_scroller),
                statusbarView.findViewById(R.id.notification_panel),
                statusbarView.findViewById(R.id.operator_name_frame),
                new ClockController(statusbarView));
    }

@@ -85,6 +88,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
            HeadsUpStatusBarView headsUpStatusBarView,
            NotificationStackScrollLayout stackScroller,
            NotificationPanelView panelView,
            View operatorNameView,
            ClockController clockController) {
        mNotificationIconAreaController = notificationIconAreaController;
        mHeadsUpManager = headsUpManager;
@@ -101,6 +105,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
        mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener);
        mStackScroller.setHeadsUpAppearanceController(this);
        mClockController = clockController;
        mOperatorNameView = operatorNameView;
        mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class);
        mDarkIconDispatcher.addDarkReceiver(this);

@@ -232,22 +237,54 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
            mShown = isShown;
            if (isShown) {
                mHeadsUpStatusBarView.setVisibility(View.VISIBLE);
                CrossFadeHelper.fadeIn(mHeadsUpStatusBarView, CONTENT_FADE_DURATION /* duration */,
                        CONTENT_FADE_DELAY /* delay */);
                show(mHeadsUpStatusBarView);
                if (!isRightClock) {
                    CrossFadeHelper.fadeOut(clockView, CONTENT_FADE_DURATION/* duration */,
                            0 /* delay */, () -> clockView.setVisibility(View.INVISIBLE));
                    hide(clockView, View.INVISIBLE);
                }
                if (mOperatorNameView != null) {
                    hide(mOperatorNameView, View.INVISIBLE);
                }
            } else {
                if (!isRightClock) {
                    CrossFadeHelper.fadeIn(clockView, CONTENT_FADE_DURATION /* duration */,
                            CONTENT_FADE_DELAY /* delay */);
                    show(clockView);
                }
                if (mOperatorNameView != null) {
                    show(mOperatorNameView);
                }
                hide(mHeadsUpStatusBarView, View.GONE);
            }
        }
    }
                CrossFadeHelper.fadeOut(mHeadsUpStatusBarView, CONTENT_FADE_DURATION/* duration */,
                        0 /* delay */, () -> mHeadsUpStatusBarView.setVisibility(View.GONE));

    /**
     * Hides the view and sets the state to endState when finished.
     *
     * @param view The view to hide.
     * @param endState One of {@link View#INVISIBLE} or {@link View#GONE}.
     * @see View#setVisibility(int)
     *
     */
    private void hide(View view, int endState) {
        if (mAnimationsEnabled) {
            CrossFadeHelper.fadeOut(view, CONTENT_FADE_DURATION /* duration */,
                    0 /* delay */, () -> view.setVisibility(endState));
        } else {
            view.setVisibility(endState);
        }
    }

    private void show(View view) {
        if (mAnimationsEnabled) {
            CrossFadeHelper.fadeIn(view, CONTENT_FADE_DURATION /* duration */,
                    CONTENT_FADE_DELAY /* delay */);
        } else {
            view.setVisibility(View.VISIBLE);
        }
    }

    @VisibleForTesting
    void setAnimationsEnabled(boolean enabled) {
        mAnimationsEnabled = enabled;
    }

    @VisibleForTesting
+20 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
    private ExpandableNotificationRow mFirst;
    private HeadsUpStatusBarView mHeadsUpStatusBarView;
    private HeadsUpManagerPhone mHeadsUpManager;
    private View mOperatorNameView;

    @Before
    public void setUp() throws Exception {
@@ -70,13 +71,15 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
        mHeadsUpStatusBarView = new HeadsUpStatusBarView(mContext, mock(View.class),
                mock(TextView.class));
        mHeadsUpManager = mock(HeadsUpManagerPhone.class);
        mOperatorNameView = new View(mContext);
        mHeadsUpAppearanceController = new HeadsUpAppearanceController(
                mock(NotificationIconAreaController.class),
                mHeadsUpManager,
                mHeadsUpStatusBarView,
                mStackScroller,
                mPanelView,
                new View(mContext));
                new View(mContext),
                mOperatorNameView);
        mHeadsUpAppearanceController.setExpandedHeight(0.0f, 0.0f);
    }

@@ -122,6 +125,22 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
        Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 1.0f, 0.0f);
    }

    @Test
    public void testOperatorNameViewUpdated() {
        mHeadsUpAppearanceController.setAnimationsEnabled(false);

        mFirst.setPinned(true);
        when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
        when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
        mHeadsUpAppearanceController.onHeadsUpPinned(mFirst);
        Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility());

        mFirst.setPinned(false);
        when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
        mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst);
        Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility());
    }

    @Test
    public void testDestroy() {
        reset(mHeadsUpManager);