DO NOT MERGE: Add old style toolbar activity to PaintBooth
OEMs on Q will be customizing the old-style toolbar. Now that
PaintBooth exclusively uses baselayouts, they won't have a way
to test their customizations in paintbooth. Add a page where
they can view the old style toolbar.
Bug: 157245704
Bug: 154244647
Test: Manually
Change-Id: Ib3bfb2812d2f8a49e251cfc85f37b645cff65dc6
diff --git a/car-ui-lib/tests/paintbooth/AndroidManifest-gradle.xml b/car-ui-lib/tests/paintbooth/AndroidManifest-gradle.xml
index 4e84426..84ed351 100644
--- a/car-ui-lib/tests/paintbooth/AndroidManifest-gradle.xml
+++ b/car-ui-lib/tests/paintbooth/AndroidManifest-gradle.xml
@@ -55,6 +55,13 @@
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>
<activity
+ android:name=".toolbar.OldToolbarActivity"
+ android:exported="false"
+ android:parentActivityName=".MainActivity"
+ android:theme="@style/Theme.CarUi">
+ <meta-data android:name="distractionOptimized" android:value="true"/>
+ </activity>
+ <activity
android:name=".overlays.OverlayActivity"
android:exported="false"
android:parentActivityName=".MainActivity">
diff --git a/car-ui-lib/tests/paintbooth/AndroidManifest.xml b/car-ui-lib/tests/paintbooth/AndroidManifest.xml
index 18cba91..ac2e32a 100644
--- a/car-ui-lib/tests/paintbooth/AndroidManifest.xml
+++ b/car-ui-lib/tests/paintbooth/AndroidManifest.xml
@@ -64,6 +64,13 @@
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>
<activity
+ android:name=".toolbar.OldToolbarActivity"
+ android:exported="false"
+ android:parentActivityName=".MainActivity"
+ android:theme="@style/Theme.CarUi">
+ <meta-data android:name="distractionOptimized" android:value="true"/>
+ </activity>
+ <activity
android:name=".overlays.OverlayActivity"
android:exported="false"
android:parentActivityName=".MainActivity">
diff --git a/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity_with_old_toolbar.xml b/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity_with_old_toolbar.xml
new file mode 100644
index 0000000..266e9b8
--- /dev/null
+++ b/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity_with_old_toolbar.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 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.
+ -->
+<androidx.constraintlayout.widget.ConstraintLayout
+ 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="@drawable/car_ui_activity_background">
+
+ <com.android.car.ui.recyclerview.CarUiRecyclerView
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipToPadding="false"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
+ <com.android.car.ui.toolbar.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/MainActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/MainActivity.java
index 3cf2b9f..e4a0a3d 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/MainActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/MainActivity.java
@@ -39,6 +39,7 @@
import com.android.car.ui.paintbooth.dialogs.DialogsActivity;
import com.android.car.ui.paintbooth.overlays.OverlayActivity;
import com.android.car.ui.paintbooth.preferences.PreferenceActivity;
+import com.android.car.ui.paintbooth.toolbar.OldToolbarActivity;
import com.android.car.ui.paintbooth.toolbar.ToolbarActivity;
import com.android.car.ui.paintbooth.widgets.WidgetActivity;
import com.android.car.ui.recyclerview.CarUiRecyclerView;
@@ -63,6 +64,7 @@
Pair.create("Preferences sample", PreferenceActivity.class),
Pair.create("Overlays", OverlayActivity.class),
Pair.create("Toolbar sample", ToolbarActivity.class),
+ Pair.create("Old Toolbar sample", OldToolbarActivity.class),
Pair.create("Widget sample", WidgetActivity.class),
Pair.create("ListItem sample", CarUiListItemActivity.class)
);
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/OldToolbarActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/OldToolbarActivity.java
new file mode 100644
index 0000000..f427990
--- /dev/null
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/OldToolbarActivity.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2020 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.android.car.ui.paintbooth.toolbar;
+
+import android.os.Bundle;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.car.ui.paintbooth.R;
+import com.android.car.ui.toolbar.Toolbar;
+
+public class OldToolbarActivity extends ToolbarActivity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Toolbar toolbar = requireViewById(R.id.toolbar);
+ RecyclerView rv = requireViewById(R.id.list);
+ toolbar.registerToolbarHeightChangeListener(height -> {
+ rv.setPadding(0, height, 0, 0);
+ });
+ }
+
+ @Override
+ protected int getLayout() {
+ return R.layout.car_ui_recycler_view_activity_with_old_toolbar;
+ }
+}
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/ToolbarActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/ToolbarActivity.java
index 54c8c0b..593b4ee 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/ToolbarActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/toolbar/ToolbarActivity.java
@@ -55,9 +55,13 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.car_ui_recycler_view_activity);
+ setContentView(getLayout());
- ToolbarController toolbar = CarUi.requireToolbar(this);
+ ToolbarController toolbarNonFinal = CarUi.getToolbar(this);
+ if (toolbarNonFinal == null) {
+ toolbarNonFinal = requireViewById(R.id.toolbar);
+ }
+ ToolbarController toolbar = toolbarNonFinal;
toolbar.setTitle(getTitle());
toolbar.setState(Toolbar.State.SUBPAGE);
toolbar.setLogo(R.drawable.ic_launcher);
@@ -318,6 +322,11 @@
prv.setAdapter(mAdapter);
}
+ /** Override in subclasses to change the layout */
+ protected int getLayout() {
+ return R.layout.car_ui_recycler_view_activity;
+ }
+
@Override
public void onCarUiInsetsChanged(Insets insets) {
requireViewById(R.id.list)