Merge "Visual update for the unseen notification indicator." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0c32c741bd
@@ -30,4 +30,5 @@
|
|||||||
android:strokeWidth="1"
|
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" />
|
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>
|
</group>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
||||||
|
|||||||
@@ -30,4 +30,4 @@
|
|||||||
android:strokeWidth="1"
|
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" />
|
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>
|
</group>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
|
|||||||
*/
|
*/
|
||||||
class CarNavigationBarView extends LinearLayout {
|
class CarNavigationBarView extends LinearLayout {
|
||||||
private View mNavButtons;
|
private View mNavButtons;
|
||||||
private View mNotificationsButton;
|
private CarNavigationButton mNotificationsButton;
|
||||||
private CarStatusBar mCarStatusBar;
|
private CarStatusBar mCarStatusBar;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private View mLockScreenButtons;
|
private View mLockScreenButtons;
|
||||||
@@ -151,10 +151,20 @@ class CarNavigationBarView extends LinearLayout {
|
|||||||
* Nav buttons will be shown.
|
* Nav buttons will be shown.
|
||||||
*/
|
*/
|
||||||
public void hideKeyguardButtons() {
|
public void hideKeyguardButtons() {
|
||||||
if (mLockScreenButtons == null) {
|
if (mLockScreenButtons == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
mNavButtons.setVisibility(View.VISIBLE);
|
mNavButtons.setVisibility(View.VISIBLE);
|
||||||
mLockScreenButtons.setVisibility(View.GONE);
|
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.
|
* code.
|
||||||
*/
|
*/
|
||||||
public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImageButton {
|
public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImageButton {
|
||||||
|
|
||||||
private static final String TAG = "CarNavigationButton";
|
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 Context mContext;
|
||||||
private String mIntent;
|
private String mIntent;
|
||||||
private String mLongIntent;
|
private String mLongIntent;
|
||||||
private boolean mBroadcastIntent;
|
private boolean mBroadcastIntent;
|
||||||
|
private boolean mHasUnseen = false;
|
||||||
private boolean mSelected = false;
|
private boolean mSelected = false;
|
||||||
private float mSelectedAlpha = 1f;
|
private float mSelectedAlpha = 1f;
|
||||||
private float mUnselectedAlpha = 1f;
|
private float mUnselectedAlpha = 1f;
|
||||||
@@ -50,6 +55,8 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
|
|||||||
public CarNavigationButton(Context context, AttributeSet attrs) {
|
public CarNavigationButton(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
|
// CarNavigationButton attrs
|
||||||
TypedArray typedArray = context.obtainStyledAttributes(
|
TypedArray typedArray = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.CarNavigationButton);
|
attrs, R.styleable.CarNavigationButton);
|
||||||
mIntent = typedArray.getString(R.styleable.CarNavigationButton_intent);
|
mIntent = typedArray.getString(R.styleable.CarNavigationButton_intent);
|
||||||
@@ -59,10 +66,15 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
|
|||||||
R.styleable.CarNavigationButton_selectedAlpha, mSelectedAlpha);
|
R.styleable.CarNavigationButton_selectedAlpha, mSelectedAlpha);
|
||||||
mUnselectedAlpha = typedArray.getFloat(
|
mUnselectedAlpha = typedArray.getFloat(
|
||||||
R.styleable.CarNavigationButton_unselectedAlpha, mUnselectedAlpha);
|
R.styleable.CarNavigationButton_unselectedAlpha, mUnselectedAlpha);
|
||||||
mIconResourceId = typedArray.getResourceId(
|
|
||||||
com.android.internal.R.styleable.ImageView_src, 0);
|
|
||||||
mSelectedIconResourceId = typedArray.getResourceId(
|
mSelectedIconResourceId = typedArray.getResourceId(
|
||||||
R.styleable.CarNavigationButton_selectedIcon, mIconResourceId);
|
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);
|
super.setSelected(selected);
|
||||||
mSelected = selected;
|
mSelected = selected;
|
||||||
setAlpha(mSelected ? mSelectedAlpha : mUnselectedAlpha);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showKeyguard() {
|
public void showKeyguard() {
|
||||||
super.showKeyguard();
|
super.showKeyguard();
|
||||||
@@ -451,9 +450,21 @@ public class CarStatusBar extends StatusBar implements
|
|||||||
mNotificationDataManager = new NotificationDataManager();
|
mNotificationDataManager = new NotificationDataManager();
|
||||||
mNotificationDataManager.setOnUnseenCountUpdateListener(
|
mNotificationDataManager.setOnUnseenCountUpdateListener(
|
||||||
() -> {
|
() -> {
|
||||||
// TODO: Update Notification Icon based on unseen count
|
if (mNavigationBarView != null && mNotificationDataManager != null) {
|
||||||
Log.d(TAG, "unseen count: " +
|
Boolean hasUnseen =
|
||||||
mNotificationDataManager.getUnseenNotificationCount());
|
mNotificationDataManager.getUnseenNotificationCount() > 0;
|
||||||
|
if (mNavigationBarView != null) {
|
||||||
|
mNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mLeftNavigationBarView != null) {
|
||||||
|
mLeftNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRightNavigationBarView != null) {
|
||||||
|
mRightNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CarHeadsUpNotificationManager carHeadsUpNotificationManager =
|
CarHeadsUpNotificationManager carHeadsUpNotificationManager =
|
||||||
|
|||||||
Reference in New Issue
Block a user