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

Commit b2c5dc52 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed the appearance of the heads up statusbar view on the lockscreen

The text is now based on the sensitivity of the notifications which
also makes sure that dynamic privacy and other functions work
properly and aren't based on the global public device state
but individual.

Bug: 130327302
Test: add hun on lockscreen, observe correct text
Change-Id: I26a12ff6395dbbfb30bf87f0da1fa0a951edec94
parent 0b8cb86f
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
    private static final String HEADS_UP_STATUS_BAR_VIEW_SUPER_PARCELABLE =
            "heads_up_status_bar_view_super_parcelable";
    private static final String FIRST_LAYOUT = "first_layout";
    private static final String PUBLIC_MODE = "public_mode";
    private static final String VISIBILITY = "visibility";
    private static final String ALPHA = "alpha";
    private int mAbsoluteStartPadding;
@@ -54,7 +53,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
    private Rect mLayoutedIconRect = new Rect();
    private int[] mTmpPosition = new int[2];
    private boolean mFirstLayout = true;
    private boolean mPublicMode;
    private int mMaxWidth;
    private View mRootView;
    private int mSysWinInset;
@@ -121,7 +119,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
        bundle.putParcelable(HEADS_UP_STATUS_BAR_VIEW_SUPER_PARCELABLE,
                super.onSaveInstanceState());
        bundle.putBoolean(FIRST_LAYOUT, mFirstLayout);
        bundle.putBoolean(PUBLIC_MODE, mPublicMode);
        bundle.putInt(VISIBILITY, getVisibility());
        bundle.putFloat(ALPHA, getAlpha());

@@ -139,7 +136,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
        Parcelable superState = bundle.getParcelable(HEADS_UP_STATUS_BAR_VIEW_SUPER_PARCELABLE);
        super.onRestoreInstanceState(superState);
        mFirstLayout = bundle.getBoolean(FIRST_LAYOUT, true);
        mPublicMode = bundle.getBoolean(PUBLIC_MODE, false);
        if (bundle.containsKey(VISIBILITY)) {
            setVisibility(bundle.getInt(VISIBILITY));
        }
@@ -166,11 +162,13 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
        if (entry != null) {
            mShowingEntry = entry;
            CharSequence text = entry.headsUpStatusBarText;
            if (mPublicMode) {
            if (entry.isSensitive()) {
                text = entry.headsUpStatusBarTextPublic;
            }
            mTextView.setText(text);
        } else {
            mShowingEntry.setOnSensitiveChangedListener(() -> setEntry(entry));
        } else if (mShowingEntry != null){
            mShowingEntry.setOnSensitiveChangedListener(null);
            mShowingEntry = null;
        }
    }
@@ -273,10 +271,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
        mTextView.setTextColor(DarkIconDispatcher.getTint(area, this, tint));
    }

    public void setPublicMode(boolean publicMode) {
        mPublicMode = publicMode;
    }

    public void setOnDrawingRectChangedListener(Runnable onDrawingRectChangedListener) {
        mOnDrawingRectChangedListener = onDrawingRectChangedListener;
    }
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
            boolean deviceSensitive = devicePublic
                    && !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic(
                    currentUserId);
            ent.getRow().setSensitive(sensitive, deviceSensitive);
            ent.setSensitive(sensitive, deviceSensitive);
            ent.getRow().setNeedsRedaction(needsRedaction);
            if (mGroupManager.isChildInGroupWithSummary(ent.notification)) {
                NotificationEntry summary = mGroupManager.getGroupSummary(ent.notification);
+26 −0
Original line number Diff line number Diff line
@@ -173,6 +173,8 @@ public final class NotificationEntry {
     * the lock screen/status bar and in the top section in the shade.
     */
    private boolean mHighPriority;
    private boolean mSensitive = true;
    private Runnable mOnSensitiveChangedListener;

    public NotificationEntry(StatusBarNotification n) {
        this(n, null);
@@ -859,6 +861,30 @@ public final class NotificationEntry {
        return Objects.equals(n.category, category);
    }

    /**
     * Set this notification to be sensitive.
     *
     * @param sensitive true if the content of this notification is sensitive right now
     * @param deviceSensitive true if the device in general is sensitive right now
     */
    public void setSensitive(boolean sensitive, boolean deviceSensitive) {
        getRow().setSensitive(sensitive, deviceSensitive);
        if (sensitive != mSensitive) {
            mSensitive = sensitive;
            if (mOnSensitiveChangedListener != null) {
                mOnSensitiveChangedListener.run();
            }
        }
    }

    public boolean isSensitive() {
        return mSensitive;
    }

    public void setOnSensitiveChangedListener(Runnable listener) {
        mOnSensitiveChangedListener = listener;
    }

    /** Information about a suggestion that is being edited. */
    public static class EditedSuggestionInfo {

+1 −1
Original line number Diff line number Diff line
@@ -5241,7 +5241,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        boolean publicMode = mLockscreenUserManager.isAnyProfilePublicMode();

        if (mHeadsUpAppearanceController != null) {
            mHeadsUpAppearanceController.setPublicMode(publicMode);
            mHeadsUpAppearanceController.onStateChanged();
        }

        SysuiStatusBarStateController state = (SysuiStatusBarStateController)
+1 −2
Original line number Diff line number Diff line
@@ -400,8 +400,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
        mHeadsUpStatusBarView.onDarkChanged(area, darkIntensity, tint);
    }

    public void setPublicMode(boolean publicMode) {
        mHeadsUpStatusBarView.setPublicMode(publicMode);
    public void onStateChanged() {
        updateTopEntry();
    }