aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPardis Beikzadeh <pardis@google.com>2020-05-11 23:21:48 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-11 23:21:48 +0000
commit778d489585053d9219466ce1371915e18a0b7069 (patch)
tree0dba61348273570c6f766fb426590d24063bf68e
parentdc2a7f7805d9766b1be3fba4b546c807b868b068 (diff)
parentf28e316f42b01a494f8fe6a3df2d6d39ca9586eb (diff)
downloadtests-778d489585053d9219466ce1371915e18a0b7069.tar.gz
Add a direct manipulation screen and some widgets. am: f28e316f42
Change-Id: I1050f20d90abb9a0f0407ea1f1d58bd039d48a28
-rw-r--r--RotaryPlayground/res/layout/rotary_direct_manipulation.xml58
-rw-r--r--RotaryPlayground/res/layout/rotary_menu.xml28
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryDirectManipulationWidgets.java40
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java37
4 files changed, 140 insertions, 23 deletions
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_menu.xml b/RotaryPlayground/res/layout/rotary_menu.xml
index b8b43d2..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/grid_example"
+ android:id="@+id/grid"
android:layout_width="match_parent"
- android:layout_height="50dp"
- android:layout_marginTop="32dp"
- android:text="Grid Example" />
+ 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/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/RotaryMenu.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
index 29f446d..d54a721 100644
--- a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
@@ -32,29 +32,36 @@ public class RotaryMenu extends Fragment {
private Fragment mRotaryCards = null;
private Fragment mRotaryGrid = null;
+ private Fragment mDirectManipulation = null;
- private Button mCardExamplesButton;
- private Button mGridExampleButton;
+ 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));
- mGridExampleButton = view.findViewById(R.id.grid_example);
- mGridExampleButton.setOnFocusChangeListener((v, hasFocus) -> showGridExample(hasFocus));
- mGridExampleButton.setOnClickListener(v -> showGridExample(/* 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();
@@ -72,6 +79,18 @@ public class RotaryMenu extends Fragment {
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)