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

Commit 997a4917 authored by Steve Elliott's avatar Steve Elliott
Browse files

Add unlock to see more messaging to locked shade

If the device is locked, and there are no notifications visible on the
keyguard, and the user expands the shade, if there would be
notifications present if the device is unlocked, then display a message.

Test: manual
      1: Enable "Only Show Unseen Notifs On Keyguard" flag
      2: Have some notifications
      3: Lock device
      4: On keyguard, observe no notifications
      5: Expand shade (without unlocking)
      Observe: New UI treatment is visible
Bug: 240472040
Change-Id: Ieeeb12aabb2b07bd9f4156a000ef8b2659be5e2f
parent a7366e4f
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -21,12 +21,29 @@
        android:layout_height="wrap_content"
        android:visibility="gone"
        >
    <LinearLayout android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            >
        <TextView
                android:id="@+id/no_notifications"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:minHeight="64dp"
            android:textAppearance="?android:attr/textAppearanceButton"
                android:gravity="center"
                android:textAppearance="?android:attr/textAppearanceButton"
                android:text="@string/empty_shade_text"/>
        <TextView
                android:id="@+id/no_notifications_footer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:gravity="center"
                android:drawablePadding="8dp"
                android:visibility="gone"
                android:textAppearance="?android:attr/textAppearanceButton"
                android:text="@string/unlock_to_see_notif_text"/>
    </LinearLayout>
</com.android.systemui.statusbar.EmptyShadeView>
+2 −0
Original line number Diff line number Diff line
@@ -403,6 +403,8 @@
        (quick_qs_offset_height (60dp)  - ongoing_appops_chip_height (24dp) ) / 2 -->
    <dimen name="notifications_top_padding_split_shade">18dp</dimen>

    <dimen name="notifications_unseen_footer_icon_size">16dp</dimen>

    <!-- Height of the status bar header bar when on Keyguard -->
    <dimen name="status_bar_header_height_keyguard">40dp</dimen>

+6 −0
Original line number Diff line number Diff line
@@ -1047,6 +1047,12 @@
    <!-- Text which is shown in the notification shade when there are no notifications. [CHAR LIMIT=30] -->
    <string name="empty_shade_text">No notifications</string>

    <!-- Text which is shown in the expanded notification shade when there are currently no notifications visible that the user hasn't already seen. [CHAR LIMIT=30] -->
    <string name="no_unseen_notif_text">No new notifications</string>

    <!-- Text which is shown in the locked notification shade when there are currently no notifications, but if the user were to unlock, notifications would appear. [CHAR LIMIT=40] -->
    <string name="unlock_to_see_notif_text">Unlock to see older notifications</string>

    <!-- Disclosure at the bottom of Quick Settings that indicates that parental controls are enabled. [CHAR LIMIT=100] -->
    <string name="quick_settings_disclosure_parental_controls">This device is managed by your parent</string>

+59 −1
Original line number Diff line number Diff line
@@ -17,9 +17,12 @@
package com.android.systemui.statusbar;

import android.annotation.ColorInt;
import android.annotation.DrawableRes;
import android.annotation.StringRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
@@ -33,16 +36,30 @@ import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
public class EmptyShadeView extends StackScrollerDecorView {

    private TextView mEmptyText;
    private TextView mEmptyFooterText;

    private @StringRes int mText = R.string.empty_shade_text;

    private @DrawableRes int mFooterIcon = R.drawable.ic_friction_lock_closed;
    private @StringRes int mFooterText = R.string.unlock_to_see_notif_text;
    private @Visibility int mFooterVisibility = View.GONE;
    private int mSize;

    public EmptyShadeView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mSize = getResources().getDimensionPixelSize(
                R.dimen.notifications_unseen_footer_icon_size);
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mSize = getResources().getDimensionPixelSize(
                R.dimen.notifications_unseen_footer_icon_size);
        mEmptyText.setText(mText);
        mEmptyFooterText.setVisibility(mFooterVisibility);
        setFooterText(mFooterText);
        setFooterIcon(mFooterIcon);
    }

    @Override
@@ -52,11 +69,13 @@ public class EmptyShadeView extends StackScrollerDecorView {

    @Override
    protected View findSecondaryView() {
        return null;
        return findViewById(R.id.no_notifications_footer);
    }

    public void setTextColor(@ColorInt int color) {
        mEmptyText.setTextColor(color);
        mEmptyFooterText.setTextColor(color);
        mEmptyFooterText.setCompoundDrawableTintList(ColorStateList.valueOf(color));
    }

    public void setText(@StringRes int text) {
@@ -64,14 +83,53 @@ public class EmptyShadeView extends StackScrollerDecorView {
        mEmptyText.setText(mText);
    }

    public void setFooterVisibility(@Visibility int visibility) {
        mFooterVisibility = visibility;
        setSecondaryVisible(visibility == View.VISIBLE, false);
    }

    public void setFooterText(@StringRes int text) {
        mFooterText = text;
        if (text != 0) {
            mEmptyFooterText.setText(mFooterText);
        } else {
            mEmptyFooterText.setText(null);
        }
    }

    public void setFooterIcon(@DrawableRes int icon) {
        mFooterIcon = icon;
        Drawable drawable;
        if (icon == 0) {
            drawable = null;
        } else {
            drawable = getResources().getDrawable(icon);
            drawable.setBounds(0, 0, mSize, mSize);
        }
        mEmptyFooterText.setCompoundDrawablesRelative(drawable, null, null, null);
    }

    @StringRes
    public int getTextResource() {
        return mText;
    }

    @StringRes
    public int getFooterTextResource() {
        return mFooterText;
    }

    @DrawableRes
    public int getFooterIconResource() {
        return mFooterIcon;
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mEmptyText = (TextView) findContentView();
        mEmptyFooterText = (TextView) findSecondaryView();
        mEmptyFooterText.setCompoundDrawableTintList(mEmptyFooterText.getTextColors());
    }

    @Override
+11 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.statusbar.notification.collection.coordinator.dagger
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
import com.android.systemui.statusbar.notification.collection.provider.SectionHeaderVisibilityProvider
import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProviderImpl
import com.android.systemui.statusbar.notification.interruption.KeyguardNotificationVisibilityProvider
import javax.inject.Inject
import kotlin.time.Duration.Companion.seconds
@@ -49,6 +50,7 @@ constructor(
    private val notifPipelineFlags: NotifPipelineFlags,
    @Application private val scope: CoroutineScope,
    private val sectionHeaderVisibilityProvider: SectionHeaderVisibilityProvider,
    private val seenNotifsProvider: SeenNotificationsProviderImpl,
    private val statusBarStateController: StatusBarStateController,
) : Coordinator {

@@ -105,6 +107,9 @@ constructor(
    @VisibleForTesting
    internal val unseenNotifFilter =
        object : NotifFilter("$TAG-unseen") {

            var hasFilteredAnyNotifs = false

            override fun shouldFilterOut(entry: NotificationEntry, now: Long): Boolean =
                when {
                    // Don't apply filter if the keyguard isn't currently showing
@@ -115,6 +120,11 @@ constructor(
                    //  - summary will be pruned if necessary, depending on if children are filtered
                    entry.parent?.summary == entry -> false
                    else -> true
                }.also { hasFiltered -> hasFilteredAnyNotifs = hasFilteredAnyNotifs || hasFiltered }

            override fun onCleanup() {
                seenNotifsProvider.hasFilteredOutSeenNotifications = hasFilteredAnyNotifs
                hasFilteredAnyNotifs = false
            }
        }

Loading