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

Commit 0c32c741 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Visual update for the unseen notification indicator." into qt-dev

parents 66a71123 307bda9c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -31,3 +31,4 @@
        android:pathData="M 6 0 C 9.31370849898 0 12 2.68629150102 12 6 C 12 9.31370849898 9.31370849898 12 6 12 C 2.68629150102 12 0 9.31370849898 0 6 C 0 2.68629150102 2.68629150102 0 6 0 Z" />
  </group>
</vector>
+14 −4
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
 */
class CarNavigationBarView extends LinearLayout {
    private View mNavButtons;
    private View mNotificationsButton;
    private CarNavigationButton mNotificationsButton;
    private CarStatusBar mCarStatusBar;
    private Context mContext;
    private View mLockScreenButtons;
@@ -151,10 +151,20 @@ class CarNavigationBarView extends LinearLayout {
     * Nav buttons will be shown.
     */
    public void hideKeyguardButtons() {
        if (mLockScreenButtons == null) {
            return;
        }
        if (mLockScreenButtons == null) return;

        mNavButtons.setVisibility(View.VISIBLE);
        mLockScreenButtons.setVisibility(View.GONE);
    }

    /**
     * Toggles the notification unseen indicator on/off.
     *
     * @param hasUnseen true if the unseen notification count is great than 0.
     */
    void toggleNotificationUnseenIndicator(Boolean hasUnseen) {
        if (mNotificationsButton == null) return;

        mNotificationsButton.setUnseen(hasUnseen);
    }
}
+33 −4
Original line number Diff line number Diff line
@@ -34,12 +34,17 @@ import java.net.URISyntaxException;
 * code.
 */
public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImageButton {

    private static final String TAG = "CarNavigationButton";

    private static final int UNSEEN_ICON_RESOURCE_ID = R.drawable.car_ic_notification_unseen;
    private static final int UNSEEN_SELECTED_ICON_RESOURCE_ID =
            R.drawable.car_ic_notification_selected_unseen;

    private Context mContext;
    private String mIntent;
    private String mLongIntent;
    private boolean mBroadcastIntent;
    private boolean mHasUnseen = false;
    private boolean mSelected = false;
    private float mSelectedAlpha = 1f;
    private float mUnselectedAlpha = 1f;
@@ -50,6 +55,8 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
    public CarNavigationButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;

        // CarNavigationButton attrs
        TypedArray typedArray = context.obtainStyledAttributes(
                attrs, R.styleable.CarNavigationButton);
        mIntent = typedArray.getString(R.styleable.CarNavigationButton_intent);
@@ -59,10 +66,15 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
                R.styleable.CarNavigationButton_selectedAlpha, mSelectedAlpha);
        mUnselectedAlpha = typedArray.getFloat(
                R.styleable.CarNavigationButton_unselectedAlpha, mUnselectedAlpha);
        mIconResourceId = typedArray.getResourceId(
                com.android.internal.R.styleable.ImageView_src, 0);
        mSelectedIconResourceId = typedArray.getResourceId(
                R.styleable.CarNavigationButton_selectedIcon, mIconResourceId);
        typedArray.recycle();

        // ImageView attrs
        TypedArray a = context.obtainStyledAttributes(
                attrs, com.android.internal.R.styleable.ImageView);
        mIconResourceId = a.getResourceId(com.android.internal.R.styleable.ImageView_src, 0);
        a.recycle();
    }


@@ -119,6 +131,23 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
        super.setSelected(selected);
        mSelected = selected;
        setAlpha(mSelected ? mSelectedAlpha : mUnselectedAlpha);
        updateImage();
    }

    /**
     * @param hasUnseen true if should indicate if this is a Unseen state, false otherwise.
     */
    public void setUnseen(boolean hasUnseen) {
        mHasUnseen = hasUnseen;
        updateImage();
    }

    private void updateImage() {
        if (mHasUnseen) {
            setImageResource(mSelected ? UNSEEN_SELECTED_ICON_RESOURCE_ID
                    : UNSEEN_ICON_RESOURCE_ID);
        } else {
            setImageResource(mSelected ? mSelectedIconResourceId : mIconResourceId);
        }
    }
}
+15 −4
Original line number Diff line number Diff line
@@ -311,7 +311,6 @@ public class CarStatusBar extends StatusBar implements
        return result;
    }


    @Override
    public void showKeyguard() {
        super.showKeyguard();
@@ -451,9 +450,21 @@ public class CarStatusBar extends StatusBar implements
        mNotificationDataManager = new NotificationDataManager();
        mNotificationDataManager.setOnUnseenCountUpdateListener(
                () -> {
                    // TODO: Update Notification Icon based on unseen count
                    Log.d(TAG, "unseen count: " +
                            mNotificationDataManager.getUnseenNotificationCount());
                    if (mNavigationBarView != null && mNotificationDataManager != null) {
                        Boolean hasUnseen =
                                mNotificationDataManager.getUnseenNotificationCount() > 0;
                        if (mNavigationBarView != null) {
                            mNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
                        }

                        if (mLeftNavigationBarView != null) {
                            mLeftNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
                        }

                        if (mRightNavigationBarView != null) {
                            mRightNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
                        }
                    }
                });

        CarHeadsUpNotificationManager carHeadsUpNotificationManager =
+1 −1

File changed.

Contains only whitespace changes.