summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-01-08 01:16:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-01-08 01:16:00 +0000
commit77f281d584e8f27fad9a6ba3f9bb4d14d7719292 (patch)
treed3ea52069968d5898e1e3cac7e1ecd0ba85bc3f9
parentfeb3ae2204d302ef7fb131e508b6772ec2eb953a (diff)
parent34c6bdee7e58a5a213cb5bca0e10aa2343445a80 (diff)
Merge "Support Unseen Indicator Icon in all CarNavigationButtons"
-rw-r--r--packages/CarSystemUI/res/drawable/car_ic_notification_selected.xml25
-rw-r--r--packages/CarSystemUI/res/drawable/car_ic_notification_selected_unseen.xml34
-rw-r--r--packages/CarSystemUI/res/drawable/car_ic_unseen_indicator.xml (renamed from packages/CarSystemUI/res/drawable/car_ic_notification_unseen.xml)5
-rw-r--r--packages/CarSystemUI/res/layout/car_navigation_bar.xml6
-rw-r--r--packages/CarSystemUI/res/layout/car_navigation_button.xml28
-rw-r--r--packages/CarSystemUI/res/values/colors.xml4
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationButton.java19
-rw-r--r--packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationButtonTest.java17
8 files changed, 51 insertions, 87 deletions
diff --git a/packages/CarSystemUI/res/drawable/car_ic_notification_selected.xml b/packages/CarSystemUI/res/drawable/car_ic_notification_selected.xml
deleted file mode 100644
index dd2254509d83..000000000000
--- a/packages/CarSystemUI/res/drawable/car_ic_notification_selected.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2019 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:viewportWidth="44"
- android:viewportHeight="44"
- android:width="44dp"
- android:height="44dp">
- <path
- android:pathData="M22 39.125C23.925 39.125 25.5 37.55 25.5 35.625L18.5 35.625C18.5 37.55 20.0575 39.125 22 39.125ZM32.5 28.625L32.5 19.875C32.5 14.5025 29.63 10.005 24.625 8.815L24.625 7.625C24.625 6.1725 23.4525 5 22 5C20.5475 5 19.375 6.1725 19.375 7.625L19.375 8.815C14.3525 10.005 11.5 14.485 11.5 19.875L11.5 28.625L8 32.125L8 33.875L36 33.875L36 32.125L32.5 28.625Z"
- android:fillColor="@color/car_nav_icon_fill_color_selected" />
-</vector> \ No newline at end of file
diff --git a/packages/CarSystemUI/res/drawable/car_ic_notification_selected_unseen.xml b/packages/CarSystemUI/res/drawable/car_ic_notification_selected_unseen.xml
deleted file mode 100644
index c5d7728515ff..000000000000
--- a/packages/CarSystemUI/res/drawable/car_ic_notification_selected_unseen.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2019 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:viewportWidth="44"
- android:viewportHeight="44"
- android:width="44dp"
- android:height="44dp">
- <path
- android:pathData="M22 39.125C23.925 39.125 25.5 37.55 25.5 35.625L18.5 35.625C18.5 37.55 20.0575 39.125 22 39.125ZM32.5 28.625L32.5 19.875C32.5 14.5025 29.63 10.005 24.625 8.815L24.625 7.625C24.625 6.1725 23.4525 5 22 5C20.5475 5 19.375 6.1725 19.375 7.625L19.375 8.815C14.3525 10.005 11.5 14.485 11.5 19.875L11.5 28.625L8 32.125L8 33.875L36 33.875L36 32.125L32.5 28.625Z"
- android:fillColor="@color/car_nav_icon_fill_color_selected" />
- <group
- android:translateX="30"
- android:translateY="2">
- <path
- android:fillColor="@color/car_nav_notification_unseen_indicator_color"
- 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>
-
diff --git a/packages/CarSystemUI/res/drawable/car_ic_notification_unseen.xml b/packages/CarSystemUI/res/drawable/car_ic_unseen_indicator.xml
index 25d1af3fcd83..025fc9c4ea3b 100644
--- a/packages/CarSystemUI/res/drawable/car_ic_notification_unseen.xml
+++ b/packages/CarSystemUI/res/drawable/car_ic_unseen_indicator.xml
@@ -19,14 +19,11 @@
android:viewportHeight="44"
android:width="44dp"
android:height="44dp">
- <path
- android:pathData="M22 39.125C23.925 39.125 25.5 37.55 25.5 35.625L18.5 35.625C18.5 37.55 20.0575 39.125 22 39.125ZM32.5 28.625L32.5 19.875C32.5 14.5025 29.63 10.005 24.625 8.815L24.625 7.625C24.625 6.1725 23.4525 5 22 5C20.5475 5 19.375 6.1725 19.375 7.625L19.375 8.815C14.3525 10.005 11.5 14.485 11.5 19.875L11.5 28.625L8 32.125L8 33.875L36 33.875L36 32.125L32.5 28.625Z"
- android:fillColor="@color/car_nav_icon_fill_color" />
<group
android:translateX="30"
android:translateY="2">
<path
- android:fillColor="@color/car_nav_notification_unseen_indicator_color"
+ android:fillColor="@color/car_nav_unseen_indicator_color"
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>
diff --git a/packages/CarSystemUI/res/layout/car_navigation_bar.xml b/packages/CarSystemUI/res/layout/car_navigation_bar.xml
index 27ad4fc16532..e2e9a336d614 100644
--- a/packages/CarSystemUI/res/layout/car_navigation_bar.xml
+++ b/packages/CarSystemUI/res/layout/car_navigation_bar.xml
@@ -114,7 +114,6 @@
style="@style/NavigationBarButton"
systemui:icon="@drawable/car_ic_notification"
systemui:longIntent="intent:#Intent;component=com.android.car.bugreport/.BugReportActivity;end"
- systemui:selectedIcon="@drawable/car_ic_notification_selected"
/>
<Space
@@ -138,8 +137,7 @@
android:paddingStart="@dimen/car_keyline_1"
android:paddingEnd="@dimen/car_keyline_1"
android:gravity="center"
- android:visibility="gone">
-
- </LinearLayout>
+ android:visibility="gone"
+ />
</com.android.systemui.navigationbar.car.CarNavigationBarView> \ No newline at end of file
diff --git a/packages/CarSystemUI/res/layout/car_navigation_button.xml b/packages/CarSystemUI/res/layout/car_navigation_button.xml
index bafbb6408f77..837252b6d716 100644
--- a/packages/CarSystemUI/res/layout/car_navigation_button.xml
+++ b/packages/CarSystemUI/res/layout/car_navigation_button.xml
@@ -18,13 +18,12 @@
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
- <LinearLayout
+ <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/car_nav_button_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
- android:gravity="center"
android:animateLayoutChanges="true"
android:orientation="vertical">
@@ -32,20 +31,35 @@
android:id="@+id/car_nav_button_icon_image"
android:layout_height="wrap_content"
android:layout_width="match_parent"
+ android:layout_gravity="center"
android:animateLayoutChanges="true"
android:background="@android:color/transparent"
- android:scaleType="fitCenter">
- </com.android.keyguard.AlphaOptimizedImageButton>
+ android:scaleType="fitCenter"
+ android:clickable="false"
+ />
<com.android.keyguard.AlphaOptimizedImageButton
android:id="@+id/car_nav_button_more_icon"
android:layout_height="wrap_content"
android:layout_width="match_parent"
+ android:layout_gravity="center"
android:animateLayoutChanges="true"
android:src="@drawable/car_ic_arrow"
android:background="@android:color/transparent"
- android:scaleType="fitCenter">
- </com.android.keyguard.AlphaOptimizedImageButton>
+ android:scaleType="fitCenter"
+ android:clickable="false"
+ />
- </LinearLayout>
+ <ImageView
+ android:id="@+id/car_nav_button_unseen_icon"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_gravity="center"
+ android:src="@drawable/car_ic_unseen_indicator"
+ android:background="@android:color/transparent"
+ android:scaleType="fitCenter"
+ android:clickable="false"
+ />
+
+ </FrameLayout>
</merge>
diff --git a/packages/CarSystemUI/res/values/colors.xml b/packages/CarSystemUI/res/values/colors.xml
index 5fcf38fce3cc..7972e09869d3 100644
--- a/packages/CarSystemUI/res/values/colors.xml
+++ b/packages/CarSystemUI/res/values/colors.xml
@@ -43,8 +43,8 @@
<!-- The color of the dividing line between grouped notifications. -->
<color name="notification_divider_color">@*android:color/notification_action_list</color>
- <!-- The color for the unseen notification indicator. -->
- <color name="car_nav_notification_unseen_indicator_color">#e25142</color>
+ <!-- The color for the unseen indicator. -->
+ <color name="car_nav_unseen_indicator_color">#e25142</color>
<!-- The color of the ripples on the untinted notifications -->
<color name="notification_ripple_untinted_color">@color/ripple_material_light</color>
diff --git a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationButton.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationButton.java
index d08fbbc8091f..b4d478572daf 100644
--- a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationButton.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationButton.java
@@ -48,13 +48,11 @@ public class CarNavigationButton extends LinearLayout {
private static final String BUTTON_FILTER_DELIMITER = ";";
private static final String EXTRA_BUTTON_CATEGORIES = "categories";
private static final String EXTRA_BUTTON_PACKAGES = "packages";
- 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 AlphaOptimizedImageButton mIcon;
private AlphaOptimizedImageButton mMoreIcon;
+ private ImageView mUnseenIcon;
private String mIntent;
private String mLongIntent;
private boolean mBroadcastIntent;
@@ -265,23 +263,22 @@ public class CarNavigationButton extends LinearLayout {
mIcon = findViewById(R.id.car_nav_button_icon_image);
mIcon.setScaleType(ImageView.ScaleType.CENTER);
- mIcon.setClickable(false);
// Always apply selected alpha if the button does not toggle alpha based on selection state.
mIcon.setAlpha(mHighlightWhenSelected ? mUnselectedAlpha : mSelectedAlpha);
mIcon.setImageResource(mIconResourceId);
mMoreIcon = findViewById(R.id.car_nav_button_more_icon);
- mMoreIcon.setClickable(false);
mMoreIcon.setAlpha(mSelectedAlpha);
mMoreIcon.setVisibility(GONE);
+
+ mUnseenIcon = findViewById(R.id.car_nav_button_unseen_icon);
+
+ mUnseenIcon.setVisibility(mHasUnseen ? VISIBLE : GONE);
}
private void updateImage() {
- if (mHasUnseen) {
- mIcon.setImageResource(mSelected ? UNSEEN_SELECTED_ICON_RESOURCE_ID
- : UNSEEN_ICON_RESOURCE_ID);
- } else {
- mIcon.setImageResource(mSelected ? mSelectedIconResourceId : mIconResourceId);
- }
+ mIcon.setImageResource(mSelected ? mSelectedIconResourceId : mIconResourceId);
+ mUnseenIcon.setVisibility(mHasUnseen ? VISIBLE : GONE);
}
+
}
diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationButtonTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationButtonTest.java
index e1ee6162ddcc..96d567d3a8b5 100644
--- a/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationButtonTest.java
+++ b/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationButtonTest.java
@@ -31,6 +31,7 @@ import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.test.filters.SmallTest;
@@ -216,6 +217,22 @@ public class CarNavigationButtonTest extends SysuiTestCase {
}), any());
}
+ @Test
+ public void onSetUnseen_hasUnseen_showsUnseenIndicator() {
+ mDefaultButton.setUnseen(true);
+ ImageView hasUnseenIndicator = mDefaultButton.findViewById(R.id.car_nav_button_unseen_icon);
+
+ assertThat(hasUnseenIndicator.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void onSetUnseen_doesNotHaveUnseen_hidesUnseenIndicator() {
+ mDefaultButton.setUnseen(false);
+ ImageView hasUnseenIndicator = mDefaultButton.findViewById(R.id.car_nav_button_unseen_icon);
+
+ assertThat(hasUnseenIndicator.getVisibility()).isEqualTo(View.GONE);
+ }
+
private String getCurrentActivityName() {
return mActivityManager.getRunningTasks(1).get(0).topActivity.flattenToShortString();
}