Move car ActionBar out of AndroidX
Action bar is moved to platform/packages/apps/Car/libs
Test: manual testing
Change-Id: I754be8789954e4a4229f10e78ba9fee53c694e85
diff --git a/car/core/api/1.0.0-alpha6.txt b/car/core/api/1.0.0-alpha6.txt
index 8d125d9..6f3fb92 100644
--- a/car/core/api/1.0.0-alpha6.txt
+++ b/car/core/api/1.0.0-alpha6.txt
@@ -156,23 +156,6 @@
package androidx.car.widget {
- public class ActionBar extends android.widget.RelativeLayout {
- ctor public ActionBar(android.content.Context!);
- ctor public ActionBar(android.content.Context!, android.util.AttributeSet!);
- ctor public ActionBar(android.content.Context!, android.util.AttributeSet!, int);
- ctor public ActionBar(android.content.Context!, android.util.AttributeSet!, int, int);
- method public void setExpandCollapseView(android.view.View);
- method public void setView(android.view.View?, @androidx.car.widget.ActionBar.SlotPosition int);
- method public void setViews(android.view.View[]?);
- field public static final int SLOT_EXPAND_COLLAPSE = 3; // 0x3
- field public static final int SLOT_LEFT = 1; // 0x1
- field public static final int SLOT_MAIN = 0; // 0x0
- field public static final int SLOT_RIGHT = 2; // 0x2
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @IntDef({androidx.car.widget.ActionBar.SLOT_MAIN, androidx.car.widget.ActionBar.SLOT_LEFT, androidx.car.widget.ActionBar.SLOT_RIGHT, androidx.car.widget.ActionBar.SLOT_EXPAND_COLLAPSE}) public static @interface ActionBar.SlotPosition {
- }
-
public final class ActionListItem extends androidx.car.widget.ListItem<androidx.car.widget.ActionListItem.ViewHolder> {
ctor public ActionListItem(android.content.Context);
method public static androidx.car.widget.ActionListItem.ViewHolder createViewHolder(android.view.View!);
diff --git a/car/core/api/current.txt b/car/core/api/current.txt
index 8d125d9..6f3fb92 100644
--- a/car/core/api/current.txt
+++ b/car/core/api/current.txt
@@ -156,23 +156,6 @@
package androidx.car.widget {
- public class ActionBar extends android.widget.RelativeLayout {
- ctor public ActionBar(android.content.Context!);
- ctor public ActionBar(android.content.Context!, android.util.AttributeSet!);
- ctor public ActionBar(android.content.Context!, android.util.AttributeSet!, int);
- ctor public ActionBar(android.content.Context!, android.util.AttributeSet!, int, int);
- method public void setExpandCollapseView(android.view.View);
- method public void setView(android.view.View?, @androidx.car.widget.ActionBar.SlotPosition int);
- method public void setViews(android.view.View[]?);
- field public static final int SLOT_EXPAND_COLLAPSE = 3; // 0x3
- field public static final int SLOT_LEFT = 1; // 0x1
- field public static final int SLOT_MAIN = 0; // 0x0
- field public static final int SLOT_RIGHT = 2; // 0x2
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @IntDef({androidx.car.widget.ActionBar.SLOT_MAIN, androidx.car.widget.ActionBar.SLOT_LEFT, androidx.car.widget.ActionBar.SLOT_RIGHT, androidx.car.widget.ActionBar.SLOT_EXPAND_COLLAPSE}) public static @interface ActionBar.SlotPosition {
- }
-
public final class ActionListItem extends androidx.car.widget.ListItem<androidx.car.widget.ActionListItem.ViewHolder> {
ctor public ActionListItem(android.content.Context);
method public static androidx.car.widget.ActionListItem.ViewHolder createViewHolder(android.view.View!);
diff --git a/car/core/res-public/values/public_attrs.xml b/car/core/res-public/values/public_attrs.xml
index 7ade86e..d746edc 100644
--- a/car/core/res-public/values/public_attrs.xml
+++ b/car/core/res-public/values/public_attrs.xml
@@ -63,9 +63,6 @@
<public type="attr" name="carMenuBarSpacing" />
<public type="attr" name="carMenuBarThickness" />
- <!-- ActionBar -->
- <public type="attr" name="columns" />
-
<!-- CarTheme -->
<public type="attr" name="carDialogTheme" />
<public type="attr" name="pagedListViewStyle" />
diff --git a/car/core/res-public/values/public_dimens.xml b/car/core/res-public/values/public_dimens.xml
index f547495..eeeea8a 100644
--- a/car/core/res-public/values/public_dimens.xml
+++ b/car/core/res-public/values/public_dimens.xml
@@ -99,21 +99,6 @@
<public type="dimen" name="car_app_bar_default_elevation"/>
<public type="dimen" name="car_application_icon_size" />
- <!-- Action Bar -->
- <public type="dimen" name="car_action_bar_height" />
- <public type="dimen" name="car_action_bar_buttons_space" />
- <public type="dimen" name="car_action_bar_button_width" />
- <public type="dimen" name="car_action_bar_button_height" />
- <public type="dimen" name="car_action_bar_activation_ring_stroke_width"/>
- <public type="dimen" name="car_action_bar_activation_ring_radius" />
- <public type="dimen" name="car_action_bar_touch_ripple_size" />
- <public type="dimen" name="car_action_bar_button_ripple_radius" />
- <public type="dimen" name="car_action_bar_elevation"/>
-
- <!-- Action Buttons -->
- <public type="dimen" name="car_action_button_icon_inset" />
- <public type="dimen" name="car_action_button_ripple_inset" />
-
<!-- Lists -->
<public type="dimen" name="car_single_line_list_item_height" />
<public type="dimen" name="car_double_line_list_item_height"/>
diff --git a/car/core/res-public/values/public_styles.xml b/car/core/res-public/values/public_styles.xml
index e0d1e16..18d6a21 100644
--- a/car/core/res-public/values/public_styles.xml
+++ b/car/core/res-public/values/public_styles.xml
@@ -94,9 +94,6 @@
<public type="style" name="Widget.Car.Dialog.Body.Light" />
<public type="style" name="Widget.Car.Dialog.Body.Dark" />
- <!-- ActionBar Styles -->
- <public type="style" name="Widget.Car.Button.ActionBar" />
-
<!-- Preference Styles -->
<public type="style" name="CarPreference" />
<public type="style" name="CarPreference.Information" />
diff --git a/car/core/res/drawable/car_action_button_activated_ring_foreground.xml b/car/core/res/drawable/car_action_button_activated_ring_foreground.xml
deleted file mode 100644
index cf9570b..0000000
--- a/car/core/res/drawable/car_action_button_activated_ring_foreground.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-<selector
- xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:state_activated="true">
- <shape
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
- <stroke
- android:color="@color/car_tint"
- android:width="@dimen/car_action_bar_activation_ring_stroke_width">
- </stroke>
- <size
- android:height="@dimen/car_action_bar_activation_ring_radius"
- android:width="@dimen/car_action_bar_activation_ring_radius"/>
- </shape>
- </item>
- <!--Yes, this is a load-bearing invisible circle.-->
- <!--Android doesn't remeasure foregrounds when state_activated changes, -->
- <!--so we need a default drawable with the same size as the one we actually want to draw-->
- <item>
- <shape
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
- <stroke
- android:color="#00000000"
- android:width="@dimen/car_action_bar_activation_ring_stroke_width">
- </stroke>
- <size
- android:height="@dimen/car_action_bar_activation_ring_radius"
- android:width="@dimen/car_action_bar_activation_ring_radius"/>
- </shape>
- </item>
-</selector>
diff --git a/car/core/res/drawable/car_action_button_background.xml b/car/core/res/drawable/car_action_button_background.xml
deleted file mode 100644
index 27e97e3..0000000
--- a/car/core/res/drawable/car_action_button_background.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-<inset xmlns:android="http://schemas.android.com/apk/res/android"
- android:inset="@dimen/car_action_button_ripple_inset" >
- <ripple android:color="@color/car_card_ripple_background" />
-</inset>
diff --git a/car/core/res/drawable/ic_overflow.xml b/car/core/res/drawable/ic_overflow.xml
deleted file mode 100644
index eda306c..0000000
--- a/car/core/res/drawable/ic_overflow.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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:width="56dp"
- android:height="56dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
-
- <group
- android:translateX="-0.750000"
- android:translateY="-0.750000">
- <path
- android:strokeWidth="1"
- android:pathData="M 0.75 24.75 L 24.75 24.75 L 24.75 0.75 L 0.75 0.75 Z" />
- <path
- android:fillColor="#000000"
- android:strokeWidth="1"
- android:pathData="M12.75,10.1666667 C13.4604167,10.1666667 14.0416667,9.58541667 14.0416667,8.875
-C14.0416667,8.16458333 13.4604167,7.58333333 12.75,7.58333333
-C12.0395833,7.58333333 11.4583333,8.16458333 11.4583333,8.875
-C11.4583333,9.58541667 12.0395833,10.1666667 12.75,10.1666667 L12.75,10.1666667
-Z M12.75,11.4583333 C12.0395833,11.4583333 11.4583333,12.0395833
-11.4583333,12.75 C11.4583333,13.4604167 12.0395833,14.0416667 12.75,14.0416667
-C13.4604167,14.0416667 14.0416667,13.4604167 14.0416667,12.75
-C14.0416667,12.0395833 13.4604167,11.4583333 12.75,11.4583333 L12.75,11.4583333
-Z M12.75,15.3333333 C12.0395833,15.3333333 11.4583333,15.9145833
-11.4583333,16.625 C11.4583333,17.3354167 12.0395833,17.9166667 12.75,17.9166667
-C13.4604167,17.9166667 14.0416667,17.3354167 14.0416667,16.625
-C14.0416667,15.9145833 13.4604167,15.3333333 12.75,15.3333333 L12.75,15.3333333
-Z" />
- </group>
-</vector>
diff --git a/car/core/res/layout/action_bar.xml b/car/core/res/layout/action_bar.xml
deleted file mode 100644
index 431a2a8..0000000
--- a/car/core/res/layout/action_bar.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-<androidx.cardview.widget.CardView
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/action_bar_wrapper"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:elevation="@dimen/car_action_bar_elevation"
- app:cardCornerRadius="@dimen/car_radius_3">
-
- <LinearLayout
- android:id="@+id/rows_container"
- android:orientation="vertical"
- android:animateLayoutChanges="true"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <LinearLayout
- android:orientation="horizontal"
- android:visibility="gone"
- android:clipChildren="false"
- android:layout_width="match_parent"
- android:layout_height="@dimen/car_action_bar_height">
- </LinearLayout>
-
- <LinearLayout
- android:orientation="horizontal"
- android:clipChildren="false"
- android:layout_width="match_parent"
- android:layout_height="@dimen/car_action_bar_height">
- </LinearLayout>
-
- </LinearLayout>
-
-</androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/car/core/res/layout/action_bar_button.xml b/car/core/res/layout/action_bar_button.xml
deleted file mode 100644
index e9d2370..0000000
--- a/car/core/res/layout/action_bar_button.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-<ImageButton style="@style/Widget.Car.Button.ActionBar" />
diff --git a/car/core/res/layout/action_bar_slot.xml b/car/core/res/layout/action_bar_slot.xml
deleted file mode 100644
index 804e356..0000000
--- a/car/core/res/layout/action_bar_slot.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="0dp"
- android:layout_height="@dimen/car_action_bar_button_height"
- android:layout_weight="1"
- android:visibility="visible"
- android:foregroundGravity="center"
- android:clipChildren="false"
- android:foreground="@drawable/car_action_button_activated_ring_foreground">
-</FrameLayout>
\ No newline at end of file
diff --git a/car/core/res/values/attrs.xml b/car/core/res/values/attrs.xml
index 4f353ab..7d288ee 100644
--- a/car/core/res/values/attrs.xml
+++ b/car/core/res/values/attrs.xml
@@ -154,12 +154,6 @@
<attr name="carMenuBarThickness" format="dimension"/>
</declare-styleable>
- <!-- Attributes for the ActionBar. -->
- <declare-styleable name="ActionBar">
- <!-- The number of horizontal slots. The minimum number is 3. -->
- <attr name="columns" format="integer" />
- </declare-styleable>
-
<declare-styleable name="CarToolbar">
<!-- Drawable to use for the navigation button located at the start of the toolbar. -->
<attr name="navigationIcon" format="reference" />
diff --git a/car/core/res/values/dimens.xml b/car/core/res/values/dimens.xml
index de948b8..df65e2e 100644
--- a/car/core/res/values/dimens.xml
+++ b/car/core/res/values/dimens.xml
@@ -100,21 +100,6 @@
<dimen name="car_app_bar_default_elevation">8dp</dimen>
<dimen name="car_application_icon_size">44dp</dimen>
- <!-- Action Bar -->
- <dimen name="car_action_bar_height">96dp</dimen>
- <dimen name="car_action_bar_buttons_space">@dimen/car_padding_4</dimen>
- <dimen name="car_action_bar_button_width">128dp</dimen>
- <dimen name="car_action_bar_button_height">128dp</dimen>
- <dimen name="car_action_bar_activation_ring_stroke_width">3dp</dimen>
- <dimen name="car_action_bar_activation_ring_radius">64dp</dimen>
- <dimen name="car_action_bar_touch_ripple_size">38dp</dimen>
- <dimen name="car_action_bar_button_ripple_radius">48dp</dimen>
- <dimen name="car_action_bar_elevation">2dp</dimen>
-
- <!-- Action Buttons -->
- <dimen name="car_action_button_icon_inset">24dp</dimen>
- <dimen name="car_action_button_ripple_inset">16dp</dimen>
-
<!-- Lists -->
<dimen name="car_single_line_list_item_height">96dp</dimen>
<dimen name="car_double_line_list_item_height">@dimen/car_single_line_list_item_height</dimen>
diff --git a/car/core/res/values/integers.xml b/car/core/res/values/integers.xml
index 075f146..23b8431 100644
--- a/car/core/res/values/integers.xml
+++ b/car/core/res/values/integers.xml
@@ -41,13 +41,6 @@
truncated. -->
<integer name="car_borderless_button_text_length_limit">20</integer>
- <!-- Action Bar animation durations -->
- <integer name="car_action_bar_expand_scale_duration_ms">233</integer>
- <integer name="car_action_bar_expand_opacity_delay_ms">33</integer>
- <integer name="car_action_bar_expand_opacity_duration_ms">133</integer>
- <integer name="car_action_bar_collapse_scale_duration_ms">100</integer>
- <integer name="car_action_bar_collapse_opacity_duration_ms">40</integer>
-
<!-- Alpha Jump Overlay -->
<!-- The number of columns of buttons to display in the alpha jump overview. -->
<integer name="car_alpha_jump_button_columns">7</integer>
diff --git a/car/core/res/values/strings.xml b/car/core/res/values/strings.xml
index 8801091..d864de8 100644
--- a/car/core/res/values/strings.xml
+++ b/car/core/res/values/strings.xml
@@ -32,10 +32,6 @@
interacting with the current application. [CHAR_LIMIT=30] -->
<string name="speed_bump_lockout_message">Focus on the road</string>
- <!-- Action Bar -->
- <!-- Content description for the 'Expand/Collapse' button [CHAR_LIMIT=50] -->
- <string name="action_bar_expand_collapse_button">Expand/collapse button</string>
-
<!-- Scroll bar -->
<!-- Content description for the page up button on the scrollbar [CHAR_LIMIT=20]. -->
<string name="scroll_bar_page_up_button">Scroll up</string>
diff --git a/car/core/res/values/styles.xml b/car/core/res/values/styles.xml
index 3770347..46ad7dd 100644
--- a/car/core/res/values/styles.xml
+++ b/car/core/res/values/styles.xml
@@ -204,27 +204,12 @@
<item name="background">@color/car_card</item>
<item name="contentInsetEnd">@dimen/car_keyline_1</item>
<item name="contentInsetStart">@dimen/car_keyline_1</item>
- <item name="elevation">@dimen/car_action_bar_elevation</item>
+ <item name="elevation">@dimen/car_app_bar_default_elevation</item>
<item name="subtitleTextAppearance">@style/TextAppearance.Car.Body2</item>
<item name="titleTextAppearance">@style/TextAppearance.Car.Body1.Medium</item>
<item name="navigationIcon">@drawable/ic_nav_arrow_back</item>
</style>
- <!-- The styling for the default action bar. -->
- <style name="Widget.Car.ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid">
- <item name="titleTextStyle">@style/TextAppearance.Car.Body1</item>
- <item name="subtitleTextStyle">@style/TextAppearance.Car.Body3</item>
- </style>
-
- <!-- The styling for the default action bar that has a dark background. -->
- <style name="Widget.Car.ActionBar.Dark">
- <item name="background">@android:color/black</item>
- <item name="backgroundStacked">@android:color/black</item>
- <item name="backgroundSplit">@android:color/black</item>
- <item name="titleTextStyle">@style/TextAppearance.Car.Body1.Light</item>
- <item name="subtitleTextStyle">@style/TextAppearance.Car.Body3.Light</item>
- </style>
-
<!-- ================ -->
<!-- CarToolbar Style -->
<!-- ================ -->
@@ -483,19 +468,6 @@
<item name="android:textAppearance">@style/TextAppearance.Car.Body2.Dark</item>
</style>
- <!-- ================ -->
- <!-- ActionBar Styles -->
- <!-- ================ -->
- <eat-comment />
-
- <!-- Styles for action buttons -->
- <style name="Widget.Car.Button.ActionBar">
- <item name="android:scaleType">fitCenter</item>
- <item name="android:padding">@dimen/car_action_button_icon_inset</item>
- <item name="android:background">@drawable/car_action_button_background</item>
- <item name="android:tint">@color/car_tint</item>
- </style>
-
<!-- ================= -->
<!-- Preference Styles -->
<!-- ================= -->
diff --git a/car/core/res/values/themes.xml b/car/core/res/values/themes.xml
index cbbaeac..794e9be 100644
--- a/car/core/res/values/themes.xml
+++ b/car/core/res/values/themes.xml
@@ -55,7 +55,6 @@
<item name="android:spinnerItemStyle">@style/CarSpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">@style/CarSpinnerItem</item>
<item name="actionBarItemBackground">@drawable/car_card_ripple_background</item>
- <item name="actionBarStyle">@style/Widget.Car.ActionBar.Dark</item>
<item name="actionBarSize">@dimen/car_app_bar_height</item>
<item name="actionButtonStyle">@style/Widget.Car.ActionButton.Light</item>
<item name="actionMenuTextAppearance">@style/TextAppearance.Car.ActionBar.Menu</item>
diff --git a/car/core/src/androidTest/AndroidManifest.xml b/car/core/src/androidTest/AndroidManifest.xml
index a154b3cb..22a0f8d 100644
--- a/car/core/src/androidTest/AndroidManifest.xml
+++ b/car/core/src/androidTest/AndroidManifest.xml
@@ -19,8 +19,6 @@
<uses-sdk android:targetSdkVersion="${target-sdk-version}"/>
<application android:supportsRtl="true">
- <activity android:name="androidx.car.widget.ActionBarTestActivity"
- android:theme="@style/Theme.Car.Light.NoActionBar" />
<activity android:name="androidx.car.drawer.CarDrawerTestActivity"
android:theme="@style/Theme.Car.Light.NoActionBar.Drawer" />
<activity android:name="androidx.car.widget.CarToolbarTestActivity"
diff --git a/car/core/src/androidTest/java/androidx/car/widget/ActionBarTest.java b/car/core/src/androidTest/java/androidx/car/widget/ActionBarTest.java
deleted file mode 100644
index 19d97af..0000000
--- a/car/core/src/androidTest/java/androidx/car/widget/ActionBarTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-package androidx.car.widget;
-
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.action.ViewActions.click;
-import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import android.content.Context;
-import android.view.View;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.Space;
-import android.widget.ToggleButton;
-
-import androidx.car.R;
-import androidx.core.util.Preconditions;
-import androidx.test.filters.MediumTest;
-import androidx.test.rule.ActivityTestRule;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/** Unit tests for {@link ActionBar}. */
-@RunWith(AndroidJUnit4.class)
-@MediumTest
-public class ActionBarTest {
- @Rule
- public ActivityTestRule<ActionBarTestActivity> mActivityRule =
- new ActivityTestRule<>(ActionBarTestActivity.class);
- private ActionBarTestActivity mActivity;
- private ActionBar mActionBar;
- private LinearLayout mRowsContainer;
- private View[] mItems;
-
- private static final int TOP_ROW_IDX = 0;
- private static final int BOTTOM_ROW_IDX = 1;
- private static final int NUM_COLS = 5;
-
- @Before
- public void setUp() {
- mActivity = mActivityRule.getActivity();
- mActionBar = mActivity.findViewById(androidx.car.test.R.id.action_bar);
- mRowsContainer = mActionBar.findViewById(R.id.rows_container);
- }
-
- private void setUpActionBarItems(int numItems) {
- mItems = new View[numItems];
- for (int i = 0; i < numItems; i++) {
- mItems[i] = createButton(mActivity);
- }
- mActivity.runOnUiThread(() -> mActionBar.setViews(mItems));
- }
-
- private ImageButton createButton(Context context) {
- ImageButton button = new ImageButton(context, null, R.style.Widget_Car_Button_ActionBar);
- button.setImageDrawable(context.getDrawable(androidx.car.test.R.drawable.ic_overflow));
- return button;
- }
-
- /**
- * Asserts that only the first 'numItems' slots are used.
- */
- private void assertLeftItemsNotEmpty(int rowIdx, int numItems) {
- for (int colIdx = 0; colIdx < NUM_COLS - 1; colIdx++) {
- if (colIdx < numItems) {
- assertNotNull(String.format("Slot (%d, %d) should be taken", rowIdx, colIdx),
- mActionBar.getViewAt(rowIdx, colIdx));
- } else {
- assertNull(String.format("Slot (%d, %d) should be empty", rowIdx, colIdx),
- mActionBar.getViewAt(rowIdx, colIdx));
- }
- }
- }
-
- /**
- * Tests that the bar with no children views is displayed correctly
- */
- @Test
- public void testEmptyState() {
- setUpActionBarItems(0);
- onView(withId(androidx.car.test.R.id.action_bar)).check((view, noViewFoundException) -> {
- Preconditions.checkNotNull(view);
- // All slots should be empty.
- assertLeftItemsNotEmpty(TOP_ROW_IDX, 0);
- assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, 0);
- });
- }
-
- /**
- * Tests that slots are used from left to right and from bottom to top
- */
- @Test
- public void testNormalSlotUsage() {
- for (int items = 1; items < NUM_COLS - 1; items++) {
- setUpActionBarItems(items);
- final int numItems = items;
- onView(withId(androidx.car.test.R.id.action_bar))
- .check((view, noViewFoundException) -> {
- Preconditions.checkNotNull(view);
- // Top row should be empty
- assertLeftItemsNotEmpty(TOP_ROW_IDX, 0);
- // Expand/collapse slot should be empty
- assertNull("Expand/collapse should be empty" ,
- mActionBar.getViewAt(BOTTOM_ROW_IDX, NUM_COLS - 1));
- // Slots on the bottom left should be taken while the rest should be empty.
- assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, numItems);
- });
- }
- }
-
- private void assertRowVisibility(int rowIdx, int visibility) {
- assertEquals(visibility, mRowsContainer.getChildAt(rowIdx).getVisibility());
- }
-
- /**
- * Tests that the expand/collapse button is added if enough views are set
- */
- @Test
- public void testExpandCollapseEnabled() {
- setUpActionBarItems(NUM_COLS + 1);
-
- // Top row should have 2 slot taken (as expand/collapse takes one slot on the bottom row)
- onView(withContentDescription(R.string.action_bar_expand_collapse_button))
- .check((view, noViewFoundException) -> {
- Preconditions.checkNotNull(view);
- assertLeftItemsNotEmpty(TOP_ROW_IDX, 2);
- assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, NUM_COLS);
- assertRowVisibility(TOP_ROW_IDX, View.GONE);
- })
- // Check that expand/collapse works
- .perform(click())
- .check((view, noViewFoundException) -> {
- assertRowVisibility(TOP_ROW_IDX, View.VISIBLE);
- })
- .perform(click())
- .check((view, noViewFoundException) -> {
- assertRowVisibility(TOP_ROW_IDX, View.GONE);
- });
- }
-
- private void setViewInPosition(View view, @ActionBar.SlotPosition int position) {
- mActivity.runOnUiThread(() -> {
- mActionBar.setView(view, position);
- });
- }
-
- /**
- * Tests that reserved slots are not used by normal views.
- */
- @Test
- public void testReservingNamedSlots() {
- View mainView = createButton(mActivity);
- setViewInPosition(mainView, ActionBar.SLOT_MAIN);
- View leftView = new Space(mActivity);
- setViewInPosition(leftView, ActionBar.SLOT_LEFT);
- setUpActionBarItems(NUM_COLS + 1);
-
- // Expand/collapse plus two other slots should be taken in the bottom row.
- onView(withContentDescription(R.string.action_bar_expand_collapse_button))
- .check((view, noViewFoundException) -> {
- // Only 2 items fit in the bottom row. The remaining 4 should be on the top
- Preconditions.checkNotNull(view);
- assertLeftItemsNotEmpty(TOP_ROW_IDX, 4);
- assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, NUM_COLS);
- assertRowVisibility(TOP_ROW_IDX, View.GONE);
- assertEquals(mainView, mActionBar.getViewAt(BOTTOM_ROW_IDX, 2));
- assertEquals(leftView, mActionBar.getViewAt(BOTTOM_ROW_IDX, 1));
- })
- .perform(click())
- .check((view, noViewFoundException) -> {
- assertRowVisibility(TOP_ROW_IDX, View.VISIBLE);
- });
- }
-
- private void setExpandCollapseCustomView(View view) {
- mActivity.runOnUiThread(() -> {
- mActionBar.setExpandCollapseView(view);
- });
- }
-
- /**
- * Tests setting custom expand/collapse views.
- */
- @Test
- public void testCustomExpandCollapseView() {
- View customExpandCollapse = new ToggleButton(mActivity);
- customExpandCollapse.setContentDescription(mActivity.getString(
- R.string.action_bar_expand_collapse_button));
- setExpandCollapseCustomView(customExpandCollapse);
- setUpActionBarItems(NUM_COLS + 1);
-
- onView(withContentDescription(R.string.action_bar_expand_collapse_button))
- .check((view, noViewFoundException) -> {
- Preconditions.checkNotNull(view);
- assertEquals(customExpandCollapse, mActionBar.getViewAt(BOTTOM_ROW_IDX,
- NUM_COLS - 1));
- });
- }
-}
diff --git a/car/core/src/androidTest/java/androidx/car/widget/ActionBarTestActivity.java b/car/core/src/androidTest/java/androidx/car/widget/ActionBarTestActivity.java
deleted file mode 100644
index f5b2458..0000000
--- a/car/core/src/androidTest/java/androidx/car/widget/ActionBarTestActivity.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-package androidx.car.widget;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-/**
- * Simple test activity for {@link PagedListView} class.
- */
-public class ActionBarTestActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(androidx.car.test.R.layout.activity_action_bar);
- }
-}
diff --git a/car/core/src/androidTest/java/androidx/car/widget/ListItemAdapterTest.java b/car/core/src/androidTest/java/androidx/car/widget/ListItemAdapterTest.java
index 4b04da9..fc767ca 100644
--- a/car/core/src/androidTest/java/androidx/car/widget/ListItemAdapterTest.java
+++ b/car/core/src/androidTest/java/androidx/car/widget/ListItemAdapterTest.java
@@ -106,7 +106,7 @@
int viewType = 1;
// Using a random layout. The actual values does not matter.
- int layoutRes = R.layout.activity_action_bar;
+ int layoutRes = R.layout.activity_column_card_view;
adapter.registerListItemViewType(
viewType, layoutRes, CustomListItem::createViewHolder);
@@ -117,7 +117,7 @@
ListItemAdapter adapter = new ListItemAdapter(mContext, /* itemProvider= */ null);
// Using a random layout. The actual values does not matter.
- int layoutRes = R.layout.activity_action_bar;
+ int layoutRes = R.layout.activity_column_card_view;
adapter.registerListItemViewType(
CustomListItem.LIST_ITEM_ID, layoutRes, CustomListItem::createViewHolder);
diff --git a/car/core/src/androidTest/res/layout/activity_action_bar.xml b/car/core/src/androidTest/res/layout/activity_action_bar.xml
deleted file mode 100644
index 43e3331..0000000
--- a/car/core/src/androidTest/res/layout/activity_action_bar.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 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.
- -->
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.car.widget.ActionBar
- android:id="@+id/action_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/car_margin"
- android:layout_marginRight="@dimen/car_margin"
- android:layout_marginBottom="@dimen/car_padding_2"
- android:layout_alignParentBottom="true"
- app:columns="5" />
-
-</RelativeLayout>
diff --git a/car/core/src/main/java/androidx/car/widget/ActionBar.java b/car/core/src/main/java/androidx/car/widget/ActionBar.java
deleted file mode 100644
index 21aaadb..0000000
--- a/car/core/src/main/java/androidx/car/widget/ActionBar.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-package androidx.car.widget;
-
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-import android.animation.LayoutTransition;
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.transition.Fade;
-import android.transition.TransitionManager;
-import android.util.AttributeSet;
-import android.util.SparseArray;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.Space;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.VisibleForTesting;
-import androidx.car.R;
-
-import java.lang.annotation.Retention;
-import java.util.Locale;
-
-/**
- * An actions panel with three distinctive zones:
- * <ul>
- * <li>Main control: located in the bottom center it shows a highlighted icon and a circular
- * progress bar.
- * <li>Secondary controls: these are displayed at the left and at the right of the main control.
- * <li>Overflow controls: these are displayed at the left and at the right of the secondary controls
- * (if the space allows) and on the additional space if the panel is expanded.
- * </ul>
- */
-public class ActionBar extends RelativeLayout {
- private static final String TAG = "ActionBar";
-
- // ActionBar container
- private ViewGroup mActionBarWrapper;
- // Rows container
- private ViewGroup mRowsContainer;
- // All slots in this action bar where 0 is the bottom-start corner of the matrix, and
- // mNumColumns * nNumRows - 1 is the top-end corner
- private FrameLayout[] mSlots;
- /** Views to set in particular {@link SlotPosition}s */
- private final SparseArray<View> mFixedViews = new SparseArray<>();
- // View to be used for the expand/collapse action
- private @Nullable View mExpandCollapseView;
- // Default expand/collapse view to use one is not provided.
- private View mDefaultExpandCollapseView;
- // Number of rows in actual use. This is the number of extra rows that will be displayed when
- // the action bar is expanded
- private int mNumExtraRowsInUse;
- // Whether the action bar is expanded or not.
- private boolean mIsExpanded;
- // Views to accomodate in the slots.
- private @Nullable View[] mViews;
- // Number of columns of slots to use.
- private int mNumColumns;
- // Maximum number of rows to use.
- private int mNumRows;
- // Fade-in Transition used for the icons entering the secondary bar.
- private final Fade mFadeIn = new Fade(Fade.IN);
- // Fade-out Transition used for the icons exiting the secondary bar.
- private final Fade mFadeOut = new Fade(Fade.OUT);
-
- @Retention(SOURCE)
- @IntDef({SLOT_MAIN, SLOT_LEFT, SLOT_RIGHT, SLOT_EXPAND_COLLAPSE})
- public @interface SlotPosition {}
-
- /** Slot used for main actions {@link ActionBar}, usually at the bottom center */
- public static final int SLOT_MAIN = 0;
- /** Slot used to host 'move left', 'rewind', 'previous' or similar secondary actions,
- * usually at the left of the main action on the bottom row */
- public static final int SLOT_LEFT = 1;
- /** Slot used to host 'move right', 'fast-forward', 'next' or similar secondary actions,
- * usually at the right of the main action on the bottom row */
- public static final int SLOT_RIGHT = 2;
- /** Slot reserved for the expand/collapse button */
- public static final int SLOT_EXPAND_COLLAPSE = 3;
-
- // Minimum number of columns supported
- private static final int MIN_COLUMNS = 3;
- // Weight for the spacers used at the start and end of each slots row.
- private static final float SPACERS_WEIGHT = 0.5f;
-
- public ActionBar(Context context) {
- super(context);
- init(context, null, 0, 0);
- }
-
- public ActionBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs, 0, 0);
- }
-
- public ActionBar(Context context, AttributeSet attrs, int defStyleAttrs) {
- super(context, attrs, defStyleAttrs);
- init(context, attrs, defStyleAttrs, 0);
- }
-
- public ActionBar(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes) {
- super(context, attrs, defStyleAttrs, defStyleRes);
- init(context, attrs, defStyleAttrs, defStyleRes);
- }
-
- private void init(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes) {
- inflate(context, R.layout.action_bar, this);
-
- TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ActionBar,
- defStyleAttrs, defStyleRes);
- mNumColumns = Math.max(ta.getInteger(R.styleable.ActionBar_columns, MIN_COLUMNS),
- MIN_COLUMNS);
- ta.recycle();
-
- mActionBarWrapper = findViewById(R.id.action_bar_wrapper);
- mRowsContainer = findViewById(R.id.rows_container);
- mNumRows = mRowsContainer.getChildCount();
- mSlots = new FrameLayout[mNumColumns * mNumRows];
-
- for (int i = 0; i < mNumRows; i++) {
- // Slots are reserved in reverse order (first slots are in the bottom row)
- ViewGroup mRow = (ViewGroup) mRowsContainer.getChildAt(mNumRows - i - 1);
- // Inflate space on the left
- Space space = new Space(context);
- mRow.addView(space);
- space.setLayoutParams(new LinearLayout.LayoutParams(0,
- ViewGroup.LayoutParams.MATCH_PARENT, SPACERS_WEIGHT));
- // Inflate necessary number of columns
- for (int j = 0; j < mNumColumns; j++) {
- int pos = i * mNumColumns + j;
- mSlots[pos] = (FrameLayout) inflate(context, R.layout.action_bar_slot, null);
- mSlots[pos].setLayoutParams(new LinearLayout.LayoutParams(0,
- ViewGroup.LayoutParams.MATCH_PARENT, 1f));
- mRow.addView(mSlots[pos]);
- }
- // Inflate space on the right
- space = new Space(context);
- mRow.addView(space);
- space.setLayoutParams(new LinearLayout.LayoutParams(0,
- ViewGroup.LayoutParams.MATCH_PARENT, SPACERS_WEIGHT));
- }
-
- mDefaultExpandCollapseView = createIconButton(context, R.drawable.ic_overflow);
- mDefaultExpandCollapseView.setContentDescription(context.getString(
- R.string.action_bar_expand_collapse_button));
- mDefaultExpandCollapseView.setOnClickListener(v -> onExpandCollapse());
-
- // Update LayoutTransitions from the timings defined in the resources.
- configureLayoutTransitions();
- }
-
- private void configureLayoutTransitions() {
- Resources res = getContext().getResources();
-
- // Load layout transition timings for both expand and collapse transitions
- int expandScaleDuration = res.getInteger(R.integer.car_action_bar_expand_scale_duration_ms);
- int expandOpacityDelay = res.getInteger(R.integer.car_action_bar_expand_opacity_delay_ms);
- int expandOpacityDuration = res
- .getInteger(R.integer.car_action_bar_expand_opacity_duration_ms);
-
- int collapseScaleDuration = res
- .getInteger(R.integer.car_action_bar_collapse_scale_duration_ms);
- int collapseOpacityDuration = res
- .getInteger(R.integer.car_action_bar_collapse_opacity_duration_ms);
-
- // Get the default LayoutTransition set by animateLayoutChanges="true"
- LayoutTransition transition = mRowsContainer.getLayoutTransition();
-
- // Set the durations for expanding and collapsing the secondary Action Bar.
- transition.setDuration(LayoutTransition.CHANGE_APPEARING, expandScaleDuration);
- transition.setDuration(LayoutTransition.CHANGE_DISAPPEARING, collapseScaleDuration);
-
- // Disable bar icons' default transitions so we can apply our custom Fade transitions.
- transition.disableTransitionType(LayoutTransition.APPEARING);
- transition.disableTransitionType(LayoutTransition.DISAPPEARING);
-
- // Set the new LayoutTransition
- mRowsContainer.setLayoutTransition(transition);
-
- // Customize Fade-in transition for secondary Action Bar icons.
- mFadeIn.setStartDelay(expandOpacityDelay);
- mFadeIn.setDuration(expandOpacityDuration);
-
- // Customize Fade-out transition for secondary Action Bar icons.
- mFadeOut.setDuration(collapseOpacityDuration);
- }
-
- /**
- * Returns an index in the {@link #mSlots} array, given a well-known slot position.
- */
- private int getSlotIndex(@SlotPosition int slotPosition) {
- switch (slotPosition) {
- case SLOT_MAIN:
- return mNumColumns / 2;
- case SLOT_LEFT:
- return mNumColumns < 3 ? -1 : (mNumColumns / 2) - 1;
- case SLOT_RIGHT:
- return mNumColumns < 2 ? -1 : (mNumColumns / 2) + 1;
- case SLOT_EXPAND_COLLAPSE:
- return mNumColumns - 1;
- default:
- throw new IllegalArgumentException("Unknown position: " + slotPosition);
- }
- }
-
- /**
- * Sets or clears the view to be displayed at a particular position.
- *
- * @param view view to be displayed, or null to leave the position available.
- * @param slotPosition position to update
- */
- public void setView(@Nullable View view, @SlotPosition int slotPosition) {
- if (view != null) {
- mFixedViews.put(slotPosition, view);
- } else {
- mFixedViews.remove(slotPosition);
- }
- updateViewsLayout();
- }
-
- /**
- * Sets the view to use for the expand/collapse action. If not provided, a default
- * {@link ImageButton} will be used. The provided {@link View} should be able be able to display
- * changes in the "activated" state appropriately.
- *
- * @param view {@link View} to use for the expand/collapse action.
- */
- public void setExpandCollapseView(@NonNull View view) {
- mExpandCollapseView = view;
- mExpandCollapseView.setOnClickListener(v -> onExpandCollapse());
- updateViewsLayout();
- }
-
- private View getExpandCollapseView() {
- return mExpandCollapseView != null ? mExpandCollapseView : mDefaultExpandCollapseView;
- }
-
- private ImageButton createIconButton(Context context, @DrawableRes int iconResId) {
- ImageButton button = (ImageButton) inflate(context, R.layout.action_bar_button, null);
- Drawable icon = context.getDrawable(iconResId);
- button.setImageDrawable(icon);
- return button;
- }
-
- /**
- * Sets the views to include in each available slot of the action bar. Slots will be filled from
- * start to end (i.e: left to right) and from bottom to top. If more views than available slots
- * are provided, all extra views will be ignored.
- *
- * @param views array of views to include in each available slot.
- */
- public void setViews(@Nullable View[] views) {
- mViews = views;
- updateViewsLayout();
- }
-
- private void updateViewsLayout() {
- // Prepare an array of positions taken
- int totalSlots = mSlots.length;
- View[] slotViews = new View[totalSlots];
-
- // Take all known positions
- for (int i = 0; i < mFixedViews.size(); i++) {
- int index = getSlotIndex(mFixedViews.keyAt(i));
- if (index >= 0 && index < slotViews.length) {
- slotViews[index] = mFixedViews.valueAt(i);
- }
- }
-
- // Set all views using both the fixed and flexible positions
- int expandCollapseIndex = getSlotIndex(SLOT_EXPAND_COLLAPSE);
- int lastUsedIndex = 0;
- int viewsIndex = 0;
- for (int i = 0; i < totalSlots; i++) {
- View viewToUse = null;
-
- if (slotViews[i] != null) {
- // If there is a view assigned for this slot, use it.
- viewToUse = slotViews[i];
- } else if (i == expandCollapseIndex && mViews != null
- && viewsIndex < mViews.length - 1) {
- // If this is the expand/collapse slot, use the corresponding view
- viewToUse = getExpandCollapseView();
- } else if (mViews != null && viewsIndex < mViews.length) {
- // Otherwise, if the slot is not reserved, and if we still have views to assign,
- // take one and assign it to this slot.
- viewToUse = mViews[viewsIndex];
- viewsIndex++;
- }
- setView(viewToUse, mSlots[i]);
- if (viewToUse != null) {
- lastUsedIndex = i;
- }
- }
-
- mNumExtraRowsInUse = lastUsedIndex / mNumColumns;
- }
-
- private void setView(@Nullable View view, FrameLayout container) {
- container.removeAllViews();
- if (view != null) {
- container.addView(view);
- container.setVisibility(VISIBLE);
- view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));
- } else {
- container.setVisibility(INVISIBLE);
- }
- }
-
- private void onExpandCollapse() {
- mIsExpanded = !mIsExpanded;
- mSlots[getSlotIndex(SLOT_EXPAND_COLLAPSE)].setActivated(mIsExpanded);
-
- // Start proper Fade transition upon expanding or collapsing the secondary Action Bar.
- TransitionManager.beginDelayedTransition(mRowsContainer, mIsExpanded ? mFadeIn : mFadeOut);
-
- for (int i = 0; i < mNumExtraRowsInUse; i++) {
- mRowsContainer.getChildAt(i).setVisibility(mIsExpanded ? VISIBLE : GONE);
- }
- }
-
- /**
- * Returns the view assigned to the given row and column, after layout.
- *
- * @param rowIdx row index from 0 being the top row, and {@link #mNumRows{ -1 being the bottom
- * row.
- * @param colIdx column index from 0 on start (left), to {@link #mNumColumns} on end (right)
- */
- @VisibleForTesting
- @Nullable
- View getViewAt(int rowIdx, int colIdx) {
- if (rowIdx < 0 || rowIdx > mRowsContainer.getChildCount()) {
- throw new IllegalArgumentException(String.format((Locale) null,
- "Row index out of range (requested: %d, max: %d)",
- rowIdx, mRowsContainer.getChildCount()));
- }
- if (colIdx < 0 || colIdx > mNumColumns) {
- throw new IllegalArgumentException(String.format((Locale) null,
- "Column index out of range (requested: %d, max: %d)",
- colIdx, mNumColumns));
- }
- FrameLayout slot = (FrameLayout) ((LinearLayout) mRowsContainer.getChildAt(rowIdx))
- .getChildAt(colIdx + 1);
- return slot.getChildCount() > 0 ? slot.getChildAt(0) : null;
- }
-}
diff --git a/samples/SupportCarDemos/src/main/AndroidManifest.xml b/samples/SupportCarDemos/src/main/AndroidManifest.xml
index 9e7b234..e450771 100644
--- a/samples/SupportCarDemos/src/main/AndroidManifest.xml
+++ b/samples/SupportCarDemos/src/main/AndroidManifest.xml
@@ -213,18 +213,5 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".SupportCarDemoActivity"/>
</activity>
-
- <activity
- android:name=".DefaultActionBarDemoActivity"
- android:label="Default Action Bar"
- android:parentActivityName=".SupportCarDemoActivity"
- android:theme="@style/Theme.Car">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- <meta-data android:name="android.support.PARENT_ACTIVITY"
- android:value=".SupportCarDemoActivity" />
- </activity>
</application>
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/samples/SupportCarDemos/src/main/java/com/example/androidx/car/ActionBarActivity.java b/samples/SupportCarDemos/src/main/java/com/example/androidx/car/ActionBarActivity.java
deleted file mode 100644
index 1ac1c79..0000000
--- a/samples/SupportCarDemos/src/main/java/com/example/androidx/car/ActionBarActivity.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-package com.example.androidx.car;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ImageButton;
-
-import androidx.annotation.DrawableRes;
-import androidx.car.widget.ActionBar;
-import androidx.fragment.app.FragmentActivity;
-
-/**
- * Demo activity for ActionBar
- */
-public class ActionBarActivity extends FragmentActivity {
- private ActionBar mActionPanel;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_action_bar);
- mActionPanel = findViewById(R.id.action_panel);
- mActionPanel.setView(createButton(this, R.drawable.ic_play),
- ActionBar.SLOT_MAIN);
- ImageButton skpPrevious = createButton(this, R.drawable.ic_skip_next);
- skpPrevious.setVisibility(View.GONE);
- mActionPanel.setView(skpPrevious, ActionBar.SLOT_LEFT);
- mActionPanel.setView(createButton(this, R.drawable.ic_skip_next),
- ActionBar.SLOT_RIGHT);
- mActionPanel.setViews(new ImageButton[]{
- createButton(this, R.drawable.ic_queue_music),
- createButton(this, R.drawable.ic_overflow),
- createButton(this, R.drawable.ic_overflow),
- createButton(this, R.drawable.ic_overflow),
- createButton(this, R.drawable.ic_overflow),
- createButton(this, R.drawable.ic_overflow)
- });
- }
-
- private ImageButton createButton(Context context, @DrawableRes int iconResId) {
- ImageButton button = new ImageButton(context, null,
- androidx.car.R.style.Widget_Car_Button_ActionBar);
- button.setImageDrawable(context.getDrawable(iconResId));
- return button;
- }
-}
diff --git a/samples/SupportCarDemos/src/main/res/drawable/ic_play.xml b/samples/SupportCarDemos/src/main/res/drawable/ic_play.xml
deleted file mode 100644
index 268104a..0000000
--- a/samples/SupportCarDemos/src/main/res/drawable/ic_play.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:name="ic_play"
- android:width="44dp"
- android:viewportWidth="44"
- android:height="44dp"
- android:viewportHeight="44" >
- <group
- android:name="group"
- android:translateX="25.025"
- android:translateY="22"
- android:scaleX="0.08892"
- android:scaleY="0.08892"
- android:rotation="90" >
- <group
- android:name="group_pivot"
- android:translateX="0.3042"
- android:translateY="-2.99512" >
- <group
- android:name="rectangle_02" >
- <path
- android:name="rectangle_02_path"
- android:pathData="M -0.25,-112.634796143 c 0.0,0.0 -26.3583984375,231.259857178 -26.3583984375,231.259857178 c 0.0,0.0 172.608398438,-0.00005 172.608398438,-0.00005 c 0.0,0.0 -146.125,-231.259750366 -146.125,-231.259750366 c 0.0,0.0 -0.125,-0.00006 -0.125,-0.00006 Z"
- android:fillColor="#FF000000" />
- </group>
- <group
- android:name="rectangle_01"
- android:translateX="-138.9834" >
- <path
- android:name="rectangle_01_path"
- android:pathData="M 138.5,-112.634811401 c 0.0,0.0 -146.125,231.259811401 -146.125,231.259811401 c 0.0,0.0 172.608398438,-0.00005 172.608398438,-0.00005 c 0.0,0.0 -26.3583984375,-231.25970459 -26.3583984375,-231.25970459 c 0.0,0.0 -0.125,-0.00006 -0.125,-0.00006 Z"
- android:fillColor="#FF000000" />
- </group>
- </group>
- </group>
-</vector>
diff --git a/samples/SupportCarDemos/src/main/res/drawable/ic_queue_music.xml b/samples/SupportCarDemos/src/main/res/drawable/ic_queue_music.xml
deleted file mode 100644
index d3db138..0000000
--- a/samples/SupportCarDemos/src/main/res/drawable/ic_queue_music.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<vector android:height="44dp" android:viewportHeight="24.0"
- android:viewportWidth="24.0" android:width="44dp" xmlns:android="http://schemas.android.com/apk/res/android">
- <path android:fillColor="#000000" android:pathData="M15,6L3,6v2h12L15,6zM15,10L3,10v2h12v-2zM3,16h8v-2L3,14v2zM17,6v8.18c-0.31,-0.11 -0.65,-0.18 -1,-0.18 -1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3L19,8h3L22,6h-5z"/>
-</vector>
diff --git a/samples/SupportCarDemos/src/main/res/drawable/ic_skip_next.xml b/samples/SupportCarDemos/src/main/res/drawable/ic_skip_next.xml
deleted file mode 100644
index 81abf37..0000000
--- a/samples/SupportCarDemos/src/main/res/drawable/ic_skip_next.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<vector android:height="44dp" android:viewportHeight="24.0"
- android:viewportWidth="24.0" android:width="44dp" xmlns:android="http://schemas.android.com/apk/res/android">
- <path android:fillColor="#000000" android:pathData="M6,18l8.5,-6L6,6v12zM16,6v12h2V6h-2z"/>
-</vector>
diff --git a/samples/SupportCarDemos/src/main/res/drawable/ic_skip_previous.xml b/samples/SupportCarDemos/src/main/res/drawable/ic_skip_previous.xml
deleted file mode 100644
index 6b3b55d..0000000
--- a/samples/SupportCarDemos/src/main/res/drawable/ic_skip_previous.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<vector android:height="44dp" android:viewportHeight="24.0"
- android:viewportWidth="24.0" android:width="44dp" xmlns:android="http://schemas.android.com/apk/res/android">
- <path android:fillColor="#000000" android:pathData="M6,6h2v12L6,18zM9.5,12l8.5,6L18,6z"/>
-</vector>
diff --git a/samples/SupportCarDemos/src/main/res/layout/activity_action_bar.xml b/samples/SupportCarDemos/src/main/res/layout/activity_action_bar.xml
deleted file mode 100644
index 48b1c2e..0000000
--- a/samples/SupportCarDemos/src/main/res/layout/activity_action_bar.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2018 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.
- -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@android:color/black">
-
- <androidx.car.widget.ActionBar
- android:id="@+id/action_panel"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/car_margin"
- android:layout_marginRight="@dimen/car_margin"
- android:layout_marginBottom="@dimen/car_padding_2"
- android:layout_alignParentBottom="true"
- app:columns="5" />
-</RelativeLayout>
\ No newline at end of file