From 5a3e17d1532e56910bfbcdb69709fcd678a72c7c Mon Sep 17 00:00:00 2001 From: Danny Epstein Date: Tue, 19 May 2020 20:16:47 -0700 Subject: [PATCH] Add rotary support to the nav bar and HUN. Add a FocusParkingView to the navigation bar and the heads-up notification window. Add a dependency on the Chassis UI library. Make the nav buttons have a blue background, or whatever color the OEM specifies for the focus highlight. Test: atest com.android.systemui.car.navigationbar.CarNavigationButtonTest Bug: 155681517 Change-Id: Ia33c7692554c15427e429ecdba3bc978224ff129 --- packages/CarSystemUI/Android.bp | 2 ++ .../res/drawable/nav_button_background.xml | 26 ------------------- .../res/layout/car_left_navigation_bar.xml | 2 +- .../res/layout/car_navigation_button.xml | 4 +-- .../res/layout/car_right_navigation_bar.xml | 2 +- .../res/layout/headsup_container_bottom.xml | 9 +++++++ packages/CarSystemUI/res/values/styles.xml | 2 +- .../navigationbar/CarNavigationBarView.java | 4 ++- .../navigationbar/CarNavigationButton.java | 6 ++--- .../NavigationBarViewFactory.java | 7 +++++ ...CarHeadsUpNotificationSystemContainer.java | 3 +-- .../CarNavigationButtonTest.java | 22 ++++++++-------- 12 files changed, 41 insertions(+), 48 deletions(-) delete mode 100644 packages/CarSystemUI/res/drawable/nav_button_background.xml diff --git a/packages/CarSystemUI/Android.bp b/packages/CarSystemUI/Android.bp index 2a8a39a1fe1aa..32b33a7585359 100644 --- a/packages/CarSystemUI/Android.bp +++ b/packages/CarSystemUI/Android.bp @@ -32,6 +32,7 @@ android_library { "SystemUIPluginLib", "SystemUISharedLib", "SettingsLib", + "car-ui-lib", "android.car.userlib", "androidx.legacy_legacy-support-v4", "androidx.recyclerview_recyclerview", @@ -95,6 +96,7 @@ android_library { "androidx.slice_slice-builders", "androidx.arch.core_core-runtime", "androidx.lifecycle_lifecycle-extensions", + "car-ui-lib", "SystemUI-tags", "SystemUI-proto", "metrics-helper-lib", diff --git a/packages/CarSystemUI/res/drawable/nav_button_background.xml b/packages/CarSystemUI/res/drawable/nav_button_background.xml deleted file mode 100644 index 376347cdf4a90..0000000000000 --- a/packages/CarSystemUI/res/drawable/nav_button_background.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - diff --git a/packages/CarSystemUI/res/layout/car_left_navigation_bar.xml b/packages/CarSystemUI/res/layout/car_left_navigation_bar.xml index a8c70989253e7..94816f81a4c5f 100644 --- a/packages/CarSystemUI/res/layout/car_left_navigation_bar.xml +++ b/packages/CarSystemUI/res/layout/car_left_navigation_bar.xml @@ -79,7 +79,7 @@ android:gravity="bottom" android:orientation="vertical"> - - - - + + + 96dp 96dp - @drawable/nav_button_background + @*android:drawable/item_background_material \ No newline at end of file diff --git a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBarView.java b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBarView.java index 20fc1bcd60132..0ced4021ce38f 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBarView.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBarView.java @@ -74,8 +74,10 @@ public class CarNavigationBarView extends LinearLayout { mDarkIconManager.setShouldLog(true); Dependency.get(StatusBarIconController.class).addIconGroup(mDarkIconManager); } - // needs to be clickable so that it will receive ACTION_MOVE events + // Needs to be clickable so that it will receive ACTION_MOVE events. setClickable(true); + // Needs to not be focusable so rotary won't highlight the entire nav bar. + setFocusable(false); } @Override diff --git a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationButton.java b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationButton.java index 5e113d6366a14..e7e33a5439f9f 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationButton.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationButton.java @@ -32,8 +32,8 @@ import android.widget.ImageView; import android.widget.LinearLayout; import com.android.internal.annotations.VisibleForTesting; -import com.android.keyguard.AlphaOptimizedImageButton; import com.android.systemui.R; +import com.android.systemui.statusbar.AlphaOptimizedImageView; import java.net.URISyntaxException; @@ -53,8 +53,8 @@ public class CarNavigationButton extends LinearLayout { private static final String EXTRA_BUTTON_PACKAGES = "packages"; private Context mContext; - private AlphaOptimizedImageButton mIcon; - private AlphaOptimizedImageButton mMoreIcon; + private AlphaOptimizedImageView mIcon; + private AlphaOptimizedImageView mMoreIcon; private ImageView mUnseenIcon; private String mIntent; private String mLongIntent; diff --git a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/NavigationBarViewFactory.java b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/NavigationBarViewFactory.java index 3b7b48a771865..d60bc418ece20 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/NavigationBarViewFactory.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/NavigationBarViewFactory.java @@ -24,6 +24,7 @@ import android.view.ViewGroup; import androidx.annotation.LayoutRes; +import com.android.car.ui.FocusParkingView; import com.android.systemui.R; import javax.inject.Inject; @@ -146,6 +147,12 @@ public class NavigationBarViewFactory { CarNavigationBarView view = (CarNavigationBarView) View.inflate(mContext, barLayout, /* root= */ null); + + // Include a FocusParkingView at the end. The rotary controller "parks" the focus here when + // the user navigates to another window. This is also used to prevent wrap-around which is + // why it must be first or last in Tab order. + view.addView(new FocusParkingView(mContext)); + mCachedViewMap.put(type, view); return mCachedViewMap.get(type); } diff --git a/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java b/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java index aeb1d39599db3..d4f720715a69e 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java @@ -24,7 +24,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.FrameLayout; import com.android.car.notification.R; import com.android.car.notification.headsup.CarHeadsUpNotificationContainer; @@ -44,7 +43,7 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica private final OverlayViewGlobalStateController mOverlayViewGlobalStateController; private final ViewGroup mWindow; - private final FrameLayout mHeadsUpContentFrame; + private final ViewGroup mHeadsUpContentFrame; @Inject CarHeadsUpNotificationSystemContainer(Context context, diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationButtonTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationButtonTest.java index 54282d39998b0..bcaa5e9a03ee7 100644 --- a/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationButtonTest.java +++ b/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationButtonTest.java @@ -36,8 +36,8 @@ import android.widget.LinearLayout; import androidx.test.filters.SmallTest; -import com.android.keyguard.AlphaOptimizedImageButton; import com.android.systemui.SysuiTestCase; +import com.android.systemui.statusbar.AlphaOptimizedImageView; import com.android.systemui.tests.R; import org.junit.Before; @@ -74,7 +74,7 @@ public class CarNavigationButtonTest extends SysuiTestCase { @Test public void onCreate_iconIsVisible() { - AlphaOptimizedImageButton icon = mDefaultButton.findViewById( + AlphaOptimizedImageView icon = mDefaultButton.findViewById( R.id.car_nav_button_icon_image); assertThat(icon.getDrawable()).isNotNull(); @@ -83,12 +83,12 @@ public class CarNavigationButtonTest extends SysuiTestCase { @Test public void onSelected_selectedIconDefined_togglesIcon() { mDefaultButton.setSelected(true); - Drawable selectedIconDrawable = ((AlphaOptimizedImageButton) mDefaultButton.findViewById( + Drawable selectedIconDrawable = ((AlphaOptimizedImageView) mDefaultButton.findViewById( R.id.car_nav_button_icon_image)).getDrawable(); mDefaultButton.setSelected(false); - Drawable unselectedIconDrawable = ((AlphaOptimizedImageButton) mDefaultButton.findViewById( + Drawable unselectedIconDrawable = ((AlphaOptimizedImageView) mDefaultButton.findViewById( R.id.car_nav_button_icon_image)).getDrawable(); assertThat(selectedIconDrawable).isNotEqualTo(unselectedIconDrawable); @@ -100,12 +100,12 @@ public class CarNavigationButtonTest extends SysuiTestCase { R.id.selected_icon_undefined); selectedIconUndefinedButton.setSelected(true); - Drawable selectedIconDrawable = ((AlphaOptimizedImageButton) mDefaultButton.findViewById( + Drawable selectedIconDrawable = ((AlphaOptimizedImageView) mDefaultButton.findViewById( R.id.car_nav_button_icon_image)).getDrawable(); selectedIconUndefinedButton.setSelected(false); - Drawable unselectedIconDrawable = ((AlphaOptimizedImageButton) mDefaultButton.findViewById( + Drawable unselectedIconDrawable = ((AlphaOptimizedImageView) mDefaultButton.findViewById( R.id.car_nav_button_icon_image)).getDrawable(); assertThat(selectedIconDrawable).isEqualTo(unselectedIconDrawable); @@ -150,7 +150,7 @@ public class CarNavigationButtonTest extends SysuiTestCase { @Test public void onSelected_doesNotShowMoreWhenSelected_doesNotShowMoreIcon() { mDefaultButton.setSelected(true); - AlphaOptimizedImageButton moreIcon = mDefaultButton.findViewById( + AlphaOptimizedImageView moreIcon = mDefaultButton.findViewById( R.id.car_nav_button_more_icon); assertThat(moreIcon.getVisibility()).isEqualTo(View.GONE); @@ -161,7 +161,7 @@ public class CarNavigationButtonTest extends SysuiTestCase { CarNavigationButton showMoreWhenSelected = mTestView.findViewById( R.id.not_highlightable_more_button); showMoreWhenSelected.setSelected(true); - AlphaOptimizedImageButton moreIcon = showMoreWhenSelected.findViewById( + AlphaOptimizedImageView moreIcon = showMoreWhenSelected.findViewById( R.id.car_nav_button_more_icon); assertThat(moreIcon.getVisibility()).isEqualTo(View.VISIBLE); @@ -173,7 +173,7 @@ public class CarNavigationButtonTest extends SysuiTestCase { R.id.highlightable_no_more_button); showMoreWhenSelected.setSelected(true); showMoreWhenSelected.setSelected(false); - AlphaOptimizedImageButton moreIcon = showMoreWhenSelected.findViewById( + AlphaOptimizedImageView moreIcon = showMoreWhenSelected.findViewById( R.id.car_nav_button_more_icon); assertThat(moreIcon.getVisibility()).isEqualTo(View.GONE); @@ -187,7 +187,7 @@ public class CarNavigationButtonTest extends SysuiTestCase { roleBasedButton.setSelected(false); roleBasedButton.setAppIcon(appIcon); - Drawable currentDrawable = ((AlphaOptimizedImageButton) roleBasedButton.findViewById( + Drawable currentDrawable = ((AlphaOptimizedImageView) roleBasedButton.findViewById( R.id.car_nav_button_icon_image)).getDrawable(); assertThat(currentDrawable).isEqualTo(appIcon); @@ -212,7 +212,7 @@ public class CarNavigationButtonTest extends SysuiTestCase { roleBasedButton.setSelected(true); roleBasedButton.setAppIcon(appIcon); - Drawable currentDrawable = ((AlphaOptimizedImageButton) roleBasedButton.findViewById( + Drawable currentDrawable = ((AlphaOptimizedImageView) roleBasedButton.findViewById( R.id.car_nav_button_icon_image)).getDrawable(); assertThat(currentDrawable).isEqualTo(appIcon);