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

Commit 7fc9dc16 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

AOD notification icons placement

Whenever there's a custom clock, notification icons should be on the top
left. The default clock will just show the dark shelf.

Test: atest NotificationStackScrollLayoutTest
Test: atest CollapsedStatusBarFragmentTest
Test: visual - with and w/o clock plugin
Test: visual - with and w/o RTL layout
Bug: 122301289
Bug: 111405682
Fixes: 120563185
Change-Id: I4c513d347f656262ee6f91bd208ab9f219e4419c
parent fd1e0362
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -87,6 +87,13 @@ public class KeyguardClockSwitch extends RelativeLayout {
        super(context, attrs);
    }

    /**
     * Returns if this view is presenting a custom clock, or the default implementation.
     */
    public boolean hasCustomClock() {
        return mClockPlugin != null;
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
+7 −0
Original line number Diff line number Diff line
@@ -141,6 +141,13 @@ public class KeyguardStatusView extends GridLayout implements
        onDensityOrFontScaleChanged();
    }

    /**
     * If we're presenting a custom clock of just the default one.
     */
    public boolean hasCustomClock() {
        return mClockView.hasCustomClock();
    }

    private void setEnableMarquee(boolean enabled) {
        if (DEBUG) Log.v(TAG, "Schedule setEnableMarquee: " + (enabled ? "Enable" : "Disable"));
        if (enabled) {
+3 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationData;
@@ -136,8 +137,8 @@ public class SystemUIFactory {
    }

    public NotificationIconAreaController createNotificationIconAreaController(Context context,
            StatusBar statusBar) {
        return new NotificationIconAreaController(context, statusBar);
            StatusBar statusBar, StatusBarStateController statusBarStateController) {
        return new NotificationIconAreaController(context, statusBar, statusBarStateController);
    }

    public KeyguardIndicationController createKeyguardIndicationController(Context context,
+6 −7
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ import java.io.PrintWriter;
 *
 * It does not collect touch events when the bouncer shows up.
 */
public class FalsingManager implements SensorEventListener {
public class FalsingManager implements SensorEventListener, StateListener {
    private static final String ENFORCE_BOUNCER = "falsing_manager_enforce_bouncer";

    private static final int[] CLASSIFIER_SENSORS = new int[] {
@@ -84,8 +84,6 @@ public class FalsingManager implements SensorEventListener {
    private boolean mShowingAod;
    private Runnable mPendingWtf;

    private final StateListener mStateListener = this::setStatusBarState;

    protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) {
        @Override
        public void onChange(boolean selfChange) {
@@ -108,7 +106,7 @@ public class FalsingManager implements SensorEventListener {
                UserHandle.USER_ALL);

        updateConfiguration();
        Dependency.get(StatusBarStateController.class).addCallback(mStateListener);
        Dependency.get(StatusBarStateController.class).addCallback(this);
    }

    public static FalsingManager getInstance(Context context) {
@@ -282,14 +280,15 @@ public class FalsingManager implements SensorEventListener {
        updateSessionActive();
    }

    private void setStatusBarState(int state) {
    @Override
    public void onStateChanged(int newState) {
        if (FalsingLog.ENABLED) {
            FalsingLog.i("setStatusBarState", new StringBuilder()
                    .append("from=").append(StatusBarState.toShortString(mState))
                    .append(" to=").append(StatusBarState.toShortString(state))
                    .append(" to=").append(StatusBarState.toShortString(newState))
                    .toString());
        }
        mState = state;
        mState = newState;
        updateSessionActive();
    }

+30 −11
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ import com.android.systemui.statusbar.phone.NotificationIconContainer;
 * overflow icons that don't fit into the regular list anymore.
 */
public class NotificationShelf extends ActivatableNotificationView implements
        View.OnLayoutChangeListener {
        View.OnLayoutChangeListener, StateListener {

    private static final boolean USE_ANIMATIONS_WHEN_OPENING =
            SystemProperties.getBoolean("debug.icon_opening_animations", true);
@@ -95,8 +95,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
    private int mCutoutHeight;
    private int mGapHeight;

    private final StateListener mStateListener = this::setStatusBarState;

    public NotificationShelf(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
@@ -121,13 +119,13 @@ public class NotificationShelf extends ActivatableNotificationView implements
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        Dependency.get(StatusBarStateController.class)
                .addCallback(mStateListener, StatusBarStateController.RANK_SHELF);
                .addCallback(this, StatusBarStateController.RANK_SHELF);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Dependency.get(StatusBarStateController.class).removeCallback(mStateListener);
        Dependency.get(StatusBarStateController.class).removeCallback(this);
    }

    public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout) {
@@ -174,6 +172,24 @@ public class NotificationShelf extends ActivatableNotificationView implements
        updateInteractiveness();
    }

    /**
     * Alpha animation with translation played when this view is visible on AOD.
     */
    public void fadeInTranslating() {
        mShelfIcons.setTranslationY(-mShelfAppearTranslation);
        mShelfIcons.setAlpha(0);
        mShelfIcons.animate()
                .setInterpolator(Interpolators.DECELERATE_QUINT)
                .translationY(0)
                .setDuration(SHELF_IN_TRANSLATION_DURATION)
                .start();
        mShelfIcons.animate()
                .alpha(1)
                .setInterpolator(Interpolators.LINEAR)
                .setDuration(SHELF_IN_TRANSLATION_DURATION)
                .start();
    }

    @Override
    protected View getContentView() {
        return mShelfIcons;
@@ -225,7 +241,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
            }
            viewState.hasItemsInStableShelf = lastViewState.inShelf;
            viewState.hidden = !mAmbientState.isShadeExpanded()
                    || mAmbientState.isQsCustomizerShowing() || mAmbientState.isFullyDark();
                    || mAmbientState.isQsCustomizerShowing();
            viewState.maxShelfEnd = maxShelfEnd;
        } else {
            viewState.hidden = true;
@@ -420,7 +436,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
        float maxTop = row.getTranslationY();
        StatusBarIconView icon = row.getEntry().expandedIcon;
        float shelfIconPosition = getTranslationY() + icon.getTop() + icon.getTranslationY();
        if (shelfIconPosition < maxTop) {
        if (shelfIconPosition < maxTop && !mAmbientState.isDark()) {
            int top = (int) (maxTop - shelfIconPosition);
            Rect clipRect = new Rect(0, top, icon.getWidth(), Math.max(top, icon.getHeight()));
            icon.setClipBounds(clipRect);
@@ -431,7 +447,7 @@ public class NotificationShelf extends ActivatableNotificationView implements

    private void updateContinuousClipping(final ExpandableNotificationRow row) {
        StatusBarIconView icon = row.getEntry().expandedIcon;
        boolean needsContinuousClipping = ViewState.isAnimatingY(icon);
        boolean needsContinuousClipping = ViewState.isAnimatingY(icon) && !mAmbientState.isDark();
        boolean isContinuousClipping = icon.getTag(TAG_CONTINUOUS_CLIPPING) != null;
        if (needsContinuousClipping && !isContinuousClipping) {
            final ViewTreeObserver observer = icon.getViewTreeObserver();
@@ -622,7 +638,9 @@ public class NotificationShelf extends ActivatableNotificationView implements
            iconState.translateContent = false;
        }
        float transitionAmount;
        if (isLastChild || !USE_ANIMATIONS_WHEN_OPENING || iconState.useFullTransitionAmount
        if (mAmbientState.isDarkAtAll() && !row.isInShelf()) {
            transitionAmount = mAmbientState.isFullyDark() ? 1 : 0;
        } else if (isLastChild || !USE_ANIMATIONS_WHEN_OPENING || iconState.useFullTransitionAmount
                || iconState.useLinearTransitionAmount) {
            transitionAmount = iconTransitionAmount;
        } else {
@@ -860,8 +878,9 @@ public class NotificationShelf extends ActivatableNotificationView implements
        mCollapsedIcons.addOnLayoutChangeListener(this);
    }

    private void setStatusBarState(int statusBarState) {
        mStatusBarState = statusBarState;
    @Override
    public void onStateChanged(int newState) {
        mStatusBarState = newState;
        updateInteractiveness();
    }

Loading