aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-05-12 07:14:08 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-05-12 07:14:08 +0000
commitf8d6904e6a8d2ebc3219ff11ba706f38820bf3b7 (patch)
tree0dba61348273570c6f766fb426590d24063bf68e
parent09cde6c76687d37228c13ad80f3a7478c11210af (diff)
parent778d489585053d9219466ce1371915e18a0b7069 (diff)
downloadtests-f8d6904e6a8d2ebc3219ff11ba706f38820bf3b7.tar.gz
Snap for 6485046 from 778d489585053d9219466ce1371915e18a0b7069 to mainline-release
Change-Id: I518224c4ed866cc640f0cce6d354df5742f0294c
-rw-r--r--RotaryPlayground/Android.bp1
-rw-r--r--RotaryPlayground/res/layout/rotary_activity.xml1
-rw-r--r--RotaryPlayground/res/layout/rotary_cards.xml1
-rw-r--r--RotaryPlayground/res/layout/rotary_direct_manipulation.xml58
-rw-r--r--RotaryPlayground/res/layout/rotary_grid.xml30
-rw-r--r--RotaryPlayground/res/layout/rotary_grid_item.xml37
-rw-r--r--RotaryPlayground/res/layout/rotary_menu.xml28
-rw-r--r--RotaryPlayground/res/values/colors.xml1
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryDirectManipulationWidgets.java40
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGrid.java59
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGridAdapter.java74
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java45
12 files changed, 356 insertions, 19 deletions
diff --git a/RotaryPlayground/Android.bp b/RotaryPlayground/Android.bp
index 002feae..2371831 100644
--- a/RotaryPlayground/Android.bp
+++ b/RotaryPlayground/Android.bp
@@ -24,6 +24,7 @@ android_app {
static_libs: [
"car-apps-common",
+ "car-ui-lib",
],
owner: "google",
diff --git a/RotaryPlayground/res/layout/rotary_activity.xml b/RotaryPlayground/res/layout/rotary_activity.xml
index bbe970c..2e63d6b 100644
--- a/RotaryPlayground/res/layout/rotary_activity.xml
+++ b/RotaryPlayground/res/layout/rotary_activity.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
diff --git a/RotaryPlayground/res/layout/rotary_cards.xml b/RotaryPlayground/res/layout/rotary_cards.xml
index ce798bc..7774918 100644
--- a/RotaryPlayground/res/layout/rotary_cards.xml
+++ b/RotaryPlayground/res/layout/rotary_cards.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
diff --git a/RotaryPlayground/res/layout/rotary_direct_manipulation.xml b/RotaryPlayground/res/layout/rotary_direct_manipulation.xml
new file mode 100644
index 0000000..914a6e3
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_direct_manipulation.xml
@@ -0,0 +1,58 @@
+<!--
+ ~ 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.
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+ <!-- Split the screen in half horizontally. -->
+
+ <!-- Two time pickers formatted differently. -->
+ <com.android.car.ui.FocusArea
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_weight="1">
+ <TimePicker
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:timePickerMode="spinner">
+ </TimePicker>
+ <TimePicker
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:timePickerMode="clock">
+ </TimePicker>
+ </com.android.car.ui.FocusArea>
+
+ <!-- A seek bar and a radial time picker. -->
+ <com.android.car.ui.FocusArea
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_weight="1">
+ <SeekBar
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ </SeekBar>
+ <RadialTimePickerView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1">
+ </RadialTimePickerView>
+ </com.android.car.ui.FocusArea>
+</LinearLayout>
diff --git a/RotaryPlayground/res/layout/rotary_grid.xml b/RotaryPlayground/res/layout/rotary_grid.xml
new file mode 100644
index 0000000..7e9998d
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_grid.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<com.android.car.ui.FocusArea
+ 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">
+
+ <com.android.car.ui.recyclerview.CarUiRecyclerView
+ android:id="@+id/rotary_grid_view"
+ app:layoutStyle="grid"
+ app:numOfColumns="3"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+</com.android.car.ui.FocusArea>
diff --git a/RotaryPlayground/res/layout/rotary_grid_item.xml b/RotaryPlayground/res/layout/rotary_grid_item.xml
new file mode 100644
index 0000000..e532ec5
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_grid_item.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<!-- This is the item layout for the rotary_grid.xml. The attribute,
+ android:focusable="true" is to allow the items to be focusable.
+ Alternatively, android:clickable="true" will also make the items
+ focusable automatically, but would mean the user could tap on the items. -->
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/rotary_grid_item"
+ android:background="@color/grid_item_background_color"
+ android:focusable="true"
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:layout_margin="10dp">
+
+ <TextView
+ android:id="@+id/rotary_grid_item_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"/>
+</FrameLayout> \ No newline at end of file
diff --git a/RotaryPlayground/res/layout/rotary_menu.xml b/RotaryPlayground/res/layout/rotary_menu.xml
index debe3ed..8aa2f56 100644
--- a/RotaryPlayground/res/layout/rotary_menu.xml
+++ b/RotaryPlayground/res/layout/rotary_menu.xml
@@ -21,27 +21,27 @@
android:orientation="vertical">
<Button
- android:id="@+id/cards_example"
+ android:id="@+id/cards"
android:layout_width="match_parent"
- android:layout_height="50dp"
- android:layout_marginTop="32dp"
- android:text="Card Examples" />
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="Cards" />
<Button
- android:id="@+id/menu_item_2"
+ android:id="@+id/direct_manipulation"
android:layout_width="match_parent"
- android:layout_height="50dp"
- android:layout_marginTop="32dp"
- android:text="Menu Item 2" />
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="Direct Manipulation" />
<Button
- android:id="@+id/menu_item_3"
+ android:id="@+id/grid"
android:layout_width="match_parent"
- android:layout_height="50dp"
- android:layout_marginTop="32dp"
- android:text="Menu Item 3" />
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="Grid" />
<Button
android:id="@+id/menu_item_4"
android:layout_width="match_parent"
- android:layout_height="50dp"
- android:layout_marginTop="32dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"
android:text="Menu Item 4" />
</com.android.car.ui.FocusArea>
diff --git a/RotaryPlayground/res/values/colors.xml b/RotaryPlayground/res/values/colors.xml
index c52fa47..05e030c 100644
--- a/RotaryPlayground/res/values/colors.xml
+++ b/RotaryPlayground/res/values/colors.xml
@@ -17,5 +17,6 @@
<resources>
<color name="card_background_color">#37393d</color>
<color name="card_disabled_background_color">#61646b</color>
+ <color name="grid_item_background_color">#006666</color>
<color name="button_disabled_background_color">#61646b</color>
</resources> \ No newline at end of file
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryDirectManipulationWidgets.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryDirectManipulationWidgets.java
new file mode 100644
index 0000000..34f9f60
--- /dev/null
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryDirectManipulationWidgets.java
@@ -0,0 +1,40 @@
+/*
+ * 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.rotaryplayground;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+/**
+ * Fragment that demos rotary interactions directly manipulating the state of UI widgets such as a
+ * {@link android.widget.SeekBar}, {@link android.widget.DatePicker}, and
+ * {@link android.widget.RadialTimePickerView}.
+ */
+public class RotaryDirectManipulationWidgets extends Fragment {
+ // TODO(agathaman): refactor a common class that takes in a fragment xml id and inflates it, to
+ // share between this and RotaryCards.
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.rotary_direct_manipulation, container, false);
+ }
+}
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGrid.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGrid.java
new file mode 100644
index 0000000..ceb0673
--- /dev/null
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGrid.java
@@ -0,0 +1,59 @@
+/*
+ * 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.rotaryplayground;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+/**
+ * Fragment with a RecyclerView Grid to demo and test z-pattern rotating navigation and
+ * vertical scroll.
+ */
+public class RotaryGrid extends Fragment {
+
+ private static final int NUMBER_OF_COLUMNS = 3;
+
+ private static final String[] DATA = {
+ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
+ "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
+ "21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
+ "31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
+ "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"};
+
+ private RotaryGridAdapter mGridAdapter;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.rotary_grid, container, false);
+ populateGridItems(view);
+ return view;
+ }
+
+ private void populateGridItems(View view) {
+ RecyclerView gridView = view.findViewById(R.id.rotary_grid_view);
+ gridView.setLayoutManager(new GridLayoutManager(getActivity(), NUMBER_OF_COLUMNS));
+ mGridAdapter = new RotaryGridAdapter(getActivity(), DATA);
+ gridView.setAdapter(mGridAdapter);
+ }
+}
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGridAdapter.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGridAdapter.java
new file mode 100644
index 0000000..8c5492c
--- /dev/null
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryGridAdapter.java
@@ -0,0 +1,74 @@
+/*
+ * 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.rotaryplayground;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The adapter that populates the example rotary grid view with strings.
+ */
+final class RotaryGridAdapter extends RecyclerView.Adapter<RotaryGridAdapter.ItemViewHolder> {
+
+ private final String[] mData;
+ private final Context mContext;
+ private final LayoutInflater mInflater;
+
+ RotaryGridAdapter(Context context, String[] data) {
+ this.mContext = context;
+ this.mInflater = LayoutInflater.from(context);
+ this.mData = data;
+ }
+
+ @Override
+ public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View view = mInflater.inflate(
+ R.layout.rotary_grid_item, parent, /* attachToRoot= */ false);
+ return new ItemViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(ItemViewHolder holder, int position) {
+ holder.setText(mData[position]);
+ }
+
+ @Override
+ public int getItemCount() {
+ return mData.length;
+ }
+
+ /** The viewholder class that contains the grid item data. */
+ static class ItemViewHolder extends RecyclerView.ViewHolder {
+ private TextView mItemText;
+
+ ItemViewHolder(View view) {
+ super(view);
+ mItemText = itemView.findViewById(R.id.rotary_grid_item_text);
+ }
+
+ void setText(String text) {
+ this.mItemText.setText(text);
+ }
+ }
+} \ No newline at end of file
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
index 272317d..d54a721 100644
--- a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
@@ -31,24 +31,37 @@ import androidx.fragment.app.Fragment;
public class RotaryMenu extends Fragment {
private Fragment mRotaryCards = null;
+ private Fragment mRotaryGrid = null;
+ private Fragment mDirectManipulation = null;
- private Button mCardExamplesButton;
+ private Button mCardButton;
+ private Button mGridButton;
+ private Button mDirectManipulationButton;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.rotary_menu, container, false);
- mCardExamplesButton = view.findViewById(R.id.cards_example);
- mCardExamplesButton.setOnFocusChangeListener((v, hasFocus) -> showRotaryCards(hasFocus));
- mCardExamplesButton.setOnClickListener(v -> showRotaryCards(/* hasFocus= */ true));
+ mCardButton = view.findViewById(R.id.cards);
+ mCardButton.setOnFocusChangeListener((v, hasFocus) -> showRotaryCards(hasFocus));
+ mCardButton.setOnClickListener(v -> showRotaryCards(/* hasFocus= */ true));
+ mGridButton = view.findViewById(R.id.grid);
+ mGridButton.setOnFocusChangeListener((v, hasFocus) -> showGridExample(hasFocus));
+ mGridButton.setOnClickListener(v -> showGridExample(/* hasFocus= */ true));
+
+ mDirectManipulationButton = view.findViewById(R.id.direct_manipulation);
+ mDirectManipulationButton.setOnFocusChangeListener(
+ (v, hasFocus) -> showDirectManipulationExamples(hasFocus));
+ mDirectManipulationButton.setOnClickListener(
+ (v -> showDirectManipulationExamples(/* hasFocus= */ true)));
return view;
}
private void showRotaryCards(boolean hasFocus) {
if (!hasFocus) {
- return; // do nothing if no focus.
+ return; // Do nothing if no focus.
}
if (mRotaryCards == null) {
mRotaryCards = new RotaryCards();
@@ -56,6 +69,28 @@ public class RotaryMenu extends Fragment {
showContent(mRotaryCards);
}
+ private void showGridExample(boolean hasFocus) {
+ if (!hasFocus) {
+ return; // do nothing if no focus.
+ }
+ if (mRotaryGrid == null) {
+ mRotaryGrid = new RotaryGrid();
+ }
+ showContent(mRotaryGrid);
+ }
+
+ // TODO(agathaman): refactor this and the showRotaryCards above into a
+ // showFragment(Fragment fragment, boolean hasFocus); method.
+ private void showDirectManipulationExamples(boolean hasFocus) {
+ if (!hasFocus) {
+ return; // Do nothing if no focus.
+ }
+ if (mDirectManipulation == null) {
+ mDirectManipulation = new RotaryDirectManipulationWidgets();
+ }
+ showContent(mDirectManipulation);
+ }
+
private void showContent(Fragment fragment) {
getFragmentManager().beginTransaction()
.replace(R.id.rotary_content, fragment)