aboutsummaryrefslogtreecommitdiff
path: root/RotaryPlayground/src/com/android/car/rotaryplayground
diff options
context:
space:
mode:
authorPardis Beikzadeh <pardis@google.com>2020-05-04 14:00:33 -0700
committerPardis Beikzadeh <pardis@google.com>2020-05-11 14:14:37 -0700
commitf28e316f42b01a494f8fe6a3df2d6d39ca9586eb (patch)
tree0dba61348273570c6f766fb426590d24063bf68e /RotaryPlayground/src/com/android/car/rotaryplayground
parent66a5959ddd1b97833926effe3fcd3cbfb56cfb0f (diff)
downloadtests-f28e316f42b01a494f8fe6a3df2d6d39ca9586eb.tar.gz
Add a direct manipulation screen and some widgets.
BUG: 153886988 Test: manual, Danny ran the app Change-Id: Idd0c128b0c272a9827b1f24e5edf2d97b3fbcf0c
Diffstat (limited to 'RotaryPlayground/src/com/android/car/rotaryplayground')
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryDirectManipulationWidgets.java40
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java37
2 files changed, 68 insertions, 9 deletions
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)