Visual update for the unseen notification indicator.
bug: 131262206 Test: Manual Test. Change-Id: I686598206c29670f8b31280349f1d5adbfb73dba (cherry picked from commit 50cfe28e03a6221d047adc7ea5e983c0fa2f3c3e)
This commit is contained in:
@@ -30,4 +30,5 @@
|
||||
android:strokeWidth="1"
|
||||
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>
|
||||
</vector>
|
||||
|
||||
|
||||
@@ -30,4 +30,4 @@
|
||||
android:strokeWidth="1"
|
||||
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>
|
||||
</vector>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
setImageResource(mSelected ? mSelectedIconResourceId : mIconResourceId);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user