aboutsummaryrefslogtreecommitdiff
path: root/RotaryPlayground
diff options
context:
space:
mode:
authorAgatha Man <agathaman@google.com>2020-05-01 11:58:10 -0700
committerAgatha Man <agathaman@google.com>2020-05-04 15:21:41 -0700
commit4b85d750df4d3dd2c3dae98679d27628be499dfd (patch)
tree4e4109c7bb295e0208d79aafeba3a8aee1a69e43 /RotaryPlayground
parenteba5ca372fa319d27af21d9cab98018894110d2f (diff)
downloadtests-4b85d750df4d3dd2c3dae98679d27628be499dfd.tar.gz
Add disabled buttons into rotary cards example
Fix: 154957293 Test: make and install Change-Id: I556c022b6dccf29b8b10ba3ccaacf87af63797e7
Diffstat (limited to 'RotaryPlayground')
-rw-r--r--RotaryPlayground/res/layout/rotary_cards.xml61
-rw-r--r--RotaryPlayground/res/values/colors.xml2
2 files changed, 57 insertions, 6 deletions
diff --git a/RotaryPlayground/res/layout/rotary_cards.xml b/RotaryPlayground/res/layout/rotary_cards.xml
index bdfa549..ecd8f7c 100644
--- a/RotaryPlayground/res/layout/rotary_cards.xml
+++ b/RotaryPlayground/res/layout/rotary_cards.xml
@@ -35,11 +35,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
- <!-- A FocusArea with normal buttons with basic attributes. Upon nudging into this area,
- the default focus should land on the first button in this container. Rotating the
- rotary controller clockwise will move the focus from top to bottom.
- Counterclockwise to move the focus from bottom to up. Nudge any direction to leave
- this focus area. -->
+ <!-- A FocusArea with some buttons.
+ Upon nudging into this area, the default focus should land on the first
+ button in this container. Rotating the rotary controller clockwise will move the focus
+ from top to bottom. Counterclockwise to move the focus from bottom to up. Nudge any
+ direction to leave this focus area. The disabled button is skipped. -->
<LinearLayout
android:id="@+id/card_normal"
android:background="@color/card_background_color"
@@ -53,12 +53,18 @@
android:onClick="onRotaryCardsButtonClick"
android:tag="test_button"
android:text="Button" />
+ <!-- This button is disabled and is not focusable by RotaryService. The RotaryService
+ can see disabled views but it can't focus them. Android doesn't allow disabled
+ views to be focused.
+ The focus will skip this button when rotating the rotary countroller. -->
<Button
+ android:background="@color/button_disabled_background_color"
android:layout_width="match_parent"
android:layout_height="50dp"
android:onClick="onRotaryCardsButtonClick"
+ android:enabled="false"
android:tag="test_button"
- android:text="Button" />
+ android:text="Disabled" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
@@ -73,6 +79,49 @@
android:text="Button" />
</LinearLayout>
+
+ <!-- A FocusArea where all elements are disabled. Elements that are disabled
+ (android:enabled="false") or not focusable (android:focusable="false") are
+ discoverable by the RotaryService, but the RotaryService will not focus them.
+ When no elements is focusable, nudging left and right from the adjacent cards
+ will cause focus to appear to skip this card -->
+ <LinearLayout
+ android:id="@+id/card_normal"
+ android:background="@color/card_disabled_background_color"
+ android:layout_margin="16dp"
+ android:layout_width="300dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:onClick="onRotaryCardsButtonClick"
+ android:enabled="false"
+ android:tag="test_button"
+ android:text="Disabled" />
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:onClick="onRotaryCardsButtonClick"
+ android:enabled="false"
+ android:tag="test_button"
+ android:text="Disabled" />
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:onClick="onRotaryCardsButtonClick"
+ android:enabled="false"
+ android:tag="test_button"
+ android:text="Disabled" />
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:onClick="onRotaryCardsButtonClick"
+ android:enabled="false"
+ android:tag="test_button"
+ android:text="Disabled" />
+ </LinearLayout>
+
<!-- A FocusArea that contains a button with a default focus attribute. Upon nudging into
this area, the focus will land on the button with the default focus attribute.
Rotating the rotary controller clockwise will move the focus from top to bottom.
diff --git a/RotaryPlayground/res/values/colors.xml b/RotaryPlayground/res/values/colors.xml
index 6636918..c52fa47 100644
--- a/RotaryPlayground/res/values/colors.xml
+++ b/RotaryPlayground/res/values/colors.xml
@@ -16,4 +16,6 @@
-->
<resources>
<color name="card_background_color">#37393d</color>
+ <color name="card_disabled_background_color">#61646b</color>
+ <color name="button_disabled_background_color">#61646b</color>
</resources> \ No newline at end of file