Remove DrawerAdapter for GarageModeTestApp
Remove androidx.car_car and androidx.appcompat_appcompat
dependency for GarageModeTestApp
Replace drawer with buttons
Test: Manual.
Change-Id: I12092ef105ad6d20118468b43b2bbccf90808948
diff --git a/tests/GarageModeTestApp/Android.mk b/tests/GarageModeTestApp/Android.mk
index a3e60f8..5fd308d 100644
--- a/tests/GarageModeTestApp/Android.mk
+++ b/tests/GarageModeTestApp/Android.mk
@@ -42,9 +42,7 @@
LOCAL_STATIC_JAVA_LIBRARIES += vehicle-hal-support-lib
LOCAL_STATIC_ANDROID_LIBRARIES += \
- androidx.car_car \
androidx.legacy_legacy-support-v4 \
- androidx.appcompat_appcompat
LOCAL_JAVA_LIBRARIES += android.car
diff --git a/tests/GarageModeTestApp/res/drawable/ic_close_white.xml b/tests/GarageModeTestApp/res/drawable/ic_close_white.xml
new file mode 100644
index 0000000..4187755
--- /dev/null
+++ b/tests/GarageModeTestApp/res/drawable/ic_close_white.xml
@@ -0,0 +1,24 @@
+<!--
+ 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:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M19.000000,6.400000l-1.400000,-1.400000 -5.600000,5.600000 -5.600000,-5.600000 -1.400000,1.400000 5.600000,5.600000 -5.600000,5.600000 1.400000,1.400000 5.600000,-5.600000 5.600000,5.600000 1.400000,-1.400000 -5.600000,-5.600000z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
\ No newline at end of file
diff --git a/tests/GarageModeTestApp/res/layout/main_activity.xml b/tests/GarageModeTestApp/res/layout/main_activity.xml
index b76e5b7..a71e3cc 100644
--- a/tests/GarageModeTestApp/res/layout/main_activity.xml
+++ b/tests/GarageModeTestApp/res/layout/main_activity.xml
@@ -13,49 +13,66 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<androidx.drawerlayout.widget.DrawerLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/drawer_layout"
+ android:background="@android:color/black"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<LinearLayout
android:background="@android:color/black"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- The min height of the Toolbar needs to be set to ensure that the icons in it
- are vertically centered. -->
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/car_toolbar"
- android:background="@android:color/black"
- android:layout_width="match_parent"
- android:layout_height="@dimen/car_app_bar_height"
- android:layout_gravity="center_vertical"
- android:minHeight="@dimen/car_app_bar_height"
- style="?attr/toolbarStyle" />
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
<FrameLayout
- android:id="@+id/activity_content"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:id="@+id/exit_button_container"
+ android:layout_width="@dimen/panel_margin"
+ android:layout_height="@dimen/app_bar_height"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:background="?android:attr/selectableItemBackground"
+ android:clickable="true"
+ android:focusable="true">
+ <ImageButton
+ android:layout_width="@dimen/icon_size"
+ android:layout_height="@dimen/icon_size"
+ android:layout_gravity="center"
+ android:adjustViewBounds="true"
+ android:background="@null"
+ android:clickable="false"
+ android:focusable="false"
+ android:scaleType="fitXY"
+ android:src="@drawable/ic_close_white"
+ android:tint="@*android:color/car_tint"/>
+ </FrameLayout>
+
+ <TextView
+ android:text="@string/app_name"
+ android:textSize="@dimen/title_size"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:layout_weight="3"/>
+
+ <Button
+ style="@style/Button"
+ android:id="@+id/offcar_test_btn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/off_car_testing"/>
+
+ <Button
+ style="@style/Button"
+ android:id="@+id/incar_test_btn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/in_car_testing"/>
</LinearLayout>
- <!-- Using a CosntraintLayout to specify a maxWidth. -->
- <androidx.constraintlayout.widget.ConstraintLayout
+ <FrameLayout
+ android:id="@+id/activity_content"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="start"
- android:layout_marginEnd="@dimen/car_margin"
- android:maxWidth="@dimen/car_drawer_max_width">
-
- <include
- layout="@layout/car_drawer"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent" />
- </androidx.constraintlayout.widget.ConstraintLayout>
-</androidx.drawerlayout.widget.DrawerLayout>
+ android:layout_height="match_parent"/>
+</LinearLayout>
diff --git a/tests/GarageModeTestApp/res/values/dimens.xml b/tests/GarageModeTestApp/res/values/dimens.xml
new file mode 100644
index 0000000..75786d0
--- /dev/null
+++ b/tests/GarageModeTestApp/res/values/dimens.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+<resources>
+ <dimen name="title_size">40dp</dimen>
+ <dimen name="icon_size">48dp</dimen>
+ <dimen name="panel_margin">80dp</dimen>
+ <dimen name="app_bar_height">60dp</dimen>
+</resources>
diff --git a/tests/GarageModeTestApp/res/values/strings.xml b/tests/GarageModeTestApp/res/values/strings.xml
index 59945125..8bab7b1 100644
--- a/tests/GarageModeTestApp/res/values/strings.xml
+++ b/tests/GarageModeTestApp/res/values/strings.xml
@@ -16,6 +16,10 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" translatable="false">GarageMode Test App</string>
+ <string name="off_car_testing" translatable="false">Offcar Test</string>
+ <string name="in_car_testing" translatable="false">Incar Test</string>
+ <string name="quit_app" translatable="false">Quit App</string>
+
<string name="button_schedule_job" translatable="false">Schedule Job</string>
<string name="button_job_info" translatable="false">Job Info</string>
<string name="button_enter_garage_mode" translatable="false">Enter GarageMode</string>
diff --git a/tests/GarageModeTestApp/res/values/styles.xml b/tests/GarageModeTestApp/res/values/styles.xml
index 642e7ea..1f98397 100644
--- a/tests/GarageModeTestApp/res/values/styles.xml
+++ b/tests/GarageModeTestApp/res/values/styles.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
<resources>
- <style name="GarageModeTheme" parent="Theme.Car.Dark.NoActionBar.Drawer">
+ <style name="GarageModeTheme" parent="android:Theme.DeviceDefault.NoActionBar">
<item name="android:textSize">24sp</item>
</style>
<style name="SectionContainer">
diff --git a/tests/GarageModeTestApp/src/com/google/android/car/garagemode/testapp/MainActivity.java b/tests/GarageModeTestApp/src/com/google/android/car/garagemode/testapp/MainActivity.java
index 2019b7e..dae859f 100644
--- a/tests/GarageModeTestApp/src/com/google/android/car/garagemode/testapp/MainActivity.java
+++ b/tests/GarageModeTestApp/src/com/google/android/car/garagemode/testapp/MainActivity.java
@@ -17,26 +17,16 @@
import android.content.res.Configuration;
import android.os.Bundle;
-import android.view.MenuItem;
-import androidx.appcompat.app.ActionBarDrawerToggle;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.Toolbar;
-import androidx.car.drawer.CarDrawerAdapter;
-import androidx.car.drawer.CarDrawerController;
-import androidx.car.drawer.DrawerItemViewHolder;
-import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
import java.util.ArrayList;
import java.util.List;
-public class MainActivity extends AppCompatActivity {
+public class MainActivity extends FragmentActivity {
private static final Logger LOG = new Logger("MainActivity");
- private CarDrawerController mDrawerController;
- private Toolbar mToolbar;
-
private final List<MenuEntry> mMenuEntries = new ArrayList<MenuEntry>() {
{
add("Offcar testing", OffcarTestingFragment.class);
@@ -58,45 +48,22 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
- DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
- ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(
- /* activity= */ this,
- drawerLayout,
- R.string.car_drawer_open,
- R.string.car_drawer_close);
-
- mToolbar = findViewById(R.id.car_toolbar);
- setSupportActionBar(mToolbar);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setHomeButtonEnabled(true);
-
mMenuEntries.get(0).onClick();
- mDrawerController = new CarDrawerController(drawerLayout, drawerToggle);
- mDrawerController.setRootAdapter(new DrawerAdapter());
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- mDrawerController.syncState();
+ findViewById(R.id.offcar_test_btn).setOnClickListener((v) -> mMenuEntries.get(0).onClick());
+ findViewById(R.id.incar_test_btn).setOnClickListener((v) -> mMenuEntries.get(1).onClick());
+ findViewById(R.id.exit_button_container).setOnClickListener(
+ (v) -> mMenuEntries.get(2).onClick());
}
@Override
protected void onStop() {
super.onStop();
- mDrawerController.closeDrawer();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- mDrawerController.onConfigurationChanged(newConfig);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- return mDrawerController.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
}
private interface ClickHandler {
@@ -177,32 +144,4 @@
.replace(R.id.activity_content, fragment)
.commit();
}
-
- private final class DrawerAdapter extends CarDrawerAdapter {
- DrawerAdapter() {
- super(MainActivity.this, true /* showDisabledOnListOnEmpty */);
- setTitle(getString(R.string.app_name));
- }
-
- @Override
- protected int getActualItemCount() {
- return mMenuEntries.size();
- }
-
- @Override
- protected void populateViewHolder(DrawerItemViewHolder holder, int position) {
- holder.getTitleView().setText(mMenuEntries.get(position).getText());
- holder.itemView.setOnClickListener(v -> onItemClick(holder.getAdapterPosition()));
- }
-
- private void onItemClick(int position) {
- if ((position < 0) || (position >= mMenuEntries.size())) {
- LOG.wtf("Unknown menu item: " + position);
- return;
- }
-
- mMenuEntries.get(position).onClick();
- mDrawerController.closeDrawer();
- }
- }
}